4 #include "../FastRandom.h" 45 Grow(a_Chunk, {a_RelX, a_RelY, a_RelZ});
56 auto growState = a_BlockMeta >> 2;
66 auto meta = a_Chunk.
GetMeta(a_RelPos);
67 auto typeMeta = meta & 0x03;
68 auto growState = meta >> 2;
74 auto newState = std::min(growState + a_NumStages, 3);
75 a_Chunk.
SetMeta(a_RelPos, static_cast<NIBBLETYPE>(newState << 2 | typeMeta));
76 return newState - growState;
85 switch (a_Meta & 0x03)
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
virtual bool CanBeAt(cChunkInterface &a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk &a_Chunk) override
Checks if the block can stay at the specified relative coords in the chunk.
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
cBlockHandler(BLOCKTYPE a_BlockType)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
virtual int Grow(cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1) override
Grows this block, if it supports growing, by the specified amount of stages (at most).
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse=false)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, cBlockEntity *a_BlockEntity, const cEntity *a_Digger, const cItem *a_Tool) override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
bool UnboundedRelGetBlock(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in ...
static eBlockFace MetaToBlockFace(NIBBLETYPE a_Meta)
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty=true, bool a_ShouldInformClients=true)
virtual void OnUpdate(cChunkInterface &cChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_PluginInterface, cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
Called when the block gets ticked either by a random tick or by a queued tick.
#define UNREACHABLE(x)
Use to mark code that should be impossible to reach.
This class bridges a vector of cItem for safe access via Lua.
cBlockCocoaPodHandler(BLOCKTYPE a_BlockType)