11 template <
bool NeedsLightToGrow>
31 Vector3i relPos(a_RelX, a_RelY, a_RelZ);
32 auto action =
CanGrow(a_Chunk, relPos);
37 Grow(a_Chunk, relPos);
76 if (!NeedsLightToGrow)
85 if (Blocklight > Light)
95 else if ((Blocklight < 9) && (SkyLight < 9))
136 for (
int x = -1; x < 2; ++x)
138 for (
int z = -1; z < 2; ++z)
140 float Adjustment = 0.0f;
163 if ((x != 0) || (z != 0))
168 Chance += Adjustment;
171 return FloorC(24.0f / Chance) + 1;
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.
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, 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.
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.
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.
cBlockHandler(BLOCKTYPE a_BlockType)
cBlockPlant(BLOCKTYPE a_BlockType)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
virtual int GetGrowthChance(cChunk &a_Chunk, Vector3i a_RelPos)
Generates an int value between 4 and 25 based on surrounding blocks that affect how quickly the plant...
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
virtual int Grow(cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1)
Grows this block, if it supports growing, by the specified amount of stages (at most).
virtual PlantAction CanGrow(cChunk &a_Chunk, Vector3i a_RelPos)
Checks whether a plant can grow grow, based on what is returned from cBlockPlant::HasEnoughLight and ...
PlantAction HasEnoughLight(cChunk &a_Chunk, Vector3i a_RelPos)
Checks whether there is enough light for the plant to grow.
cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
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 ...
Base class for plants that use light values to decide whether to grow or not.
bool DigBlock(cWorldInterface &a_WorldInterface, Vector3i a_BlockPos)
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
virtual bool CanSustainPlant(BLOCKTYPE a_Plant)
Checks whether the block has an effect on growing the plant.
PlantAction
The action the plant can take on an update.