Use LastSentPos for mob spawn packet in 1.11+ (#4490)
This commit is contained in:
parent
7d4934534e
commit
cff9f7571b
@ -389,9 +389,10 @@ void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob)
|
|||||||
Pkt.WriteBEUInt64(0);
|
Pkt.WriteBEUInt64(0);
|
||||||
Pkt.WriteBEUInt64(a_Mob.GetUniqueID());
|
Pkt.WriteBEUInt64(a_Mob.GetUniqueID());
|
||||||
Pkt.WriteVarInt32(static_cast<UInt32>(a_Mob.GetMobType()));
|
Pkt.WriteVarInt32(static_cast<UInt32>(a_Mob.GetMobType()));
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosX());
|
Vector3d LastSentPos = a_Mob.GetLastSentPos();
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosY());
|
Pkt.WriteBEDouble(LastSentPos.x);
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosZ());
|
Pkt.WriteBEDouble(LastSentPos.y);
|
||||||
|
Pkt.WriteBEDouble(LastSentPos.z);
|
||||||
Pkt.WriteByteAngle(a_Mob.GetPitch());
|
Pkt.WriteByteAngle(a_Mob.GetPitch());
|
||||||
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
|
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
|
||||||
Pkt.WriteByteAngle(a_Mob.GetYaw());
|
Pkt.WriteByteAngle(a_Mob.GetYaw());
|
||||||
|
@ -325,53 +325,6 @@ cProtocol_1_12::cProtocol_1_12(cClientHandle * a_Client, const AString & a_Serve
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::SendSpawnMob(const cMonster & a_Mob)
|
|
||||||
{
|
|
||||||
ASSERT(m_State == 3); // In game mode?
|
|
||||||
|
|
||||||
cPacketizer Pkt(*this, pktSpawnMob);
|
|
||||||
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
|
|
||||||
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
|
|
||||||
Pkt.WriteBEUInt64(0);
|
|
||||||
Pkt.WriteBEUInt64(a_Mob.GetUniqueID());
|
|
||||||
Pkt.WriteVarInt32(static_cast<UInt32>(a_Mob.GetMobType()));
|
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosX());
|
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosY());
|
|
||||||
Pkt.WriteBEDouble(a_Mob.GetPosZ());
|
|
||||||
Pkt.WriteByteAngle(a_Mob.GetPitch());
|
|
||||||
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
|
|
||||||
Pkt.WriteByteAngle(a_Mob.GetYaw());
|
|
||||||
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedX() * 400));
|
|
||||||
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedY() * 400));
|
|
||||||
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedZ() * 400));
|
|
||||||
WriteEntityMetadata(Pkt, a_Mob);
|
|
||||||
Pkt.WriteBEUInt8(0xff); // Metadata terminator
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
|
|
||||||
{
|
|
||||||
int BlockX, BlockY, BlockZ;
|
|
||||||
if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Face);
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand);
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorX);
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorY);
|
|
||||||
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorZ);
|
|
||||||
m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), FloorC(CursorX * 16), FloorC(CursorY * 16), FloorC(CursorZ * 16), HandIntToEnum(Hand));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
void cProtocol_1_12::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||||
{
|
{
|
||||||
cServer * Server = cRoot::Get()->GetServer();
|
cServer * Server = cRoot::Get()->GetServer();
|
||||||
@ -1080,59 +1033,6 @@ void cProtocol_1_12::HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks)
|
|
||||||
{
|
|
||||||
ASSERT(m_State == 3); // In game mode?
|
|
||||||
|
|
||||||
cPacketizer Pkt(*this, pktTitle);
|
|
||||||
Pkt.WriteVarInt32(3); // Set title display times
|
|
||||||
Pkt.WriteBEInt32(a_FadeInTicks);
|
|
||||||
Pkt.WriteBEInt32(a_DisplayTicks);
|
|
||||||
Pkt.WriteBEInt32(a_FadeOutTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::SendHideTitle(void)
|
|
||||||
{
|
|
||||||
ASSERT(m_State == 3); // In game mode?
|
|
||||||
|
|
||||||
cPacketizer Pkt(*this, pktTitle);
|
|
||||||
Pkt.WriteVarInt32(4); // Hide title
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::SendResetTitle(void)
|
|
||||||
{
|
|
||||||
ASSERT(m_State == 3); // In game mode?
|
|
||||||
|
|
||||||
cPacketizer Pkt(*this, pktTitle);
|
|
||||||
Pkt.WriteVarInt32(5); // Reset title
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol_1_12::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
|
|
||||||
{
|
|
||||||
ASSERT(m_State == 3); // In game mode?
|
|
||||||
|
|
||||||
cPacketizer Pkt(*this, pktCollectEntity);
|
|
||||||
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
|
|
||||||
Pkt.WriteVarInt32(a_Player.GetUniqueID());
|
|
||||||
Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
|
bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
|
||||||
{
|
{
|
||||||
switch (m_State)
|
switch (m_State)
|
||||||
|
@ -32,16 +32,10 @@ class cProtocol_1_12 :
|
|||||||
public:
|
public:
|
||||||
cProtocol_1_12(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_12(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
virtual void SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
|
|
||||||
virtual void SendHideTitle(void) override;
|
|
||||||
virtual void SendResetTitle(void) override;
|
|
||||||
virtual void SendSpawnMob(const cMonster & a_Mob) override;
|
|
||||||
virtual void SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
|
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
|
||||||
virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer);
|
||||||
virtual void HandlePacketCraftingBookData(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketCraftingBookData(cByteBuffer & a_ByteBuffer);
|
||||||
virtual void HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer) override;
|
|
||||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||||
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
|
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
|
||||||
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
|
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user