Class BlockPlacementRule
java.lang.Object
net.minestom.server.instance.block.rule.BlockPlacementRule
- Direct Known Subclasses:
AxisPlacementRule
,RedstonePlacementRule
,WallPlacementRule
public abstract class BlockPlacementRule
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description BlockPlacementRule(short blockId)
BlockPlacementRule(Block block)
-
Method Summary
Modifier and Type Method Description abstract short
blockPlace(Instance instance, Block block, BlockFace blockFace, Player pl)
Called when the block is placed.abstract short
blockRefresh(Instance instance, BlockPosition blockPosition, short currentStateID)
Called when the block state id can be updated (for instance if a neighbour block changed).abstract boolean
canPlace(Instance instance, BlockPosition blockPosition)
Gets if the block can be placed inblockPosition
.short
getBlockId()
-
Constructor Details
-
BlockPlacementRule
public BlockPlacementRule(short blockId) -
BlockPlacementRule
-
-
Method Details
-
canPlace
Gets if the block can be placed inblockPosition
. Can for example, be used for blocks which have to be placed on a solid block.- Parameters:
instance
- the instance of the blockblockPosition
- the position where the block is trying to get place- Returns:
- true if the block placement position is valid
-
blockRefresh
public abstract short blockRefresh(Instance instance, BlockPosition blockPosition, short currentStateID)Called when the block state id can be updated (for instance if a neighbour block changed).- Parameters:
instance
- the instance of the blockblockPosition
- the block positioncurrentStateID
- the current block state id of the block- Returns:
- the updated block state id
-
blockPlace
Called when the block is placed.- Parameters:
instance
- the instance of the blockblock
- the block placedblockFace
- the block facepl
- the player who placed the block- Returns:
- the block state id of the placed block
-
getBlockId
public short getBlockId()
-