Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
cBlockEntityWithItems Class Reference

#include <BlockEntityWithItems.h>

Inheritance diagram for cBlockEntityWithItems:
Inheritance graph
[legend]
Collaboration diagram for cBlockEntityWithItems:
Collaboration graph
[legend]

Public Member Functions

 cBlockEntityWithItems (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, int a_ItemGridWidth, int a_ItemGridHeight, cWorld *a_World)
 
virtual cItems ConvertToPickups () const override
 Returns the contents of this block entity that it would drop if broken. More...
 
virtual void CopyFrom (const cBlockEntity &a_Src) override
 Copies all properties of a_Src into this entity, except for its m_World and location. More...
 
cItemGridGetContents (void)
 Returns the ItemGrid used for storing the contents. More...
 
const cItemGridGetContents (void) const
 Const version of the GetContents() function for C++ type-safety. More...
 
const cItemGetSlot (int a_SlotNum) const
 
const cItemGetSlot (int a_X, int a_Y) const
 
void SetSlot (int a_SlotNum, const cItem &a_Item)
 
void SetSlot (int a_X, int a_Y, const cItem &a_Item)
 
- Public Member Functions inherited from cBlockEntity
OwnedBlockEntity Clone (Vector3i a_Pos)
 Makes an exact copy of this block entity, except for its m_World (set to nullptr), and at a new position. More...
 
virtual void Destroy ()
 Called when this block entity's associated block is destroyed. More...
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual void OnAddToWorld (cWorld &a_World, cChunk &a_Chunk)
 Called when the block entity object is added to a world. More...
 
virtual void OnRemoveFromWorld ()
 Called when the block entity object is removed from a world. More...
 
virtual void SendTo (cClientHandle &a_Client)=0
 Sends the packet defining the block entity to the client specified. More...
 
void SetPos (Vector3i a_NewPos)
 Updates the internally stored position. More...
 
void SetWorld (cWorld *a_World)
 
virtual bool Tick (std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
 Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. More...
 
virtual bool UsedBy (cPlayer *a_Player)=0
 Called when a player uses this entity; should open the UI window. More...
 
virtual ~cBlockEntity ()=default
 
- Public Member Functions inherited from cItemGrid::cListener
virtual ~cListener ()
 
- Public Member Functions inherited from cBlockEntityWindowOwner
 cBlockEntityWindowOwner (cBlockEntity *a_BlockEntity)
 
virtual Vector3i GetBlockPos (void) override
 Returns the block position at which the element owning the window is. More...
 
- Public Member Functions inherited from cWindowOwner
void CloseWindow (void)
 
 cWindowOwner ()
 
cWindowGetWindow (void) const
 
void OpenWindow (cWindow *a_Window)
 
virtual ~cWindowOwner ()
 

Protected Member Functions

virtual void OnSlotChanged (cItemGrid *a_Grid, int a_SlotNum) override
 Called whenever a slot changes. More...
 
- Protected Member Functions inherited from cBlockEntity
 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 

Protected Attributes

cItemGrid m_Contents
 
- Protected Attributes inherited from cBlockEntity
NIBBLETYPE m_BlockMeta
 The block meta representing this particular instance in the world Mainly used for directional entities, such as dispensers. More...
 
BLOCKTYPE m_BlockType
 The blocktype representing this particular instance in the world. More...
 
Vector3i m_Pos
 Position in absolute block coordinates. More...
 
int m_RelX
 Position relative to the chunk, used to speed up ticking. More...
 
int m_RelZ
 
cWorldm_World
 

Private Types

using Super = cBlockEntity
 

Additional Inherited Members

- Static Public Member Functions inherited from cBlockEntity
static OwnedBlockEntity CreateByBlockType (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World=nullptr)
 Creates a new block entity for the specified block type at the specified absolute pos. More...
 
static bool IsBlockEntityBlockType (BLOCKTYPE a_BlockType)
 Returns true if the specified blocktype is supposed to have an associated block entity. More...
 

Detailed Description

Definition at line 22 of file BlockEntityWithItems.h.

Member Typedef Documentation

◆ Super

Definition at line 31 of file BlockEntityWithItems.h.

Constructor & Destructor Documentation

◆ cBlockEntityWithItems()

cBlockEntityWithItems::cBlockEntityWithItems ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
int  a_ItemGridWidth,
int  a_ItemGridHeight,
cWorld a_World 
)

Definition at line 11 of file BlockEntityWithItems.cpp.

Member Function Documentation

◆ ConvertToPickups()

cItems cBlockEntityWithItems::ConvertToPickups ( ) const
overridevirtual

Returns the contents of this block entity that it would drop if broken.

Note that the block handler will usually handle pickups for the block itself, in addition to any items returned here.

Reimplemented from cBlockEntity.

Definition at line 29 of file BlockEntityWithItems.cpp.

◆ CopyFrom()

void cBlockEntityWithItems::CopyFrom ( const cBlockEntity a_Src)
overridevirtual

Copies all properties of a_Src into this entity, except for its m_World and location.

Each non-abstract descendant should override to copy its specific properties, and call Super::CopyFrom(a_Src) to copy the common ones.

Reimplemented from cBlockEntity.

Reimplemented in cHopperEntity, cFurnaceEntity, cDropSpenserEntity, cChestEntity, cBrewingstandEntity, and cBeaconEntity.

Definition at line 40 of file BlockEntityWithItems.cpp.

◆ GetContents() [1/2]

cItemGrid& cBlockEntityWithItems::GetContents ( void  )
inline

Returns the ItemGrid used for storing the contents.

Definition at line 56 of file BlockEntityWithItems.h.

◆ GetContents() [2/2]

const cItemGrid& cBlockEntityWithItems::GetContents ( void  ) const
inline

Const version of the GetContents() function for C++ type-safety.

Definition at line 61 of file BlockEntityWithItems.h.

◆ GetSlot() [1/2]

const cItem& cBlockEntityWithItems::GetSlot ( int  a_SlotNum) const
inline

Definition at line 49 of file BlockEntityWithItems.h.

◆ GetSlot() [2/2]

const cItem& cBlockEntityWithItems::GetSlot ( int  a_X,
int  a_Y 
) const
inline

Definition at line 50 of file BlockEntityWithItems.h.

◆ OnSlotChanged()

void cBlockEntityWithItems::OnSlotChanged ( cItemGrid a_ItemGrid,
int  a_SlotNum 
)
overrideprotectedvirtual

Called whenever a slot changes.

Implements cItemGrid::cListener.

Reimplemented in cFurnaceEntity, cBrewingstandEntity, and cChestEntity.

Definition at line 51 of file BlockEntityWithItems.cpp.

◆ SetSlot() [1/2]

void cBlockEntityWithItems::SetSlot ( int  a_SlotNum,
const cItem a_Item 
)
inline

Definition at line 52 of file BlockEntityWithItems.h.

◆ SetSlot() [2/2]

void cBlockEntityWithItems::SetSlot ( int  a_X,
int  a_Y,
const cItem a_Item 
)
inline

Definition at line 53 of file BlockEntityWithItems.h.

Member Data Documentation

◆ m_Contents

cItemGrid cBlockEntityWithItems::m_Contents
protected

Definition at line 65 of file BlockEntityWithItems.h.


The documentation for this class was generated from the following files: