5 #include "../FastRandom.h" 7 #include "../Bindings/PluginManager.h" 85 for (
int i = 0; i < 2; i++)
87 int OfsX = rand.RandInt(-1, 1);
88 int OfsY = rand.RandInt(-3, 1);
89 int OfsZ = rand.RandInt(-1, 1);
98 Vector3i pos(a_RelX + OfsX, a_RelY + OfsY, a_RelZ + OfsZ);
100 if (chunk ==
nullptr)
111 auto abovePos = pos.
addedY(1);
112 BLOCKTYPE above = chunk->GetBlock(abovePos);
113 NIBBLETYPE light = std::max(chunk->GetBlockLight(abovePos), chunk->GetTimeAlteredLight(chunk->GetSkyLight(abovePos)));
120 auto absPos = chunk->RelativeToAbsolute(pos);
121 if (!
cRoot::Get()->GetPluginManager()->CallHookBlockSpread(*chunk->GetWorld(), absPos.x, absPos.y, absPos.z,
ssGrassSpread))
142 ASSERT(!
"Unhandled blocktype in dirt handler!");
cWorld * GetWorld(void) const
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15) independent of daytime.
bool IsBlockWater(BLOCKTYPE a_BlockType)
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
Light alterations based on time.
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
virtual void OnUpdate(cChunkInterface &cChunkInterface, 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.
static bool IsValidHeight(int a_Height)
Validates a height-coordinate.
cBlockHandler(BLOCKTYPE a_BlockType)
cBlockDirtHandler(BLOCKTYPE a_BlockType)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld...
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ)
bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType)
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
static bool IsTransparent(BLOCKTYPE a_Type)
Handler used for all types of dirt and grassblock.
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, std::unique_ptr< cChunkCoordCallback > a_Callback={})
Queues a chunk for lighting; a_Callback is called after the chunk is lighted.
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.
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients=true)
This class bridges a vector of cItem for safe access via Lua.
bool IsBlockLava(BLOCKTYPE a_BlockType)
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...