13 template <BLOCKTYPE ProduceBlockType, ENUM_ITEM_ID StemPickupType>
32 return cItem(StemPickupType, 1, 0);
60 auto oldMeta = a_Chunk.
GetMeta(a_RelPos);
61 auto meta = oldMeta + a_NumStages;
74 return meta - oldMeta;
89 static const Vector3i neighborOfs[] =
100 isValid = isValid && a_Chunk.
UnboundedRelGetBlock(a_StemRelPos + neighborOfs[1], blockType[1], blockMeta);
101 isValid = isValid && a_Chunk.
UnboundedRelGetBlock(a_StemRelPos + neighborOfs[2], blockType[2], blockMeta);
102 isValid = isValid && a_Chunk.
UnboundedRelGetBlock(a_StemRelPos + neighborOfs[3], blockType[3], blockMeta);
105 (blockType[0] == ProduceBlockType) ||
106 (blockType[1] == ProduceBlockType) ||
107 (blockType[2] == ProduceBlockType) ||
108 (blockType[3] == ProduceBlockType)
117 int checkType = random.RandInt(3);
120 case 0: x = 1;
break;
121 case 1: x = -1;
break;
122 case 2: z = 1;
break;
123 case 3: z = -1;
break;
127 switch (blockType[checkType])
136 default:
return false;
141 auto produceRelPos = a_StemRelPos +
Vector3i(x, 0, z);
152 FLOGD(
"Growing melon / pumpkin at {0} (<{1}, {2}> from stem), overwriting {3}, growing on top of {4}, meta {5}",
cWorld * GetWorld(void) const
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.
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.
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
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)
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).
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
cBlockStemsHandler(BLOCKTYPE a_BlockType)
Handler for stems from which produce grows in an adjacent block (melon, pumpkin) after it becomes rip...
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...
bool growProduce(cChunk &a_Chunk, Vector3i a_StemRelPos)
Grows the final produce next to the stem at the specified pos.
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 ...
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
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.
AString ItemTypeToString(short a_ItemType)
Translates itemtype into a string.
This class bridges a vector of cItem for safe access via Lua.