summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol18x.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/Protocol18x.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 'src/Protocol/Protocol18x.cpp')
-rw-r--r--src/Protocol/Protocol18x.cpp655
1 files changed, 329 insertions, 326 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index c48ab14ad..a1ca25200 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -161,8 +161,8 @@ void cProtocol180::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);
}
@@ -175,10 +175,10 @@ void cProtocol180::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.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
- Pkt.WriteByte(a_Byte1);
- Pkt.WriteByte(a_Byte2);
- Pkt.WriteVarInt(a_BlockType);
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteBEInt8(a_Byte1);
+ Pkt.WriteBEInt8(a_Byte2);
+ Pkt.WriteVarInt32(a_BlockType);
}
@@ -190,9 +190,9 @@ void cProtocol180::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.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
- Pkt.WriteChar(a_Stage);
+ Pkt.WriteVarInt32(a_EntityID);
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteBEInt8(a_Stage);
}
@@ -204,8 +204,8 @@ void cProtocol180::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x23); // Block Change packet
- Pkt.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
- Pkt.WriteVarInt(((UInt32)a_BlockType << 4) | ((UInt32)a_BlockMeta & 15));
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteVarInt32(((UInt32)a_BlockType << 4) | ((UInt32)a_BlockMeta & 15));
}
@@ -217,14 +217,14 @@ void cProtocol180::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.WriteVarInt((UInt32)a_Changes.size());
+ Pkt.WriteBEInt32(a_ChunkX);
+ Pkt.WriteBEInt32(a_ChunkZ);
+ Pkt.WriteVarInt32((UInt32)a_Changes.size());
for (sSetBlockVector::const_iterator itr = a_Changes.begin(), end = a_Changes.end(); itr != end; ++itr)
{
- short Coords = (short) (itr->m_RelY | (itr->m_RelZ << 8) | (itr->m_RelX << 12));
- Pkt.WriteShort(Coords);
- Pkt.WriteVarInt((itr->m_BlockType & 0xFFF) << 4 | (itr->m_BlockMeta & 0xF));
+ Int16 Coords = static_cast<Int16>(itr->m_RelY | (itr->m_RelZ << 8) | (itr->m_RelX << 12));
+ Pkt.WriteBEInt16(Coords);
+ Pkt.WriteVarInt32((itr->m_BlockType & 0xFFF) << 4 | (itr->m_BlockMeta & 0xF));
} // for itr - a_Changes[]
}
@@ -238,7 +238,7 @@ void cProtocol180::SendChat(const AString & a_Message)
cPacketizer Pkt(*this, 0x02); // Chat Message packet
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
- Pkt.WriteChar(0);
+ Pkt.WriteBEInt8(0);
}
@@ -255,7 +255,7 @@ void cProtocol180::SendChat(const cCompositeChat & a_Message)
// Send the message to the client:
cPacketizer Pkt(*this, 0x02);
Pkt.WriteString(a_Message.CreateJsonString(ShouldUseChatPrefixes));
- Pkt.WriteChar(0);
+ Pkt.WriteBEInt8(0);
}
@@ -283,8 +283,8 @@ void cProtocol180::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteVarInt(a_Player.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Player.GetUniqueID());
}
@@ -296,8 +296,8 @@ void cProtocol180::SendDestroyEntity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x13); // Destroy Entities packet
- Pkt.WriteVarInt(1);
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(1);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
}
@@ -334,7 +334,7 @@ void cProtocol180::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.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -346,10 +346,10 @@ void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1D); // Entity Effect packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteByte(a_EffectID);
- Pkt.WriteByte(a_Amplifier);
- Pkt.WriteVarInt((UInt32)a_Duration);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
+ Pkt.WriteBEUInt8(static_cast<UInt8>(a_Amplifier));
+ Pkt.WriteVarInt32((UInt32)a_Duration);
Pkt.WriteBool(false); // Hide particles
}
@@ -362,8 +362,8 @@ void cProtocol180::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x04); // Entity Equipment packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteShort(a_SlotNum);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt16(a_SlotNum);
WriteItem(Pkt, a_Item);
}
@@ -376,7 +376,7 @@ void cProtocol180::SendEntityHeadLook(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x19); // Entity Head Look packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
}
@@ -389,7 +389,7 @@ void cProtocol180::SendEntityLook(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x16); // Entity Look packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetYaw());
Pkt.WriteByteAngle(a_Entity.GetPitch());
Pkt.WriteBool(a_Entity.IsOnGround());
@@ -404,9 +404,9 @@ void cProtocol180::SendEntityMetadata(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityMetadata(Pkt, a_Entity);
- Pkt.WriteByte(0x7f); // The termination byte
+ Pkt.WriteBEUInt8(0x7f); // The termination byte
}
@@ -418,7 +418,7 @@ void cProtocol180::SendEntityProperties(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x20); // Entity Properties packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityProperties(Pkt, a_Entity);
}
@@ -431,10 +431,10 @@ void cProtocol180::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.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_RelX);
- Pkt.WriteChar(a_RelY);
- Pkt.WriteChar(a_RelZ);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEInt8(a_RelX);
+ Pkt.WriteBEInt8(a_RelY);
+ Pkt.WriteBEInt8(a_RelZ);
Pkt.WriteBool(a_Entity.IsOnGround());
}
@@ -447,10 +447,10 @@ void cProtocol180::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.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteChar(a_RelX);
- Pkt.WriteChar(a_RelY);
- Pkt.WriteChar(a_RelZ);
+ Pkt.WriteVarInt32(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());
Pkt.WriteBool(a_Entity.IsOnGround());
@@ -465,8 +465,8 @@ void cProtocol180::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);
}
@@ -478,11 +478,11 @@ void cProtocol180::SendEntityVelocity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m/s to 8000 m/tick
- Pkt.WriteShort((short)(a_Entity.GetSpeedX() * 400));
- Pkt.WriteShort((short)(a_Entity.GetSpeedY() * 400));
- Pkt.WriteShort((short)(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedZ() * 400));
}
@@ -494,20 +494,20 @@ void cProtocol180::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));
}
@@ -519,8 +519,8 @@ void cProtocol180::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!
}
@@ -533,9 +533,9 @@ void cProtocol180::SendHealth(void)
cPacketizer Pkt(*this, 0x06); // Update Health packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteFloat((float)Player->GetHealth());
- Pkt.WriteVarInt((UInt32)Player->GetFoodLevel());
- Pkt.WriteFloat((float)Player->GetFoodSaturationLevel());
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
+ Pkt.WriteVarInt32((UInt32)Player->GetFoodLevel());
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetFoodSaturationLevel()));
}
@@ -547,8 +547,8 @@ void cProtocol180::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);
}
@@ -566,7 +566,7 @@ void cProtocol180::SendKeepAlive(int a_PingID)
}
cPacketizer Pkt(*this, 0x00); // Keep Alive packet
- Pkt.WriteVarInt(a_PingID);
+ Pkt.WriteVarInt32(a_PingID);
}
@@ -579,11 +579,11 @@ void cProtocol180::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((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
- Pkt.WriteChar((char)a_World.GetDimension());
- Pkt.WriteByte(2); // TODO: Difficulty (set to Normal)
- Pkt.WriteByte(Server->GetMaxPlayers());
+ Pkt.WriteBEUInt32(a_Player.GetUniqueID());
+ Pkt.WriteBEUInt8((Byte)a_Player.GetEffectiveGameMode() | (Server->IsHardcore() ? 0x08 : 0)); // Hardcore flag bit 4
+ Pkt.WriteBEInt8((char)a_World.GetDimension());
+ Pkt.WriteBEUInt8(2); // TODO: Difficulty (set to Normal)
+ Pkt.WriteBEUInt8(Server->GetMaxPlayers());
Pkt.WriteString("default"); // Level type - wtf?
Pkt.WriteBool(false); // Reduced Debug Info - wtf?
}
@@ -592,13 +592,13 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
// Send the spawn position:
{
cPacketizer Pkt(*this, 0x05); // Spawn Position packet
- Pkt.WritePosition((int)a_World.GetSpawnX(), (int)a_World.GetSpawnY(), (int)a_World.GetSpawnZ());
+ Pkt.WritePosition64((int)a_World.GetSpawnX(), (int)a_World.GetSpawnY(), (int)a_World.GetSpawnZ());
}
// Send the server difficulty:
{
cPacketizer Pkt(*this, 0x41);
- Pkt.WriteChar(1);
+ Pkt.WriteBEInt8(1);
}
// Send player abilities:
@@ -615,7 +615,7 @@ void cProtocol180::SendLoginSuccess(void)
// Enable compression:
{
cPacketizer Pkt(*this, 0x03); // Set compression packet
- Pkt.WriteVarInt(256);
+ Pkt.WriteVarInt32(256);
}
m_State = 3; // State = Game
@@ -639,10 +639,10 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting)
double PosZ = a_Painting.GetPosZ();
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.WritePosition((int)PosX, (int)PosY, (int)PosZ);
- Pkt.WriteChar(a_Painting.GetProtocolFacing());
+ Pkt.WritePosition64((int)PosX, (int)PosY, (int)PosZ);
+ Pkt.WriteBEInt8(a_Painting.GetProtocolFacing());
}
@@ -654,19 +654,19 @@ void cProtocol180::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colo
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt(a_ID);
- Pkt.WriteByte(m_Scale);
+ Pkt.WriteVarInt32(a_ID);
+ Pkt.WriteBEUInt8(m_Scale);
- Pkt.WriteVarInt(0);
- Pkt.WriteByte(1);
- Pkt.WriteByte(a_Length);
- Pkt.WriteByte(a_X);
- Pkt.WriteByte(a_Y);
+ Pkt.WriteVarInt32(0);
+ Pkt.WriteBEUInt8(1);
+ Pkt.WriteBEUInt8(a_Length);
+ Pkt.WriteBEUInt8(a_X);
+ Pkt.WriteBEUInt8(a_Y);
- Pkt.WriteVarInt(a_Length);
+ Pkt.WriteVarInt32(a_Length);
for (unsigned int i = 0; i < a_Length; ++i)
{
- Pkt.WriteByte(a_Colors[i]);
+ Pkt.WriteBEUInt8(a_Colors[i]);
}
}
@@ -679,18 +679,18 @@ void cProtocol180::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decor
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt(a_ID);
- Pkt.WriteByte(m_Scale);
- Pkt.WriteVarInt(a_Decorators.size());
+ Pkt.WriteVarInt32(a_ID);
+ Pkt.WriteBEUInt8(m_Scale);
+ Pkt.WriteVarInt32(a_Decorators.size());
for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
{
- Pkt.WriteByte((it->GetType() << 4) | (it->GetRot() & 0xf));
- Pkt.WriteByte(it->GetPixelX());
- Pkt.WriteByte(it->GetPixelZ());
+ Pkt.WriteBEUInt8((it->GetType() << 4) | (it->GetRot() & 0xf));
+ Pkt.WriteBEUInt8(it->GetPixelX());
+ Pkt.WriteBEUInt8(it->GetPixelZ());
}
- Pkt.WriteByte(0);
+ Pkt.WriteBEUInt8(0);
}
@@ -715,22 +715,22 @@ void cProtocol180::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.WriteVarInt(a_Pickup.GetUniqueID());
- Pkt.WriteByte((0x05 << 5) | 10); // Slot type + index 10
+ Pkt.WriteVarInt32(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
}
}
@@ -758,9 +758,9 @@ void cProtocol180::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()));
}
@@ -772,8 +772,8 @@ void cProtocol180::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);
}
@@ -786,16 +786,16 @@ void cProtocol180::SendParticleEffect(const AString & a_ParticleName, float a_Sr
int ParticleID = GetParticleID(a_ParticleName);
cPacketizer Pkt(*this, 0x2A);
- Pkt.WriteInt(ParticleID);
+ Pkt.WriteBEInt32(ParticleID);
Pkt.WriteBool(false);
- 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);
}
@@ -807,13 +807,13 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteVarInt(0);
- Pkt.WriteVarInt(1);
+ Pkt.WriteVarInt32(0);
+ Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
Pkt.WriteString(a_Player.GetPlayerListName());
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)
{
Pkt.WriteString(((Json::Value)*itr).get("name", "").asString());
@@ -830,8 +830,8 @@ void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
}
}
- Pkt.WriteVarInt((UInt32)a_Player.GetGameMode());
- Pkt.WriteVarInt((UInt32)a_Player.GetClientHandle()->GetPing());
+ Pkt.WriteVarInt32((UInt32)a_Player.GetGameMode());
+ Pkt.WriteVarInt32((UInt32)a_Player.GetClientHandle()->GetPing());
Pkt.WriteBool(false);
}
@@ -844,8 +844,8 @@ void cProtocol180::SendPlayerListRemovePlayer(const cPlayer & a_Player)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteVarInt(4);
- Pkt.WriteVarInt(1);
+ Pkt.WriteVarInt32(4);
+ Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
}
@@ -858,10 +858,10 @@ void cProtocol180::SendPlayerListUpdateGameMode(const cPlayer & a_Player)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteVarInt(1);
- Pkt.WriteVarInt(1);
+ Pkt.WriteVarInt32(1);
+ Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt((UInt32)a_Player.GetGameMode());
+ Pkt.WriteVarInt32((UInt32)a_Player.GetGameMode());
}
@@ -876,10 +876,10 @@ void cProtocol180::SendPlayerListUpdatePing(const cPlayer & a_Player)
if (ClientHandle != nullptr)
{
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteVarInt(2);
- Pkt.WriteVarInt(1);
+ Pkt.WriteVarInt32(2);
+ Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
- Pkt.WriteVarInt(static_cast<UInt32>(ClientHandle->GetPing()));
+ Pkt.WriteVarInt32(static_cast<UInt32>(ClientHandle->GetPing()));
}
}
@@ -892,8 +892,8 @@ void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
- Pkt.WriteVarInt(3);
- Pkt.WriteVarInt(1);
+ Pkt.WriteVarInt32(3);
+ Pkt.WriteVarInt32(1);
Pkt.WriteUUID(a_Player.GetUUID());
if (a_CustomName.empty())
@@ -917,22 +917,22 @@ void cProtocol180::SendPlayerMaxSpeed(void)
cPacketizer Pkt(*this, 0x20); // Entity Properties
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteVarInt(Player->GetUniqueID());
- Pkt.WriteInt(1); // Count
+ Pkt.WriteVarInt32(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.WriteVarInt(1); // Modifier count
- Pkt.WriteInt64(0x662a6b8dda3e4c1c);
- Pkt.WriteInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
- Pkt.WriteByte(2);
+ Pkt.WriteVarInt32(1); // Modifier count
+ Pkt.WriteBEUInt64(0x662a6b8dda3e4c1c);
+ Pkt.WriteBEUInt64(0x881396ea6097278d); // UUID of the modifier
+ Pkt.WriteBEDouble(Player->GetSprintingMaxSpeed() - Player->GetNormalMaxSpeed());
+ Pkt.WriteBEUInt8(2);
}
else
{
- Pkt.WriteVarInt(0); // Modifier count
+ Pkt.WriteVarInt32(0); // Modifier count
}
}
@@ -946,15 +946,15 @@ void cProtocol180::SendPlayerMoveLook(void)
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteDouble(Player->GetPosX());
+ Pkt.WriteBEDouble(Player->GetPosX());
// The "+ 0.001" is there because otherwise the player falls through the block they were standing on.
- Pkt.WriteDouble(Player->GetPosY() + 0.001);
+ Pkt.WriteBEDouble(Player->GetPosY() + 0.001);
- Pkt.WriteDouble(Player->GetPosZ());
- Pkt.WriteFloat((float)Player->GetYaw());
- Pkt.WriteFloat((float)Player->GetPitch());
- Pkt.WriteByte(0);
+ Pkt.WriteBEDouble(Player->GetPosZ());
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetYaw()));
+ Pkt.WriteBEFloat(static_cast<float>(Player->GetPitch()));
+ Pkt.WriteBEUInt8(0);
}
@@ -975,7 +975,7 @@ void cProtocol180::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.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.
@@ -983,12 +983,12 @@ void cProtocol180::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((4 << 5 | (2 & 0x1F)) & 0xFF);
+ Pkt.WriteBEInt16(ItemType);
+ Pkt.WriteBEUInt8((3 << 5) | 6); // Metadata: float + index 6
+ Pkt.WriteBEFloat(static_cast<float>(a_Player.GetHealth()));
+ Pkt.WriteBEUInt8((4 << 5 | (2 & 0x1F)) & 0xFF);
Pkt.WriteString(a_Player.GetName());
- Pkt.WriteByte(0x7f); // Metadata: end
+ Pkt.WriteBEUInt8(0x7f); // Metadata: end
}
@@ -1013,8 +1013,8 @@ void cProtocol180::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x1e);
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteByte(a_EffectID);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(a_EffectID);
}
@@ -1031,9 +1031,9 @@ void cProtocol180::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;
}
@@ -1048,9 +1048,9 @@ void cProtocol180::SendExperience(void)
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
- Pkt.WriteFloat(Player->GetXpPercentage());
- Pkt.WriteVarInt((UInt32)Player->GetXpLevel());
- Pkt.WriteVarInt((UInt32)Player->GetCurrentXp());
+ Pkt.WriteBEFloat(Player->GetXpPercentage());
+ Pkt.WriteVarInt32((UInt32)Player->GetXpLevel());
+ Pkt.WriteVarInt32((UInt32)Player->GetCurrentXp());
}
@@ -1062,11 +1062,11 @@ void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb)
ASSERT(m_State == 3); // In game mode?
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(a_ExpOrb.GetReward());
+ Pkt.WriteBEInt16(a_ExpOrb.GetReward());
}
@@ -1079,7 +1079,7 @@ void cProtocol180::SendScoreboardObjective(const AString & a_Name, const AString
cPacketizer Pkt(*this, 0x3b);
Pkt.WriteString(a_Name);
- Pkt.WriteByte(a_Mode);
+ Pkt.WriteBEUInt8(a_Mode);
if ((a_Mode == 0) || (a_Mode == 2))
{
Pkt.WriteString(a_DisplayName);
@@ -1097,12 +1097,12 @@ void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString &
cPacketizer Pkt(*this, 0x3c);
Pkt.WriteString(a_Player);
- Pkt.WriteByte(a_Mode);
+ Pkt.WriteBEUInt8(a_Mode);
Pkt.WriteString(a_Objective);
if (a_Mode != 1)
{
- Pkt.WriteVarInt((UInt32) a_Score);
+ Pkt.WriteVarInt32((UInt32) a_Score);
}
}
@@ -1115,7 +1115,7 @@ void cProtocol180::SendDisplayObjective(const AString & a_Objective, cScoreboard
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3d);
- Pkt.WriteByte((int) a_Display);
+ Pkt.WriteBEUInt8((int) a_Display);
Pkt.WriteString(a_Objective);
}
@@ -1129,11 +1129,11 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub
cPacketizer Pkt(*this, 0x29); // Sound Effect packet
Pkt.WriteString(a_SoundName);
- Pkt.WriteInt((int)(a_X * 8.0));
- Pkt.WriteInt((int)(a_Y * 8.0));
- Pkt.WriteInt((int)(a_Z * 8.0));
- Pkt.WriteFloat(a_Volume);
- Pkt.WriteByte((Byte)(a_Pitch * 63));
+ Pkt.WriteBEInt32((int)(a_X * 8.0));
+ Pkt.WriteBEInt32((int)(a_Y * 8.0));
+ Pkt.WriteBEInt32((int)(a_Z * 8.0));
+ Pkt.WriteBEFloat(a_Volume);
+ Pkt.WriteBEUInt8((Byte)(a_Pitch * 63));
}
@@ -1145,9 +1145,9 @@ void cProtocol180::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x28); // Effect packet
- Pkt.WriteInt(a_EffectID);
- Pkt.WritePosition(a_SrcX, a_SrcY, a_SrcZ);
- Pkt.WriteInt(a_Data);
+ Pkt.WriteBEInt32(a_EffectID);
+ Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ);
+ Pkt.WriteBEInt32(a_Data);
Pkt.WriteBool(false);
}
@@ -1160,17 +1160,17 @@ void cProtocol180::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(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 12));
- Pkt.WriteShort((short)(a_FallingBlock.GetSpeedX() * 400));
- Pkt.WriteShort((short)(a_FallingBlock.GetSpeedY() * 400));
- Pkt.WriteShort((short)(a_FallingBlock.GetSpeedZ() * 400));
+ Pkt.WriteBEInt32(((int)a_FallingBlock.GetBlockType()) | (((int)a_FallingBlock.GetBlockMeta()) << 12));
+ Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedX() * 400));
+ Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedY() * 400));
+ Pkt.WriteBEInt16((short)(a_FallingBlock.GetSpeedZ() * 400));
}
@@ -1182,19 +1182,19 @@ void cProtocol180::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((short)(a_Mob.GetSpeedX() * 400));
- Pkt.WriteShort((short)(a_Mob.GetSpeedY() * 400));
- Pkt.WriteShort((short)(a_Mob.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16((short)(a_Mob.GetSpeedX() * 400));
+ Pkt.WriteBEInt16((short)(a_Mob.GetSpeedY() * 400));
+ Pkt.WriteBEInt16((short)(a_Mob.GetSpeedZ() * 400));
WriteEntityMetadata(Pkt, a_Mob);
- Pkt.WriteByte(0x7f); // Metadata terminator
+ Pkt.WriteBEUInt8(0x7f); // Metadata terminator
}
@@ -1213,19 +1213,19 @@ void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
}
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WriteByte(a_ObjectType);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WriteBEUInt8(a_ObjectType);
Pkt.WriteFPInt(PosX);
Pkt.WriteFPInt(a_Entity.GetPosY());
Pkt.WriteFPInt(PosZ);
Pkt.WriteByteAngle(a_Entity.GetPitch());
Pkt.WriteByteAngle(Yaw);
- Pkt.WriteInt(a_ObjectData);
+ Pkt.WriteBEInt32(a_ObjectData);
if (a_ObjectData != 0)
{
- Pkt.WriteShort((short)(a_Entity.GetSpeedX() * 400));
- Pkt.WriteShort((short)(a_Entity.GetSpeedY() * 400));
- Pkt.WriteShort((short)(a_Entity.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedX() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedY() * 400));
+ Pkt.WriteBEInt16((short)(a_Entity.GetSpeedZ() * 400));
}
}
@@ -1238,19 +1238,19 @@ void cProtocol180::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.WriteByte(a_VehicleType);
+ Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
+ Pkt.WriteBEUInt8(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((short)(a_Vehicle.GetSpeedX() * 400));
- Pkt.WriteShort((short)(a_Vehicle.GetSpeedY() * 400));
- Pkt.WriteShort((short)(a_Vehicle.GetSpeedZ() * 400));
+ Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedX() * 400));
+ Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedY() * 400));
+ Pkt.WriteBEInt16((short)(a_Vehicle.GetSpeedZ() * 400));
}
}
@@ -1263,7 +1263,7 @@ void cProtocol180::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)
{
@@ -1271,7 +1271,7 @@ void cProtocol180::SendStatistics(const cStatManager & a_Manager)
const AString & StatName = cStatInfo::GetName((eStatistic) i);
Pkt.WriteString(StatName);
- Pkt.WriteVarInt(Value);
+ Pkt.WriteVarInt32(Value);
}
}
@@ -1284,7 +1284,7 @@ void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
- Pkt.WriteVarInt((int)a_Results.size());
+ Pkt.WriteVarInt32((int)a_Results.size());
for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr)
{
@@ -1301,7 +1301,7 @@ void cProtocol180::SendTeleportEntity(const cEntity & a_Entity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x18);
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteFPInt(a_Entity.GetPosX());
Pkt.WriteFPInt(a_Entity.GetPosY());
Pkt.WriteFPInt(a_Entity.GetPosZ());
@@ -1319,8 +1319,8 @@ void cProtocol180::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);
@@ -1340,8 +1340,8 @@ void cProtocol180::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);
}
@@ -1353,11 +1353,11 @@ void cProtocol180::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.WriteVarInt(0); // Data size
+ Pkt.WriteBEInt16(0); // Primary bitmap
+ Pkt.WriteVarInt32(0); // Data size
}
@@ -1368,7 +1368,7 @@ void cProtocol180::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x35); // Update tile entity packet
- Pkt.WritePosition(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
+ Pkt.WritePosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
Byte Action = 0;
switch (a_BlockEntity.GetBlockType())
@@ -1380,7 +1380,7 @@ void cProtocol180::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);
}
@@ -1394,7 +1394,7 @@ void cProtocol180::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x33);
- Pkt.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Json::StyledWriter JsonWriter;
AString Lines[] = { a_Line1, a_Line2, a_Line3, a_Line4 };
@@ -1415,8 +1415,8 @@ void cProtocol180::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x0a);
- Pkt.WriteVarInt(a_Entity.GetUniqueID());
- Pkt.WritePosition(a_BlockX, a_BlockY, a_BlockZ);
+ Pkt.WriteVarInt32(a_Entity.GetUniqueID());
+ Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -1429,8 +1429,8 @@ void cProtocol180::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
@@ -1445,8 +1445,8 @@ void cProtocol180::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(a_Window.GetNumSlots());
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
+ Pkt.WriteBEInt16(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)
@@ -1464,7 +1464,7 @@ void cProtocol180::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());
}
@@ -1482,7 +1482,7 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window)
}
cPacketizer Pkt(*this, 0x2d);
- Pkt.WriteChar(a_Window.GetWindowID());
+ Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteString(a_Window.GetWindowTypeName());
Pkt.WriteString(Printf("{\"text\":\"%s\"}", a_Window.GetWindowTitle().c_str()));
@@ -1492,19 +1492,19 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window)
case cWindow::wtEnchantment:
case cWindow::wtAnvil:
{
- Pkt.WriteChar(0);
+ Pkt.WriteBEInt8(0);
break;
}
default:
{
- Pkt.WriteChar(a_Window.GetNumNonInventorySlots());
+ Pkt.WriteBEInt8(a_Window.GetNumNonInventorySlots());
break;
}
}
if (a_Window.GetWindowType() == cWindow::wtAnimalChest)
{
- Pkt.WriteInt(0); // TODO: The animal's EntityID
+ Pkt.WriteBEInt32(0); // TODO: The animal's EntityID
}
}
@@ -1517,9 +1517,9 @@ void cProtocol180::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);
}
@@ -1538,7 +1538,10 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress
return false;
}
- int Status = compress2((Bytef*)CompressedData, &CompressedSize, (const Bytef*)a_Packet.data(), a_Packet.size(), Z_DEFAULT_COMPRESSION);
+ int Status = compress2(
+ reinterpret_cast<Bytef *>(CompressedData), &CompressedSize,
+ reinterpret_cast<const Bytef *>(a_Packet.data()), a_Packet.size(), Z_DEFAULT_COMPRESSION
+ );
if (Status != Z_OK)
{
return false;
@@ -1546,12 +1549,12 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress
AString LengthData;
cByteBuffer Buffer(20);
- Buffer.WriteVarInt((UInt32)a_Packet.size());
+ Buffer.WriteVarInt32(static_cast<UInt32>(a_Packet.size()));
Buffer.ReadAll(LengthData);
Buffer.CommitRead();
- Buffer.WriteVarInt(CompressedSize + LengthData.size());
- Buffer.WriteVarInt(a_Packet.size());
+ Buffer.WriteVarInt32(CompressedSize + LengthData.size());
+ Buffer.WriteVarInt32(static_cast<UInt32>(a_Packet.size()));
Buffer.ReadAll(LengthData);
Buffer.CommitRead();
@@ -1949,7 +1952,7 @@ void cProtocol180::HandlePacketStatusPing(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEInt64, Int64, Timestamp);
cPacketizer Pkt(*this, 0x01); // Ping packet
- Pkt.WriteInt64(Timestamp);
+ Pkt.WriteBEInt64(Timestamp);
}
@@ -2086,10 +2089,10 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
cPacketizer Pkt(*this, 0x01);
Pkt.WriteString(Server->GetServerID());
const AString & PubKeyDer = Server->GetPublicKeyDER();
- Pkt.WriteVarInt((short)PubKeyDer.size());
+ Pkt.WriteVarInt32((short)PubKeyDer.size());
Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
- Pkt.WriteVarInt(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.WriteVarInt32(4);
+ Pkt.WriteBEInt32((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
m_Client->SetUsername(Username);
return;
}
@@ -2115,7 +2118,7 @@ void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status);
int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadPosition(BlockX, BlockY, BlockZ))
+ if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ))
{
return;
}
@@ -2131,7 +2134,7 @@ void cProtocol180::HandlePacketBlockDig(cByteBuffer & a_ByteBuffer)
void cProtocol180::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
{
int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadPosition(BlockX, BlockY, BlockZ))
+ if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ))
{
return;
}
@@ -2410,7 +2413,7 @@ void cProtocol180::HandlePacketTabComplete(cByteBuffer & a_ByteBuffer)
void cProtocol180::HandlePacketUpdateSign(cByteBuffer & a_ByteBuffer)
{
int BlockX, BlockY, BlockZ;
- if (!a_ByteBuffer.ReadPosition(BlockX, BlockY, BlockZ))
+ if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ))
{
return;
}
@@ -2799,8 +2802,8 @@ void cProtocol180::SendPacket(cPacketizer & a_Pkt)
else if (m_State == 3)
{
// The packet is not compressed, indicate this in the packet header:
- m_OutPacketLenBuffer.WriteVarInt(PacketLen + 1);
- m_OutPacketLenBuffer.WriteVarInt(0);
+ m_OutPacketLenBuffer.WriteVarInt32(PacketLen + 1);
+ m_OutPacketLenBuffer.WriteVarInt32(0);
AString LengthData;
m_OutPacketLenBuffer.ReadAll(LengthData);
SendData(LengthData.data(), LengthData.size());
@@ -2808,7 +2811,7 @@ void cProtocol180::SendPacket(cPacketizer & a_Pkt)
else
{
// Compression doesn't apply to this state, send raw data:
- m_OutPacketLenBuffer.WriteVarInt(PacketLen);
+ m_OutPacketLenBuffer.WriteVarInt32(PacketLen);
AString LengthData;
m_OutPacketLenBuffer.ReadAll(LengthData);
SendData(LengthData.data(), LengthData.size());
@@ -2853,17 +2856,17 @@ void cProtocol180::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.WriteByte (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.WriteChar(0);
+ a_Pkt.WriteBEInt8(0);
return;
}
@@ -2913,7 +2916,7 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
AString Result = Writer.GetResult();
if (Result.size() == 0)
{
- a_Pkt.WriteChar(0);
+ a_Pkt.WriteBEInt8(0);
return;
}
a_Pkt.WriteBuf(Result.data(), Result.size());
@@ -3038,21 +3041,21 @@ void cProtocol180::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:
@@ -3062,11 +3065,11 @@ 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.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)
{
@@ -3074,20 +3077,20 @@ void cProtocol180::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
@@ -3099,13 +3102,13 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
{
case cProjectileEntity::pkArrow:
{
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(reinterpret_cast<const cArrowEntity &>(Projectile).IsCritical() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(reinterpret_cast<const cArrowEntity &>(Projectile).IsCritical() ? 1 : 0);
break;
}
case cProjectileEntity::pkFirework:
{
- a_Pkt.WriteByte(0xa8);
+ a_Pkt.WriteBEUInt8(0xa8);
WriteItem(a_Pkt, reinterpret_cast<const cFireworkEntity &>(Projectile).GetItem());
break;
}
@@ -3126,10 +3129,10 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
case cEntity::etItemFrame:
{
auto & Frame = reinterpret_cast<const cItemFrame &>(a_Entity);
- a_Pkt.WriteByte(0xa8);
+ a_Pkt.WriteBEUInt8(0xa8);
WriteItem(a_Pkt, Frame.GetItem());
- a_Pkt.WriteByte(0x09);
- a_Pkt.WriteByte(Frame.GetItemRotation());
+ a_Pkt.WriteBEUInt8(0x09);
+ a_Pkt.WriteBEUInt8(Frame.GetItemRotation());
break;
} // case etItemFrame
@@ -3151,38 +3154,38 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
case mtBat:
{
auto & Bat = reinterpret_cast<const cBat &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(Bat.IsHanging() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(Bat.IsHanging() ? 1 : 0);
break;
} // case mtBat
case mtCreeper:
{
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(Creeper.IsBlowing() ? 1 : -1);
- a_Pkt.WriteByte(0x11);
- a_Pkt.WriteByte(Creeper.IsCharged() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(Creeper.IsBlowing() ? 1 : -1);
+ a_Pkt.WriteBEUInt8(0x11);
+ a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0);
break;
} // case mtCreeper
case mtEnderman:
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
- a_Pkt.WriteByte(0x30);
- a_Pkt.WriteShort(static_cast<Byte>(Enderman.GetCarriedBlock()));
- a_Pkt.WriteByte(0x11);
- a_Pkt.WriteByte(static_cast<Byte>(Enderman.GetCarriedMeta()));
- a_Pkt.WriteByte(0x12);
- a_Pkt.WriteByte(Enderman.IsScreaming() ? 1 : 0);
+ 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);
break;
} // case mtEnderman
case mtGhast:
{
auto & Ghast = reinterpret_cast<const cGhast &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(Ghast.IsCharging());
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(Ghast.IsCharging());
break;
} // case mtGhast
@@ -3218,89 +3221,89 @@ void cProtocol180::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(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(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:
{
auto & MagmaCube = reinterpret_cast<const cMagmaCube &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(MagmaCube.GetSize());
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(MagmaCube.GetSize());
break;
} // case mtMagmaCube
case mtPig:
{
auto & Pig = reinterpret_cast<const cPig &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(Pig.IsSaddled() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(Pig.IsSaddled() ? 1 : 0);
break;
} // case mtPig
case mtSheep:
{
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob);
- a_Pkt.WriteByte(0x10);
+ a_Pkt.WriteBEUInt8(0x10);
Byte SheepMetadata = 0;
SheepMetadata = Sheep.GetFurColor();
if (Sheep.IsSheared())
{
SheepMetadata |= 0x10;
}
- a_Pkt.WriteByte(SheepMetadata);
+ a_Pkt.WriteBEUInt8(SheepMetadata);
break;
} // case mtSheep
case mtSkeleton:
{
auto & Skeleton = reinterpret_cast<const cSkeleton &>(a_Mob);
- a_Pkt.WriteByte(0x0d);
- a_Pkt.WriteByte(Skeleton.IsWither() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x0d);
+ a_Pkt.WriteBEUInt8(Skeleton.IsWither() ? 1 : 0);
break;
} // case mtSkeleton
case mtSlime:
{
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob);
- a_Pkt.WriteByte(0x10);
- a_Pkt.WriteByte(Slime.GetSize());
+ a_Pkt.WriteBEUInt8(0x10);
+ a_Pkt.WriteBEUInt8(Slime.GetSize());
break;
} // case mtSlime
case mtVillager:
{
auto & Villager = reinterpret_cast<const cVillager &>(a_Mob);
- a_Pkt.WriteByte(0x50);
- a_Pkt.WriteInt(Villager.GetVilType());
+ a_Pkt.WriteBEUInt8(0x50);
+ a_Pkt.WriteBEInt32(Villager.GetVilType());
break;
} // case mtVillager
case mtWitch:
{
auto & Witch = reinterpret_cast<const cWitch &>(a_Mob);
- a_Pkt.WriteByte(0x15);
- a_Pkt.WriteByte(Witch.IsAngry() ? 1 : 0);
+ a_Pkt.WriteBEUInt8(0x15);
+ a_Pkt.WriteBEUInt8(Witch.IsAngry() ? 1 : 0);
break;
} // case mtWitch
case mtWither:
{
auto & Wither = reinterpret_cast<const cWither &>(a_Mob);
- a_Pkt.WriteByte(0x54); // Int at index 20
- a_Pkt.WriteInt(Wither.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(Wither.GetWitherInvulnerableTicks());
+ a_Pkt.WriteBEUInt8(0x66); // Float at index 6
+ a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
} // case mtWither
@@ -3320,27 +3323,27 @@ void cProtocol180::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(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(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
} // switch (a_Mob.GetType())
@@ -3355,7 +3358,7 @@ void cProtocol180::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;
}
@@ -3363,7 +3366,7 @@ void cProtocol180::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
}