2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cBlockEntity.h"
|
|
|
|
#include "cWindowOwner.h"
|
2011-12-29 08:39:15 -05:00
|
|
|
#include "packets/cPacket_BlockAction.h"
|
2011-10-03 14:41:19 -04:00
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
namespace Json
|
|
|
|
{
|
|
|
|
class Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
class cClientHandle;
|
|
|
|
class cServer;
|
|
|
|
class cItem;
|
|
|
|
class cNBTData;
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cChestEntity :
|
|
|
|
public cBlockEntity,
|
|
|
|
public cWindowOwner
|
2011-10-03 14:41:19 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-02-13 16:47:03 -05:00
|
|
|
cChestEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
2011-10-03 14:41:19 -04:00
|
|
|
virtual ~cChestEntity();
|
|
|
|
virtual void Destroy();
|
|
|
|
|
|
|
|
void HandleData( cNBTData* a_NBTData );
|
|
|
|
|
2012-05-28 12:47:57 -04:00
|
|
|
const cItem * GetSlot( int a_Slot ) const;
|
2011-10-03 14:41:19 -04:00
|
|
|
void SetSlot( int a_Slot, cItem & a_Item );
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
OBSOLETE bool LoadFromFile(cFile & a_File); // deprecated format
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
bool LoadFromJson( const Json::Value& a_Value );
|
2012-02-16 08:42:35 -05:00
|
|
|
virtual void SaveToJson(Json::Value& a_Value ) override;
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
void SendTo( cClientHandle* a_Client, cServer* a_Server );
|
|
|
|
|
2012-02-15 09:22:44 -05:00
|
|
|
virtual void UsedBy( cPlayer * a_Player ) override;
|
2011-10-03 14:41:19 -04:00
|
|
|
|
2011-12-29 08:16:23 -05:00
|
|
|
cChestEntity *GetJoinedChest() { return m_JoinedChest; }
|
|
|
|
void SetJoinedChest(cChestEntity *a_Chest) { m_JoinedChest = a_Chest; }
|
|
|
|
void RemoveJoinedChest(cChestEntity *a_Chest) { if (m_JoinedChest && m_JoinedChest == a_Chest) { m_JoinedChest = NULL; m_TopChest = false; } }
|
|
|
|
|
|
|
|
int GetChestHeight() { return ((m_JoinedChest) ? c_ChestHeight * 2 : c_ChestHeight); }
|
2012-02-15 09:22:44 -05:00
|
|
|
cItem * GetContents(bool a_OnlyThis = false);
|
2011-12-29 08:16:23 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
static const int c_ChestWidth = 9;
|
|
|
|
static const int c_ChestHeight = 3;
|
2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
private:
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
cItem * m_Content;
|
|
|
|
bool m_TopChest;
|
|
|
|
cChestEntity * m_JoinedChest;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|