Cuberite
A lightweight, fast and extensible game server for Minecraft
Private Types | Private Member Functions | Static Private Attributes | List of all members
cBlockFenceHandler Class Referencefinal

#include <BlockFence.h>

Inheritance diagram for cBlockFenceHandler:
Inheritance graph
[legend]
Collaboration diagram for cBlockFenceHandler:
Collaboration graph
[legend]

Private Types

using Super = cBlockHandler
 

Private Member Functions

virtual cBoundingBox GetPlacementCollisionBox (BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const override
 Returns the relative bounding box that must be entity-free in order for the block to be placed. More...
 
virtual bool IsUseable (void) const override
 Called to check whether this block supports a rclk action. More...
 
virtual void OnBroken (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, const cEntity *a_Digger) const override
 Called after a block gets broken (replaced with air), by natural means. More...
 
virtual void OnCancelRightClick (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const override
 Called when a right click to this block is cancelled. More...
 
virtual bool OnUse (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos) const override
 Called when the user right clicks the block and the block is useable. More...
 

Static Private Attributes

static constexpr double MAX_COORD = 0.6
 
static constexpr double MIN_COORD = 0.4
 

Additional Inherited Members

- Public Member Functions inherited from cBlockHandler
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. More...
 
virtual bool CanSustainPlant (BLOCKTYPE a_Plant) const
 Checks whether the block has an effect on growing the plant. More...
 
constexpr cBlockHandler (BLOCKTYPE a_BlockType)
 
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. More...
 
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. More...
 
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. More...
 
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://minecraft.wiki/w/Map_item_format. More...
 
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). More...
 
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 block. More...
 
virtual NIBBLETYPE MetaMirrorXY (NIBBLETYPE a_Meta) const
 Mirrors a given block meta around the XY plane. More...
 
virtual NIBBLETYPE MetaMirrorXZ (NIBBLETYPE a_Meta) const
 Mirros a given block meta around the XZ plane. More...
 
virtual NIBBLETYPE MetaMirrorYZ (NIBBLETYPE a_Meta) const
 Mirros a given block meta around the YZ plane. More...
 
virtual NIBBLETYPE MetaRotateCCW (NIBBLETYPE a_Meta) const
 Rotates a given block meta counter-clockwise. More...
 
virtual NIBBLETYPE MetaRotateCW (NIBBLETYPE a_Meta) const
 Rotates a given block meta clockwise. More...
 
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. More...
 
virtual void OnNeighborChanged (cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
 Called when a direct neighbor of this block has been changed. More...
 
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. More...
 
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. More...
 
- Static Public Member Functions inherited from cBlockHandler
static const cBlockHandlerFor (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. More...
 
static void NeighborChanged (cChunkInterface &a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor)
 Notifies the specified neighbor that the current block has changed. More...
 
static unsigned char ToolFortuneLevel (const cItem *a_Tool)
 Returns the fortune level of a tool, if it is a valid tool. More...
 
static bool ToolHasSilkTouch (const cItem *a_Tool)
 Returns true if the specified tool is valid and has a non-zero silk-touch enchantment. More...
 
- Protected Member Functions inherited from cBlockHandler
 ~cBlockHandler ()=default
 
- Protected Attributes inherited from cBlockHandler
const BLOCKTYPE m_BlockType
 

Detailed Description

Definition at line 13 of file BlockFence.h.

Member Typedef Documentation

◆ Super

Definition at line 16 of file BlockFence.h.

Member Function Documentation

◆ GetPlacementCollisionBox()

virtual cBoundingBox cBlockFenceHandler::GetPlacementCollisionBox ( BLOCKTYPE  a_XM,
BLOCKTYPE  a_XP,
BLOCKTYPE  a_YM,
BLOCKTYPE  a_YP,
BLOCKTYPE  a_ZM,
BLOCKTYPE  a_ZP 
) const
inlineoverrideprivatevirtual

Returns the relative bounding box that must be entity-free in order for the block to be placed.

a_XM, a_XP, etc. stand for the blocktype of the minus-X neighbor, the positive-X neighbor, etc.

Reimplemented from cBlockHandler.

Definition at line 30 of file BlockFence.h.

◆ IsUseable()

virtual bool cBlockFenceHandler::IsUseable ( void  ) const
inlineoverrideprivatevirtual

Called to check whether this block supports a rclk action.

If it returns true, OnUse() is called

Reimplemented from cBlockHandler.

Definition at line 147 of file BlockFence.h.

◆ OnBroken()

virtual void cBlockFenceHandler::OnBroken ( cChunkInterface a_ChunkInterface,
cWorldInterface a_WorldInterface,
Vector3i  a_BlockPos,
BLOCKTYPE  a_OldBlockType,
NIBBLETYPE  a_OldBlockMeta,
const cEntity a_Digger 
) const
inlineoverrideprivatevirtual

Called after a block gets broken (replaced with air), by natural means.

The block is already dug up in the world, the original block type and meta is passed in a_OldBlockType and a_OldBlockMeta. By default notifies all direct neighbors via their OnNeighborChanged() callbacks. You can determine what kind of entity broke the block (e.g. player) by checking a_Digger!

Reimplemented from cBlockHandler.

Definition at line 156 of file BlockFence.h.

◆ OnCancelRightClick()

virtual void cBlockFenceHandler::OnCancelRightClick ( cChunkInterface a_ChunkInterface,
cWorldInterface a_WorldInterface,
cPlayer a_Player,
const Vector3i  a_BlockPos,
eBlockFace  a_BlockFace 
) const
inlineoverrideprivatevirtual

Called when a right click to this block is cancelled.

Descendants should force the server to send the real state of a block to the client to prevent client assuming the operation was successfull.

Reimplemented from cBlockHandler.

Definition at line 132 of file BlockFence.h.

◆ OnUse()

virtual bool cBlockFenceHandler::OnUse ( cChunkInterface a_ChunkInterface,
cWorldInterface a_WorldInterface,
cPlayer a_Player,
const Vector3i  a_BlockPos,
eBlockFace  a_BlockFace,
const Vector3i  a_CursorPos 
) const
inlineoverrideprivatevirtual

Called when the user right clicks the block and the block is useable.

a_CursorPos is the cursor position within the clicked block face. Returns true if the use was successful, return false to use the block as a "normal" block

Reimplemented from cBlockHandler.

Definition at line 85 of file BlockFence.h.

Member Data Documentation

◆ MAX_COORD

constexpr double cBlockFenceHandler::MAX_COORD = 0.6
staticconstexprprivate

Definition at line 28 of file BlockFence.h.

◆ MIN_COORD

constexpr double cBlockFenceHandler::MIN_COORD = 0.4
staticconstexprprivate

Definition at line 27 of file BlockFence.h.


The documentation for this class was generated from the following file: