summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol17x.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-22 23:09:23 +0100
committerMattes D <github@xoft.cz>2015-03-22 23:09:23 +0100
commitb913c5da69f362abbb70de6e11baca4cbce2b919 (patch)
tree782854bd86c7165e38459e592fb81979270f732a /src/Protocol/Protocol17x.cpp
parentUnified cPacketizer across all protocols. (diff)
downloadcuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar.gz
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar.bz2
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar.lz
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar.xz
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.tar.zst
cuberite-b913c5da69f362abbb70de6e11baca4cbce2b919.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol17x.cpp657
1 files changed, 329 insertions, 328 deletions
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 9632a54b7..2bc58e7e5 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -165,8 +165,8 @@ void cProtocol172::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1b); // Attach Entity packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteUInt32((a_Vehicle != nullptr) ? a_Vehicle->GetUniqueID() : 0);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32((a_Vehicle != nullptr) ? a_Vehicle->GetUniqueID() : 0);
Pkt.WriteBool(false);
}
@@ -179,12 +179,12 @@ void cProtocol172::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, cha
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x24); // Block Action packet
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteShort(static_cast<short>(a_BlockY));
- Pkt.WriteInt(a_BlockZ);
- Pkt.WriteByte(static_cast<Byte>(a_Byte1));
- Pkt.WriteByte(static_cast<Byte>(a_Byte2));
- Pkt.WriteVarInt(a_BlockType);
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEInt16(static_cast<Int16>(a_BlockY));
+ Pkt.WriteBEInt32(a_BlockZ);
+ Pkt.WriteBEInt8(a_Byte1);
+ Pkt.WriteBEInt8(a_Byte2);
+ Pkt.WriteVarInt32(a_BlockType);
}
@@ -196,11 +196,11 @@ void cProtocol172::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_Blo
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x25); // Block Break Animation packet
- Pkt.WriteVarInt(a_EntityID);
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteInt(a_BlockY);
- Pkt.WriteInt(a_BlockZ);
- Pkt.WriteChar(a_Stage);
+ Pkt.WriteVarInt32(a_EntityID);
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEInt32(a_BlockY);
+ Pkt.WriteBEInt32(a_BlockZ);
+ Pkt.WriteBEInt8(a_Stage);
}
@@ -213,11 +213,11 @@ void cProtocol172::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
ASSERT((a_BlockY >= 0) && (a_BlockY < 256));
cPacketizer Pkt(*this, 0x23); // Block Change packet
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteByte(static_cast<Byte>(a_BlockY));
- Pkt.WriteInt(a_BlockZ);
- Pkt.WriteVarInt(a_BlockType);
- Pkt.WriteByte(a_BlockMeta);
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_BlockY));
+ Pkt.WriteBEInt32(a_BlockZ);
+ Pkt.WriteVarInt32(a_BlockType);
+ Pkt.WriteBEUInt8(a_BlockMeta);
}
@@ -229,15 +229,15 @@ void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x22); // Multi Block Change packet
- Pkt.WriteInt(a_ChunkX);
- Pkt.WriteInt(a_ChunkZ);
- Pkt.WriteShort((short)a_Changes.size());
- Pkt.WriteInt((int)a_Changes.size() * 4);
+ Pkt.WriteBEInt32(a_ChunkX);
+ Pkt.WriteBEInt32(a_ChunkZ);
+ Pkt.WriteBEUInt16(static_cast<UInt16>(a_Changes.size()));
+ Pkt.WriteBEUInt32(static_cast<UInt32>(a_Changes.size() * 4));
for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr)
{
int Coords = itr->m_RelY | (itr->m_RelZ << 8) | (itr->m_RelX << 12);
int Blocks = static_cast<int>(itr->m_BlockMeta | (itr->m_BlockType << 4));
- Pkt.WriteInt((Coords << 16) | Blocks);
+ Pkt.WriteBEInt32((Coords << 16) | Blocks);
} // for itr - a_Changes[]
}
@@ -282,8 +282,8 @@ void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_3_2, a_ChunkX, a_ChunkZ);
cPacketizer Pkt(*this, 0x21); // Chunk Data packet
- Pkt.WriteInt(a_ChunkX);
- Pkt.WriteInt(a_ChunkZ);
+ Pkt.WriteBEInt32(a_ChunkX);
+ Pkt.WriteBEInt32(a_ChunkZ);
Pkt.WriteBuf(ChunkData.data(), ChunkData.size());
}
@@ -296,8 +296,8 @@ void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteUInt32(a_Player.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Player.GetUniqueID());
}
@@ -309,8 +309,8 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x13); // Destroy Entities packet
- Pkt.WriteByte(1);
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(1);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
}
@@ -347,9 +347,9 @@ void cProtocol172::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
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteInt(a_BlockY);
- Pkt.WriteInt(a_BlockZ);
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEInt32(a_BlockY);
+ Pkt.WriteBEInt32(a_BlockZ);
}
@@ -363,10 +363,10 @@ void cProtocol172::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
ASSERT((a_Amplifier >= 0) && (a_Amplifier < 256));
cPacketizer Pkt(*this, 0x1D); // Entity Effect packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteByte(static_cast<Byte>(a_EffectID));
- Pkt.WriteByte(static_cast<Byte>(a_Amplifier));
- Pkt.WriteShort(a_Duration);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_EffectID));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Amplifier));
+ Pkt.WriteBEInt16(a_Duration);
}
@@ -378,8 +378,8 @@ void cProtocol172::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x04); // Entity Equipment packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteShort(a_SlotNum);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt16(a_SlotNum);
WriteItem(Pkt, a_Item);
}
@@ -392,7 +392,7 @@ void cProtocol172::SendEntityHeadLook(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x19); // Entity Head Look packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
}
@@ -405,7 +405,7 @@ void cProtocol172::SendEntityLook(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x16); // Entity Look packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetYaw());
Pkt.WriteByteAngle(a_Entity.GetPitch());
}
@@ -419,9 +419,9 @@ void cProtocol172::SendEntityMetadata(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
WriteEntityMetadata(Pkt, a_Entity);
- Pkt.WriteByte(0x7f); // The termination byte
+ Pkt.WriteBEUInt8(0x7f); // The termination byte
}
@@ -433,7 +433,7 @@ void cProtocol172::SendEntityProperties(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x20); // Entity Properties packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
WriteEntityProperties(Pkt, a_Entity);
}
@@ -446,10 +446,10 @@ void cProtocol172::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x15); // Entity Relative Move packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_RelX);
- Pkt.WriteChar(a_RelY);
- Pkt.WriteChar(a_RelZ);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_RelX);
+ Pkt.WriteBEInt8(a_RelY);
+ Pkt.WriteBEInt8(a_RelZ);
}
@@ -461,10 +461,10 @@ void cProtocol172::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX,
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x17); // Entity Look And Relative Move packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_RelX);
- Pkt.WriteChar(a_RelY);
- Pkt.WriteChar(a_RelZ);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_RelX);
+ Pkt.WriteBEInt8(a_RelY);
+ Pkt.WriteBEInt8(a_RelZ);
Pkt.WriteByteAngle(a_Entity.GetYaw());
Pkt.WriteByteAngle(a_Entity.GetPitch());
}
@@ -478,8 +478,8 @@ void cProtocol172::SendEntityStatus(const cEntity & a_Entity, char a_Status)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1a); // Entity Status packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_Status);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_Status);
}
@@ -491,11 +491,11 @@ void cProtocol172::SendEntityVelocity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m/s to 8000 m/tick
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedX() * 400));
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedY() * 400));
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedZ() * 400));
}
@@ -507,20 +507,20 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x27); // Explosion packet
- Pkt.WriteFloat((float)a_BlockX);
- Pkt.WriteFloat((float)a_BlockY);
- Pkt.WriteFloat((float)a_BlockZ);
- Pkt.WriteFloat((float)a_Radius);
- Pkt.WriteInt((int)a_BlocksAffected.size());
+ Pkt.WriteBEFloat(static_cast<float>(a_BlockX));
+ Pkt.WriteBEFloat(static_cast<float>(a_BlockY));
+ Pkt.WriteBEFloat(static_cast<float>(a_BlockZ));
+ Pkt.WriteBEFloat(static_cast<float>(a_Radius));
+ Pkt.WriteBEUInt32(static_cast<UInt32>(a_BlocksAffected.size()));
for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(), end = a_BlocksAffected.end(); itr != end; ++itr)
{
- Pkt.WriteChar((char)itr->x);
- Pkt.WriteChar((char)itr->y);
- Pkt.WriteChar((char)itr->z);
+ Pkt.WriteBEInt8(static_cast<Int8>(itr->x));
+ Pkt.WriteBEInt8(static_cast<Int8>(itr->y));
+ Pkt.WriteBEInt8(static_cast<Int8>(itr->z));
} // for itr - a_BlockAffected[]
- Pkt.WriteFloat((float)a_PlayerMotion.x);
- Pkt.WriteFloat((float)a_PlayerMotion.y);
- Pkt.WriteFloat((float)a_PlayerMotion.z);
+ Pkt.WriteBEFloat(static_cast<float>(a_PlayerMotion.x));
+ Pkt.WriteBEFloat(static_cast<float>(a_PlayerMotion.y));
+ Pkt.WriteBEFloat(static_cast<float>(a_PlayerMotion.z));
}
@@ -532,8 +532,8 @@ void cProtocol172::SendGameMode(eGameMode a_GameMode)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
- Pkt.WriteByte(3); // Reason: Change game mode
- Pkt.WriteFloat((float)a_GameMode);
+ Pkt.WriteBEUInt8(3); // Reason: Change game mode
+ Pkt.WriteBEFloat(static_cast<float>(a_GameMode)); // The protocol really represents the value with a float!
}
@@ -546,9 +546,9 @@ void cProtocol172::SendHealth(void)
cPacketizer Pkt(*this, 0x06); // Update Health packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteFloat(static_cast<float>(Player->GetHealth()));
- Pkt.WriteShort(static_cast<short>(Player->GetFoodLevel()));
- Pkt.WriteFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
+ Pkt.WriteBEInt16(static_cast<short>(Player->GetFoodLevel()));
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
}
@@ -560,8 +560,8 @@ void cProtocol172::SendInventorySlot(char a_WindowID, short a_SlotNum, const cIt
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x2f); // Set Slot packet
- Pkt.WriteChar(a_WindowID);
- Pkt.WriteShort(a_SlotNum);
+ Pkt.WriteBEInt8(a_WindowID);
+ Pkt.WriteBEInt16(a_SlotNum);
WriteItem(Pkt, a_Item);
}
@@ -579,7 +579,7 @@ void cProtocol172::SendKeepAlive(int a_PingID)
}
cPacketizer Pkt(*this, 0x00); // Keep Alive packet
- Pkt.WriteInt(a_PingID);
+ Pkt.WriteBEInt32(a_PingID);
}
@@ -592,11 +592,11 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
{
cServer * Server = cRoot::Get()->GetServer();
cPacketizer Pkt(*this, 0x01); // Join Game packet
- Pkt.WriteUInt32(a_Player.GetUniqueID());
- Pkt.WriteByte(static_cast<Byte>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteChar(static_cast<char>(a_World.GetDimension()));
- Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte(static_cast<Byte>(std::min(Server->GetMaxPlayers(), 60)));
+ Pkt.WriteBEUInt32(a_Player.GetUniqueID());
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Player.GetEffectiveGameMode()) | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
+ Pkt.WriteBEInt8(static_cast<char>(a_World.GetDimension()));
+ Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
+ Pkt.WriteBEUInt8(static_cast<Byte>(std::min(Server->GetMaxPlayers(), 60)));
Pkt.WriteString("default"); // Level type - wtf?
}
m_LastSentDimension = a_World.GetDimension();
@@ -604,9 +604,9 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
// Send the spawn position:
{
cPacketizer Pkt(*this, 0x05); // Spawn Position packet
- Pkt.WriteInt(static_cast<int>(a_World.GetSpawnX()));
- Pkt.WriteInt(static_cast<int>(a_World.GetSpawnY()));
- Pkt.WriteInt(static_cast<int>(a_World.GetSpawnZ()));
+ Pkt.WriteBEInt32(static_cast<int>(a_World.GetSpawnX()));
+ Pkt.WriteBEInt32(static_cast<int>(a_World.GetSpawnY()));
+ Pkt.WriteBEInt32(static_cast<int>(a_World.GetSpawnZ()));
}
// Send player abilities:
@@ -638,12 +638,12 @@ void cProtocol172::SendPaintingSpawn(const cPainting & a_Painting)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x10); // Spawn Painting packet
- Pkt.WriteVarInt(a_Painting.GetUniqueID());
+ Pkt.WriteVarInt32(a_Painting.GetUniqueID());
Pkt.WriteString(a_Painting.GetName().c_str());
- Pkt.WriteInt(static_cast<int>(a_Painting.GetPosX()));
- Pkt.WriteInt(static_cast<int>(a_Painting.GetPosY()));
- Pkt.WriteInt(static_cast<int>(a_Painting.GetPosZ()));
- Pkt.WriteInt(a_Painting.GetProtocolFacing());
+ Pkt.WriteBEInt32(static_cast<int>(a_Painting.GetPosX()));
+ Pkt.WriteBEInt32(static_cast<int>(a_Painting.GetPosY()));
+ Pkt.WriteBEInt32(static_cast<int>(a_Painting.GetPosZ()));
+ Pkt.WriteBEInt32(a_Painting.GetProtocolFacing());
}
@@ -658,12 +658,12 @@ void cProtocol172::SendMapColumn(int a_MapID, int a_X, int a_Y, const Byte * a_C
ASSERT((a_Y >= 0) && (a_Y < 256));
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt(static_cast<UInt32>(a_MapID));
- Pkt.WriteShort (static_cast<short>(3 + a_Length));
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
+ Pkt.WriteBEUInt16(static_cast<UInt16>(3 + a_Length));
- Pkt.WriteByte(0);
- Pkt.WriteByte(static_cast<Byte>(a_X));
- Pkt.WriteByte(static_cast<Byte>(a_Y));
+ Pkt.WriteBEUInt8(0);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_X));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Y));
Pkt.WriteBuf(reinterpret_cast<const char *>(a_Colors), a_Length);
}
@@ -678,18 +678,18 @@ void cProtocol172::SendMapDecorators(int a_MapID, const cMapDecoratorList & a_De
ASSERT(1 + 3 * a_Decorators.size() < USHRT_MAX);
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt(static_cast<UInt32>(a_MapID));
- Pkt.WriteShort (static_cast<short>(1 + (3 * a_Decorators.size())));
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
+ Pkt.WriteBEUInt16(static_cast<UInt16>(1 + (3 * a_Decorators.size())));
- Pkt.WriteByte(1);
+ Pkt.WriteBEUInt8(1);
for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
{
ASSERT(it->GetPixelX() < 256);
ASSERT(it->GetPixelZ() < 256);
- Pkt.WriteByte(static_cast<Byte>((it->GetType() << 4) | static_cast<Byte>(it->GetRot() & 0xf)));
- Pkt.WriteByte(static_cast<Byte>(it->GetPixelX()));
- Pkt.WriteByte(static_cast<Byte>(it->GetPixelZ()));
+ Pkt.WriteBEUInt8(static_cast<Byte>((it->GetType() << 4) | static_cast<Byte>(it->GetRot() & 0xf)));
+ Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelX()));
+ Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelZ()));
}
}
@@ -703,11 +703,11 @@ void cProtocol172::SendMapInfo(int a_MapID, unsigned int a_Scale)
ASSERT(a_Scale < 256);
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt(static_cast<UInt32>(a_MapID));
- Pkt.WriteShort (2);
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
+ Pkt.WriteBEUInt16(2);
- Pkt.WriteByte(2);
- Pkt.WriteByte(static_cast<Byte>(a_Scale));
+ Pkt.WriteBEUInt8(2);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Scale));
}
@@ -720,21 +720,21 @@ void cProtocol172::SendPickupSpawn(const cPickup & a_Pickup)
{
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
- Pkt.WriteVarInt(a_Pickup.GetUniqueID());
- Pkt.WriteByte(2); // Type = Pickup
+ Pkt.WriteVarInt32(a_Pickup.GetUniqueID());
+ Pkt.WriteBEUInt8(2); // Type = Pickup
Pkt.WriteFPInt(a_Pickup.GetPosX());
Pkt.WriteFPInt(a_Pickup.GetPosY());
Pkt.WriteFPInt(a_Pickup.GetPosZ());
Pkt.WriteByteAngle(a_Pickup.GetYaw());
Pkt.WriteByteAngle(a_Pickup.GetPitch());
- Pkt.WriteInt(0); // No object data
+ Pkt.WriteBEInt32(0); // No object data
}
{
cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet
- Pkt.WriteUInt32(a_Pickup.GetUniqueID());
- Pkt.WriteByte((0x05 << 5) | 10); // Slot type + index 10
+ Pkt.WriteBEUInt32(a_Pickup.GetUniqueID());
+ Pkt.WriteBEUInt8((0x05 << 5) | 10); // Slot type + index 10
WriteItem(Pkt, a_Pickup.GetItem());
- Pkt.WriteByte(0x7f); // End of metadata
+ Pkt.WriteBEUInt8(0x7f); // End of metadata
}
}
@@ -762,9 +762,9 @@ void cProtocol172::SendPlayerAbilities(void)
{
Flags |= 0x04;
}
- Pkt.WriteByte(Flags);
- Pkt.WriteFloat((float)(0.05 * Player->GetFlyingMaxSpeed()));
- Pkt.WriteFloat((float)(0.1 * Player->GetNormalMaxSpeed()));
+ Pkt.WriteBEUInt8(Flags);
+ Pkt.WriteBEFloat(static_cast<float>(0.05 * Player->GetFlyingMaxSpeed()));
+ Pkt.WriteBEFloat(static_cast<float>(0.1 * Player->GetNormalMaxSpeed()));
}
@@ -776,8 +776,8 @@ void cProtocol172::SendEntityAnimation(const cEntity & a_Entity, char a_Animatio
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0b); // Animation packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_Animation);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_Animation);
}
@@ -790,14 +790,14 @@ void cProtocol172::SendParticleEffect(const AString & a_ParticleName, float a_Sr
cPacketizer Pkt(*this, 0x2A);
Pkt.WriteString(a_ParticleName);
- Pkt.WriteFloat(a_SrcX);
- Pkt.WriteFloat(a_SrcY);
- Pkt.WriteFloat(a_SrcZ);
- Pkt.WriteFloat(a_OffsetX);
- Pkt.WriteFloat(a_OffsetY);
- Pkt.WriteFloat(a_OffsetZ);
- Pkt.WriteFloat(a_ParticleData);
- Pkt.WriteInt(a_ParticleAmount);
+ Pkt.WriteBEFloat(a_SrcX);
+ Pkt.WriteBEFloat(a_SrcY);
+ Pkt.WriteBEFloat(a_SrcZ);
+ Pkt.WriteBEFloat(a_OffsetX);
+ Pkt.WriteBEFloat(a_OffsetY);
+ Pkt.WriteBEFloat(a_OffsetZ);
+ Pkt.WriteBEFloat(a_ParticleData);
+ Pkt.WriteBEInt32(a_ParticleAmount);
}
@@ -811,7 +811,7 @@ void cProtocol172::SendPlayerListAddPlayer(const cPlayer & a_Player)
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
Pkt.WriteString(a_Player.GetPlayerListName());
Pkt.WriteBool(true);
- Pkt.WriteShort(a_Player.GetClientHandle()->GetPing());
+ Pkt.WriteBEInt16(a_Player.GetClientHandle()->GetPing());
}
@@ -825,7 +825,7 @@ void cProtocol172::SendPlayerListRemovePlayer(const cPlayer & a_Player)
cPacketizer Pkt(*this, 0x38);
Pkt.WriteString(a_Player.GetPlayerListName());
Pkt.WriteBool(false);
- Pkt.WriteShort(0);
+ Pkt.WriteBEInt16(0);
}
@@ -869,22 +869,22 @@ void cProtocol172::SendPlayerMaxSpeed(void)
cPacketizer Pkt(*this, 0x20); // Entity Properties
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteUInt32(Player->GetUniqueID());
- Pkt.WriteInt(1); // Count
+ Pkt.WriteBEUInt32(Player->GetUniqueID());
+ Pkt.WriteBEInt32(1); // Count
Pkt.WriteString("generic.movementSpeed");
// The default game speed is 0.1, multiply that value by the relative speed:
- Pkt.WriteDouble(0.1 * Player->GetNormalMaxSpeed());
+ Pkt.WriteBEDouble(0.1 * Player->GetNormalMaxSpeed());
if (Player->IsSprinting())
{
- Pkt.WriteShort(1); // Modifier count
- Pkt.WriteInt64(0x662a6b8dda3e4c1c);
- Pkt.WriteInt64(static_cast<Int64>(0x881396ea6097278d)); // UUID of the modifier
- Pkt.WriteDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
- Pkt.WriteByte(2);
+ Pkt.WriteBEInt16(1); // Modifier count
+ Pkt.WriteBEUInt64(0x662a6b8dda3e4c1c);
+ Pkt.WriteBEUInt64(0x881396ea6097278d); // UUID of the modifier
+ Pkt.WriteBEDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
+ Pkt.WriteBEUInt8(2);
}
else
{
- Pkt.WriteShort(0); // Modifier count
+ Pkt.WriteBEInt16(0); // Modifier count
}
}
@@ -898,15 +898,15 @@ void cProtocol172::SendPlayerMoveLook(void)
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteDouble(Player->GetPosX());
+ Pkt.WriteBEDouble(Player->GetPosX());
// Protocol docs say this is PosY, but #323 says this is eye-pos
// Moreover, the "+ 0.001" is there because otherwise the player falls through the block they were standing on.
- Pkt.WriteDouble(Player->GetStance() + 0.001);
+ Pkt.WriteBEDouble(Player->GetStance() + 0.001);
- Pkt.WriteDouble(Player->GetPosZ());
- Pkt.WriteFloat((float)Player->GetYaw());
- Pkt.WriteFloat((float)Player->GetPitch());
+ Pkt.WriteBEDouble(Player->GetPosZ());
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetYaw()));
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetPitch()));
Pkt.WriteBool(Player->IsOnGround());
}
@@ -930,7 +930,7 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
// Called to spawn another player for the client
cPacketizer Pkt(*this, 0x0c); // Spawn Player packet
- Pkt.WriteVarInt(a_Player.GetUniqueID());
+ Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteString(cMojangAPI::MakeUUIDDashed(a_Player.GetClientHandle()->GetUUID()));
if (a_Player.HasCustomName())
{
@@ -946,10 +946,10 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteByteAngle(a_Player.GetYaw());
Pkt.WriteByteAngle(a_Player.GetPitch());
short ItemType = a_Player.GetEquippedItem().IsEmpty() ? 0 : a_Player.GetEquippedItem().m_ItemType;
- Pkt.WriteShort(ItemType);
- Pkt.WriteByte((3 << 5) | 6); // Metadata: float + index 6
- Pkt.WriteFloat((float)a_Player.GetHealth());
- Pkt.WriteByte(0x7f); // Metadata: end
+ Pkt.WriteBEInt16(ItemType);
+ Pkt.WriteBEUInt8((3 << 5) | 6); // Metadata: float + index 6
+ Pkt.WriteBEFloat(static_cast<float>(a_Player.GetHealth()));
+ Pkt.WriteBEUInt8(0x7f); // Metadata: end
}
@@ -959,10 +959,11 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol172::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
{
ASSERT(m_State == 3); // In game mode?
+ ASSERT(a_Message.size() <= std::numeric_limits<UInt16>::max());
cPacketizer Pkt(*this, 0x3f);
Pkt.WriteString(a_Channel);
- Pkt.WriteShort((short)a_Message.size());
+ Pkt.WriteBEUInt16(static_cast<UInt16>(a_Message.size()));
Pkt.WriteBuf(a_Message.data(), a_Message.size());
}
@@ -976,8 +977,8 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
ASSERT((a_EffectID >= 0) && (a_EffectID < 256));
cPacketizer Pkt(*this, 0x1e);
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteByte(static_cast<Byte>(a_EffectID));
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_EffectID));
}
@@ -994,9 +995,9 @@ void cProtocol172::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens
cPacketizer Pkt(*this, 0x07); // Respawn packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteInt((int)a_Dimension);
- Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte((Byte)Player->GetEffectiveGameMode());
+ Pkt.WriteBEInt32((int)a_Dimension);
+ Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
+ Pkt.WriteBEUInt8((Byte)Player->GetEffectiveGameMode());
Pkt.WriteString("default");
m_LastSentDimension = a_Dimension;
}
@@ -1011,9 +1012,9 @@ void cProtocol172::SendExperience (void)
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteFloat(Player->GetXpPercentage());
- Pkt.WriteShort(static_cast<UInt16>(std::max<int>(Player->GetXpLevel(), std::numeric_limits<UInt16>::max())));
- Pkt.WriteShort(static_cast<UInt16>(std::max<int>(Player->GetCurrentXp(), std::numeric_limits<UInt16>::max())));
+ Pkt.WriteBEFloat(Player->GetXpPercentage());
+ Pkt.WriteBEInt16(static_cast<UInt16>(std::max<int>(Player->GetXpLevel(), std::numeric_limits<UInt16>::max())));
+ Pkt.WriteBEInt16(static_cast<UInt16>(std::max<int>(Player->GetCurrentXp(), std::numeric_limits<UInt16>::max())));
}
@@ -1026,11 +1027,11 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb)
ASSERT((a_ExpOrb.GetReward() >= 0) && (a_ExpOrb.GetReward() < SHRT_MAX));
cPacketizer Pkt(*this, 0x11);
- Pkt.WriteVarInt(a_ExpOrb.GetUniqueID());
+ Pkt.WriteVarInt32(a_ExpOrb.GetUniqueID());
Pkt.WriteFPInt(a_ExpOrb.GetPosX());
Pkt.WriteFPInt(a_ExpOrb.GetPosY());
Pkt.WriteFPInt(a_ExpOrb.GetPosZ());
- Pkt.WriteShort(static_cast<short>(a_ExpOrb.GetReward()));
+ Pkt.WriteBEInt16(static_cast<short>(a_ExpOrb.GetReward()));
}
@@ -1044,7 +1045,7 @@ void cProtocol172::SendScoreboardObjective(const AString & a_Name, const AString
cPacketizer Pkt(*this, 0x3b);
Pkt.WriteString(a_Name);
Pkt.WriteString(a_DisplayName);
- Pkt.WriteByte(a_Mode);
+ Pkt.WriteBEUInt8(a_Mode);
}
@@ -1057,12 +1058,12 @@ void cProtocol172::SendScoreUpdate(const AString & a_Objective, const AString &
cPacketizer Pkt(*this, 0x3c);
Pkt.WriteString(a_Player);
- Pkt.WriteByte(a_Mode);
+ Pkt.WriteBEUInt8(a_Mode);
if (a_Mode != 1)
{
Pkt.WriteString(a_Objective);
- Pkt.WriteInt((int) a_Score);
+ Pkt.WriteBEInt32((int) a_Score);
}
}
@@ -1075,7 +1076,7 @@ void cProtocol172::SendDisplayObjective(const AString & a_Objective, cScoreboard
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3d);
- Pkt.WriteByte(static_cast<Byte>(a_Display));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Display));
Pkt.WriteString(a_Objective);
}
@@ -1089,11 +1090,11 @@ void cProtocol172::SendSoundEffect(const AString & a_SoundName, double a_X, doub
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteInt(static_cast<int>(a_X * 8.0));
- Pkt.WriteInt(static_cast<int>(a_Y * 8.0));
- Pkt.WriteInt(static_cast<int>(a_Z * 8.0));
- Pkt.WriteFloat(a_Volume);
- Pkt.WriteByte(static_cast<Byte>(a_Pitch * 63));
+ Pkt.WriteBEInt32(static_cast<int>(a_X * 8.0));
+ Pkt.WriteBEInt32(static_cast<int>(a_Y * 8.0));
+ Pkt.WriteBEInt32(static_cast<int>(a_Z * 8.0));
+ Pkt.WriteBEFloat(a_Volume);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_Pitch * 63));
}
@@ -1106,11 +1107,11 @@ void cProtocol172::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
ASSERT((a_SrcY >= 0) && (a_SrcY < 256));
cPacketizer Pkt(*this, 0x28); // Effect packet
- Pkt.WriteInt(a_EffectID);
- Pkt.WriteInt(a_SrcX);
- Pkt.WriteByte(static_cast<Byte>(a_SrcY));
- Pkt.WriteInt(a_SrcZ);
- Pkt.WriteInt(a_Data);
+ Pkt.WriteBEInt32(a_EffectID);
+ Pkt.WriteBEInt32(a_SrcX);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_SrcY));
+ Pkt.WriteBEInt32(a_SrcZ);
+ Pkt.WriteBEInt32(a_Data);
Pkt.WriteBool(false);
}
@@ -1123,17 +1124,17 @@ void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
- Pkt.WriteVarInt(a_FallingBlock.GetUniqueID());
- Pkt.WriteByte(70); // Falling block
+ Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID());
+ Pkt.WriteBEUInt8(70); // Falling block
Pkt.WriteFPInt(a_FallingBlock.GetPosX());
Pkt.WriteFPInt(a_FallingBlock.GetPosY());
Pkt.WriteFPInt(a_FallingBlock.GetPosZ());
Pkt.WriteByteAngle(a_FallingBlock.GetYaw());
Pkt.WriteByteAngle(a_FallingBlock.GetPitch());
- Pkt.WriteInt((static_cast<int>(a_FallingBlock.GetBlockType()) | ((static_cast<int>(a_FallingBlock.GetBlockMeta()) << 16))));
- Pkt.WriteShort(static_cast<short>(a_FallingBlock.GetSpeedX() * 400));
- Pkt.WriteShort(static_cast<short>(a_FallingBlock.GetSpeedY() * 400));
- Pkt.WriteShort(static_cast<short>(a_FallingBlock.GetSpeedZ() * 400));
+ Pkt.WriteBEInt32((static_cast<int>(a_FallingBlock.GetBlockType()) | ((static_cast<int>(a_FallingBlock.GetBlockMeta()) << 16))));
+ Pkt.WriteBEInt16(static_cast<short>(a_FallingBlock.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_FallingBlock.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_FallingBlock.GetSpeedZ() * 400));
}
@@ -1145,19 +1146,19 @@ void cProtocol172::SendSpawnMob(const cMonster & a_Mob)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet
- Pkt.WriteVarInt(a_Mob.GetUniqueID());
- Pkt.WriteByte((Byte)a_Mob.GetMobType());
+ Pkt.WriteVarInt32(a_Mob.GetUniqueID());
+ Pkt.WriteBEUInt8((Byte)a_Mob.GetMobType());
Pkt.WriteFPInt(a_Mob.GetPosX());
Pkt.WriteFPInt(a_Mob.GetPosY());
Pkt.WriteFPInt(a_Mob.GetPosZ());
Pkt.WriteByteAngle(a_Mob.GetPitch());
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
Pkt.WriteByteAngle(a_Mob.GetYaw());
- Pkt.WriteShort(static_cast<short>(a_Mob.GetSpeedX() * 400));
- Pkt.WriteShort(static_cast<short>(a_Mob.GetSpeedY() * 400));
- Pkt.WriteShort(static_cast<short>(a_Mob.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Mob.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Mob.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Mob.GetSpeedZ() * 400));
WriteEntityMetadata(Pkt, a_Mob);
- Pkt.WriteByte(0x7f); // Metadata terminator
+ Pkt.WriteBEUInt8(0x7f); // Metadata terminator
}
@@ -1169,19 +1170,19 @@ void cProtocol172::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_ObjectType);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_ObjectType);
Pkt.WriteFPInt(a_Entity.GetPosX());
Pkt.WriteFPInt(a_Entity.GetPosY());
Pkt.WriteFPInt(a_Entity.GetPosZ());
Pkt.WriteByteAngle(a_Entity.GetPitch());
Pkt.WriteByteAngle(a_Entity.GetYaw());
- Pkt.WriteInt(a_ObjectData);
+ Pkt.WriteBEInt32(a_ObjectData);
if (a_ObjectData != 0)
{
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedX() * 400));
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedY() * 400));
- Pkt.WriteShort(static_cast<short>(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16(static_cast<short>(a_Entity.GetSpeedZ() * 400));
}
}
@@ -1194,19 +1195,19 @@ void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
- Pkt.WriteVarInt(a_Vehicle.GetUniqueID());
- Pkt.WriteChar(a_VehicleType);
+ Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
+ Pkt.WriteBEInt8(a_VehicleType);
Pkt.WriteFPInt(a_Vehicle.GetPosX());
Pkt.WriteFPInt(a_Vehicle.GetPosY());
Pkt.WriteFPInt(a_Vehicle.GetPosZ());
Pkt.WriteByteAngle(a_Vehicle.GetPitch());
Pkt.WriteByteAngle(a_Vehicle.GetYaw());
- Pkt.WriteInt(a_VehicleSubType);
+ Pkt.WriteBEInt32(a_VehicleSubType);
if (a_VehicleSubType != 0)
{
- Pkt.WriteShort(static_cast<Int16>(a_Vehicle.GetSpeedX() * 400));
- Pkt.WriteShort(static_cast<Int16>(a_Vehicle.GetSpeedY() * 400));
- Pkt.WriteShort(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));
}
}
@@ -1219,7 +1220,7 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x37);
- Pkt.WriteVarInt(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
+ Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
for (size_t i = 0; i < (size_t)statCount; ++i)
{
@@ -1227,7 +1228,7 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager)
const AString & StatName = cStatInfo::GetName((eStatistic) i);
Pkt.WriteString(StatName);
- Pkt.WriteVarInt(static_cast<UInt32>(Value));
+ Pkt.WriteVarInt32(static_cast<UInt32>(Value));
}
}
@@ -1240,7 +1241,7 @@ void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
- Pkt.WriteVarInt(static_cast<UInt32>(a_Results.size()));
+ Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size()));
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
{
@@ -1257,7 +1258,7 @@ void cProtocol172::SendTeleportEntity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x18);
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteFPInt(a_Entity.GetPosX());
Pkt.WriteFPInt(a_Entity.GetPosY());
Pkt.WriteFPInt(a_Entity.GetPosZ());
@@ -1274,8 +1275,8 @@ void cProtocol172::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
- Pkt.WriteVarInt(0); // EntityID = 0, always
- Pkt.WriteByte(1); // Type = Thunderbolt
+ Pkt.WriteVarInt32(0); // EntityID = 0, always
+ Pkt.WriteBEUInt8(1); // Type = Thunderbolt
Pkt.WriteFPInt(a_BlockX);
Pkt.WriteFPInt(a_BlockY);
Pkt.WriteFPInt(a_BlockZ);
@@ -1295,8 +1296,8 @@ void cProtocol172::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do
}
cPacketizer Pkt(*this, 0x03);
- Pkt.WriteInt64(a_WorldAge);
- Pkt.WriteInt64(a_TimeOfDay);
+ Pkt.WriteBEInt64(a_WorldAge);
+ Pkt.WriteBEInt64(a_TimeOfDay);
}
@@ -1308,12 +1309,12 @@ void cProtocol172::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x21); // Chunk Data packet
- Pkt.WriteInt(a_ChunkX);
- Pkt.WriteInt(a_ChunkZ);
+ Pkt.WriteBEInt32(a_ChunkX);
+ Pkt.WriteBEInt32(a_ChunkZ);
Pkt.WriteBool(true);
- Pkt.WriteShort(0); // Primary bitmap
- Pkt.WriteShort(0); // Add bitmap
- Pkt.WriteInt(0); // Compressed data size
+ Pkt.WriteBEInt16(0); // Primary bitmap
+ Pkt.WriteBEInt16(0); // Add bitmap
+ Pkt.WriteBEInt32(0); // Compressed data size
}
@@ -1324,9 +1325,9 @@ void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x35); // Update tile entity packet
- Pkt.WriteInt(a_BlockEntity.GetPosX());
- Pkt.WriteShort(static_cast<short>(a_BlockEntity.GetPosY()));
- Pkt.WriteInt(a_BlockEntity.GetPosZ());
+ Pkt.WriteBEInt32(a_BlockEntity.GetPosX());
+ Pkt.WriteBEInt16(static_cast<short>(a_BlockEntity.GetPosY()));
+ Pkt.WriteBEInt32(a_BlockEntity.GetPosZ());
Byte Action = 0;
switch (a_BlockEntity.GetBlockType())
@@ -1338,7 +1339,7 @@ void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
case E_BLOCK_FLOWER_POT: Action = 5; break; // Update flower pot
default: ASSERT(!"Unhandled or unimplemented BlockEntity update request!"); break;
}
- Pkt.WriteByte(Action);
+ Pkt.WriteBEUInt8(Action);
WriteBlockEntity(Pkt, a_BlockEntity);
}
@@ -1353,9 +1354,9 @@ void cProtocol172::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons
ASSERT((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height));
cPacketizer Pkt(*this, 0x33);
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteShort((short)a_BlockY);
- Pkt.WriteInt(a_BlockZ);
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEInt16(static_cast<Int16>(a_BlockY));
+ Pkt.WriteBEInt32(a_BlockZ);
// Need to send only up to 15 chars, otherwise the client crashes (#598)
Pkt.WriteString(a_Line1.substr(0, 15));
Pkt.WriteString(a_Line2.substr(0, 15));
@@ -1373,10 +1374,10 @@ void cProtocol172::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
ASSERT((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height));
cPacketizer Pkt(*this, 0x0a);
- Pkt.WriteUInt32(a_Entity.GetUniqueID());
- Pkt.WriteInt(a_BlockX);
- Pkt.WriteByte(static_cast<Byte>(a_BlockY));
- Pkt.WriteInt(a_BlockZ);
+ Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt32(a_BlockX);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_BlockY));
+ Pkt.WriteBEInt32(a_BlockZ);
}
@@ -1389,8 +1390,8 @@ void cProtocol172::SendWeather(eWeather a_Weather)
{
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
- Pkt.WriteByte((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
- Pkt.WriteFloat(0); // Unused for weather
+ Pkt.WriteBEUInt8((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
+ Pkt.WriteBEFloat(0); // Unused for weather
}
// TODO: Fade effect, somehow
@@ -1405,8 +1406,8 @@ void cProtocol172::SendWholeInventory(const cWindow & a_Window)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x30); // Window Items packet
- Pkt.WriteChar(a_Window.GetWindowID());
- Pkt.WriteShort(static_cast<short>(a_Window.GetNumSlots()));
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
+ Pkt.WriteBEInt16(static_cast<short>(a_Window.GetNumSlots()));
cItems Slots;
a_Window.GetSlots(*(m_Client->GetPlayer()), Slots);
for (cItems::const_iterator itr = Slots.begin(), end = Slots.end(); itr != end; ++itr)
@@ -1424,7 +1425,7 @@ void cProtocol172::SendWindowClose(const cWindow & a_Window)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x2e);
- Pkt.WriteChar(a_Window.GetWindowID());
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
}
@@ -1442,14 +1443,14 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window)
}
cPacketizer Pkt(*this, 0x2d);
- Pkt.WriteChar(a_Window.GetWindowID());
- Pkt.WriteChar(static_cast<char>(a_Window.GetWindowType()));
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
+ Pkt.WriteBEInt8(static_cast<char>(a_Window.GetWindowType()));
Pkt.WriteString(a_Window.GetWindowTitle());
- Pkt.WriteChar(static_cast<char>(a_Window.GetNumNonInventorySlots()));
+ Pkt.WriteBEInt8(static_cast<char>(a_Window.GetNumNonInventorySlots()));
Pkt.WriteBool(true);
if (a_Window.GetWindowType() == cWindow::wtAnimalChest)
{
- Pkt.WriteInt(0); // TODO: The animal's EntityID
+ Pkt.WriteBEInt32(0); // TODO: The animal's EntityID
}
}
@@ -1462,9 +1463,9 @@ void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x31); // Window Property packet
- Pkt.WriteChar(a_Window.GetWindowID());
- Pkt.WriteShort(a_Property);
- Pkt.WriteShort(a_Value);
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
+ Pkt.WriteBEInt16(a_Property);
+ Pkt.WriteBEInt16(a_Value);
}
@@ -1709,7 +1710,7 @@ void cProtocol172::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEInt64, Int64, Timestamp);
cPacketizer Pkt(*this, 0x01); // Ping packet
- Pkt.WriteInt64(Timestamp);
+ Pkt.WriteBEInt64(Timestamp);
}
@@ -1858,10 +1859,10 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
cPacketizer Pkt(*this, 0x01);
Pkt.WriteString(Server->GetServerID());
const AString & PubKeyDer = Server->GetPublicKeyDER();
- Pkt.WriteShort((short)PubKeyDer.size());
+ Pkt.WriteBEUInt16(static_cast<UInt16>(PubKeyDer.size()));
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
- Pkt.WriteShort(4);
- Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
+ Pkt.WriteBEInt16(4);
+ Pkt.WriteBEUInt32(static_cast<UInt32>(reinterpret_cast<uintptr_t>(this))); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
m_Client->SetUsername(Username);
return;
}
@@ -2389,7 +2390,7 @@ void cProtocol172::SendPacket(cPacketizer & a_Packet)
// Send the packet length
UInt32 PacketLen = static_cast<UInt32>(m_OutPacketBuffer.GetUsedSpace());
- m_OutPacketLenBuffer.WriteVarInt(PacketLen);
+ m_OutPacketLenBuffer.WriteVarInt32(PacketLen);
m_OutPacketLenBuffer.ReadAll(DataToSend);
SendData(DataToSend.data(), DataToSend.size());
m_OutPacketLenBuffer.CommitRead();
@@ -2586,17 +2587,17 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
if (a_Item.IsEmpty())
{
- a_Pkt.WriteShort(-1);
+ a_Pkt.WriteBEInt16(-1);
return;
}
- a_Pkt.WriteShort(ItemType);
- a_Pkt.WriteChar (a_Item.m_ItemCount);
- a_Pkt.WriteShort(a_Item.m_ItemDamage);
+ a_Pkt.WriteBEInt16(ItemType);
+ a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
+ a_Pkt.WriteBEInt16(a_Item.m_ItemDamage);
if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR))
{
- a_Pkt.WriteShort(-1);
+ a_Pkt.WriteBEInt16(-1);
return;
}
@@ -2772,21 +2773,21 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
{
Flags |= 0x20;
}
- a_Pkt.WriteByte(0); // Byte(0) + index 0
- a_Pkt.WriteByte(Flags);
+ a_Pkt.WriteBEUInt8(0); // Byte(0) + index 0
+ a_Pkt.WriteBEUInt8(Flags);
switch (a_Entity.GetEntityType())
{
case cEntity::etPlayer: break; // TODO?
case cEntity::etPickup:
{
- a_Pkt.WriteByte((5 << 5) | 10); // Slot(5) + index 10
+ a_Pkt.WriteBEUInt8((5 << 5) | 10); // Slot(5) + index 10
WriteItem(a_Pkt, reinterpret_cast<const cPickup &>(a_Entity).GetItem());
break;
}
case cEntity::etMinecart:
{
- a_Pkt.WriteByte(0x51);
+ a_Pkt.WriteBEUInt8(0x51);
// 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:
@@ -2796,11 +2797,11 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
Health: 1 | 3 - (1 - 3) = 5
*/
auto & Minecart = reinterpret_cast<const cMinecart &>(a_Entity);
- a_Pkt.WriteInt((((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * Minecart.LastDamage()) * 4);
- a_Pkt.WriteByte(0x52);
- a_Pkt.WriteInt(1); // Shaking direction, doesn't seem to affect anything
- a_Pkt.WriteByte(0x73);
- a_Pkt.WriteFloat(static_cast<float>(Minecart.LastDamage() + 10)); // Damage taken / shake effect multiplyer
+ 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
if (Minecart.GetPayload() == cMinecart::mpNone)
{
@@ -2808,20 +2809,20 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
const cItem & MinecartContent = RideableMinecart.GetContent();
if (!MinecartContent.IsEmpty())
{
- a_Pkt.WriteByte(0x54);
+ a_Pkt.WriteBEUInt8(0x54);
int Content = MinecartContent.m_ItemType;
Content |= MinecartContent.m_ItemDamage << 8;
- a_Pkt.WriteInt(Content);
- a_Pkt.WriteByte(0x55);
- a_Pkt.WriteInt(RideableMinecart.GetBlockHeight());
- a_Pkt.WriteByte(0x56);
- a_Pkt.WriteByte(1);
+ a_Pkt.WriteBEInt32(Content);
+ a_Pkt.WriteBEUInt8(0x55);
+ a_Pkt.WriteBEInt32(RideableMinecart.GetBlockHeight());
+ a_Pkt.WriteBEUInt8(0x56);
+ a_Pkt.WriteBEUInt8(1);
}
}
else if (Minecart.GetPayload() == cMinecart::mpFurnace)
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cMinecartWithFurnace &>(Minecart).IsFueled() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cMinecartWithFurnace &>(Minecart).IsFueled() ? 1 : 0);
}
break;
} // case etMinecart
@@ -2833,13 +2834,13 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
{
case cProjectileEntity::pkArrow:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cArrowEntity &>(a_Entity).IsCritical() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cArrowEntity &>(a_Entity).IsCritical() ? 1 : 0);
break;
}
case cProjectileEntity::pkFirework:
{
- a_Pkt.WriteByte(0xa8);
+ a_Pkt.WriteBEUInt8(0xa8);
WriteItem(a_Pkt, reinterpret_cast<const cFireworkEntity &>(a_Entity).GetItem());
break;
}
@@ -2857,10 +2858,10 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
case cEntity::etItemFrame:
{
auto & Frame = reinterpret_cast<const cItemFrame &>(a_Entity);
- a_Pkt.WriteByte(0xa2);
+ a_Pkt.WriteBEUInt8(0xa2);
WriteItem(a_Pkt, Frame.GetItem());
- a_Pkt.WriteByte(0x03);
- a_Pkt.WriteByte(Frame.GetItemRotation() / 2);
+ a_Pkt.WriteBEUInt8(0x03);
+ a_Pkt.WriteBEUInt8(Frame.GetItemRotation() / 2);
break;
} // case etItemFrame
@@ -2881,36 +2882,36 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
case mtBat:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cBat &>(a_Mob).IsHanging() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cBat &>(a_Mob).IsHanging() ? 1 : 0);
break;
} // case mtBat
case mtCreeper:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cCreeper &>(a_Mob).IsBlowing() ? 1 : 0);
- a_Pkt.WriteByte(0x11);
- a_Pkt.WriteByte(reinterpret_cast<const cCreeper &>(a_Mob).IsCharged() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cCreeper &>(a_Mob).IsBlowing() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x11);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cCreeper &>(a_Mob).IsCharged() ? 1 : 0);
break;
} // case mtCreeper
case mtEnderman:
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte((Byte)(Enderman.GetCarriedBlock()));
- a_Pkt.WriteByte(0x11);
- a_Pkt.WriteByte((Byte)(Enderman.GetCarriedMeta()));
- a_Pkt.WriteByte(0x12);
- a_Pkt.WriteByte(Enderman.IsScreaming() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8((Byte)(Enderman.GetCarriedBlock()));
+ a_Pkt.WriteBEUInt8(0x11);
+ a_Pkt.WriteBEUInt8((Byte)(Enderman.GetCarriedMeta()));
+ a_Pkt.WriteBEUInt8(0x12);
+ a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0);
break;
} // case mtEnderman
case mtGhast:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cGhast &>(a_Mob).IsCharging());
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cGhast &>(a_Mob).IsCharging());
break;
} // case mtGhast
@@ -2946,81 +2947,81 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
Flags |= 0x80;
}
- a_Pkt.WriteByte(0x50); // Int at index 16
- a_Pkt.WriteInt(Flags);
- a_Pkt.WriteByte(0x13); // Byte at index 19
- a_Pkt.WriteByte(static_cast<Byte>(Horse.GetHorseType()));
- a_Pkt.WriteByte(0x54); // Int at index 20
+ 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<Byte>(Horse.GetHorseType()));
+ a_Pkt.WriteBEUInt8(0x54); // Int at index 20
int Appearance = 0;
Appearance = Horse.GetHorseColor();
Appearance |= Horse.GetHorseStyle() << 8;
- a_Pkt.WriteInt(Appearance);
- a_Pkt.WriteByte(0x56); // Int at index 22
- a_Pkt.WriteInt(Horse.GetHorseArmour());
+ a_Pkt.WriteBEInt32(Appearance);
+ a_Pkt.WriteBEUInt8(0x56); // Int at index 22
+ a_Pkt.WriteBEInt32(Horse.GetHorseArmour());
break;
} // case mtHorse
case mtMagmaCube:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(static_cast<Byte>(reinterpret_cast<const cMagmaCube &>(a_Mob).GetSize()));
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(static_cast<Byte>(reinterpret_cast<const cMagmaCube &>(a_Mob).GetSize()));
break;
} // case mtMagmaCube
case mtPig:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cPig &>(a_Mob).IsSaddled() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cPig &>(a_Mob).IsSaddled() ? 1 : 0);
break;
} // case mtPig
case mtSheep:
{
- a_Pkt.WriteByte(0x10);
+ a_Pkt.WriteBEUInt8(0x10);
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob);
Byte SheepMetadata = static_cast<Byte>(Sheep.GetFurColor() & 0x0f);
if (Sheep.IsSheared())
{
SheepMetadata |= 0x10;
}
- a_Pkt.WriteByte(SheepMetadata);
+ a_Pkt.WriteBEUInt8(SheepMetadata);
break;
} // case mtSheep
case mtSkeleton:
{
- a_Pkt.WriteByte(0x0d);
- a_Pkt.WriteByte(reinterpret_cast<const cSkeleton &>(a_Mob).IsWither() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0d);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cSkeleton &>(a_Mob).IsWither() ? 1 : 0);
break;
} // case mtSkeleton
case mtSlime:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(static_cast<Byte>(reinterpret_cast<const cSlime &>(a_Mob).GetSize()));
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(static_cast<Byte>(reinterpret_cast<const cSlime &>(a_Mob).GetSize()));
break;
} // case mtSlime
case mtVillager:
{
- a_Pkt.WriteByte(0x50);
- a_Pkt.WriteInt(reinterpret_cast<const cVillager &>(a_Mob).GetVilType());
+ a_Pkt.WriteBEUInt8(0x50);
+ a_Pkt.WriteBEInt32(reinterpret_cast<const cVillager &>(a_Mob).GetVilType());
break;
} // case mtVillager
case mtWitch:
{
- a_Pkt.WriteByte(0x15);
- a_Pkt.WriteByte(reinterpret_cast<const cWitch &>(a_Mob).IsAngry() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x15);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cWitch &>(a_Mob).IsAngry() ? 1 : 0);
break;
} // case mtWitch
case mtWither:
{
- a_Pkt.WriteByte(0x54); // Int at index 20
- a_Pkt.WriteInt(static_cast<int>(reinterpret_cast<const cWither &>(a_Mob).GetWitherInvulnerableTicks()));
- a_Pkt.WriteByte(0x66); // Float at index 6
- a_Pkt.WriteFloat(static_cast<float>(a_Mob.GetHealth()));
+ a_Pkt.WriteBEUInt8(0x54); // Int at index 20
+ a_Pkt.WriteBEInt32(static_cast<int>(reinterpret_cast<const cWither &>(a_Mob).GetWitherInvulnerableTicks()));
+ a_Pkt.WriteBEUInt8(0x66); // Float at index 6
+ a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
} // case mtWither
@@ -3040,27 +3041,27 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
WolfStatus |= 0x4;
}
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(WolfStatus);
-
- a_Pkt.WriteByte(0x72);
- a_Pkt.WriteFloat(static_cast<float>(a_Mob.GetHealth()));
- a_Pkt.WriteByte(0x13);
- a_Pkt.WriteByte(Wolf.IsBegging() ? 1 : 0);
- a_Pkt.WriteByte(0x14);
- a_Pkt.WriteByte(static_cast<Byte>(Wolf.GetCollarColor()));
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(WolfStatus);
+
+ a_Pkt.WriteBEUInt8(0x72);
+ 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<Byte>(Wolf.GetCollarColor()));
break;
} // case mtWolf
case mtZombie:
{
auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob);
- a_Pkt.WriteByte(0x0c);
- a_Pkt.WriteByte(Zombie.IsBaby() ? 1 : 0);
- a_Pkt.WriteByte(0x0d);
- a_Pkt.WriteByte(Zombie.IsVillagerZombie() ? 1 : 0);
- a_Pkt.WriteByte(0x0e);
- a_Pkt.WriteByte(Zombie.IsConverting() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEUInt8(Zombie.IsBaby() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0d);
+ a_Pkt.WriteBEUInt8(Zombie.IsVillagerZombie() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0e);
+ a_Pkt.WriteBEUInt8(Zombie.IsConverting() ? 1 : 0);
break;
} // case mtZombie
@@ -3074,10 +3075,10 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
// Custom name:
if (a_Mob.HasCustomName())
{
- a_Pkt.WriteByte(0x8a);
+ a_Pkt.WriteBEUInt8(0x8a);
a_Pkt.WriteString(a_Mob.GetCustomName());
- a_Pkt.WriteByte(0x0b);
- a_Pkt.WriteByte(a_Mob.IsCustomNameAlwaysVisible() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0b);
+ a_Pkt.WriteBEUInt8(a_Mob.IsCustomNameAlwaysVisible() ? 1 : 0);
}
}
@@ -3090,7 +3091,7 @@ void cProtocol172::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_
if (!a_Entity.IsMob())
{
// No properties for anything else than mobs
- a_Pkt.WriteInt(0);
+ a_Pkt.WriteBEInt32(0);
return;
}
@@ -3098,7 +3099,7 @@ void cProtocol172::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_
// TODO: Send properties and modifiers based on the mob type
- a_Pkt.WriteInt(0); // NumProperties
+ a_Pkt.WriteBEInt32(0); // NumProperties
}
@@ -3121,7 +3122,7 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
{
// Called to spawn another player for the client
cPacketizer Pkt(*this, 0x0c); // Spawn Player packet
- Pkt.WriteVarInt(a_Player.GetUniqueID());
+ Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteString(cMojangAPI::MakeUUIDDashed(a_Player.GetClientHandle()->GetUUID()));
if (a_Player.HasCustomName())
{
@@ -3133,7 +3134,7 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
}
const Json::Value & Properties = a_Player.GetClientHandle()->GetProperties();
- Pkt.WriteVarInt(Properties.size());
+ Pkt.WriteVarInt32(Properties.size());
for (Json::Value::iterator itr = Properties.begin(), end = Properties.end(); itr != end; ++itr)
{
@@ -3148,10 +3149,10 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
Pkt.WriteByteAngle(a_Player.GetYaw());
Pkt.WriteByteAngle(a_Player.GetPitch());
short ItemType = a_Player.GetEquippedItem().IsEmpty() ? 0 : a_Player.GetEquippedItem().m_ItemType;
- Pkt.WriteShort(ItemType);
- Pkt.WriteByte((3 << 5) | 6); // Metadata: float + index 6
- Pkt.WriteFloat((float)a_Player.GetHealth());
- Pkt.WriteByte(0x7f); // Metadata: end
+ Pkt.WriteBEInt16(ItemType);
+ Pkt.WriteBEUInt8((3 << 5) | 6); // Metadata: float + index 6
+ Pkt.WriteBEFloat(static_cast<float>(a_Player.GetHealth()));
+ Pkt.WriteBEUInt8(0x7f); // Metadata: end
}