From 68776c4d5919638b3cecccd083155cd58ccac573 Mon Sep 17 00:00:00 2001 From: KingCol13 <48412633+KingCol13@users.noreply.github.com> Date: Fri, 9 Jul 2021 18:45:53 +0100 Subject: Item frame maps (#5258) + Send map data when item frame spawns. + Add some casts to placate compiler warnings. * size_t for array access. * Mark chunk dirty when rotation or item in item frame is changed. --- src/Entities/ItemFrame.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Entities/ItemFrame.cpp') diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp index ef2939e06..eeab06737 100644 --- a/src/Entities/ItemFrame.cpp +++ b/src/Entities/ItemFrame.cpp @@ -4,6 +4,7 @@ #include "ItemFrame.h" #include "Player.h" #include "../ClientHandle.h" +#include "Chunk.h" @@ -26,7 +27,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) if (!m_Item.IsEmpty()) { - // Item not empty, rotate, clipping values to zero to three inclusive + // Item not empty, rotate, clipping values to zero to seven inclusive m_ItemRotation++; if (m_ItemRotation >= 8) { @@ -46,6 +47,7 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player) } GetWorld()->BroadcastEntityMetadata(*this); // Update clients + GetParentChunk()->MarkDirty(); // Mark chunk dirty to save rotation or item } @@ -97,4 +99,13 @@ void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle) Super::SpawnOn(a_ClientHandle); a_ClientHandle.SendSpawnEntity(*this); a_ClientHandle.SendEntityMetadata(*this); + + if (m_Item.m_ItemType == E_ITEM_MAP) + { + cMap * Map = GetWorld()->GetMapManager().GetMapData(static_cast(m_Item.m_ItemDamage)); + if (Map != nullptr) + { + a_ClientHandle.SendMapData(*Map, 0, 0); + } + } } -- cgit v1.2.3