81 virtual bool Tick(std::chrono::milliseconds a_Dt,
cChunk & a_Chunk);
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
#define FAST_FLOOR_DIV(x, div)
Faster than (int)floorf((float)x / (float)div)
virtual void SendTo(cClientHandle &a_Client)=0
Sends the packet defining the block entity to the client specified.
int m_RelX
Position relative to the chunk, used to speed up ticking.
BLOCKTYPE m_BlockType
The blocktype representing this particular instance in the world.
cWorld * GetWorld() const
NIBBLETYPE m_BlockMeta
The block meta representing this particular instance in the world Mainly used for directional entitie...
virtual void Destroy()
Called when this block entity's associated block is destroyed.
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.
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.
void SetWorld(cWorld *a_World)
virtual cItems ConvertToPickups() const
Returns the contents of this block entity that it would drop if broken.
virtual ~cBlockEntity()=default
void SetPos(Vector3i a_NewPos)
Updates the internally stored position.
virtual void OnRemoveFromWorld()
Called when the block entity object is removed from a world.
cBlockEntity(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos, cWorld *a_World)
Vector3i GetRelPos() const
Vector3i m_Pos
Position in absolute block coordinates.
virtual bool UsedBy(cPlayer *a_Player)=0
Called when a player uses this entity; should open the UI window.
static bool IsBlockEntityBlockType(BLOCKTYPE a_BlockType)
Returns true if the specified blocktype is supposed to have an associated block entity.
virtual void CopyFrom(const cBlockEntity &a_Src)
Copies all properties of a_Src into this entity, except for its m_World and location.
virtual void OnAddToWorld(cWorld &a_World, cChunk &a_Chunk)
Called when the block entity object is added to a world.
OwnedBlockEntity Clone(Vector3i a_Pos)
Makes an exact copy of this block entity, except for its m_World (set to nullptr),...
BLOCKTYPE GetBlockType() const
This class bridges a vector of cItem for safe access via Lua.
std::unordered_map< size_t, OwnedBlockEntity > cBlockEntities
std::unique_ptr< cBlockEntity > OwnedBlockEntity