13 template <BLOCKTYPE ProduceBlockType, ENUM_ITEM_TYPE StemPickupType>
36 return cItem(StemPickupType);
40 double Cumulative = 0;
43 for (; Count < 4; Count++)
46 if (Cumulative > Threshold)
52 return cItem(StemPickupType, Count);
80 const auto OldMeta = a_Chunk.
GetMeta(a_RelPos);
81 const auto NewMeta = std::clamp<NIBBLETYPE>(
static_cast<NIBBLETYPE>(OldMeta + a_NumStages), 0, 7);
82 a_Chunk.
SetMeta(a_RelPos, NewMeta);
83 return NewMeta - OldMeta;
95 static constexpr std::array<Vector3i, 4> NeighborOfs =
123 const auto CheckType = Random.RandInt<
size_t>(3);
126 case 0: x = 1;
break;
127 case 1: x = -1;
break;
128 case 2: z = 1;
break;
129 case 3: z = -1;
break;
147 const auto ProduceRelPos = a_StemRelPos +
Vector3i(x, 0, z);
158 FLOGD(
"Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, meta {5}",
167 a_Chunk.
SetBlock(ProduceRelPos, ProduceBlockType, Meta);
182 81.3, 17.42, 1.24, 0.03
185 65.1, 30.04, 4.62, 0.24
191 39.44, 43.02, 15.64, 1.9
194 29.13, 44.44, 22.22, 3.7
197 21.6, 43.2, 28.8, 6.4
200 15.17, 39.82, 34.84, 10.16
203 10.16, 34.84, 39.82, 15.17
AString ItemTypeToString(short a_ItemType)
Translates itemtype into a string.
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.
Base class for plants that use light values to decide whether to grow or not.
Handler for stems from which produce grows in an adjacent block (melon, pumpkin) after it becomes rip...
static constexpr std::array< std::array< double, 4 >, 8 > m_AgeSeedDropProbability
The array describes how many seed may be dropped at which age.
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 void BearFruit(cChunk &a_Chunk, const Vector3i a_StemRelPos) const override
Grows the final produce next to the stem at the specified position.
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 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.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
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.
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
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...
RealType RandReal(RealType a_Min, RealType a_Max)
Return a random RealType in the range [a_Min, a_Max).
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.