summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel O'Brien <marmot.daniel@gmail.com>2013-11-14 22:35:02 +0100
committerDaniel O'Brien <marmot.daniel@gmail.com>2013-11-14 22:35:02 +0100
commitf6e16ce15082d867ed182690e3a80435cf60dc84 (patch)
treebd6cdcbcdac65ad2528ff87829b80181a44516cc
parentfixed XpGetPercentage (diff)
downloadcuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar.gz
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar.bz2
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar.lz
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar.xz
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.tar.zst
cuberite-f6e16ce15082d867ed182690e3a80435cf60dc84.zip
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua6
-rw-r--r--source/Protocol/Protocol.h3
-rw-r--r--source/Protocol/Protocol125.cpp15
-rw-r--r--source/Protocol/Protocol125.h1
-rw-r--r--source/Protocol/Protocol17x.cpp12
-rw-r--r--source/Protocol/Protocol17x.h1
-rw-r--r--source/Protocol/ProtocolRecognizer.cpp10
-rw-r--r--source/Protocol/ProtocolRecognizer.h1
8 files changed, 48 insertions, 1 deletions
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index 04a15a002..119e1525e 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -44,6 +44,7 @@ function Initialize(Plugin)
PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off");
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("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player");
-- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@@ -839,3 +840,8 @@ end
+function HandleAddExperience(a_Split, a_Player)
+ a_Player->AddExperience(200);
+
+ return true;
+end \ No newline at end of file
diff --git a/source/Protocol/Protocol.h b/source/Protocol/Protocol.h
index 5023ea227..c00c3cad4 100644
--- a/source/Protocol/Protocol.h
+++ b/source/Protocol/Protocol.h
@@ -22,9 +22,9 @@ class cWindow;
class cInventory;
class cPawn;
class cPickup;
+class cWorld;
class cMonster;
class cChunkDataSerializer;
-class cWorld;
class cFallingBlock;
@@ -85,6 +85,7 @@ public:
virtual void SendPlayerPosition (void) = 0;
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
virtual void SendRespawn (void) = 0;
+ virtual void SendSetExperience (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 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;
diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp
index 9f2770815..08a2b8656 100644
--- a/source/Protocol/Protocol125.cpp
+++ b/source/Protocol/Protocol125.cpp
@@ -72,6 +72,7 @@ enum
PACKET_ENT_STATUS = 0x26,
PACKET_ATTACH_ENTITY = 0x27,
PACKET_METADATA = 0x28,
+ PACKET_EXPERIENCE = 0x2b,
PACKET_PRE_CHUNK = 0x32,
PACKET_MAP_CHUNK = 0x33,
PACKET_MULTI_BLOCK = 0x34,
@@ -690,6 +691,20 @@ void cProtocol125::SendRespawn(void)
+void cProtocol125::SendSetExperience(void)
+{
+ cCSLock Lock(m_CSPacket);
+ WriteByte (PACKET_EXPERIENCE);
+ WriteFloat (m_Client->GetPlayer()->XpGetPercentage());
+ WriteShort (m_Client->GetPlayer()->XpGetLevel());
+ WriteShort (m_Client->GetPlayer()->XpGetTotal());
+ Flush();
+}
+
+
+
+
+
void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
// Not needed in this protocol version
diff --git a/source/Protocol/Protocol125.h b/source/Protocol/Protocol125.h
index db913bb57..48309a961 100644
--- a/source/Protocol/Protocol125.h
+++ b/source/Protocol/Protocol125.h
@@ -62,6 +62,7 @@ public:
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override;
+ virtual void SendSetExperience (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 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;
diff --git a/source/Protocol/Protocol17x.cpp b/source/Protocol/Protocol17x.cpp
index 628b8e071..b14c52cba 100644
--- a/source/Protocol/Protocol17x.cpp
+++ b/source/Protocol/Protocol17x.cpp
@@ -597,6 +597,18 @@ void cProtocol172::SendRespawn(void)
+void cProtocol172::SendSetExperience (void)
+{
+ cPacketizer Pkt(*this, 0x1F); //Experience Packet
+ Pkt.WriteFloat(m_Client->GetPlayer()->XpGetPercentage());
+ Pkt.WriteShort(m_Client->GetPlayer()->XpGetLevel());
+ Pkt.WriteShort(m_Client->GetPlayer()->XpGetTotal());
+}
+
+
+
+
+
void cProtocol172::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
{
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
diff --git a/source/Protocol/Protocol17x.h b/source/Protocol/Protocol17x.h
index 844069403..99ae3a087 100644
--- a/source/Protocol/Protocol17x.h
+++ b/source/Protocol/Protocol17x.h
@@ -72,6 +72,7 @@ public:
virtual void SendPlayerSpawn (const cPlayer & a_Player) 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 SendSetExperience (void) 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 SendSpawnMob (const cMonster & a_Mob) override;
diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp
index 9234785b5..283c20811 100644
--- a/source/Protocol/ProtocolRecognizer.cpp
+++ b/source/Protocol/ProtocolRecognizer.cpp
@@ -466,6 +466,16 @@ void cProtocolRecognizer::SendRespawn(void)
+void cProtocolRecognizer::SendSetExperience(void)
+{
+ ASSERT(m_Protocol != NULL);
+ m_Protocol->SendSetExperience();
+}
+
+
+
+
+
void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
ASSERT(m_Protocol != NULL);
diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h
index c085e2cd8..a32772282 100644
--- a/source/Protocol/ProtocolRecognizer.h
+++ b/source/Protocol/ProtocolRecognizer.h
@@ -97,6 +97,7 @@ public:
virtual void SendPlayerPosition (void) override;
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
virtual void SendRespawn (void) override;
+ virtual void SendSetExperience (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 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;