summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp17
-rw-r--r--src/Entities/Player.h3
2 files changed, 20 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;
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 8fa463c5a..a2ee13b45 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -431,6 +431,9 @@ public:
void SendHealth(void);
+ // Send current active hotbar slot
+ void SendHotbarActiveSlot(void);
+
void SendExperience(void);
/** In UI windows, get the item that the player is dragging */