5 #include "../FastRandom.h"
12 template <NIBBLETYPE RipeMeta>
27 std::binomial_distribution<> Binomial(a_BaseRolls + a_FortuneLevel, 0.57);
40 if (a_BlockMeta < RipeMeta)
50 ASSERT(!
"Unhandled block type");
86 if (rand.RandBool(0.02))
96 ASSERT(!
"Unhandled block type");
109 const auto OldMeta = a_Chunk.
GetMeta(a_RelPos);
110 const auto NewMeta = std::clamp<NIBBLETYPE>(
static_cast<NIBBLETYPE>(OldMeta + a_NumStages), 0, RipeMeta);
111 a_Chunk.
SetMeta(a_RelPos, NewMeta);
112 return NewMeta - OldMeta;
@ E_ITEM_POISONOUS_POTATO
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Common class that takes care of beetroots, carrots, potatoes and wheat.
static char CalculateSeedCount(char a_Min, char a_BaseRolls, unsigned char a_FortuneLevel)
Calculate the number of seeds to drop when the crop is broken.
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 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.
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 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.
static unsigned char ToolFortuneLevel(const cItem *a_Tool)
Returns the fortune level of a tool, if it is a valid tool.
const BLOCKTYPE m_BlockType
Base class for plants that use light values to decide whether to grow or not.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
This class bridges a vector of cItem for safe access via Lua.
void Add(const cItem &a_Item)
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.