5 #include "../FastRandom.h"
7 #include "../Bindings/PluginManager.h"
73 for (
unsigned i = 0; i < 2; i++)
76 int OfsX = Random.RandInt(-1, 1);
77 int OfsY = Random.RandInt(-3, 1);
78 int OfsZ = Random.RandInt(-1, 1);
101 const auto AbovePos = a_RelPos.
addedY(1);
109 const auto Above = a_Chunk.
GetBlock(AbovePos);
136 if ((Chunk ==
nullptr) || !Chunk->IsValid())
152 const auto AbovePos = a_RelPos.
addedY(1);
153 const auto Above = Chunk->GetBlock(AbovePos);
154 const auto Light = std::max(Chunk->GetBlockLight(AbovePos), Chunk->GetSkyLightAltered(AbovePos));
163 const auto AbsPos = Chunk->RelativeToAbsolute(a_RelPos);
bool IsBlockWater(BLOCKTYPE a_BlockType)
bool IsBlockWaterOrIce(BLOCKTYPE a_BlockType)
bool IsBlockLava(BLOCKTYPE a_BlockType)
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.
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
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...
static void TrySpreadTo(cChunk &a_Chunk, Vector3i a_RelPos)
Attempt to spread grass to a block at the given position.
static Survivability DetermineSurvivability(cChunk &a_Chunk, const Vector3i a_RelPos)
Check if conditions are favourable to a grass block at the given position.
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_PluginInterface, cChunk &a_Chunk, const Vector3i a_RelPos) const override
Called when the block gets ticked either by a random tick or by a queued tick.
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 bool ToolHasSilkTouch(const cItem *a_Tool)
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
bool IsLightValid(void) const
NIBBLETYPE GetSkyLightAltered(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15), taking daytime into a account.
cWorld * GetWorld(void) const
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
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.
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.