5 #include "../FastRandom.h"
49 auto Meta = a_Chunk.
GetMeta(a_RelPos);
57 if (((Meta & 0x08) != 0) && random.RandBool(0.45) &&
CanGrowAt(a_Chunk, a_RelPos.
x, a_RelPos.
y, a_RelPos.
z, Meta))
63 else if (((Meta & 0x08) == 0) && random.RandBool(0.45))
65 a_Chunk.
SetMeta(a_RelPos, 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)
227 bool LargeTree =
true;
229 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
232 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
235 LargeTree = LargeTree && (type ==
E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
@ E_META_SAPLING_DARK_OAK
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
const BLOCKTYPE m_BlockType
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
virtual int Grow(cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1) const override
Grows this block, if it supports growing, by the specified amount of stages (at most).
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
virtual bool CanBeAt(const cChunk &a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
Checks if the block can stay at the specified relative coords in the chunk.
static bool IsLargeTree(cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_PluginInterface, cChunk &a_Chunk, const Vector3i a_RelPos) const override
Called when the block gets ticked either by a random tick or by a queued tick.
static bool CanGrowAt(cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition) const
Converts the coord relative to this chunk into an absolute coord.
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.
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 ...
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
cWorld * GetWorld(void) const
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...
This class bridges a vector of cItem for safe access via Lua.
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
bool GrowTreeFromSapling(Vector3i a_BlockPos)
Grows a tree from the sapling at the specified coords.
bool GrowTree(Vector3i a_BlockPos)
Grows a tree at the specified coords.