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 in blockPosition.
    short getBlockId()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • canPlace

      public abstract boolean canPlace​(Instance instance, BlockPosition blockPosition)
      Gets if the block can be placed in blockPosition. Can for example, be used for blocks which have to be placed on a solid block.
      Parameters:
      instance - the instance of the block
      blockPosition - 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 block
      blockPosition - the block position
      currentStateID - the current block state id of the block
      Returns:
      the updated block state id
    • blockPlace

      public abstract short blockPlace​(Instance instance, Block block, BlockFace blockFace, Player pl)
      Called when the block is placed.
      Parameters:
      instance - the instance of the block
      block - the block placed
      blockFace - the block face
      pl - the player who placed the block
      Returns:
      the block state id of the placed block
    • getBlockId

      public short getBlockId()