5 #include "../FastRandom.h" 12 template <NIBBLETYPE RipeMeta>
34 if (a_BlockMeta < RipeMeta)
43 ASSERT(!
"Unhandled block type");
53 char SeedCount = 1 + ((rand.RandInt<
char>(2) + rand.RandInt<
char>(2)) / 2);
55 char BeetrootCount = 1 + ((rand.RandInt<
char>(2) + rand.RandInt<
char>(2)) / 2);
62 res.
Add(
E_ITEM_SEEDS, 1 + ((rand.RandInt<
char>(2) + rand.RandInt<
char>(2)) / 2), 0);
67 res.
Add(
E_ITEM_CARROT, 1 + ((rand.RandInt<
char>(2) + rand.RandInt<
char>(2)) / 2), 0);
72 res.
Add(
E_ITEM_POTATO, 1 + ((rand.RandInt<
char>(2) + rand.RandInt<
char>(2)) / 2), 0);
73 if (rand.RandBool(0.05))
82 ASSERT(!
"Unhandled block type");
95 auto oldMeta = a_Chunk.
GetMeta(a_RelPos);
96 if (oldMeta >= RipeMeta)
101 auto newMeta = std::min<int>(oldMeta + a_NumStages, RipeMeta);
102 ASSERT(newMeta > oldMeta);
104 return newMeta - oldMeta;
cWorld * GetWorld(void) const
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.
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.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
cBlockCropsHandler(BLOCKTYPE a_BlockType)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
void Add(const cItem &a_Item)
Common class that takes care of beetroots, carrots, potatoes and wheat.
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 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.
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
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).
Base class for plants that use light values to decide whether to grow or not.
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
This class bridges a vector of cItem for safe access via Lua.