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/Entities/Player.cpp | |
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 '')
-rw-r--r-- | src/Entities/Player.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6ddfeb75c..bf5daf172 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -743,6 +743,18 @@ void cPlayer::SendHealth(void) +void cPlayer::SendHotbarActiveSlot(void) +{ + if (m_ClientHandle != nullptr) + { + m_ClientHandle->SendHeldItemChange(m_Inventory.GetEquippedSlotNum()); + } +} + + + + + void cPlayer::SendExperience(void) { if (m_ClientHandle != nullptr) @@ -2212,6 +2224,10 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) } m_Inventory.LoadFromJson(root["inventory"]); + + int equippedSlotNum = root.get("equippedItemSlot", 0).asInt(); + m_Inventory.SetEquippedSlotNum(equippedSlotNum); + cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents); m_LoadedWorldName = root.get("world", "world").asString(); @@ -2302,6 +2318,7 @@ bool cPlayer::SaveToDisk() root["position"] = JSON_PlayerPosition; root["rotation"] = JSON_PlayerRotation; root["inventory"] = JSON_Inventory; + root["equippedItemSlot"] = m_Inventory.GetEquippedSlotNum(); root["enderchestinventory"] = JSON_EnderChestInventory; root["health"] = m_Health; root["xpTotal"] = m_LifetimeTotalXp; |