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