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

70 lines
1.9 KiB
C
Raw Permalink 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"
#include "../World.h"
// tolua_begin
class cBlockEntityWithItems :
2014-09-27 18:19:28 +00:00
public cBlockEntity,
// tolua_end
2014-09-27 18:19:28 +00:00
public cItemGrid::cListener,
// tolua_begin
2014-09-27 18:19:28 +00:00
public cBlockEntityWindowOwner
{
// tolua_end
2016-02-05 21:45:45 +00:00
2020-04-13 16:38:06 +00:00
using Super = cBlockEntity;
public: // tolua_export
cBlockEntityWithItems(
BLOCKTYPE a_BlockType, // Type of the block that the entity represents
2017-06-15 13:32:33 +00:00
NIBBLETYPE a_BlockMeta, // Meta of the block that the entity represents
Vector3i a_Pos, // Abs 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 13:32:33 +00:00
);
// cBlockEntity overrides:
virtual cItems ConvertToPickups() const override;
2017-06-15 13:32:33 +00:00
virtual void CopyFrom(const cBlockEntity & a_Src) override;
2016-02-05 21:45:45 +00:00
// tolua_begin
2016-02-05 21:45:45 +00: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 21:45:45 +00: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 14:49:10 +00:00
/** Returns the ItemGrid used for storing the contents */
cItemGrid & GetContents(void) { return m_Contents; }
// tolua_end
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** Const version of the GetContents() function for C++ type-safety */
const cItemGrid & GetContents(void) const { return m_Contents; }
protected:
2020-10-20 11:28:45 +00:00
cItemGrid m_Contents;
2016-02-05 21:45:45 +00:00
// cItemGrid::cListener overrides:
2017-06-15 13:32:33 +00:00
virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override;
} ; // tolua_export