Created
April 9, 2016 22:31
-
-
Save Pokechu22/b08d71d42bda3e481cf9b62d2f9917b5 to your computer and use it in GitHub Desktop.
Changes between Protocol18x.cpp and Protocol19x.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/protocol/protocol18x.cpp b/src/protocol/protocol19x.cpp | |
index ae9571f..8ee10d5 100644 | |
--- a/src/protocol/protocol18x.cpp | |
+++ b/src/protocol/protocol19x.cpp | |
@@ -1,16 +1,20 @@ | |
-// Protocol18x.cpp | |
+// Protocol19x.cpp | |
/* | |
-Implements the 1.8.x protocol classes: | |
- - cProtocol180 | |
- - release 1.8.0 protocol (#47) | |
-(others may be added later in the future for the 1.8 release series) | |
+Implements the 1.9.x protocol classes: | |
+ - cProtocol190 | |
+ - release 1.9.0 protocol (#107) | |
+ - cProtocol191 | |
+ - release 1.9.1 protocol (#108) | |
+ - cProtocol192 | |
+ - release 1.9.2 protocol (#109) | |
+(others may be added later in the future for the 1.9 release series) | |
*/ | |
#include "Globals.h" | |
#include "json/json.h" | |
-#include "Protocol18x.h" | |
+#include "Protocol19x.h" | |
#include "ChunkDataSerializer.h" | |
#include "PolarSSL++/Sha1Checksum.h" | |
#include "Packetizer.h" | |
@@ -99,9 +103,9 @@ extern bool g_ShouldLogCommIn, g_ShouldLogCommOut; | |
//////////////////////////////////////////////////////////////////////////////// | |
-// cProtocol180: | |
+// cProtocol190: | |
-cProtocol180::cProtocol180(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : | |
+cProtocol190::cProtocol190(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : | |
super(a_Client), | |
m_ServerAddress(a_ServerAddress), | |
m_ServerPort(a_ServerPort), | |
@@ -147,7 +151,7 @@ cProtocol180::cProtocol180(cClientHandle * a_Client, const AString & a_ServerAdd | |
-void cProtocol180::DataReceived(const char * a_Data, size_t a_Size) | |
+void cProtocol190::DataReceived(const char * a_Data, size_t a_Size) | |
{ | |
if (m_IsEncrypted) | |
{ | |
@@ -171,25 +175,24 @@ void cProtocol180::DataReceived(const char * a_Data, size_t a_Size) | |
-void cProtocol180::SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) | |
+void cProtocol190::SendAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- | |
- cPacketizer Pkt(*this, 0x1b); // Attach Entity packet | |
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteBEUInt32(a_Vehicle.GetUniqueID()); | |
- Pkt.WriteBool(false); | |
+ cPacketizer Pkt(*this, 0x40); // Set passangers packet | |
+ Pkt.WriteVarInt32(a_Vehicle.GetUniqueID()); | |
+ Pkt.WriteVarInt32(1); // 1 passenger | |
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
} | |
-void cProtocol180::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) | |
+void cProtocol190::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x24); // Block Action packet | |
+ cPacketizer Pkt(*this, 0x0a); // Block Action packet | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
Pkt.WriteBEInt8(a_Byte1); | |
Pkt.WriteBEInt8(a_Byte2); | |
@@ -200,11 +203,11 @@ void cProtocol180::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, cha | |
-void cProtocol180::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) | |
+void cProtocol190::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x25); // Block Break Animation packet | |
+ cPacketizer Pkt(*this, 0x08); // Block Break Animation packet | |
Pkt.WriteVarInt32(a_EntityID); | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
Pkt.WriteBEInt8(a_Stage); | |
@@ -214,11 +217,11 @@ void cProtocol180::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_Blo | |
-void cProtocol180::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) | |
+void cProtocol190::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x23); // Block Change packet | |
+ cPacketizer Pkt(*this, 0x0b); // Block Change packet | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
Pkt.WriteVarInt32((static_cast<UInt32>(a_BlockType) << 4) | (static_cast<UInt32>(a_BlockMeta) & 15)); | |
} | |
@@ -227,11 +230,11 @@ void cProtocol180::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO | |
-void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) | |
+void cProtocol190::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x22); // Multi Block Change packet | |
+ cPacketizer Pkt(*this, 0x10); // Multi Block Change packet | |
Pkt.WriteBEInt32(a_ChunkX); | |
Pkt.WriteBEInt32(a_ChunkZ); | |
Pkt.WriteVarInt32(static_cast<UInt32>(a_Changes.size())); | |
@@ -247,11 +250,11 @@ void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV | |
-void cProtocol180::SendChat(const AString & a_Message, eChatType a_Type) | |
+void cProtocol190::SendChat(const AString & a_Message, eChatType a_Type) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x02); // Chat Message packet | |
+ cPacketizer Pkt(*this, 0x0f); // Chat Message packet | |
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str())); | |
Pkt.WriteBEInt8(a_Type); | |
} | |
@@ -260,13 +263,13 @@ void cProtocol180::SendChat(const AString & a_Message, eChatType a_Type) | |
-void cProtocol180::SendChat(const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) | |
+void cProtocol190::SendChat(const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
// Send the message to the client: | |
- cPacketizer Pkt(*this, 0x02); | |
+ cPacketizer Pkt(*this, 0x0f); // Chat Message packet | |
Pkt.WriteString(a_Message.CreateJsonString(a_ShouldUseChatPrefixes)); | |
Pkt.WriteBEInt8(a_Type); | |
} | |
@@ -275,13 +278,13 @@ void cProtocol180::SendChat(const cCompositeChat & a_Message, eChatType a_Type, | |
-void cProtocol180::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) | |
+void cProtocol190::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
// Serialize first, before creating the Packetizer (the packetizer locks a CS) | |
// This contains the flags and bitmasks, too | |
- const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_8_0, a_ChunkX, a_ChunkZ); | |
+ const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_9_0, a_ChunkX, a_ChunkZ); | |
cCSLock Lock(m_CSPacket); | |
SendData(ChunkData.data(), ChunkData.size()); | |
@@ -291,11 +294,11 @@ void cProtocol180::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize | |
-void cProtocol180::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) | |
+void cProtocol190::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x0d); // Collect Item packet | |
+ cPacketizer Pkt(*this, 0x49); // Collect Item packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteVarInt32(a_Player.GetUniqueID()); | |
} | |
@@ -304,11 +307,11 @@ void cProtocol180::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a | |
-void cProtocol180::SendDestroyEntity(const cEntity & a_Entity) | |
+void cProtocol190::SendDestroyEntity(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x13); // Destroy Entities packet | |
+ cPacketizer Pkt(*this, 0x30); // Destroy Entities packet | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
} | |
@@ -317,21 +320,19 @@ void cProtocol180::SendDestroyEntity(const cEntity & a_Entity) | |
-void cProtocol180::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) | |
+void cProtocol190::SendDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- | |
- cPacketizer Pkt(*this, 0x1b); // Attach Entity packet | |
- Pkt.WriteBEUInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteBEUInt32(0); | |
- Pkt.WriteBool(false); | |
+ cPacketizer Pkt(*this, 0x40); // Set passangers packet | |
+ Pkt.WriteVarInt32(a_PreviousVehicle.GetUniqueID()); | |
+ Pkt.WriteVarInt32(0); // No passangers | |
} | |
-void cProtocol180::SendDisconnect(const AString & a_Reason) | |
+void cProtocol190::SendDisconnect(const AString & a_Reason) | |
{ | |
switch (m_State) | |
{ | |
@@ -345,7 +346,7 @@ void cProtocol180::SendDisconnect(const AString & a_Reason) | |
case 3: | |
{ | |
// In-game: | |
- cPacketizer Pkt(*this, 0x40); | |
+ cPacketizer Pkt(*this, 0x1a); | |
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str())); | |
break; | |
} | |
@@ -356,11 +357,11 @@ void cProtocol180::SendDisconnect(const AString & a_Reason) | |
-void cProtocol180::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) | |
+void cProtocol190::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x36); // Sign Editor Open packet | |
+ cPacketizer Pkt(*this, 0x2a); // Sign Editor Open packet | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
} | |
@@ -368,11 +369,11 @@ void cProtocol180::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ) | |
-void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) | |
+void cProtocol190::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x1D); // Entity Effect packet | |
+ cPacketizer Pkt(*this, 0x4c); // Entity Effect packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID)); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier)); | |
@@ -384,13 +385,18 @@ void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in | |
-void cProtocol180::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) | |
+void cProtocol190::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x04); // Entity Equipment packet | |
+ cPacketizer Pkt(*this, 0x3c); // Entity Equipment packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteBEInt16(a_SlotNum); | |
+ // Needs to be adjusted due to the insertion of offhand at slot 1 | |
+ if (a_SlotNum > 0) | |
+ { | |
+ a_SlotNum++; | |
+ } | |
+ Pkt.WriteVarInt32(a_SlotNum); | |
WriteItem(Pkt, a_Item); | |
} | |
@@ -398,11 +404,11 @@ void cProtocol180::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum | |
-void cProtocol180::SendEntityHeadLook(const cEntity & a_Entity) | |
+void cProtocol190::SendEntityHeadLook(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x19); // Entity Head Look packet | |
+ cPacketizer Pkt(*this, 0x34); // Entity Head Look packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteByteAngle(a_Entity.GetHeadYaw()); | |
} | |
@@ -411,11 +417,11 @@ void cProtocol180::SendEntityHeadLook(const cEntity & a_Entity) | |
-void cProtocol180::SendEntityLook(const cEntity & a_Entity) | |
+void cProtocol190::SendEntityLook(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x16); // Entity Look packet | |
+ cPacketizer Pkt(*this, 0x27); // Entity Look packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteByteAngle(a_Entity.GetYaw()); | |
Pkt.WriteByteAngle(a_Entity.GetPitch()); | |
@@ -426,25 +432,25 @@ void cProtocol180::SendEntityLook(const cEntity & a_Entity) | |
-void cProtocol180::SendEntityMetadata(const cEntity & a_Entity) | |
+void cProtocol190::SendEntityMetadata(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet | |
+ cPacketizer Pkt(*this, 0x39); // Entity Metadata packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
WriteEntityMetadata(Pkt, a_Entity); | |
- Pkt.WriteBEUInt8(0x7f); // The termination byte | |
+ Pkt.WriteBEUInt8(0xff); // The termination byte | |
} | |
-void cProtocol180::SendEntityProperties(const cEntity & a_Entity) | |
+void cProtocol190::SendEntityProperties(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x20); // Entity Properties packet | |
+ cPacketizer Pkt(*this, 0x4b); // Entity Properties packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
WriteEntityProperties(Pkt, a_Entity); | |
} | |
@@ -453,15 +459,16 @@ void cProtocol180::SendEntityProperties(const cEntity & a_Entity) | |
-void cProtocol180::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) | |
+void cProtocol190::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x15); // Entity Relative Move packet | |
+ cPacketizer Pkt(*this, 0x25); // Entity Relative Move packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteBEInt8(a_RelX); | |
- Pkt.WriteBEInt8(a_RelY); | |
- Pkt.WriteBEInt8(a_RelZ); | |
+ // TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that. | |
+ Pkt.WriteBEInt16(a_RelX * 128); | |
+ Pkt.WriteBEInt16(a_RelY * 128); | |
+ Pkt.WriteBEInt16(a_RelZ * 128); | |
Pkt.WriteBool(a_Entity.IsOnGround()); | |
} | |
@@ -469,15 +476,16 @@ void cProtocol180::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char | |
-void cProtocol180::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) | |
+void cProtocol190::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x17); // Entity Look And Relative Move packet | |
+ cPacketizer Pkt(*this, 0x26); // Entity Look And Relative Move packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteBEInt8(a_RelX); | |
- Pkt.WriteBEInt8(a_RelY); | |
- Pkt.WriteBEInt8(a_RelZ); | |
+ // TODO: 1.9 changed these from chars to shorts, meaning that there can be more percision and data. Other code needs to be updated for that. | |
+ Pkt.WriteBEInt16(a_RelX * 128); | |
+ Pkt.WriteBEInt16(a_RelY * 128); | |
+ Pkt.WriteBEInt16(a_RelZ * 128); | |
Pkt.WriteByteAngle(a_Entity.GetYaw()); | |
Pkt.WriteByteAngle(a_Entity.GetPitch()); | |
Pkt.WriteBool(a_Entity.IsOnGround()); | |
@@ -487,11 +495,11 @@ void cProtocol180::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, | |
-void cProtocol180::SendEntityStatus(const cEntity & a_Entity, char a_Status) | |
+void cProtocol190::SendEntityStatus(const cEntity & a_Entity, char a_Status) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x1a); // Entity Status packet | |
+ cPacketizer Pkt(*this, 0x1b); // Entity Status packet | |
Pkt.WriteBEUInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteBEInt8(a_Status); | |
} | |
@@ -500,11 +508,11 @@ void cProtocol180::SendEntityStatus(const cEntity & a_Entity, char a_Status) | |
-void cProtocol180::SendEntityVelocity(const cEntity & a_Entity) | |
+void cProtocol190::SendEntityVelocity(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x12); // Entity Velocity packet | |
+ cPacketizer Pkt(*this, 0x3b); // Entity Velocity packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
// 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick | |
Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400)); | |
@@ -516,11 +524,11 @@ void cProtocol180::SendEntityVelocity(const cEntity & a_Entity) | |
-void cProtocol180::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) | |
+void cProtocol190::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x27); // Explosion packet | |
+ cPacketizer Pkt(*this, 0x1c); // Explosion packet | |
Pkt.WriteBEFloat(static_cast<float>(a_BlockX)); | |
Pkt.WriteBEFloat(static_cast<float>(a_BlockY)); | |
Pkt.WriteBEFloat(static_cast<float>(a_BlockZ)); | |
@@ -541,11 +549,11 @@ void cProtocol180::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc | |
-void cProtocol180::SendGameMode(eGameMode a_GameMode) | |
+void cProtocol190::SendGameMode(eGameMode a_GameMode) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x2b); // Change Game State packet | |
+ cPacketizer Pkt(*this, 0x1e); // Change Game State packet | |
Pkt.WriteBEUInt8(3); // Reason: Change game mode | |
Pkt.WriteBEFloat(static_cast<float>(a_GameMode)); // The protocol really represents the value with a float! | |
} | |
@@ -554,11 +562,11 @@ void cProtocol180::SendGameMode(eGameMode a_GameMode) | |
-void cProtocol180::SendHealth(void) | |
+void cProtocol190::SendHealth(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x06); // Update Health packet | |
+ cPacketizer Pkt(*this, 0x3e); // Update Health packet | |
cPlayer * Player = m_Client->GetPlayer(); | |
Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth())); | |
Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetFoodLevel())); | |
@@ -569,7 +577,7 @@ void cProtocol180::SendHealth(void) | |
-void cProtocol180::SendHideTitle(void) | |
+void cProtocol190::SendHideTitle(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -581,11 +589,11 @@ void cProtocol180::SendHideTitle(void) | |
-void cProtocol180::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item) | |
+void cProtocol190::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x2f); // Set Slot packet | |
+ cPacketizer Pkt(*this, 0x16); // Set Slot packet | |
Pkt.WriteBEInt8(a_WindowID); | |
Pkt.WriteBEInt16(a_SlotNum); | |
WriteItem(Pkt, a_Item); | |
@@ -595,7 +603,7 @@ void cProtocol180::SendInventorySlot(char a_WindowID, short a_SlotNum, const cIt | |
-void cProtocol180::SendKeepAlive(UInt32 a_PingID) | |
+void cProtocol190::SendKeepAlive(UInt32 a_PingID) | |
{ | |
// Drop the packet if the protocol is not in the Game state yet (caused a client crash): | |
if (m_State != 3) | |
@@ -604,7 +612,7 @@ void cProtocol180::SendKeepAlive(UInt32 a_PingID) | |
return; | |
} | |
- cPacketizer Pkt(*this, 0x00); // Keep Alive packet | |
+ cPacketizer Pkt(*this, 0x1f); // Keep Alive packet | |
Pkt.WriteVarInt32(a_PingID); | |
} | |
@@ -612,12 +620,12 @@ void cProtocol180::SendKeepAlive(UInt32 a_PingID) | |
-void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World) | |
+void cProtocol190::SendLogin(const cPlayer & a_Player, const cWorld & a_World) | |
{ | |
// Send the Join Game packet: | |
{ | |
cServer * Server = cRoot::Get()->GetServer(); | |
- cPacketizer Pkt(*this, 0x01); // Join Game packet | |
+ cPacketizer Pkt(*this, 0x23); // Join Game packet | |
Pkt.WriteBEUInt32(a_Player.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 | |
Pkt.WriteBEInt8(static_cast<Int8>(a_World.GetDimension())); | |
@@ -630,13 +638,13 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World) | |
// Send the spawn position: | |
{ | |
- cPacketizer Pkt(*this, 0x05); // Spawn Position packet | |
+ cPacketizer Pkt(*this, 0x43); // Spawn Position packet | |
Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ())); | |
} | |
// Send the server difficulty: | |
{ | |
- cPacketizer Pkt(*this, 0x41); | |
+ cPacketizer Pkt(*this, 0x0d); // Server difficulty packet | |
Pkt.WriteBEInt8(1); | |
} | |
@@ -647,7 +655,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World) | |
-void cProtocol180::SendLoginSuccess(void) | |
+void cProtocol190::SendLoginSuccess(void) | |
{ | |
ASSERT(m_State == 2); // State: login? | |
@@ -670,15 +678,18 @@ void cProtocol180::SendLoginSuccess(void) | |
-void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting) | |
+void cProtocol190::SendPaintingSpawn(const cPainting & a_Painting) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
double PosX = a_Painting.GetPosX(); | |
double PosY = a_Painting.GetPosY(); | |
double PosZ = a_Painting.GetPosZ(); | |
- cPacketizer Pkt(*this, 0x10); // Spawn Painting packet | |
+ cPacketizer Pkt(*this, 0x04); // Spawn Painting packet | |
Pkt.WriteVarInt32(a_Painting.GetUniqueID()); | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_Painting.GetUniqueID()); | |
Pkt.WriteString(a_Painting.GetName().c_str()); | |
Pkt.WritePosition64(static_cast<Int32>(PosX), static_cast<Int32>(PosY), static_cast<Int32>(PosZ)); | |
Pkt.WriteBEInt8(static_cast<Int8>(a_Painting.GetProtocolFacing())); | |
@@ -688,14 +699,15 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting) | |
-void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY) | |
+void cProtocol190::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x34); | |
+ cPacketizer Pkt(*this, 0x24); // Map packet | |
Pkt.WriteVarInt32(a_Map.GetID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Map.GetScale())); | |
+ Pkt.WriteBool(true); | |
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetDecorators().size())); | |
for (const auto & Decorator : a_Map.GetDecorators()) | |
{ | |
@@ -719,28 +731,35 @@ void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataS | |
-void cProtocol180::SendPickupSpawn(const cPickup & a_Pickup) | |
+void cProtocol190::SendPickupSpawn(const cPickup & a_Pickup) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
{ | |
- cPacketizer Pkt(*this, 0x0e); // Spawn Object packet | |
+ cPacketizer Pkt(*this, 0x00); // Spawn Object packet | |
Pkt.WriteVarInt32(a_Pickup.GetUniqueID()); | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_Pickup.GetUniqueID()); | |
Pkt.WriteBEUInt8(2); // Type = Pickup | |
- Pkt.WriteFPInt(a_Pickup.GetPosX()); | |
- Pkt.WriteFPInt(a_Pickup.GetPosY()); | |
- Pkt.WriteFPInt(a_Pickup.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_Pickup.GetPosX()); | |
+ Pkt.WriteBEDouble(a_Pickup.GetPosY()); | |
+ Pkt.WriteBEDouble(a_Pickup.GetPosZ()); | |
Pkt.WriteByteAngle(a_Pickup.GetYaw()); | |
Pkt.WriteByteAngle(a_Pickup.GetPitch()); | |
Pkt.WriteBEInt32(0); // No object data | |
+ Pkt.WriteBEInt16(0); // No velocity | |
+ Pkt.WriteBEInt16(0); | |
+ Pkt.WriteBEInt16(0); | |
} | |
{ | |
- cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet | |
+ cPacketizer Pkt(*this, 0x39); // Entity Metadata packet | |
Pkt.WriteVarInt32(a_Pickup.GetUniqueID()); | |
- Pkt.WriteBEUInt8((0x05 << 5) | 10); // Slot type + index 10 | |
+ Pkt.WriteBEUInt8(5); // Index 5: Item | |
+ Pkt.WriteBEUInt8(METADATA_TYPE_ITEM); | |
WriteItem(Pkt, a_Pickup.GetItem()); | |
- Pkt.WriteBEUInt8(0x7f); // End of metadata | |
+ Pkt.WriteBEUInt8(0xff); // End of metadata | |
} | |
} | |
@@ -748,11 +767,11 @@ void cProtocol180::SendPickupSpawn(const cPickup & a_Pickup) | |
-void cProtocol180::SendPlayerAbilities(void) | |
+void cProtocol190::SendPlayerAbilities(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x39); // Player Abilities packet | |
+ cPacketizer Pkt(*this, 0x2b); // Player Abilities packet | |
Byte Flags = 0; | |
cPlayer * Player = m_Client->GetPlayer(); | |
if (Player->IsGameModeCreative()) | |
@@ -777,11 +796,11 @@ void cProtocol180::SendPlayerAbilities(void) | |
-void cProtocol180::SendEntityAnimation(const cEntity & a_Entity, char a_Animation) | |
+void cProtocol190::SendEntityAnimation(const cEntity & a_Entity, char a_Animation) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x0b); // Animation packet | |
+ cPacketizer Pkt(*this, 0x06); // Animation packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteBEInt8(a_Animation); | |
} | |
@@ -790,12 +809,12 @@ void cProtocol180::SendEntityAnimation(const cEntity & a_Entity, char a_Animatio | |
-void cProtocol180::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) | |
+void cProtocol190::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
int ParticleID = GetParticleID(a_ParticleName); | |
- cPacketizer Pkt(*this, 0x2A); | |
+ cPacketizer Pkt(*this, 0x22); // Particle effect packet | |
Pkt.WriteBEInt32(ParticleID); | |
Pkt.WriteBool(false); | |
Pkt.WriteBEFloat(a_SrcX); | |
@@ -812,12 +831,12 @@ void cProtocol180::SendParticleEffect(const AString & a_ParticleName, float a_Sr | |
-void cProtocol180::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) | |
+void cProtocol190::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
int ParticleID = GetParticleID(a_ParticleName); | |
- cPacketizer Pkt(*this, 0x2A); | |
+ cPacketizer Pkt(*this, 0x22); // Particle effect packet | |
Pkt.WriteBEInt32(ParticleID); | |
Pkt.WriteBool(false); | |
Pkt.WriteBEFloat(a_Src.x); | |
@@ -856,11 +875,11 @@ void cProtocol180::SendParticleEffect(const AString & a_ParticleName, Vector3f a | |
-void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player) | |
+void cProtocol190::SendPlayerListAddPlayer(const cPlayer & a_Player) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x38); // Playerlist Item packet | |
+ cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet | |
Pkt.WriteVarInt32(0); | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteUUID(a_Player.GetUUID()); | |
@@ -893,11 +912,11 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player) | |
-void cProtocol180::SendPlayerListRemovePlayer(const cPlayer & a_Player) | |
+void cProtocol190::SendPlayerListRemovePlayer(const cPlayer & a_Player) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x38); // Playerlist Item packet | |
+ cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet | |
Pkt.WriteVarInt32(4); | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteUUID(a_Player.GetUUID()); | |
@@ -907,11 +926,11 @@ void cProtocol180::SendPlayerListRemovePlayer(const cPlayer & a_Player) | |
-void cProtocol180::SendPlayerListUpdateGameMode(const cPlayer & a_Player) | |
+void cProtocol190::SendPlayerListUpdateGameMode(const cPlayer & a_Player) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x38); // Playerlist Item packet | |
+ cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteUUID(a_Player.GetUUID()); | |
@@ -922,14 +941,14 @@ void cProtocol180::SendPlayerListUpdateGameMode(const cPlayer & a_Player) | |
-void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player) | |
+void cProtocol190::SendPlayerListUpdatePing(const cPlayer & a_Player) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
auto ClientHandle = a_Player.GetClientHandlePtr(); | |
if (ClientHandle != nullptr) | |
{ | |
- cPacketizer Pkt(*this, 0x38); // Playerlist Item packet | |
+ cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet | |
Pkt.WriteVarInt32(2); | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteUUID(a_Player.GetUUID()); | |
@@ -941,11 +960,11 @@ void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player) | |
-void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) | |
+void cProtocol190::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x38); // Playerlist Item packet | |
+ cPacketizer Pkt(*this, 0x2d); // Playerlist Item packet | |
Pkt.WriteVarInt32(3); | |
Pkt.WriteVarInt32(1); | |
Pkt.WriteUUID(a_Player.GetUUID()); | |
@@ -965,11 +984,11 @@ void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con | |
-void cProtocol180::SendPlayerMaxSpeed(void) | |
+void cProtocol190::SendPlayerMaxSpeed(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x20); // Entity Properties | |
+ cPacketizer Pkt(*this, 0x4b); // Entity Properties | |
cPlayer * Player = m_Client->GetPlayer(); | |
Pkt.WriteVarInt32(Player->GetUniqueID()); | |
Pkt.WriteBEInt32(1); // Count | |
@@ -994,11 +1013,11 @@ void cProtocol180::SendPlayerMaxSpeed(void) | |
-void cProtocol180::SendPlayerMoveLook(void) | |
+void cProtocol190::SendPlayerMoveLook(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x08); // Player Position And Look packet | |
+ cPacketizer Pkt(*this, 0x2e); // Player Position And Look packet | |
cPlayer * Player = m_Client->GetPlayer(); | |
Pkt.WriteBEDouble(Player->GetPosX()); | |
Pkt.WriteBEDouble(Player->GetPosY()); | |
@@ -1006,13 +1025,14 @@ void cProtocol180::SendPlayerMoveLook(void) | |
Pkt.WriteBEFloat(static_cast<float>(Player->GetYaw())); | |
Pkt.WriteBEFloat(static_cast<float>(Player->GetPitch())); | |
Pkt.WriteBEUInt8(0); | |
+ Pkt.WriteVarInt32(0); // Teleport ID - not implemented here | |
} | |
-void cProtocol180::SendPlayerPosition(void) | |
+void cProtocol190::SendPlayerPosition(void) | |
{ | |
// There is no dedicated packet for this, send the whole thing: | |
SendPlayerMoveLook(); | |
@@ -1022,35 +1042,35 @@ void cProtocol180::SendPlayerPosition(void) | |
-void cProtocol180::SendPlayerSpawn(const cPlayer & a_Player) | |
+void cProtocol190::SendPlayerSpawn(const cPlayer & a_Player) | |
{ | |
// Called to spawn another player for the client | |
- cPacketizer Pkt(*this, 0x0c); // Spawn Player packet | |
+ cPacketizer Pkt(*this, 0x05); // Spawn Player packet | |
Pkt.WriteVarInt32(a_Player.GetUniqueID()); | |
Pkt.WriteUUID(cMojangAPI::MakeUUIDShort(a_Player.GetUUID())); | |
- Pkt.WriteFPInt(a_Player.GetPosX()); | |
- Pkt.WriteFPInt(a_Player.GetPosY() + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. | |
- Pkt.WriteFPInt(a_Player.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_Player.GetPosX()); | |
+ Pkt.WriteBEDouble(a_Player.GetPosY() + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. | |
+ Pkt.WriteBEDouble(a_Player.GetPosZ()); | |
Pkt.WriteByteAngle(a_Player.GetYaw()); | |
Pkt.WriteByteAngle(a_Player.GetPitch()); | |
- short ItemType = a_Player.GetEquippedItem().IsEmpty() ? 0 : a_Player.GetEquippedItem().m_ItemType; | |
- Pkt.WriteBEInt16(ItemType); | |
- Pkt.WriteBEUInt8((3 << 5) | 6); // Metadata: float + index 6 | |
+ Pkt.WriteBEUInt8(6); // Start metadata - Index 6: Health | |
+ Pkt.WriteBEUInt8(METADATA_TYPE_FLOAT); | |
Pkt.WriteBEFloat(static_cast<float>(a_Player.GetHealth())); | |
- Pkt.WriteBEUInt8((4 << 5 | (2 & 0x1F)) & 0xFF); | |
+ Pkt.WriteBEUInt8(2); // Index 2: Custom name | |
+ Pkt.WriteBEUInt8(METADATA_TYPE_STRING); | |
Pkt.WriteString(a_Player.GetName()); | |
- Pkt.WriteBEUInt8(0x7f); // Metadata: end | |
+ Pkt.WriteBEUInt8(0xff); // Metadata: end | |
} | |
-void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString & a_Message) | |
+void cProtocol190::SendPluginMessage(const AString & a_Channel, const AString & a_Message) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x3f); | |
+ cPacketizer Pkt(*this, 0x18); // Plugin message packet | |
Pkt.WriteString(a_Channel); | |
Pkt.WriteBuf(a_Message.data(), a_Message.size()); | |
} | |
@@ -1059,11 +1079,11 @@ void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString & | |
-void cProtocol180::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) | |
+void cProtocol190::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x1e); | |
+ cPacketizer Pkt(*this, 0x31); // Remove entity effect packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID)); | |
} | |
@@ -1072,7 +1092,7 @@ void cProtocol180::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect | |
-void cProtocol180::SendResetTitle(void) | |
+void cProtocol190::SendResetTitle(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -1084,7 +1104,7 @@ void cProtocol180::SendResetTitle(void) | |
-void cProtocol180::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) | |
+void cProtocol190::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks) | |
{ | |
if ((m_LastSentDimension == a_Dimension) && !a_ShouldIgnoreDimensionChecks) | |
{ | |
@@ -1092,7 +1112,7 @@ void cProtocol180::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens | |
return; | |
} | |
- cPacketizer Pkt(*this, 0x07); // Respawn packet | |
+ cPacketizer Pkt(*this, 0x33); // Respawn packet | |
cPlayer * Player = m_Client->GetPlayer(); | |
Pkt.WriteBEInt32(static_cast<Int32>(a_Dimension)); | |
Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal) | |
@@ -1105,11 +1125,11 @@ void cProtocol180::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens | |
-void cProtocol180::SendExperience(void) | |
+void cProtocol190::SendExperience(void) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x1f); // Experience Packet | |
+ cPacketizer Pkt(*this, 0x3d); // Experience Packet | |
cPlayer * Player = m_Client->GetPlayer(); | |
Pkt.WriteBEFloat(Player->GetXpPercentage()); | |
Pkt.WriteVarInt32(static_cast<UInt32>(Player->GetXpLevel())); | |
@@ -1120,15 +1140,15 @@ void cProtocol180::SendExperience(void) | |
-void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb) | |
+void cProtocol190::SendExperienceOrb(const cExpOrb & a_ExpOrb) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x11); | |
+ cPacketizer Pkt(*this, 0x01); // Spawn experience orb packet | |
Pkt.WriteVarInt32(a_ExpOrb.GetUniqueID()); | |
- Pkt.WriteFPInt(a_ExpOrb.GetPosX()); | |
- Pkt.WriteFPInt(a_ExpOrb.GetPosY()); | |
- Pkt.WriteFPInt(a_ExpOrb.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_ExpOrb.GetPosX()); | |
+ Pkt.WriteBEDouble(a_ExpOrb.GetPosY()); | |
+ Pkt.WriteBEDouble(a_ExpOrb.GetPosZ()); | |
Pkt.WriteBEInt16(static_cast<Int16>(a_ExpOrb.GetReward())); | |
} | |
@@ -1136,11 +1156,11 @@ void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb) | |
-void cProtocol180::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) | |
+void cProtocol190::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x3b); | |
+ cPacketizer Pkt(*this, 0x3f); // Scoreboard objective packet | |
Pkt.WriteString(a_Name); | |
Pkt.WriteBEUInt8(a_Mode); | |
if ((a_Mode == 0) || (a_Mode == 2)) | |
@@ -1154,11 +1174,11 @@ void cProtocol180::SendScoreboardObjective(const AString & a_Name, const AString | |
-void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) | |
+void cProtocol190::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x3c); | |
+ cPacketizer Pkt(*this, 0x42); // Update score packet | |
Pkt.WriteString(a_Player); | |
Pkt.WriteBEUInt8(a_Mode); | |
Pkt.WriteString(a_Objective); | |
@@ -1173,11 +1193,11 @@ void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString & | |
-void cProtocol180::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) | |
+void cProtocol190::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x3d); | |
+ cPacketizer Pkt(*this, 0x38); // Display scoreboard packet | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display)); | |
Pkt.WriteString(a_Objective); | |
} | |
@@ -1186,7 +1206,7 @@ void cProtocol180::SendDisplayObjective(const AString & a_Objective, cScoreboard | |
-void cProtocol180::SendSetSubTitle(const cCompositeChat & a_SubTitle) | |
+void cProtocol190::SendSetSubTitle(const cCompositeChat & a_SubTitle) | |
{ | |
SendSetRawSubTitle(a_SubTitle.CreateJsonString(false)); | |
} | |
@@ -1195,7 +1215,7 @@ void cProtocol180::SendSetSubTitle(const cCompositeChat & a_SubTitle) | |
-void cProtocol180::SendSetRawSubTitle(const AString & a_SubTitle) | |
+void cProtocol190::SendSetRawSubTitle(const AString & a_SubTitle) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -1209,7 +1229,7 @@ void cProtocol180::SendSetRawSubTitle(const AString & a_SubTitle) | |
-void cProtocol180::SendSetTitle(const cCompositeChat & a_Title) | |
+void cProtocol190::SendSetTitle(const cCompositeChat & a_Title) | |
{ | |
SendSetRawTitle(a_Title.CreateJsonString(false)); | |
} | |
@@ -1218,7 +1238,7 @@ void cProtocol180::SendSetTitle(const cCompositeChat & a_Title) | |
-void cProtocol180::SendSetRawTitle(const AString & a_Title) | |
+void cProtocol190::SendSetRawTitle(const AString & a_Title) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -1232,12 +1252,13 @@ void cProtocol180::SendSetRawTitle(const AString & a_Title) | |
-void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) | |
+void cProtocol190::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x29); // Sound Effect packet | |
+ cPacketizer Pkt(*this, 0x19); // Named sound effect packet | |
Pkt.WriteString(a_SoundName); | |
+ Pkt.WriteVarInt32(0); // Master sound category (may want to be changed to a parameter later) | |
Pkt.WriteBEInt32(static_cast<Int32>(a_X * 8.0)); | |
Pkt.WriteBEInt32(static_cast<Int32>(a_Y * 8.0)); | |
Pkt.WriteBEInt32(static_cast<Int32>(a_Z * 8.0)); | |
@@ -1249,11 +1270,11 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub | |
-void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) | |
+void cProtocol190::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x28); // Effect packet | |
+ cPacketizer Pkt(*this, 0x21); // Effect packet | |
Pkt.WriteBEInt32(static_cast<int>(a_EffectID)); | |
Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ); | |
Pkt.WriteBEInt32(a_Data); | |
@@ -1264,16 +1285,19 @@ void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX | |
-void cProtocol180::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) | |
+void cProtocol190::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x0e); // Spawn Object packet | |
+ cPacketizer Pkt(*this, 0x00); // Spawn Object packet | |
Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID()); | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_FallingBlock.GetUniqueID()); | |
Pkt.WriteBEUInt8(70); // Falling block | |
- Pkt.WriteFPInt(a_FallingBlock.GetPosX()); | |
- Pkt.WriteFPInt(a_FallingBlock.GetPosY()); | |
- Pkt.WriteFPInt(a_FallingBlock.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_FallingBlock.GetPosX()); | |
+ Pkt.WriteBEDouble(a_FallingBlock.GetPosY()); | |
+ Pkt.WriteBEDouble(a_FallingBlock.GetPosZ()); | |
Pkt.WriteByteAngle(a_FallingBlock.GetYaw()); | |
Pkt.WriteByteAngle(a_FallingBlock.GetPitch()); | |
Pkt.WriteBEInt32(static_cast<Int32>(a_FallingBlock.GetBlockType()) | (static_cast<Int32>(a_FallingBlock.GetBlockMeta()) << 12)); | |
@@ -1286,16 +1310,19 @@ void cProtocol180::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock) | |
-void cProtocol180::SendSpawnMob(const cMonster & a_Mob) | |
+void cProtocol190::SendSpawnMob(const cMonster & a_Mob) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet | |
+ cPacketizer Pkt(*this, 0x03); // Spawn Mob packet | |
Pkt.WriteVarInt32(a_Mob.GetUniqueID()); | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_Mob.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType())); | |
- Pkt.WriteFPInt(a_Mob.GetPosX()); | |
- Pkt.WriteFPInt(a_Mob.GetPosY()); | |
- Pkt.WriteFPInt(a_Mob.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_Mob.GetPosX()); | |
+ Pkt.WriteBEDouble(a_Mob.GetPosY()); | |
+ Pkt.WriteBEDouble(a_Mob.GetPosZ()); | |
Pkt.WriteByteAngle(a_Mob.GetPitch()); | |
Pkt.WriteByteAngle(a_Mob.GetHeadYaw()); | |
Pkt.WriteByteAngle(a_Mob.GetYaw()); | |
@@ -1303,14 +1330,14 @@ void cProtocol180::SendSpawnMob(const cMonster & a_Mob) | |
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedY() * 400)); | |
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedZ() * 400)); | |
WriteEntityMetadata(Pkt, a_Mob); | |
- Pkt.WriteBEUInt8(0x7f); // Metadata terminator | |
+ Pkt.WriteBEUInt8(0xff); // Metadata terminator | |
} | |
-void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) | |
+void cProtocol190::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
double PosX = a_Entity.GetPosX(); | |
@@ -1321,57 +1348,57 @@ void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, | |
FixItemFramePositions(a_ObjectData, PosX, PosZ, Yaw); | |
} | |
- cPacketizer Pkt(*this, 0xe); // Spawn Object packet | |
+ cPacketizer Pkt(*this, 0x00); // Spawn Object packet | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_Entity.GetUniqueID()); | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_ObjectType)); | |
- Pkt.WriteFPInt(PosX); | |
- Pkt.WriteFPInt(a_Entity.GetPosY()); | |
- Pkt.WriteFPInt(PosZ); | |
+ Pkt.WriteBEDouble(PosX); | |
+ Pkt.WriteBEDouble(a_Entity.GetPosY()); | |
+ Pkt.WriteBEDouble(PosZ); | |
Pkt.WriteByteAngle(a_Entity.GetPitch()); | |
Pkt.WriteByteAngle(Yaw); | |
Pkt.WriteBEInt32(a_ObjectData); | |
- if (a_ObjectData != 0) | |
- { | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400)); | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400)); | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400)); | |
- } | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedX() * 400)); | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedY() * 400)); | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Entity.GetSpeedZ() * 400)); | |
} | |
-void cProtocol180::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) | |
+void cProtocol190::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0xe); // Spawn Object packet | |
+ cPacketizer Pkt(*this, 0x00); // Spawn Object packet | |
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID()); | |
+ // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. | |
+ Pkt.WriteBEUInt64(0); | |
+ Pkt.WriteBEUInt64(a_Vehicle.GetUniqueID()); | |
Pkt.WriteBEUInt8(static_cast<UInt8>(a_VehicleType)); | |
- Pkt.WriteFPInt(a_Vehicle.GetPosX()); | |
- Pkt.WriteFPInt(a_Vehicle.GetPosY()); | |
- Pkt.WriteFPInt(a_Vehicle.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_Vehicle.GetPosX()); | |
+ Pkt.WriteBEDouble(a_Vehicle.GetPosY()); | |
+ Pkt.WriteBEDouble(a_Vehicle.GetPosZ()); | |
Pkt.WriteByteAngle(a_Vehicle.GetPitch()); | |
Pkt.WriteByteAngle(a_Vehicle.GetYaw()); | |
Pkt.WriteBEInt32(a_VehicleSubType); | |
- if (a_VehicleSubType != 0) | |
- { | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedX() * 400)); | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedY() * 400)); | |
- Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedZ() * 400)); | |
- } | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedX() * 400)); | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedY() * 400)); | |
+ Pkt.WriteBEInt16(static_cast<Int16>(a_Vehicle.GetSpeedZ() * 400)); | |
} | |
-void cProtocol180::SendStatistics(const cStatManager & a_Manager) | |
+void cProtocol190::SendStatistics(const cStatManager & a_Manager) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x37); | |
+ cPacketizer Pkt(*this, 0x07); // Statistics packet | |
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only | |
size_t Count = static_cast<size_t>(statCount); | |
@@ -1389,11 +1416,11 @@ void cProtocol180::SendStatistics(const cStatManager & a_Manager) | |
-void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results) | |
+void cProtocol190::SendTabCompletionResults(const AStringVector & a_Results) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet | |
+ cPacketizer Pkt(*this, 0x0e); // Tab-Complete packet | |
Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size())); | |
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr) | |
@@ -1406,15 +1433,15 @@ void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results) | |
-void cProtocol180::SendTeleportEntity(const cEntity & a_Entity) | |
+void cProtocol190::SendTeleportEntity(const cEntity & a_Entity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x18); | |
+ cPacketizer Pkt(*this, 0x4a); // Entity teleport packet | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
- Pkt.WriteFPInt(a_Entity.GetPosX()); | |
- Pkt.WriteFPInt(a_Entity.GetPosY()); | |
- Pkt.WriteFPInt(a_Entity.GetPosZ()); | |
+ Pkt.WriteBEDouble(a_Entity.GetPosX()); | |
+ Pkt.WriteBEDouble(a_Entity.GetPosY()); | |
+ Pkt.WriteBEDouble(a_Entity.GetPosZ()); | |
Pkt.WriteByteAngle(a_Entity.GetYaw()); | |
Pkt.WriteByteAngle(a_Entity.GetPitch()); | |
Pkt.WriteBool(a_Entity.IsOnGround()); | |
@@ -1424,23 +1451,23 @@ void cProtocol180::SendTeleportEntity(const cEntity & a_Entity) | |
-void cProtocol180::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ) | |
+void cProtocol190::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x2c); // Spawn Global Entity packet | |
+ cPacketizer Pkt(*this, 0x02); // Spawn Global Entity packet | |
Pkt.WriteVarInt32(0); // EntityID = 0, always | |
Pkt.WriteBEUInt8(1); // Type = Thunderbolt | |
- Pkt.WriteFPInt(a_BlockX); | |
- Pkt.WriteFPInt(a_BlockY); | |
- Pkt.WriteFPInt(a_BlockZ); | |
+ Pkt.WriteBEDouble(a_BlockX); | |
+ Pkt.WriteBEDouble(a_BlockY); | |
+ Pkt.WriteBEDouble(a_BlockZ); | |
} | |
-void cProtocol180::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) | |
+void cProtocol190::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -1456,7 +1483,7 @@ void cProtocol180::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_F | |
-void cProtocol180::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) | |
+void cProtocol190::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
if (!a_DoDaylightCycle) | |
@@ -1465,7 +1492,7 @@ void cProtocol180::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do | |
a_TimeOfDay = std::min(-a_TimeOfDay, -1LL); | |
} | |
- cPacketizer Pkt(*this, 0x03); | |
+ cPacketizer Pkt(*this, 0x44); // Time update packet | |
Pkt.WriteBEInt64(a_WorldAge); | |
Pkt.WriteBEInt64(a_TimeOfDay); | |
} | |
@@ -1474,26 +1501,23 @@ void cProtocol180::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do | |
-void cProtocol180::SendUnloadChunk(int a_ChunkX, int a_ChunkZ) | |
+void cProtocol190::SendUnloadChunk(int a_ChunkX, int a_ChunkZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x21); // Chunk Data packet | |
+ cPacketizer Pkt(*this, 0x1d); // Unload chunk packet | |
Pkt.WriteBEInt32(a_ChunkX); | |
Pkt.WriteBEInt32(a_ChunkZ); | |
- Pkt.WriteBool(true); | |
- Pkt.WriteBEInt16(0); // Primary bitmap | |
- Pkt.WriteVarInt32(0); // Data size | |
} | |
-void cProtocol180::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) | |
+void cProtocol190::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x35); // Update tile entity packet | |
+ cPacketizer Pkt(*this, 0x09); // Update tile entity packet | |
Pkt.WritePosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ()); | |
Byte Action = 0; | |
@@ -1515,11 +1539,11 @@ void cProtocol180::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity) | |
-void cProtocol180::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) | |
+void cProtocol190::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x33); | |
+ cPacketizer Pkt(*this, 0x46); // Update sign packet | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
Json::StyledWriter JsonWriter; | |
@@ -1536,11 +1560,11 @@ void cProtocol180::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons | |
-void cProtocol180::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) | |
+void cProtocol190::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x0a); | |
+ cPacketizer Pkt(*this, 0x2f); // Use bed | |
Pkt.WriteVarInt32(a_Entity.GetUniqueID()); | |
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ); | |
} | |
@@ -1549,12 +1573,12 @@ void cProtocol180::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc | |
-void cProtocol180::SendWeather(eWeather a_Weather) | |
+void cProtocol190::SendWeather(eWeather a_Weather) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
{ | |
- cPacketizer Pkt(*this, 0x2b); // Change Game State packet | |
+ cPacketizer Pkt(*this, 0x1e); // Change Game State packet | |
Pkt.WriteBEUInt8((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain | |
Pkt.WriteBEFloat(0); // Unused for weather | |
} | |
@@ -1566,11 +1590,11 @@ void cProtocol180::SendWeather(eWeather a_Weather) | |
-void cProtocol180::SendWholeInventory(const cWindow & a_Window) | |
+void cProtocol190::SendWholeInventory(const cWindow & a_Window) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x30); // Window Items packet | |
+ cPacketizer Pkt(*this, 0x14); // Window Items packet | |
Pkt.WriteBEInt8(a_Window.GetWindowID()); | |
Pkt.WriteBEInt16(static_cast<Int16>(a_Window.GetNumSlots())); | |
cItems Slots; | |
@@ -1585,11 +1609,11 @@ void cProtocol180::SendWholeInventory(const cWindow & a_Window) | |
-void cProtocol180::SendWindowClose(const cWindow & a_Window) | |
+void cProtocol190::SendWindowClose(const cWindow & a_Window) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x2e); | |
+ cPacketizer Pkt(*this, 0x12); // Close window packet | |
Pkt.WriteBEInt8(a_Window.GetWindowID()); | |
} | |
@@ -1597,7 +1621,7 @@ void cProtocol180::SendWindowClose(const cWindow & a_Window) | |
-void cProtocol180::SendWindowOpen(const cWindow & a_Window) | |
+void cProtocol190::SendWindowOpen(const cWindow & a_Window) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
@@ -1607,7 +1631,7 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window) | |
return; | |
} | |
- cPacketizer Pkt(*this, 0x2d); | |
+ cPacketizer Pkt(*this, 0x13); // Open window packet | |
Pkt.WriteBEInt8(a_Window.GetWindowID()); | |
Pkt.WriteString(a_Window.GetWindowTypeName()); | |
Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_Window.GetWindowTitle().c_str())); | |
@@ -1638,11 +1662,11 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window) | |
-void cProtocol180::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) | |
+void cProtocol190::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value) | |
{ | |
ASSERT(m_State == 3); // In game mode? | |
- cPacketizer Pkt(*this, 0x31); // Window Property packet | |
+ cPacketizer Pkt(*this, 0x15); // Window Property packet | |
Pkt.WriteBEInt8(a_Window.GetWindowID()); | |
Pkt.WriteBEInt16(a_Property); | |
Pkt.WriteBEInt16(a_Value); | |
@@ -1652,7 +1676,7 @@ void cProtocol180::SendWindowProperty(const cWindow & a_Window, short a_Property | |
-bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_CompressedData) | |
+bool cProtocol190::CompressPacket(const AString & a_Packet, AString & a_CompressedData) | |
{ | |
// Compress the data: | |
char CompressedData[MAX_COMPRESSED_PACKET_LEN]; | |
@@ -1695,7 +1719,7 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress | |
-int cProtocol180::GetParticleID(const AString & a_ParticleName) | |
+int cProtocol190::GetParticleID(const AString & a_ParticleName) | |
{ | |
static bool IsInitialized = false; | |
static std::map<AString, int> ParticleMap; | |
@@ -1761,7 +1785,7 @@ int cProtocol180::GetParticleID(const AString & a_ParticleName) | |
-void cProtocol180::FixItemFramePositions(int a_ObjectData, double & a_PosX, double & a_PosZ, double & a_Yaw) | |
+void cProtocol190::FixItemFramePositions(int a_ObjectData, double & a_PosX, double & a_PosZ, double & a_Yaw) | |
{ | |
switch (a_ObjectData) | |
{ | |
@@ -1796,7 +1820,7 @@ void cProtocol180::FixItemFramePositions(int a_ObjectData, double & a_PosX, doub | |
-void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) | |
+void cProtocol190::AddReceivedData(const char * a_Data, size_t a_Size) | |
{ | |
// Write the incoming data into the comm log file: | |
if (g_ShouldLogCommIn && m_CommLogFile.IsOpen()) | |
@@ -1926,7 +1950,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) | |
if (!HandlePacket(bb, PacketType)) | |
{ | |
// Unknown packet, already been reported, but without the length. Log the length here: | |
- LOGWARNING("Unhandled packet: type 0x%x, state %d, length %u", PacketType, m_State, PacketLen); | |
+ LOGWARNING("Protocol 1.9: Unhandled packet: type 0x%x, state %d, length %u", PacketType, m_State, PacketLen); | |
#ifdef _DEBUG | |
// Dump the packet contents into the log: | |
@@ -1952,7 +1976,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) | |
if (bb.GetReadableSpace() != 1) | |
{ | |
// Read more or less than packet length, report as error | |
- LOGWARNING("Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes", | |
+ LOGWARNING("Protocol 1.9: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes", | |
PacketType, m_State, bb.GetUsedSpace() - bb.GetReadableSpace(), PacketLen | |
); | |
@@ -1981,7 +2005,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) | |
ASSERT(m_ReceivedData.GetReadableSpace() == OldReadableSpace); | |
AString Hex; | |
CreateHexDump(Hex, AllData.data(), AllData.size(), 16); | |
- m_CommLogFile.Printf("There are " SIZE_T_FMT " (0x" SIZE_T_FMT_HEX ") bytes of non-parse-able data left in the buffer:\n%s", | |
+ m_CommLogFile.Printf("Protocol 1.9: There are " SIZE_T_FMT " (0x" SIZE_T_FMT_HEX ") bytes of non-parse-able data left in the buffer:\n%s", | |
m_ReceivedData.GetReadableSpace(), m_ReceivedData.GetReadableSpace(), Hex.c_str() | |
); | |
m_CommLogFile.Flush(); | |
@@ -1991,7 +2015,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size) | |
-bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) | |
+bool cProtocol190::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) | |
{ | |
switch (m_State) | |
{ | |
@@ -2022,30 +2046,36 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) | |
// Game | |
switch (a_PacketType) | |
{ | |
- case 0x00: HandlePacketKeepAlive (a_ByteBuffer); return true; | |
- case 0x01: HandlePacketChatMessage (a_ByteBuffer); return true; | |
- case 0x02: HandlePacketUseEntity (a_ByteBuffer); return true; | |
- case 0x03: HandlePacketPlayer (a_ByteBuffer); return true; | |
- case 0x04: HandlePacketPlayerPos (a_ByteBuffer); return true; | |
- case 0x05: HandlePacketPlayerLook (a_ByteBuffer); return true; | |
- case 0x06: HandlePacketPlayerPosLook (a_ByteBuffer); return true; | |
- case 0x07: HandlePacketBlockDig (a_ByteBuffer); return true; | |
- case 0x08: HandlePacketBlockPlace (a_ByteBuffer); return true; | |
- case 0x09: HandlePacketSlotSelect (a_ByteBuffer); return true; | |
- case 0x0a: HandlePacketAnimation (a_ByteBuffer); return true; | |
- case 0x0b: HandlePacketEntityAction (a_ByteBuffer); return true; | |
- case 0x0c: HandlePacketSteerVehicle (a_ByteBuffer); return true; | |
- case 0x0d: HandlePacketWindowClose (a_ByteBuffer); return true; | |
- case 0x0e: HandlePacketWindowClick (a_ByteBuffer); return true; | |
- case 0x0f: // Confirm transaction - not used in MCS | |
- case 0x10: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true; | |
- case 0x11: HandlePacketEnchantItem (a_ByteBuffer); return true; | |
- case 0x12: HandlePacketUpdateSign (a_ByteBuffer); return true; | |
- case 0x13: HandlePacketPlayerAbilities (a_ByteBuffer); return true; | |
- case 0x14: HandlePacketTabComplete (a_ByteBuffer); return true; | |
- case 0x15: HandlePacketClientSettings (a_ByteBuffer); return true; | |
- case 0x16: HandlePacketClientStatus (a_ByteBuffer); return true; | |
- case 0x17: HandlePacketPluginMessage (a_ByteBuffer); return true; | |
+ case 0x00: HandleConfirmTeleport (a_ByteBuffer); return true; | |
+ case 0x01: HandlePacketTabComplete (a_ByteBuffer); return true; | |
+ case 0x02: HandlePacketChatMessage (a_ByteBuffer); return true; | |
+ case 0x03: HandlePacketClientStatus (a_ByteBuffer); return true; | |
+ case 0x04: HandlePacketClientSettings (a_ByteBuffer); return true; | |
+ case 0x05: break; // Confirm transaction - not used in MCS | |
+ case 0x06: HandlePacketEnchantItem (a_ByteBuffer); return true; | |
+ case 0x07: HandlePacketWindowClick (a_ByteBuffer); return true; | |
+ case 0x08: HandlePacketWindowClose (a_ByteBuffer); return true; | |
+ case 0x09: HandlePacketPluginMessage (a_ByteBuffer); return true; | |
+ case 0x0a: HandlePacketUseEntity (a_ByteBuffer); return true; | |
+ case 0x0b: HandlePacketKeepAlive (a_ByteBuffer); return true; | |
+ case 0x0c: HandlePacketPlayerPos (a_ByteBuffer); return true; | |
+ case 0x0d: HandlePacketPlayerPosLook (a_ByteBuffer); return true; | |
+ case 0x0e: HandlePacketPlayerLook (a_ByteBuffer); return true; | |
+ case 0x0f: HandlePacketPlayer (a_ByteBuffer); return true; | |
+ case 0x10: break; // Vehicle move - not yet implemented | |
+ case 0x11: break; // Steer boat - not yet implemented | |
+ case 0x12: HandlePacketPlayerAbilities (a_ByteBuffer); return true; | |
+ case 0x13: HandlePacketBlockDig (a_ByteBuffer); return true; | |
+ case 0x14: HandlePacketEntityAction (a_ByteBuffer); return true; | |
+ case 0x15: HandlePacketSteerVehicle (a_ByteBuffer); return true; | |
+ case 0x16: break; // Resource pack status - not yet implemented | |
+ case 0x17: HandlePacketSlotSelect (a_ByteBuffer); return true; | |
+ case 0x18: HandlePacketCreativeInventoryAction(a_ByteBuffer); return true; | |
+ case 0x19: HandlePacketUpdateSign (a_ByteBuffer); return true; | |
+ case 0x1a: HandlePacketAnimation (a_ByteBuffer); return true; | |
+ case 0x1b: break; // Spectate? | |
+ case 0x1c: HandlePacketBlockPlace (a_ByteBuffer); return true; | |
+ case 0x1d: HandlePacketUseItem (a_ByteBuffer); return true; | |
} | |
break; | |
} | |
@@ -2077,7 +2107,7 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) | |
-void cProtocol180::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEInt64, Int64, Timestamp); | |
@@ -2089,7 +2119,7 @@ void cProtocol180::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
{ | |
cServer * Server = cRoot::Get()->GetServer(); | |
AString ServerDescription = Server->GetDescription(); | |
@@ -2100,8 +2130,8 @@ void cProtocol180::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
// Version: | |
Json::Value Version; | |
- Version["name"] = "Cuberite 1.8"; | |
- Version["protocol"] = 47; | |
+ Version["name"] = "Cuberite 1.9"; | |
+ Version["protocol"] = 107; | |
// Players: | |
Json::Value Players; | |
@@ -2134,7 +2164,7 @@ void cProtocol180::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer) | |
{ | |
UInt32 EncKeyLength, EncNonceLength; | |
if (!a_ByteBuffer.ReadVarInt(EncKeyLength)) | |
@@ -2197,7 +2227,7 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe | |
-void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) | |
{ | |
AString Username; | |
if (!a_ByteBuffer.ReadVarUTF8String(Username)) | |
@@ -2234,8 +2264,10 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketAnimation(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketAnimation(cByteBuffer & a_ByteBuffer) | |
{ | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand); | |
+ | |
m_Client->HandleAnimation(0); // Packet exists solely for arm-swing notification | |
} | |
@@ -2243,7 +2275,7 @@ void cProtocol180::HandlePacketAnimation(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status); | |
@@ -2253,7 +2285,7 @@ void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) | |
return; | |
} | |
- HANDLE_READ(a_ByteBuffer, ReadBEInt8, Int8, Face); | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Face); | |
m_Client->HandleLeftClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), Status); | |
} | |
@@ -2261,7 +2293,7 @@ void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) | |
{ | |
int BlockX, BlockY, BlockZ; | |
if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ)) | |
@@ -2269,11 +2301,8 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) | |
return; | |
} | |
- HANDLE_READ(a_ByteBuffer, ReadBEInt8, Int8, Face); | |
- | |
- cItem Item; | |
- ReadItem(a_ByteBuffer, Item, 3); | |
- | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Face); | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorX); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorY); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, CursorZ); | |
@@ -2284,7 +2313,7 @@ void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketChatMessage(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketChatMessage(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Message); | |
m_Client->HandleChat(Message); | |
@@ -2294,13 +2323,14 @@ void cProtocol180::HandlePacketChatMessage(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketClientSettings(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketClientSettings(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Locale); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, ViewDistance); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, ChatFlags); | |
HANDLE_READ(a_ByteBuffer, ReadBool, bool, ChatColors); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, SkinFlags); | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, MainHand); | |
m_Client->SetLocale(Locale); | |
m_Client->SetViewDistance(ViewDistance); | |
@@ -2311,7 +2341,7 @@ void cProtocol180::HandlePacketClientSettings(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, ActionID); | |
switch (ActionID) | |
@@ -2343,7 +2373,17 @@ void cProtocol180::HandlePacketClientStatus(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandleConfirmTeleport(cByteBuffer & a_ByteBuffer) | |
+{ | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt32, UInt32, TeleportID); | |
+ // We don't actually validate that this packet is sent or anything yet, but it still needs to be read. | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+void cProtocol190::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEInt16, Int16, SlotNum); | |
cItem Item; | |
@@ -2358,7 +2398,7 @@ void cProtocol180::HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffe | |
-void cProtocol180::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, PlayerID); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Action); | |
@@ -2378,7 +2418,7 @@ void cProtocol180::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, KeepAliveID); | |
m_Client->HandleKeepAlive(KeepAliveID); | |
@@ -2388,7 +2428,7 @@ void cProtocol180::HandlePacketKeepAlive(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPlayer(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPlayer(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBool, bool, IsOnGround); | |
// TODO: m_Client->HandlePlayerOnGround(IsOnGround); | |
@@ -2398,7 +2438,7 @@ void cProtocol180::HandlePacketPlayer(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Flags); | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, FlyingSpeed); | |
@@ -2422,7 +2462,7 @@ void cProtocol180::HandlePacketPlayerAbilities(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPlayerLook(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPlayerLook(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Yaw); | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Pitch); | |
@@ -2434,7 +2474,7 @@ void cProtocol180::HandlePacketPlayerLook(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPlayerPos(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPlayerPos(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosX); | |
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosY); | |
@@ -2447,7 +2487,7 @@ void cProtocol180::HandlePacketPlayerPos(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosX); | |
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosY); | |
@@ -2462,7 +2502,7 @@ void cProtocol180::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel); | |
@@ -2493,7 +2533,7 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketSlotSelect(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketSlotSelect(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEInt16, Int16, SlotNum); | |
m_Client->HandleSlotSelected(SlotNum); | |
@@ -2503,7 +2543,7 @@ void cProtocol180::HandlePacketSlotSelect(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketSteerVehicle(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketSteerVehicle(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Sideways); | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Forward); | |
@@ -2527,9 +2567,10 @@ void cProtocol180::HandlePacketSteerVehicle(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Text); | |
+ HANDLE_READ(a_ByteBuffer, ReadBool, bool, AssumeCommand); | |
HANDLE_READ(a_ByteBuffer, ReadBool, bool, HasPosition); | |
if (HasPosition) | |
@@ -2544,7 +2585,7 @@ void cProtocol180::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) | |
{ | |
int BlockX, BlockY, BlockZ; | |
if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ)) | |
@@ -2553,15 +2594,10 @@ void cProtocol180::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) | |
} | |
AString Lines[4]; | |
- Json::Value root; | |
- Json::Reader reader; | |
for (int i = 0; i < 4; i++) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Line); | |
- if (reader.parse(Line, root, false)) | |
- { | |
- Lines[i] = root.asString(); | |
- } | |
+ Lines[i] = Line; | |
} | |
m_Client->HandleUpdateSign(BlockX, BlockY, BlockZ, Lines[0], Lines[1], Lines[2], Lines[3]); | |
@@ -2571,7 +2607,7 @@ void cProtocol180::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, EntityID); | |
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, Type); | |
@@ -2580,6 +2616,7 @@ void cProtocol180::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
{ | |
case 0: | |
{ | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, Hand) | |
m_Client->HandleUseEntity(EntityID, false); | |
break; | |
} | |
@@ -2593,6 +2630,7 @@ void cProtocol180::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, TargetX); | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, TargetY); | |
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, TargetZ); | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, Hand); | |
// TODO: Do anything | |
break; | |
@@ -2609,7 +2647,19 @@ void cProtocol180::HandlePacketUseEntity(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketEnchantItem(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketUseItem(cByteBuffer & a_ByteBuffer) | |
+{ | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt64, Hand); | |
+ | |
+ // TODO: Handle this right-click - we need to figure out what they are looking at or else rewrite the HandleRightClick method. | |
+ // m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), CursorX, CursorY, CursorZ, m_Client->GetPlayer()->GetEquippedItem()); | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+void cProtocol190::HandlePacketEnchantItem(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, WindowID); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Enchantment); | |
@@ -2621,13 +2671,13 @@ void cProtocol180::HandlePacketEnchantItem(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, WindowID); | |
HANDLE_READ(a_ByteBuffer, ReadBEInt16, Int16, SlotNum); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Button); | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt16, UInt16, TransactionID); | |
- HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Mode); | |
+ HANDLE_READ(a_ByteBuffer, ReadVarInt32, UInt32, Mode); | |
cItem Item; | |
ReadItem(a_ByteBuffer, Item); | |
@@ -2673,7 +2723,7 @@ void cProtocol180::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandlePacketWindowClose(cByteBuffer & a_ByteBuffer) | |
+void cProtocol190::HandlePacketWindowClose(cByteBuffer & a_ByteBuffer) | |
{ | |
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, WindowID); | |
m_Client->HandleWindowClose(WindowID); | |
@@ -2683,7 +2733,7 @@ void cProtocol180::HandlePacketWindowClose(cByteBuffer & a_ByteBuffer) | |
-void cProtocol180::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel) | |
+void cProtocol190::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel) | |
{ | |
if (a_Channel == "MC|AdvCdm") | |
{ | |
@@ -2748,7 +2798,7 @@ void cProtocol180::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const | |
-void cProtocol180::SendData(const char * a_Data, size_t a_Size) | |
+void cProtocol190::SendData(const char * a_Data, size_t a_Size) | |
{ | |
if (m_IsEncrypted) | |
{ | |
@@ -2772,7 +2822,7 @@ void cProtocol180::SendData(const char * a_Data, size_t a_Size) | |
-bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) | |
+bool cProtocol190::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) | |
{ | |
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemType); | |
if (ItemType == -1) | |
@@ -2807,7 +2857,7 @@ bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a | |
-void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) | |
+void cProtocol190::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) | |
{ | |
// Parse into NBT: | |
cParsedNBT NBT(a_Metadata.data(), a_Metadata.size()); | |
@@ -2882,7 +2932,7 @@ void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata) | |
-void cProtocol180::StartEncryption(const Byte * a_Key) | |
+void cProtocol190::StartEncryption(const Byte * a_Key) | |
{ | |
m_Encryptor.Init(a_Key, a_Key); | |
m_Decryptor.Init(a_Key, a_Key); | |
@@ -2904,7 +2954,7 @@ void cProtocol180::StartEncryption(const Byte * a_Key) | |
-eBlockFace cProtocol180::FaceIntToBlockFace(Int8 a_BlockFace) | |
+eBlockFace cProtocol190::FaceIntToBlockFace(UInt32 a_BlockFace) | |
{ | |
// Normalize the blockface values returned from the protocol | |
// Anything known gets mapped 1:1, everything else returns BLOCK_FACE_NONE | |
@@ -2925,9 +2975,9 @@ eBlockFace cProtocol180::FaceIntToBlockFace(Int8 a_BlockFace) | |
//////////////////////////////////////////////////////////////////////////////// | |
-// cProtocol180::cPacketizer: | |
+// cProtocol190::cPacketizer: | |
-void cProtocol180::SendPacket(cPacketizer & a_Pkt) | |
+void cProtocol190::SendPacket(cPacketizer & a_Pkt) | |
{ | |
UInt32 PacketLen = static_cast<UInt32>(m_OutPacketBuffer.GetUsedSpace()); | |
AString PacketData, CompressedPacket; | |
@@ -2937,7 +2987,7 @@ void cProtocol180::SendPacket(cPacketizer & a_Pkt) | |
if ((m_State == 3) && (PacketLen >= 256)) | |
{ | |
// Compress the packet payload: | |
- if (!cProtocol180::CompressPacket(PacketData, CompressedPacket)) | |
+ if (!cProtocol190::CompressPacket(PacketData, CompressedPacket)) | |
{ | |
return; | |
} | |
@@ -2987,7 +3037,7 @@ void cProtocol180::SendPacket(cPacketizer & a_Pkt) | |
-void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) | |
+void cProtocol190::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) | |
{ | |
short ItemType = a_Item.m_ItemType; | |
ASSERT(ItemType >= -1); // Check validity of packets in debug runtime | |
@@ -3075,7 +3125,7 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) | |
-void cProtocol180::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_BlockEntity) | |
+void cProtocol190::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_BlockEntity) | |
{ | |
cFastNBTWriter Writer; | |
@@ -3179,10 +3229,10 @@ void cProtocol180::WriteBlockEntity(cPacketizer & a_Pkt, const cBlockEntity & a_ | |
-void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) | |
+void cProtocol190::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) | |
{ | |
// Common metadata: | |
- Byte Flags = 0; | |
+ Int8 Flags = 0; | |
if (a_Entity.IsOnFire()) | |
{ | |
Flags |= 0x01; | |
@@ -3203,21 +3253,24 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
{ | |
Flags |= 0x20; | |
} | |
- a_Pkt.WriteBEUInt8(0); // Byte(0) + index 0 | |
- a_Pkt.WriteBEUInt8(Flags); | |
+ a_Pkt.WriteBEUInt8(0); // Index 0 | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); // Type | |
+ a_Pkt.WriteBEInt8(Flags); | |
switch (a_Entity.GetEntityType()) | |
{ | |
case cEntity::etPlayer: break; // TODO? | |
case cEntity::etPickup: | |
{ | |
- a_Pkt.WriteBEUInt8((5 << 5) | 10); // Slot(5) + index 10 | |
+ a_Pkt.WriteBEUInt8(5); // Index 5: Item | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_ITEM); | |
WriteItem(a_Pkt, reinterpret_cast<const cPickup &>(a_Entity).GetItem()); | |
break; | |
} | |
case cEntity::etMinecart: | |
{ | |
- a_Pkt.WriteBEUInt8(0x51); | |
+ a_Pkt.WriteBEUInt8(5); // Index 5: Shaking power | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
// The following expression makes Minecarts shake more with less health or higher damage taken | |
// It gets half the maximum health, and takes it away from the current health minus the half health: | |
@@ -3227,11 +3280,15 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
Health: 1 | 3 - (1 - 3) = 5 | |
*/ | |
auto & Minecart = reinterpret_cast<const cMinecart &>(a_Entity); | |
- a_Pkt.WriteBEInt32((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * Minecart.LastDamage()) * 4); | |
- a_Pkt.WriteBEUInt8(0x52); | |
- a_Pkt.WriteBEInt32(1); // Shaking direction, doesn't seem to affect anything | |
- a_Pkt.WriteBEUInt8(0x73); | |
- a_Pkt.WriteBEFloat(static_cast<float>(Minecart.LastDamage() + 10)); // Damage taken / shake effect multiplyer | |
+ a_Pkt.WriteVarInt32((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * Minecart.LastDamage()) * 4); | |
+ | |
+ a_Pkt.WriteBEUInt8(6); // Index 6: Shaking direction (doesn't seem to effect anything) | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(1); | |
+ | |
+ a_Pkt.WriteBEUInt8(7); // Index 7: Shake multiplier / damage taken | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_FLOAT); | |
+ a_Pkt.WriteBEFloat(static_cast<float>(Minecart.LastDamage() + 10)); | |
if (Minecart.GetPayload() == cMinecart::mpNone) | |
{ | |
@@ -3239,20 +3296,26 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
const cItem & MinecartContent = RideableMinecart.GetContent(); | |
if (!MinecartContent.IsEmpty()) | |
{ | |
- a_Pkt.WriteBEUInt8(0x54); | |
+ a_Pkt.WriteBEUInt8(8); // Index 8: Block ID and damage | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
int Content = MinecartContent.m_ItemType; | |
Content |= MinecartContent.m_ItemDamage << 8; | |
- a_Pkt.WriteBEInt32(Content); | |
- a_Pkt.WriteBEUInt8(0x55); | |
- a_Pkt.WriteBEInt32(RideableMinecart.GetBlockHeight()); | |
- a_Pkt.WriteBEUInt8(0x56); | |
- a_Pkt.WriteBEUInt8(1); | |
+ a_Pkt.WriteVarInt32(Content); | |
+ | |
+ a_Pkt.WriteBEUInt8(9); // Index 9: Block ID and damage | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(RideableMinecart.GetBlockHeight()); | |
+ | |
+ a_Pkt.WriteBEUInt8(10); // Index 10: Show block | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(true); | |
} | |
} | |
else if (Minecart.GetPayload() == cMinecart::mpFurnace) | |
{ | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(reinterpret_cast<const cMinecartWithFurnace &>(Minecart).IsFueled() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is powered | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(reinterpret_cast<const cMinecartWithFurnace &>(Minecart).IsFueled()); | |
} | |
break; | |
} // case etMinecart | |
@@ -3264,13 +3327,15 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
{ | |
case cProjectileEntity::pkArrow: | |
{ | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(reinterpret_cast<const cArrowEntity &>(Projectile).IsCritical() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(5); // Index 5: Is critical | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ a_Pkt.WriteBEInt8(reinterpret_cast<const cArrowEntity &>(Projectile).IsCritical() ? 1 : 0); | |
break; | |
} | |
case cProjectileEntity::pkFirework: | |
{ | |
- a_Pkt.WriteBEUInt8(0xa8); | |
+ a_Pkt.WriteBEUInt8(5); // Index 5: Firework item used for this firework | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_ITEM); | |
WriteItem(a_Pkt, reinterpret_cast<const cFireworkEntity &>(Projectile).GetItem()); | |
break; | |
} | |
@@ -3291,10 +3356,12 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
case cEntity::etItemFrame: | |
{ | |
auto & Frame = reinterpret_cast<const cItemFrame &>(a_Entity); | |
- a_Pkt.WriteBEUInt8(0xa8); | |
+ a_Pkt.WriteBEUInt8(5); // Index 5: Item | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_ITEM); | |
WriteItem(a_Pkt, Frame.GetItem()); | |
- a_Pkt.WriteBEUInt8(0x09); | |
- a_Pkt.WriteBEUInt8(Frame.GetItemRotation()); | |
+ a_Pkt.WriteBEUInt8(6); // Index 6: Rotation | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Frame.GetItemRotation()); | |
break; | |
} // case etItemFrame | |
@@ -3309,19 +3376,23 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En | |
-void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
+void cProtocol190::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
{ | |
// Living Enitiy Metadata | |
if (a_Mob.HasCustomName()) | |
{ | |
- a_Pkt.WriteBEUInt8(0x82); | |
+ // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up? | |
+ a_Pkt.WriteBEUInt8(2); // Index 2: Custom name | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_STRING); | |
a_Pkt.WriteString(a_Mob.GetCustomName()); | |
- a_Pkt.WriteBEUInt8(0x03); | |
+ a_Pkt.WriteBEUInt8(3); // Index 3: Custom name always visible | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
a_Pkt.WriteBool(a_Mob.IsCustomNameAlwaysVisible()); | |
} | |
- a_Pkt.WriteBEUInt8(0x66); | |
+ a_Pkt.WriteBEUInt8(6); // Index 6: Health | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_FLOAT); | |
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth())); | |
switch (a_Mob.GetMobType()) | |
@@ -3329,45 +3400,58 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
case mtBat: | |
{ | |
auto & Bat = reinterpret_cast<const cBat &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(Bat.IsHanging() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Bat flags - currently only hanging | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ a_Pkt.WriteBEInt8(Bat.IsHanging() ? 0 : 1); | |
break; | |
} // case mtBat | |
case mtCreeper: | |
{ | |
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(Creeper.IsBlowing() ? 1 : 255); | |
- a_Pkt.WriteBEUInt8(0x11); | |
- a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: State (idle or "blowing") | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Creeper.IsBlowing() ? 1 : -1); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Is charged | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Creeper.IsCharged()); | |
+ | |
+ a_Pkt.WriteBEUInt8(13); // Index 13: Is ignited | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Creeper.IsBurnedWithFlintAndSteel()); | |
break; | |
} // case mtCreeper | |
case mtEnderman: | |
{ | |
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x30); | |
- a_Pkt.WriteBEInt16(static_cast<Byte>(Enderman.GetCarriedBlock())); | |
- a_Pkt.WriteBEUInt8(0x11); | |
- a_Pkt.WriteBEUInt8(static_cast<Byte>(Enderman.GetCarriedMeta())); | |
- a_Pkt.WriteBEUInt8(0x12); | |
- a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Carried block | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BLOCKID); | |
+ UInt32 Carried = 0; | |
+ Carried |= Enderman.GetCarriedBlock() << 4; | |
+ Carried |= Enderman.GetCarriedMeta(); | |
+ a_Pkt.WriteVarInt32(Carried); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Is screaming | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Enderman.IsScreaming()); | |
break; | |
} // case mtEnderman | |
case mtGhast: | |
{ | |
auto & Ghast = reinterpret_cast<const cGhast &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(Ghast.IsCharging()); | |
+ a_Pkt.WriteBEUInt8(11); // Is attacking | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Ghast.IsCharging()); | |
break; | |
} // case mtGhast | |
case mtHorse: | |
{ | |
auto & Horse = reinterpret_cast<const cHorse &>(a_Mob); | |
- int Flags = 0; | |
+ Int8 Flags = 0; | |
if (Horse.IsTame()) | |
{ | |
Flags |= 0x02; | |
@@ -3392,139 +3476,176 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
{ | |
Flags |= 0x80; | |
} | |
- a_Pkt.WriteBEUInt8(0x50); // Int at index 16 | |
- a_Pkt.WriteBEInt32(Flags); | |
- a_Pkt.WriteBEUInt8(0x13); // Byte at index 19 | |
- a_Pkt.WriteBEUInt8(static_cast<UInt8>(Horse.GetHorseType())); | |
- a_Pkt.WriteBEUInt8(0x54); // Int at index 20 | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: flags | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ a_Pkt.WriteBEInt8(Flags); | |
+ | |
+ a_Pkt.WriteBEUInt8(13); // Index 13: Variant / type | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Horse.GetHorseType()); | |
+ | |
+ a_Pkt.WriteBEUInt8(14); // Index 14: Color / style | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
int Appearance = 0; | |
Appearance = Horse.GetHorseColor(); | |
Appearance |= Horse.GetHorseStyle() << 8; | |
- a_Pkt.WriteBEInt32(Appearance); | |
- a_Pkt.WriteBEUInt8(0x56); // Int at index 22 | |
- a_Pkt.WriteBEInt32(Horse.GetHorseArmour()); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Horse.IsBaby() ? -1 : (Horse.IsInLoveCooldown() ? 1 : 0)); | |
+ a_Pkt.WriteVarInt32(Appearance); | |
+ | |
+ a_Pkt.WriteBEUInt8(16); // Index 16: Armor | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Horse.GetHorseArmour()); | |
+ | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Horse.IsBaby()); | |
break; | |
} // case mtHorse | |
case mtMagmaCube: | |
{ | |
auto & MagmaCube = reinterpret_cast<const cMagmaCube &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(static_cast<UInt8>(MagmaCube.GetSize())); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Size | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(MagmaCube.GetSize()); | |
break; | |
} // case mtMagmaCube | |
case mtOcelot: | |
{ | |
auto & Ocelot = reinterpret_cast<const cOcelot &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Ocelot.IsBaby() ? -1 : (Ocelot.IsInLoveCooldown() ? 1 : 0)); | |
+ | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Ocelot.IsBaby()); | |
break; | |
} // case mtOcelot | |
case mtCow: | |
{ | |
auto & Cow = reinterpret_cast<const cCow &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Cow.IsBaby() ? -1 : (Cow.IsInLoveCooldown() ? 1 : 0)); | |
+ | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Cow.IsBaby()); | |
break; | |
} // case mtCow | |
case mtChicken: | |
{ | |
auto & Chicken = reinterpret_cast<const cChicken &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Chicken.IsBaby() ? -1 : (Chicken.IsInLoveCooldown() ? 1 : 0)); | |
+ | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Chicken.IsBaby()); | |
break; | |
} // case mtChicken | |
case mtPig: | |
{ | |
auto & Pig = reinterpret_cast<const cPig &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Pig.IsBaby() ? -1 : (Pig.IsInLoveCooldown() ? 1 : 0)); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(Pig.IsSaddled() ? 1 : 0); | |
+ | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Pig.IsBaby()); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Is saddled | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Pig.IsSaddled()); | |
break; | |
} // case mtPig | |
case mtSheep: | |
{ | |
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Sheep.IsBaby() ? -1 : (Sheep.IsInLoveCooldown() ? 1 : 0)); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- Byte SheepMetadata = 0; | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Sheep.IsBaby()); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: sheared, color | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ Int8 SheepMetadata = 0; | |
SheepMetadata = static_cast<Byte>(Sheep.GetFurColor()); | |
if (Sheep.IsSheared()) | |
{ | |
SheepMetadata |= 0x10; | |
} | |
- a_Pkt.WriteBEUInt8(SheepMetadata); | |
+ a_Pkt.WriteBEInt8(SheepMetadata); | |
break; | |
} // case mtSheep | |
case mtRabbit: | |
{ | |
auto & Rabbit = reinterpret_cast<const cRabbit &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x12); | |
- a_Pkt.WriteBEUInt8(Rabbit.GetRabbitTypeAsNumber()); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Rabbit.IsBaby() ? -1 : (Rabbit.IsInLoveCooldown() ? 1 : 0)); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Rabbit.IsBaby()); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Type | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Rabbit.GetRabbitTypeAsNumber()); | |
break; | |
} // case mtRabbit | |
case mtSkeleton: | |
{ | |
auto & Skeleton = reinterpret_cast<const cSkeleton &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0d); | |
- a_Pkt.WriteBEUInt8(Skeleton.IsWither() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Type | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Skeleton.IsWither() ? 1 : 0); | |
break; | |
} // case mtSkeleton | |
case mtSlime: | |
{ | |
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(static_cast<UInt8>(Slime.GetSize())); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Size | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Slime.GetSize()); | |
break; | |
} // case mtSlime | |
case mtVillager: | |
{ | |
auto & Villager = reinterpret_cast<const cVillager &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x50); | |
- a_Pkt.WriteBEInt32(Villager.GetVilType()); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Villager.IsBaby() ? -1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Villager.IsBaby()); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Type | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Villager.GetVilType()); | |
break; | |
} // case mtVillager | |
case mtWitch: | |
{ | |
auto & Witch = reinterpret_cast<const cWitch &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x15); | |
- a_Pkt.WriteBEUInt8(Witch.IsAngry() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is angry | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Witch.IsAngry()); | |
break; | |
} // case mtWitch | |
case mtWither: | |
{ | |
auto & Wither = reinterpret_cast<const cWither &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x54); // Int at index 20 | |
- a_Pkt.WriteBEInt32(static_cast<Int32>(Wither.GetWitherInvulnerableTicks())); | |
- a_Pkt.WriteBEUInt8(0x66); // Float at index 6 | |
- a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth())); | |
+ a_Pkt.WriteBEUInt8(14); // Index 14: Invulnerable ticks | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Wither.GetWitherInvulnerableTicks()); | |
+ | |
+ // TODO: Use boss bar packet for health | |
break; | |
} // case mtWither | |
case mtWolf: | |
{ | |
auto & Wolf = reinterpret_cast<const cWolf &>(a_Mob); | |
- Byte WolfStatus = 0; | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Wolf.IsBaby()); | |
+ | |
+ Int8 WolfStatus = 0; | |
if (Wolf.IsSitting()) | |
{ | |
WolfStatus |= 0x1; | |
@@ -3537,37 +3658,47 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
{ | |
WolfStatus |= 0x4; | |
} | |
- a_Pkt.WriteBEUInt8(0x10); | |
- a_Pkt.WriteBEUInt8(WolfStatus); | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: status | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ a_Pkt.WriteBEInt8(WolfStatus); | |
- a_Pkt.WriteBEUInt8(0x72); | |
+ a_Pkt.WriteBEUInt8(14); // Index 14: Health | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_FLOAT); | |
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth())); | |
- a_Pkt.WriteBEUInt8(0x13); | |
- a_Pkt.WriteBEUInt8(Wolf.IsBegging() ? 1 : 0); | |
- a_Pkt.WriteBEUInt8(0x14); | |
- a_Pkt.WriteBEUInt8(static_cast<UInt8>(Wolf.GetCollarColor())); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Wolf.IsBaby() ? -1 : 0); | |
+ | |
+ a_Pkt.WriteBEUInt8(15); // Index 15: Is begging | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Wolf.IsBegging()); | |
+ | |
+ a_Pkt.WriteBEUInt8(16); // Index 16: Collar color | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BYTE); | |
+ a_Pkt.WriteVarInt32(static_cast<UInt8>(Wolf.GetCollarColor())); | |
break; | |
} // case mtWolf | |
case mtZombie: | |
{ | |
auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(Zombie.IsBaby() ? 1 : -1); | |
- a_Pkt.WriteBEUInt8(0x0d); | |
- a_Pkt.WriteBEUInt8(Zombie.IsVillagerZombie() ? 1 : 0); | |
- a_Pkt.WriteBEUInt8(0x0e); | |
- a_Pkt.WriteBEUInt8(Zombie.IsConverting() ? 1 : 0); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Zombie.IsBaby()); | |
+ | |
+ a_Pkt.WriteBEUInt8(12); // Index 12: Is a villager | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); | |
+ a_Pkt.WriteVarInt32(Zombie.IsVillagerZombie() ? 1 : 0); // TODO: This actually encodes the zombie villager profession, but that isn't implemented yet. | |
+ | |
+ a_Pkt.WriteBEUInt8(13); // Index 13: Is converting | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(Zombie.IsConverting()); | |
break; | |
} // case mtZombie | |
case mtZombiePigman: | |
{ | |
auto & ZombiePigman = reinterpret_cast<const cZombiePigman &>(a_Mob); | |
- a_Pkt.WriteBEUInt8(0x0c); | |
- a_Pkt.WriteBEInt8(ZombiePigman.IsBaby() ? 1 : -1); | |
+ a_Pkt.WriteBEUInt8(11); // Index 11: Is baby | |
+ a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); | |
+ a_Pkt.WriteBool(ZombiePigman.IsBaby()); | |
break; | |
} // case mtZombiePigman | |
} // switch (a_Mob.GetType()) | |
@@ -3577,7 +3708,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) | |
-void cProtocol180::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_Entity) | |
+void cProtocol190::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_Entity) | |
{ | |
if (!a_Entity.IsMob()) | |
{ | |
@@ -3595,3 +3726,155 @@ void cProtocol180::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_ | |
+ | |
+ | |
+//////////////////////////////////////////////////////////////////////////////// | |
+// cProtocol191: | |
+ | |
+cProtocol191::cProtocol191(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : | |
+ super(a_Client, a_ServerAddress, a_ServerPort, a_State) | |
+{ | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+void cProtocol191::SendLogin(const cPlayer & a_Player, const cWorld & a_World) | |
+{ | |
+ // Send the Join Game packet: | |
+ { | |
+ cServer * Server = cRoot::Get()->GetServer(); | |
+ cPacketizer Pkt(*this, 0x23); // Join Game packet | |
+ Pkt.WriteBEUInt32(a_Player.GetUniqueID()); | |
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4 | |
+ Pkt.WriteBEInt32(static_cast<Int32>(a_World.GetDimension())); | |
+ Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal) | |
+ Pkt.WriteBEUInt8(static_cast<UInt8>(Clamp<int>(Server->GetMaxPlayers(), 0, 255))); | |
+ Pkt.WriteString("default"); // Level type - wtf? | |
+ Pkt.WriteBool(false); // Reduced Debug Info - wtf? | |
+ } | |
+ m_LastSentDimension = a_World.GetDimension(); | |
+ | |
+ // Send the spawn position: | |
+ { | |
+ cPacketizer Pkt(*this, 0x43); // Spawn Position packet | |
+ Pkt.WritePosition64(FloorC(a_World.GetSpawnX()), FloorC(a_World.GetSpawnY()), FloorC(a_World.GetSpawnZ())); | |
+ } | |
+ | |
+ // Send the server difficulty: | |
+ { | |
+ cPacketizer Pkt(*this, 0x0d); // Server difficulty packet | |
+ Pkt.WriteBEInt8(1); | |
+ } | |
+ | |
+ // Send player abilities: | |
+ SendPlayerAbilities(); | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+void cProtocol191::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
+{ | |
+ cServer * Server = cRoot::Get()->GetServer(); | |
+ AString ServerDescription = Server->GetDescription(); | |
+ int NumPlayers = Server->GetNumPlayers(); | |
+ int MaxPlayers = Server->GetMaxPlayers(); | |
+ AString Favicon = Server->GetFaviconData(); | |
+ cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); | |
+ | |
+ // Version: | |
+ Json::Value Version; | |
+ Version["name"] = "Cuberite 1.9.1"; | |
+ Version["protocol"] = 108; | |
+ | |
+ // Players: | |
+ Json::Value Players; | |
+ Players["online"] = NumPlayers; | |
+ Players["max"] = MaxPlayers; | |
+ // TODO: Add "sample" | |
+ | |
+ // Description: | |
+ Json::Value Description; | |
+ Description["text"] = ServerDescription.c_str(); | |
+ | |
+ // Create the response: | |
+ Json::Value ResponseValue; | |
+ ResponseValue["version"] = Version; | |
+ ResponseValue["players"] = Players; | |
+ ResponseValue["description"] = Description; | |
+ if (!Favicon.empty()) | |
+ { | |
+ ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); | |
+ } | |
+ | |
+ Json::StyledWriter Writer; | |
+ AString Response = Writer.write(ResponseValue); | |
+ | |
+ cPacketizer Pkt(*this, 0x00); // Response packet | |
+ Pkt.WriteString(Response); | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+//////////////////////////////////////////////////////////////////////////////// | |
+// cProtocol192: | |
+ | |
+cProtocol192::cProtocol192(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : | |
+ super(a_Client, a_ServerAddress, a_ServerPort, a_State) | |
+{ | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ | |
+void cProtocol192::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) | |
+{ | |
+ cServer * Server = cRoot::Get()->GetServer(); | |
+ AString ServerDescription = Server->GetDescription(); | |
+ int NumPlayers = Server->GetNumPlayers(); | |
+ int MaxPlayers = Server->GetMaxPlayers(); | |
+ AString Favicon = Server->GetFaviconData(); | |
+ cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); | |
+ | |
+ // Version: | |
+ Json::Value Version; | |
+ Version["name"] = "Cuberite 1.9.2"; | |
+ Version["protocol"] = 109; | |
+ | |
+ // Players: | |
+ Json::Value Players; | |
+ Players["online"] = NumPlayers; | |
+ Players["max"] = MaxPlayers; | |
+ // TODO: Add "sample" | |
+ | |
+ // Description: | |
+ Json::Value Description; | |
+ Description["text"] = ServerDescription.c_str(); | |
+ | |
+ // Create the response: | |
+ Json::Value ResponseValue; | |
+ ResponseValue["version"] = Version; | |
+ ResponseValue["players"] = Players; | |
+ ResponseValue["description"] = Description; | |
+ if (!Favicon.empty()) | |
+ { | |
+ ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); | |
+ } | |
+ | |
+ Json::StyledWriter Writer; | |
+ AString Response = Writer.write(ResponseValue); | |
+ | |
+ cPacketizer Pkt(*this, 0x00); // Response packet | |
+ Pkt.WriteString(Response); | |
+} | |
+ | |
+ | |
+ | |
+ | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment