From 3e802932a6797fc0f4768ebc61cf9ac4f498c7fb Mon Sep 17 00:00:00 2001 From: changyong guo Date: Mon, 23 Jul 2018 06:23:33 +0800 Subject: recover hotbar selected slot after reconnect (#4249) 1. implement protocol message SendHeldItemChange 2. add save / load inventory equipped item slot in JSON 3. send held item slot message after player connect to server Fixes #4189 --- src/Protocol/Protocol_1_8.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Protocol/Protocol_1_8.cpp') 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(Player->GetInventory().GetEquippedSlotNum())); +} + + + + + void cProtocol_1_8_0::SendHideTitle(void) { ASSERT(m_State == 3); // In game mode? -- cgit v1.2.3