Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cBlockEntity Class Referenceabstract

#include <BlockEntity.h>

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

Public Member Functions

cBlockEntityClone (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 CopyFrom (const cBlockEntity &a_Src)
 Copies all properties of a_Src into this entity, except for its m_World and location. More...
 
virtual void Destroy ()
 
BLOCKTYPE GetBlockType () const
 
int GetChunkX () const
 
int GetChunkZ () const
 
virtual const char * GetClass () const
 Returns the name of the topmost class (the most descendant). More...
 
virtual const char * GetParentClass () const
 Returns the name of the parent class, or empty string if no parent class. More...
 
Vector3i GetPos () const
 
int GetPosX () const
 
int GetPosY () const
 
int GetPosZ () const
 
Vector3i GetRelPos () const
 
int GetRelX () const
 
int GetRelZ () const
 
cWorldGetWorld () const
 
virtual bool IsA (const char *a_ClassName) const
 Returns true if the object is the specified class, or its descendant. 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 ()
 

Static Public Member Functions

static cBlockEntityCreateByBlockType (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 const char * GetClassStatic ()
 
static bool IsBlockEntityBlockType (BLOCKTYPE a_BlockType)
 Returns true if the specified blocktype is supposed to have an associated block entity. More...
 

Protected Member Functions

 cBlockEntity (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
 

Protected Attributes

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
 

Detailed Description

Definition at line 40 of file BlockEntity.h.

Constructor & Destructor Documentation

cBlockEntity::cBlockEntity ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
cWorld a_World 
)
inlineprotected

Definition at line 43 of file BlockEntity.h.

virtual cBlockEntity::~cBlockEntity ( )
inlinevirtual

Definition at line 56 of file BlockEntity.h.

Member Function Documentation

cBlockEntity * cBlockEntity::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.

Uses CopyFrom() to copy the properties.

Definition at line 114 of file BlockEntity.cpp.

void cBlockEntity::CopyFrom ( const cBlockEntity a_Src)
virtual

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 in cMobHeadEntity, cNoteEntity, cHopperEntity, cBrewingstandEntity, cDropSpenserEntity, cFlowerPotEntity, cFurnaceEntity, cJukeboxEntity, cBlockEntityWithItems, cSignEntity, cChestEntity, cBedEntity, cCommandBlockEntity, cBeaconEntity, and cMobSpawnerEntity.

Definition at line 125 of file BlockEntity.cpp.

cBlockEntity * cBlockEntity::CreateByBlockType ( BLOCKTYPE  a_BlockType,
NIBBLETYPE  a_BlockMeta,
Vector3i  a_Pos,
cWorld a_World = nullptr 
)
static

Creates a new block entity for the specified block type at the specified absolute pos.

If a_World is valid, then the entity is created bound to that world Returns nullptr for unknown block types.

Definition at line 76 of file BlockEntity.cpp.

virtual void cBlockEntity::Destroy ( void  )
inlinevirtual

Reimplemented in cBrewingstandEntity, cFlowerPotEntity, cFurnaceEntity, and cBlockEntityWithItems.

Definition at line 58 of file BlockEntity.h.

BLOCKTYPE cBlockEntity::GetBlockType ( ) const
inline

Definition at line 111 of file BlockEntity.h.

int cBlockEntity::GetChunkX ( ) const
inline

Definition at line 115 of file BlockEntity.h.

int cBlockEntity::GetChunkZ ( ) const
inline

Definition at line 116 of file BlockEntity.h.

virtual const char* cBlockEntity::GetClass ( ) const
inlinevirtual

Returns the name of the topmost class (the most descendant).

Used for Lua bindings to push the correct object type.

Definition at line 96 of file BlockEntity.h.

static const char* cBlockEntity::GetClassStatic ( void  )
inlinestatic

Definition at line 87 of file BlockEntity.h.

virtual const char* cBlockEntity::GetParentClass ( ) const
inlinevirtual

Returns the name of the parent class, or empty string if no parent class.

Definition at line 99 of file BlockEntity.h.

Vector3i cBlockEntity::GetPos ( ) const
inline

Definition at line 104 of file BlockEntity.h.

int cBlockEntity::GetPosX ( ) const
inline

Definition at line 105 of file BlockEntity.h.

int cBlockEntity::GetPosY ( ) const
inline

Definition at line 106 of file BlockEntity.h.

int cBlockEntity::GetPosZ ( ) const
inline

Definition at line 107 of file BlockEntity.h.

Vector3i cBlockEntity::GetRelPos ( ) const
inline

Definition at line 109 of file BlockEntity.h.

int cBlockEntity::GetRelX ( ) const
inline

Definition at line 118 of file BlockEntity.h.

int cBlockEntity::GetRelZ ( ) const
inline

Definition at line 119 of file BlockEntity.h.

cWorld* cBlockEntity::GetWorld ( ) const
inline

Definition at line 113 of file BlockEntity.h.

virtual bool cBlockEntity::IsA ( const char *  a_ClassName) const
inlinevirtual

Returns true if the object is the specified class, or its descendant.

Definition at line 93 of file BlockEntity.h.

bool cBlockEntity::IsBlockEntityBlockType ( BLOCKTYPE  a_BlockType)
static

Returns true if the specified blocktype is supposed to have an associated block entity.

Definition at line 39 of file BlockEntity.cpp.

virtual void cBlockEntity::SendTo ( cClientHandle a_Client)
pure virtual
void cBlockEntity::SetPos ( Vector3i  a_NewPos)

Updates the internally stored position.

Note that this should not ever be used for world-contained block entities, it is meant only for when BEs in a cBlockArea are manipulated. Asserts that the block entity is not assigned to a world.

Definition at line 29 of file BlockEntity.cpp.

void cBlockEntity::SetWorld ( cWorld a_World)
inline

Definition at line 60 of file BlockEntity.h.

virtual bool cBlockEntity::Tick ( std::chrono::milliseconds  a_Dt,
cChunk a_Chunk 
)
inlinevirtual

Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking.

By default does nothing.

Reimplemented in cHopperEntity, cBrewingstandEntity, cDropSpenserEntity, cFurnaceEntity, cBeaconEntity, cCommandBlockEntity, and cMobSpawnerEntity.

Definition at line 132 of file BlockEntity.h.

virtual bool cBlockEntity::UsedBy ( cPlayer a_Player)
pure virtual

Called when a player uses this entity; should open the UI window.

returns true if the use was successful, return false to use the block as a "normal" block

Implemented in cMobHeadEntity, cHopperEntity, cNoteEntity, cBrewingstandEntity, cDropSpenserEntity, cFurnaceEntity, cFlowerPotEntity, cJukeboxEntity, cSignEntity, cChestEntity, cBedEntity, cCommandBlockEntity, cBeaconEntity, cMobSpawnerEntity, and cEnderChestEntity.

Member Data Documentation

NIBBLETYPE cBlockEntity::m_BlockMeta
protected

The block meta representing this particular instance in the world Mainly used for directional entities, such as dispensers.

Definition at line 153 of file BlockEntity.h.

BLOCKTYPE cBlockEntity::m_BlockType
protected

The blocktype representing this particular instance in the world.

Mainly used for multi-block-type entities, such as furnaces / lit furnaces.

Definition at line 149 of file BlockEntity.h.

Vector3i cBlockEntity::m_Pos
protected

Position in absolute block coordinates.

Definition at line 142 of file BlockEntity.h.

int cBlockEntity::m_RelX
protected

Position relative to the chunk, used to speed up ticking.

Definition at line 145 of file BlockEntity.h.

int cBlockEntity::m_RelZ
protected

Definition at line 145 of file BlockEntity.h.

cWorld* cBlockEntity::m_World
protected

Definition at line 155 of file BlockEntity.h.


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