From 84a7e14e86b0bb4025e3c93d6a5d09ee8240a531 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 26 May 2013 15:29:43 +0000 Subject: Block entities with storage now correctly mark the chunk as dirty when their contents change. http://forum.mc-server.org/showthread.php?tid=434&pid=8210#pid8210 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1515 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BlockEntityWithItems.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/BlockEntityWithItems.h') diff --git a/source/BlockEntityWithItems.h b/source/BlockEntityWithItems.h index e5753359d..b160b8ed4 100644 --- a/source/BlockEntityWithItems.h +++ b/source/BlockEntityWithItems.h @@ -19,6 +19,10 @@ // tolua_begin class cBlockEntityWithItems : public cBlockEntity + // tolua_end + // tolua doesn't seem to support multiple inheritance? + , public cItemGrid::cListener + // tolua_begin { typedef cBlockEntity super; @@ -34,6 +38,7 @@ public: super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World), m_Contents(a_ItemGridWidth, a_ItemGridHeight) { + m_Contents.AddListener(*this); } virtual void Destroy(void) override @@ -64,6 +69,14 @@ public: protected: cItemGrid m_Contents; + + // cItemGrid::cListener overrides: + virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) + { + ASSERT(a_Grid == &m_Contents); + ASSERT(m_World != NULL); + m_World->MarkChunkDirty(GetChunkX(), GetChunkZ()); + } } ; // tolua_export -- cgit v1.2.3