|
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Go to the documentation of this file.
4 #include "../Defines.h"
6 #include "../BoundingBox.h"
196 static char FortuneDiscreteRandom(
char a_MinDrop,
char a_DefaultMax,
unsigned char a_BonusMax,
char a_DropCap = 25);
virtual void OnDigging(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos) const
Called when the player starts digging the block.
static bool ToolHasSilkTouch(const cItem *a_Tool)
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment.
const BLOCKTYPE m_BlockType
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cItem *a_Tool=nullptr) const
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
Represents two sets of coords, minimum and maximum for each direction.
virtual bool IsUseable(void) const
Called to check whether this block supports a rclk action.
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const
Mirrors a given block meta around the XY plane.
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const
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, Vector3i a_Position, NIBBLETYPE a_Meta) const
Checks if the block can stay at the specified relative coords in the chunk.
virtual void OnCancelRightClick(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const
Called when a right click to this block is cancelled.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
virtual bool OnUse(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos) const
Called when the user right clicks the block and the block is useable.
static const cBlockHandler & For(BLOCKTYPE a_BlockType)
static char FortuneDiscreteRandom(char a_MinDrop, char a_DefaultMax, unsigned char a_BonusMax, char a_DropCap=25)
Returns a random number of drops taking into account fortune.
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_BlockPluginInterface, cChunk &a_Chunk, const Vector3i a_RelPos) const
Called when the block gets ticked either by a random tick or by a queued tick.
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const
Mirros a given block meta around the YZ plane.
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const
Rotates a given block meta counter-clockwise.
static void NeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor)
Notifies the specified neighbor that the current block has changed.
virtual bool DoesIgnoreBuildCollision(const cWorld &a_World, const cItem &a_HeldItem, Vector3i a_Position, NIBBLETYPE a_Meta, eBlockFace a_ClickedBlockFace, bool a_ClickedDirectly) const
Checks if the player can build "inside" this block.
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, const cEntity *a_Digger) const
Called after a block gets broken (replaced with air), by natural means.
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const
Called by cWorld::SetBlock() after the block has been set.
This class bridges a vector of cItem for safe access via Lua.
unsigned char BLOCKTYPE
The datatype used by blockdata.
void Check(cChunkInterface &ChunkInterface, cBlockPluginInterface &a_PluginInterface, Vector3i a_RelPos, cChunk &a_Chunk) const
Called when one of the neighbors gets set; equivalent to MC block update.
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const
Rotates a given block meta clockwise.
virtual void OnNeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
Called when a direct neighbor of this block has been changed.
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) const
Mirros a given block meta around the XZ plane.
virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const
Checks whether the block has an effect on growing the plant.
virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const
Returns the relative bounding box that must be entity-free in order for the block to be placed.
virtual int Grow(cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1) const
Grows this block, if it supports growing, by the specified amount of stages (at most).
static unsigned char ToolFortuneLevel(const cItem *a_Tool)
Returns the fortune level of a tool, if it is a valid tool.
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
virtual bool IsInsideBlock(const Vector3d a_RelPosition, const NIBBLETYPE a_BlockMeta) const
Tests if a_RelPosition is inside the block, where a_RelPosition is relative to the origin of the bloc...