summaryrefslogtreecommitdiffstats
path: root/source/cChestEntity.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-28 18:47:57 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-28 18:47:57 +0200
commit1a0bfd8d28c68d3ee60352ef67c58da946c43cea (patch)
tree821bb46846db0464a1ddbbfe4c60e335a375d33e /source/cChestEntity.cpp
parentIce finisher generator; fixed snow on water. (diff)
downloadcuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar.gz
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar.bz2
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar.lz
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar.xz
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.tar.zst
cuberite-1a0bfd8d28c68d3ee60352ef67c58da946c43cea.zip
Diffstat (limited to '')
-rw-r--r--source/cChestEntity.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
index e1976836b..7a0de425a 100644
--- a/source/cChestEntity.cpp
+++ b/source/cChestEntity.cpp
@@ -73,7 +73,7 @@ void cChestEntity::Destroy()
-cItem * cChestEntity::GetSlot( int a_Slot )
+const cItem * cChestEntity::GetSlot( int a_Slot ) const
{
if( a_Slot > -1 && a_Slot < c_ChestHeight*c_ChestWidth )
{
@@ -161,7 +161,7 @@ void cChestEntity::SaveToJson( Json::Value& a_Value )
for(unsigned int i = 0; i < NumSlots; i++)
{
Json::Value Slot;
- cItem* Item = GetSlot( i );
+ const cItem * Item = GetSlot( i );
if( Item ) Item->GetJson( Slot );
AllSlots.append( Slot );
}
@@ -210,6 +210,14 @@ void cChestEntity::UsedBy( cPlayer * a_Player )
ChestOpen.m_Byte1 = (char)1;
ChestOpen.m_Byte2 = (char)1;
m_World->BroadcastToChunkOfBlock(m_PosX, m_PosY, m_PosZ, &ChestOpen);
+
+ // This is rather a hack
+ // Instead of marking the chunk as dirty upon chest contents change, we mark it dirty now
+ // We cannot properly detect contents change, but such a change doesn't happen without a player opening the chest first.
+ // The few false positives aren't much to worry about
+ int ChunkX, ChunkY = 0, ChunkZ;
+ cChunkDef::BlockToChunk(m_PosX, m_PosY, m_PosZ, ChunkX, ChunkZ);
+ m_World->MarkChunkDirty(ChunkX, ChunkY, ChunkZ);
}