Interface BlockBehaviour


public interface BlockBehaviour
The server-side logic of a block type: how it is placed, used and removed, and how it interacts with light.
Since:
0.1.0
  • Method Details

    • type

      BlockType type()
      Returns the block type this behaviour drives.
      Returns:
      the block type this behaviour drives
      Since:
      0.1.0
    • key

      default TypedKey<BlockType> key()
      Returns the key of the block type this behaviour drives.
      Returns:
      the key of the block type this behaviour drives
      Since:
      0.1.0
    • placementState

      default @Nullable BlockData placementState(BlockPlaceContext context)
      Chooses the state a player places, for instance facing the player.
      Parameters:
      context - where and how the block is being placed
      Returns:
      the state to place, or null to refuse the placement
      Since:
      0.1.0
    • use

      default boolean use(Player player, BlockPosition position, BlockData data)
      Called when a player uses the block, a right click, unless they sneak with an item in hand. Opening a crafting table or an ender chest happens here.

      Runs on the thread of the region owning the block.

      Parameters:
      player - the player using the block
      position - where the block is, in the player's world
      data - the state of the block
      Returns:
      true when the use is handled: the held item is then neither used nor placed
      Since:
      0.1.0
    • onRemove

      default void onRemove(World world, BlockPosition position, BlockData data)
      Called when the block is about to be replaced by another block type: broken, blown up, or overwritten by a plugin. The block and its block entity are still in place, so that what it holds can be read.

      Runs on the thread of the region owning the block.

      Parameters:
      world - the world of the block
      position - where the block is
      data - the state being removed
      Since:
      0.1.0
    • lightEmission

      default int lightEmission(BlockData data)
      Returns the light level the state emits, from 0 to 15.
      Parameters:
      data - the state
      Returns:
      the light level the state emits, from 0 to 15
      Since:
      0.1.0
    • lightOpacity

      default int lightOpacity(BlockData data)
      Returns how much light the state absorbs, from 0 (transparent) to 15 (opaque).
      Parameters:
      data - the state
      Returns:
      how much light the state absorbs, from 0 (transparent) to 15 (opaque)
      Since:
      0.1.0
    • mapColor

      default @Nullable MapColor mapColor(BlockData data)
      Returns the color terrain maps draw the state with.
      Parameters:
      data - the state
      Returns:
      the color, MapColor.NONE for a block maps look through, or null (the default) to keep the vanilla color of the block
      Since:
      0.1.0
      See Also: