1
0

finished #143 I believe

This commit is contained in:
Daniel O'Brien 2013-11-16 02:23:50 +11:00
parent 5e3614ce87
commit 04dff4882a
14 changed files with 45 additions and 16 deletions

View File

@ -46,6 +46,7 @@ function Initialize(Plugin)
PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player");
PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player");
PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player");
PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp");
-- Enable the following line for BlockArea / Generator interface testing: -- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@ -852,3 +853,13 @@ function HandleAddExperience(a_Split, a_Player)
return true; return true;
end end
function HandleRemoveXp(a_Split, a_Player)
a_Player:SetExperience(0);
return true;
end

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/15/13 10:14:19. ** Generated automatically by tolua++-1.0.92 on 11/16/13 02:20:34.
*/ */
#ifndef __cplusplus #ifndef __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/15/13 10:14:20. ** Generated automatically by tolua++-1.0.92 on 11/16/13 02:20:35.
*/ */
/* Exported function */ /* Exported function */

View File

@ -261,6 +261,9 @@ void cClientHandle::Authenticate(void)
// Send health // Send health
m_Player->SendHealth(); m_Player->SendHealth();
// Send experience
m_Player->SendExperience();
// Send gamemode (1.6.1 movementSpeed): // Send gamemode (1.6.1 movementSpeed):
SendGameMode(m_Player->GetGameMode()); SendGameMode(m_Player->GetGameMode());
@ -1873,9 +1876,9 @@ void cClientHandle::SendRespawn(void)
void cClientHandle::SendSetExperience(void) void cClientHandle::SendExperience(void)
{ {
m_Protocol->SendSetExperience(); m_Protocol->SendExperience();
} }

View File

@ -120,7 +120,7 @@ public:
void SendPlayerPosition (void); void SendPlayerPosition (void);
void SendPlayerSpawn (const cPlayer & a_Player); void SendPlayerSpawn (const cPlayer & a_Player);
void SendRespawn (void); void SendRespawn (void);
void SendSetExperience (void); void SendExperience (void);
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8 void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data); void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock); void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock);

View File

@ -339,7 +339,7 @@ bool cPlayer::SetExperience(short int a_XpTotal)
m_XpTotal = a_XpTotal; m_XpTotal = a_XpTotal;
//send details to client //send details to client
m_ClientHandle->SendSetExperience(); SendExperience();
return true; return true;
} }
@ -363,7 +363,7 @@ short cPlayer::AddExperience(short a_Xp_delta)
m_XpTotal += a_Xp_delta; m_XpTotal += a_Xp_delta;
//send details to client //send details to client
m_ClientHandle->SendSetExperience(); SendExperience();
return m_XpTotal; return m_XpTotal;
} }
@ -615,6 +615,18 @@ void cPlayer::SendHealth(void)
void cPlayer::SendExperience(void)
{
if (m_ClientHandle != NULL)
{
m_ClientHandle->SendExperience();
}
}
void cPlayer::ClearInventoryPaintSlots(void) void cPlayer::ClearInventoryPaintSlots(void)
{ {
// Clear the list of slots that are being inventory-painted. Used by cWindow only // Clear the list of slots that are being inventory-painted. Used by cWindow only
@ -1419,12 +1431,13 @@ bool cPlayer::LoadFromDisk()
SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble()); SetRoll ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());
} }
m_Health = root.get("health", 0).asInt(); m_Health = root.get("health", 0).asInt();
m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt(); m_AirLevel = root.get("air", MAX_AIR_LEVEL).asInt();
m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt(); m_FoodLevel = root.get("food", MAX_FOOD_LEVEL).asInt();
m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble(); m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();
m_FoodTickTimer = root.get("foodTickTimer", 0).asInt(); m_FoodTickTimer = root.get("foodTickTimer", 0).asInt();
m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble(); m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();
m_XpTotal = root.get("experience", 0).asInt();
//SetExperience(root.get("experience", 0).asInt()); //SetExperience(root.get("experience", 0).asInt());

View File

@ -270,6 +270,8 @@ public:
void SendHealth(void); void SendHealth(void);
void SendExperience(void);
// In UI windows, the item that the player is dragging: // In UI windows, the item that the player is dragging:
bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); } bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); }
cItem & GetDraggingItem(void) {return m_DraggingItem; } cItem & GetDraggingItem(void) {return m_DraggingItem; }

View File

@ -85,7 +85,7 @@ public:
virtual void SendPlayerPosition (void) = 0; virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendRespawn (void) = 0; virtual void SendRespawn (void) = 0;
virtual void SendSetExperience (void) = 0; virtual void SendExperience (void) = 0;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8 virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) = 0;

View File

@ -691,7 +691,7 @@ void cProtocol125::SendRespawn(void)
void cProtocol125::SendSetExperience(void) void cProtocol125::SendExperience(void)
{ {
cCSLock Lock(m_CSPacket); cCSLock Lock(m_CSPacket);
WriteByte (PACKET_EXPERIENCE); WriteByte (PACKET_EXPERIENCE);

View File

@ -62,7 +62,7 @@ public:
virtual void SendPlayerPosition (void) override; virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override; virtual void SendRespawn (void) override;
virtual void SendSetExperience (void) override; virtual void SendExperience (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;

View File

@ -597,7 +597,7 @@ void cProtocol172::SendRespawn(void)
void cProtocol172::SendSetExperience (void) void cProtocol172::SendExperience (void)
{ {
cPacketizer Pkt(*this, 0x1F); //Experience Packet cPacketizer Pkt(*this, 0x1F); //Experience Packet
Pkt.WriteFloat(m_Client->GetPlayer()->XpGetPercentage()); Pkt.WriteFloat(m_Client->GetPlayer()->XpGetPercentage());

View File

@ -72,7 +72,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override; virtual void SendRespawn (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
virtual void SendSetExperience (void) override; virtual void SendExperience (void) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;
virtual void SendSpawnMob (const cMonster & a_Mob) override; virtual void SendSpawnMob (const cMonster & a_Mob) override;

View File

@ -466,10 +466,10 @@ void cProtocolRecognizer::SendRespawn(void)
void cProtocolRecognizer::SendSetExperience(void) void cProtocolRecognizer::SendExperience(void)
{ {
ASSERT(m_Protocol != NULL); ASSERT(m_Protocol != NULL);
m_Protocol->SendSetExperience(); m_Protocol->SendExperience();
} }

View File

@ -97,7 +97,7 @@ public:
virtual void SendPlayerPosition (void) override; virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override; virtual void SendRespawn (void) override;
virtual void SendSetExperience (void) override; virtual void SendExperience (void) override;
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override; virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override; virtual void SendSpawnFallingBlock (const cFallingBlock & a_FallingBlock) override;