From cc26f1646308a71ea78f0656efa670915e5e7345 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 10 Apr 2013 19:52:03 +0000 Subject: Added cItemGrid to represent an XY grid of items; converted chests to use cItemGrid. http://forum.mc-server.org/showthread.php?tid=831 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1380 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ChestEntity.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'source/ChestEntity.h') diff --git a/source/ChestEntity.h b/source/ChestEntity.h index 03102a80b..be8172073 100644 --- a/source/ChestEntity.h +++ b/source/ChestEntity.h @@ -3,6 +3,7 @@ #include "BlockEntity.h" #include "UI/WindowOwner.h" +#include "ItemGrid.h" @@ -15,8 +16,6 @@ namespace Json class cClientHandle; class cServer; -class cItem; -class cLootProbab; class cNBTData; @@ -41,14 +40,11 @@ public: static const char * GetClassStatic() { return "cChestEntity"; } - const cItem * GetSlot(int a_Slot) const; // tolua_export - void SetSlot(int a_Slot, const cItem & a_Item ); // tolua_export + // tolua_begin + const cItem & GetSlot(int a_Slot) const { return m_Contents.GetItem(a_Slot); } + void SetSlot(int a_Slot, const cItem & a_Item ) { m_Contents.SetItem(a_Slot, a_Item); } + // tolua_end - /** Generates random loot from the specified loot probability table, with a chance of enchanted books added. - A total of a_NumSlots are taken by the loot - */ - void GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, int a_CountLootProbabs, int a_NumSlots, int a_Seed); - bool LoadFromJson( const Json::Value& a_Value ); // cBlockEntity overrides: @@ -59,14 +55,16 @@ public: /// Opens a new chest window for this chests. Scans for neighbors to open a double chest window, if appropriate. void OpenNewWindow(void); - cItem * GetContents(void) { return m_Content; } + const cItemGrid & GetContents(void) const { return m_Contents; } + + cItemGrid & GetContents(void) { return m_Contents; } // tolua_export static const int c_ChestWidth = 9; static const int c_ChestHeight = 3; private: - cItem m_Content[c_ChestWidth * c_ChestHeight]; // TODO: replace this by a generic ItemGridHolder + cItemGrid m_Contents; } ; // tolua_export -- cgit v1.2.3