![]() |
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <BlockDoor.h>
Public Member Functions | |
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. More... | |
cBlockDoorHandler (BLOCKTYPE a_BlockType) | |
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. More... | |
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://minecraft.gamepedia.com/Map_item_format. More... | |
virtual bool | GetPlacementBlockTypeMeta (cChunkInterface &a_ChunkInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) override |
Called before a block is placed into a world. More... | |
virtual cBoundingBox | GetPlacementCollisionBox (BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) override |
Returns the relative bounding box that must be entity-free in order for the block to be placed. More... | |
virtual bool | IsUseable (void) override |
Checks if the block can be placed at this point. More... | |
virtual NIBBLETYPE | MetaMirrorXY (NIBBLETYPE a_Meta) override |
Mirrors a given block meta around the XY plane. More... | |
virtual NIBBLETYPE | MetaMirrorYZ (NIBBLETYPE a_Meta) override |
Mirros a given block meta around the YZ plane. More... | |
virtual NIBBLETYPE | MetaRotateCCW (NIBBLETYPE a_Meta) override |
Rotates a given block meta counter-clockwise. More... | |
virtual NIBBLETYPE | MetaRotateCW (NIBBLETYPE a_Meta) override |
Rotates a given block meta clockwise. More... | |
virtual void | OnBroken (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) override |
Called after a block gets broken (replaced with air), either by player or by natural means. More... | |
virtual void | OnCancelRightClick (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override |
Called when a right click to this block is cancelled. More... | |
virtual bool | OnUse (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override |
Called if the user right clicks the block and the block is useable returns true if the use was successful, return false to use the block as a "normal" block. More... | |
![]() | |
cMetaRotator (BLOCKTYPE a_BlockType) | |
![]() | |
virtual bool | CanSustainPlant (BLOCKTYPE a_Plant) |
Checks whether the block has an effect on growing the plant. More... | |
cBlockHandler (BLOCKTYPE a_BlockType) | |
virtual void | Check (cChunkInterface &ChunkInterface, cBlockPluginInterface &a_PluginInterface, Vector3i a_RelPos, cChunk &a_Chunk) |
Called when one of the neighbors gets set; equivalent to MC block update. More... | |
virtual bool | DoesDropOnUnsuitable (void) |
Returns if this block drops if it gets destroyed by an unsuitable situation. More... | |
virtual bool | DoesIgnoreBuildCollision (cChunkInterface &ChunkInterface, Vector3i a_Pos, cPlayer &a_Player, NIBBLETYPE a_Meta) |
Checks if the player can build "inside" this block. More... | |
virtual int | Grow (cChunk &a_Chunk, Vector3i a_RelPos, int a_NumStages=1) |
Grows this block, if it supports growing, by the specified amount of stages (at most). More... | |
virtual bool | IsClickedThrough (void) |
Indicates whether the client will click through this block. More... | |
virtual bool | IsInsideBlock (Vector3d a_Position, const BLOCKTYPE a_BlockType, const NIBBLETYPE a_BlockMeta) |
Tests if a_Position is inside the block where a_Position is relative to the origin of the block Note that this is considered from a "top-down" perspective i.e. More... | |
virtual NIBBLETYPE | MetaMirrorXZ (NIBBLETYPE a_Meta) |
Mirros a given block meta around the XZ plane. More... | |
virtual void | OnBreaking (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos) |
Called before a block gets broken (replaced with air), either by player or by natural means. More... | |
virtual void | OnDigging (cChunkInterface &cChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) |
Called when the player starts digging the block. More... | |
virtual void | OnNeighborChanged (cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) |
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) |
Called by cWorld::SetBlock() after the block has been set. More... | |
virtual void | OnPlacedByPlayer (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const sSetBlock &a_BlockChange) |
Called by cPlayer::PlaceBlocks() for each block after it has been set to the world. More... | |
virtual void | OnPlayerBreakingBlock (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, Vector3i a_BlockPos) |
Called just before the player breaks the block. More... | |
virtual void | OnPlayerBrokeBlock (cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) |
Called just after the player breaks the block. More... | |
virtual void | OnUpdate (cChunkInterface &cChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_BlockPluginInterface, cChunk &a_Chunk, int a_RelX, int a_RelY, int a_RelZ) |
Called when the block gets ticked either by a random tick or by a queued tick. More... | |
virtual | ~cBlockHandler () |
Static Public Member Functions | |
static bool | CanBeOn (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) |
Returns true if door can be placed on the specified block type. More... | |
static bool | CanReplaceBlock (BLOCKTYPE a_BlockType) |
static void | ChangeDoor (cChunkInterface &a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) |
Changes the door at the specified coords from open to close or vice versa. More... | |
static NIBBLETYPE | GetCompleteDoorMeta (cChunkInterface &a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) |
Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta The coords may point to either part of the door. More... | |
static Vector3i | GetRelativeDirectionToOutside (NIBBLETYPE a_BlockMeta) |
Returns a vector pointing one block in the direction the door is facing (where the outside is). More... | |
static bool | IsDoorBlockType (BLOCKTYPE a_Block) |
Returns true if the specified blocktype is any kind of door. More... | |
static NIBBLETYPE | IsOpen (cChunkInterface &a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) |
Returns true iff the door at the specified coords is open. More... | |
static NIBBLETYPE | PlayerYawToMetaData (double a_Yaw) |
Converts the player's yaw to placed door's blockmeta. More... | |
static void | SetOpen (cChunkInterface &a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) |
Sets the door to the specified state. 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 bool | ToolHasSilkTouch (const cItem *a_Tool) |
Returns true if the specified tool is valid and has a non-zero silk-touch enchantment. More... | |
Private Types | |
using | super = cMetaRotator< cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true > |
Additional Inherited Members | |
![]() | |
static cBlockHandler * | CreateBlockHandler (BLOCKTYPE a_BlockType) |
![]() | |
BLOCKTYPE | m_BlockType |
Definition at line 13 of file BlockDoor.h.
|
private |
Definition at line 16 of file BlockDoor.h.
cBlockDoorHandler::cBlockDoorHandler | ( | BLOCKTYPE | a_BlockType | ) |
Definition at line 10 of file BlockDoor.cpp.
|
inlineoverridevirtual |
Checks if the block can stay at the specified relative coords in the chunk.
Reimplemented from cBlockHandler.
Definition at line 97 of file BlockDoor.h.
|
inlinestatic |
Returns true if door can be placed on the specified block type.
Definition at line 103 of file BlockDoor.h.
|
inlinestatic |
Definition at line 125 of file BlockDoor.h.
|
inlinestatic |
Changes the door at the specified coords from open to close or vice versa.
Definition at line 308 of file BlockDoor.h.
|
inlineoverridevirtual |
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
Doesn't do any actual block change / mining, only calculates the pickups. a_BlockEntity is the block entity present at the block, if any, nullptr if none. a_Digger is the entity that caused the conversion, usually the player digging. a_Tool is the tool used for the digging. The default implementation drops a single item created from m_BlockType and the current meta.
Reimplemented from cBlockHandler.
Definition at line 63 of file BlockDoor.h.
|
inlinestatic |
Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta The coords may point to either part of the door.
The returned value has bit 3 (0x08) set iff the coords point to the top part of the door. Fails gracefully for (invalid) doors on the world's top and bottom.
Definition at line 238 of file BlockDoor.h.
|
inlineoverridevirtual |
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https://minecraft.gamepedia.com/Map_item_format.
Reimplemented from cBlockHandler.
Definition at line 317 of file BlockDoor.h.
|
inlineoverridevirtual |
Called before a block is placed into a world.
The handler should return true to allow placement, false to refuse. Also, the handler should set a_BlockType and a_BlockMeta to correct values for the newly placed block. Called by cItemHandler::GetPlacementBlockTypeMeta() if the item is a block
Reimplemented from cBlockHandler.
Definition at line 31 of file BlockDoor.h.
|
overridevirtual |
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 106 of file BlockDoor.cpp.
|
inlinestatic |
Returns a vector pointing one block in the direction the door is facing (where the outside is).
Definition at line 181 of file BlockDoor.h.
|
inlinestatic |
Returns true if the specified blocktype is any kind of door.
Definition at line 197 of file BlockDoor.h.
|
inlinestatic |
Returns true iff the door at the specified coords is open.
The coords may point to either the top part or the bottom part of the door.
Definition at line 224 of file BlockDoor.h.
|
inlineoverridevirtual |
Checks if the block can be placed at this point.
Default: CanBeAt(...) NOTE: This call doesn't actually place the block Called to check whether this block supports a rclk action. If it returns true, OnUse() is called
Reimplemented from cBlockHandler.
Definition at line 92 of file BlockDoor.h.
|
overridevirtual |
Mirrors a given block meta around the XY plane.
Default: no change Returns block meta following rotation
Reimplemented from cMetaRotator< cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true >.
Definition at line 152 of file BlockDoor.cpp.
|
overridevirtual |
Mirros a given block meta around the YZ plane.
Default: no change Returns block meta following rotation
Reimplemented from cMetaRotator< cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true >.
Definition at line 186 of file BlockDoor.cpp.
|
overridevirtual |
Rotates a given block meta counter-clockwise.
Default: no change Returns block meta following rotation
Reimplemented from cMetaRotator< cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true >.
Definition at line 116 of file BlockDoor.cpp.
|
overridevirtual |
Rotates a given block meta clockwise.
Default: no change Returns block meta following rotation
Reimplemented from cMetaRotator< cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true >.
Definition at line 134 of file BlockDoor.cpp.
|
overridevirtual |
Called after a block gets broken (replaced with air), either by player or by natural means.
If by player, it is called before the OnPlayerBrokeBlock() callback. 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.
Reimplemented from cBlockHandler.
Definition at line 19 of file BlockDoor.cpp.
|
overridevirtual |
Called when a right click to this block is cancelled.
It forces the server to send the real state of a block to the client to prevent client assuming the operation is successfull
Reimplemented from cBlockHandler.
Definition at line 83 of file BlockDoor.cpp.
|
overridevirtual |
Called if the user right clicks the block and the block is useable returns true if the use was successful, return false to use the block as a "normal" block.
Reimplemented from cBlockHandler.
Definition at line 43 of file BlockDoor.cpp.
|
inlinestatic |
Converts the player's yaw to placed door's blockmeta.
Definition at line 149 of file BlockDoor.h.
|
inlinestatic |
Sets the door to the specified state.
If the door is already in that state, does nothing.
Definition at line 271 of file BlockDoor.h.