1
0
cuberite-2a/src/BlockEntities/BlockEntityWithItems.h

75 lines
1.9 KiB
C
Raw Normal View History

// BlockEntityWithItems.h
// Declares the cBlockEntityWithItems class representing a common ancestor for all block entities that have an ItemGrid
#pragma once
#include "BlockEntity.h"
#include "../ItemGrid.h"
#include "../UI/WindowOwner.h"
2014-09-26 13:13:19 -04:00
#include "World.h"
// tolua_begin
class cBlockEntityWithItems :
2014-09-27 14:19:28 -04:00
public cBlockEntity,
// tolua_end
2014-09-27 14:19:28 -04:00
public cItemGrid::cListener,
// tolua_begin
2014-09-27 14:19:28 -04:00
public cBlockEntityWindowOwner
{
2017-06-15 09:32:33 -04:00
typedef cBlockEntity Super;
public:
// tolua_end
2016-02-05 16:45:45 -05:00
BLOCKENTITY_PROTODEF(cBlockEntityWithItems)
2016-02-05 16:45:45 -05:00
2017-06-15 09:32:33 -04:00
cBlockEntityWithItems(
BLOCKTYPE a_BlockType, // Type of the block that the entity represents
2017-06-15 09:32:33 -04:00
NIBBLETYPE a_BlockMeta, // Meta of the block that the entity represents
int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
int a_ItemGridWidth, int a_ItemGridHeight, // Dimensions of the ItemGrid
cWorld * a_World // Optional world to assign to the entity
2017-06-15 09:32:33 -04:00
);
// cBlockEntity overrides:
virtual void Destroy(void) override;
virtual void CopyFrom(const cBlockEntity & a_Src) override;
2016-02-05 16:45:45 -05:00
// tolua_begin
2016-02-05 16:45:45 -05:00
const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); }
const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); }
2016-02-05 16:45:45 -05:00
void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); }
void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); }
2015-07-31 10:49:10 -04:00
/** Returns the ItemGrid used for storing the contents */
cItemGrid & GetContents(void) { return m_Contents; }
// tolua_end
2016-02-05 16:45:45 -05:00
2015-07-31 10:49:10 -04:00
/** Const version of the GetContents() function for C++ type-safety */
const cItemGrid & GetContents(void) const { return m_Contents; }
protected:
cItemGrid m_Contents;
2016-02-05 16:45:45 -05:00
// cItemGrid::cListener overrides:
2017-06-15 09:32:33 -04:00
virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override;
} ; // tolua_export