5 #include "../FastRandom.h" 56 if (((Meta & 0x08) != 0) && random.RandBool(0.45) &&
CanGrowAt(a_Chunk, a_RelX, a_RelY, a_RelZ, Meta))
63 else if (((Meta & 0x08) == 0) && random.RandBool(0.45))
65 a_Chunk.
SetMeta(a_RelX, a_RelY, a_RelZ, Meta | 0x08);
76 a_Meta = a_Meta & 0x07;
78 bool LargeTree =
false;
91 if (
IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
106 if (
IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
116 if (!
IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
127 if (!
IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
160 while (CheckHeight && CanGrow)
162 check = a_Chunk.
GetBlock(a_RelX, a_RelY + CheckHeight, a_RelZ);
190 auto blockMeta = a_Chunk.
GetMeta(a_RelPos);
191 auto typeMeta = blockMeta & 0x07;
192 auto growState = blockMeta >> 3;
200 if (a_NumStages == 1)
233 bool LargeTree =
true;
235 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
238 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
241 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
cWorld * GetWorld(void) const
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.
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15) independent of daytime.
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
Light alterations based on time.
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
unsigned char BLOCKTYPE
The datatype used by blockdata.
bool GrowTreeFromSapling(Vector3i a_BlockPos, NIBBLETYPE a_SaplingMeta)
Grows a tree at the specified coords, based on the sapling meta provided.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition)
Converts the coord relative to this chunk into an absolute coord.
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap...
cBlockHandler(BLOCKTYPE a_BlockType)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
cBlockSaplingHandler(BLOCKTYPE a_BlockType)
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...
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.
bool GrowTree(int a_BlockX, int a_BlockY, int a_BlockZ)
Grows a tree at the specified coords.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
bool IsLargeTree(cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
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.
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 ...
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
static bool IsTransparent(BLOCKTYPE a_Type)
bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
bool CanGrowAt(cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ, 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)
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients=true)
This class bridges a vector of cItem for safe access via Lua.