diff options
author | changyong guo <guo1487@163.com> | 2018-07-23 00:23:33 +0200 |
---|---|---|
committer | peterbell10 <peterbell10@live.co.uk> | 2018-07-23 00:23:33 +0200 |
commit | 3e802932a6797fc0f4768ebc61cf9ac4f498c7fb (patch) | |
tree | 18dc1b8ce84c3202034c859a3d775c8beb2b68be /src/Protocol | |
parent | cIsThread: Reset m_ShouldTerminate after the thread has stopped (#4258) (diff) | |
download | cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar.gz cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar.bz2 cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar.lz cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar.xz cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.tar.zst cuberite-3e802932a6797fc0f4768ebc61cf9ac4f498c7fb.zip |
Diffstat (limited to 'src/Protocol')
-rw-r--r-- | src/Protocol/PacketID.cpp | 3 | ||||
-rw-r--r-- | src/Protocol/Protocol.h | 2 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.cpp | 11 | ||||
-rw-r--r-- | src/Protocol/ProtocolRecognizer.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 13 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 14 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.h | 1 |
8 files changed, 46 insertions, 0 deletions
diff --git a/src/Protocol/PacketID.cpp b/src/Protocol/PacketID.cpp index 47d274f25..135d60a6c 100644 --- a/src/Protocol/PacketID.cpp +++ b/src/Protocol/PacketID.cpp @@ -41,6 +41,7 @@ UInt32 cProtocol_1_9_0::GetPacketId(eOutgoingPackets a_Packet) case sendExplosion: return 0x1c; case sendGameMode: return 0x1e; case sendHealth: return 0x3e; + case sendHeldItemChange: return 0x37; case sendInventorySlot: return 0x16; case sendJoinGame: return 0x23; case sendKeepAlive: return 0x1f; @@ -124,6 +125,7 @@ UInt32 cProtocol_1_12::GetPacketId(eOutgoingPackets a_Packet) case sendEntityVelocity: return 0x3d; case sendExperience: return 0x3f; case sendHealth: return 0x40; + case sendHeldItemChange: return 0x39; case sendLeashEntity: return 0x3c; case sendPlayerMaxSpeed: return 0x4d; case sendRemoveEntityEffect: return 0x32; @@ -161,6 +163,7 @@ UInt32 cProtocol_1_12_1::GetPacketId(eOutgoingPackets a_Packet) case sendEntityVelocity: return 0x3e; case sendExperience: return 0x40; case sendHealth: return 0x41; + case sendHeldItemChange: return 0x3a; case sendLeashEntity: return 0x3d; case sendPlayerList: return 0x2e; case sendPlayerAbilities: return 0x2c; diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 235b60020..1a912f8f9 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -89,6 +89,7 @@ public: sendExplosion, sendGameMode, sendHealth, + sendHeldItemChange, sendInventorySlot, sendJoinGame, sendKeepAlive, @@ -160,6 +161,7 @@ public: virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) = 0; virtual void SendGameMode (eGameMode a_GameMode) = 0; virtual void SendHealth (void) = 0; + virtual void SendHeldItemChange (int a_ItemIndex) = 0; virtual void SendHideTitle (void) = 0; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) = 0; virtual void SendKeepAlive (UInt32 a_PingID) = 0; diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 912091acc..27ed2e6ad 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -428,6 +428,17 @@ void cProtocolRecognizer::SendHealth(void) +void cProtocolRecognizer::SendHeldItemChange(int a_ItemIndex) +{ + ASSERT(m_Protocol != nullptr); + m_Protocol->SendHeldItemChange(a_ItemIndex); +} + + + + + + void cProtocolRecognizer::SendHideTitle(void) { ASSERT(m_Protocol != nullptr); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index a29daad94..805197db8 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -85,6 +85,7 @@ public: virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; + virtual void SendHeldItemChange (int a_ItemIndex) override; virtual void SendHideTitle (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; virtual void SendKeepAlive (UInt32 a_PingID) override; diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 58f067278..643f99841 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -592,6 +592,19 @@ void cProtocol_1_8_0::SendHealth(void) +void cProtocol_1_8_0::SendHeldItemChange(int a_ItemIndex) +{ + ASSERT((a_ItemIndex >= 0) && (a_ItemIndex <= 8)); // Valid check + + cPacketizer Pkt(*this, 0x09); // Held item change + cPlayer * Player = m_Client->GetPlayer(); + Pkt.WriteBEInt8(static_cast<Int8>(Player->GetInventory().GetEquippedSlotNum())); +} + + + + + void cProtocol_1_8_0::SendHideTitle(void) { ASSERT(m_State == 3); // In game mode? diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h index 108cc9798..fd71a2da3 100644 --- a/src/Protocol/Protocol_1_8.h +++ b/src/Protocol/Protocol_1_8.h @@ -77,6 +77,7 @@ public: virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; + virtual void SendHeldItemChange (int a_ItemIndex) override; virtual void SendHideTitle (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; virtual void SendKeepAlive (UInt32 a_PingID) override; diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index 64721ed04..2621f140c 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -636,6 +636,20 @@ void cProtocol_1_9_0::SendHealth(void) +void cProtocol_1_9_0::SendHeldItemChange(int a_ItemIndex) +{ + ASSERT((a_ItemIndex >= 0) && (a_ItemIndex <= 8)); // Valid check + + cPacketizer Pkt(*this, GetPacketId(sendHeldItemChange)); // Held item change + cPlayer * Player = m_Client->GetPlayer(); + Pkt.WriteBEInt8(static_cast<Int8>(Player->GetInventory().GetEquippedSlotNum())); +} + + + + + + void cProtocol_1_9_0::SendHideTitle(void) { ASSERT(m_State == 3); // In game mode? diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h index a7fd137a9..a7111436b 100644 --- a/src/Protocol/Protocol_1_9.h +++ b/src/Protocol/Protocol_1_9.h @@ -83,6 +83,7 @@ public: virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; + virtual void SendHeldItemChange (int a_ItemIndex) override; virtual void SendHideTitle (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; virtual void SendKeepAlive (UInt32 a_PingID) override; |