summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.h
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2014-10-11 19:32:21 +0200
committerAlexander Harkness <bearbin@gmail.com>2014-10-11 19:32:21 +0200
commit93833069a80fe4aec33a95148df39ad40671ddaf (patch)
tree2e6a335a60e618b5fe456ca8a586a2c5448c8c87 /src/Entities/Minecart.h
parentReverted submodule changes. (diff)
parentMerge pull request #1528 from kjanku1/master (diff)
downloadcuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.gz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.bz2
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.lz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.xz
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.tar.zst
cuberite-93833069a80fe4aec33a95148df39ad40671ddaf.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Minecart.h41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index 410d3c77d..6b6ad36b5 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -10,6 +10,8 @@
#pragma once
#include "Entity.h"
+#include "World.h"
+#include "../UI/WindowOwner.h"
@@ -108,27 +110,46 @@ protected:
class cMinecartWithChest :
- public cMinecart
+ public cMinecart,
+ public cItemGrid::cListener,
+ public cEntityWindowOwner
{
typedef cMinecart super;
public:
CLASS_PROTODEF(cMinecartWithChest)
- /// Number of item slots in the chest
- static const int NumSlots = 9 * 3;
-
cMinecartWithChest(double a_X, double a_Y, double a_Z);
+
+ enum
+ {
+ ContentsHeight = 3,
+ ContentsWidth = 9,
+ };
- const cItem & GetSlot(int a_Idx) const { return m_Items[a_Idx]; }
- cItem & GetSlot(int a_Idx) { return m_Items[a_Idx]; }
-
- void SetSlot(size_t a_Idx, const cItem & a_Item);
+ const cItem & GetSlot(int a_Idx) const { return m_Contents.GetSlot(a_Idx); }
+ void SetSlot(size_t a_Idx, const cItem & a_Item) { m_Contents.SetSlot(a_Idx, a_Item); }
protected:
+ cItemGrid m_Contents;
+ void OpenNewWindow(void);
+ virtual void Destroyed() override;
- /// The chest contents:
- cItem m_Items[NumSlots];
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum)
+ {
+ UNUSED(a_SlotNum);
+ ASSERT(a_Grid == &m_Contents);
+ if (m_World != NULL)
+ {
+ if (GetWindow() != NULL)
+ {
+ GetWindow()->BroadcastWholeWindow();
+ }
+
+ m_World->MarkChunkDirty(GetChunkX(), GetChunkZ());
+ }
+ }
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;