Interface BlockHandler

All Known Implementing Classes:

public interface BlockHandler
Interface used to provide block behavior. Set with Block.withHandler(BlockHandler).

Implementations are expected to be thread safe.

  • Method Details

    • onPlace

      default void onPlace(@NotNull @NotNull BlockHandler.Placement placement)
      Called when a block has been placed.
      placement - the placement details
    • onDestroy

      default void onDestroy(@NotNull @NotNull BlockHandler.Destroy destroy)
      Called when a block has been destroyed or replaced.
      destroy - the destroy details
    • onInteract

      default boolean onInteract(@NotNull @NotNull BlockHandler.Interaction interaction)
      Handles interactions with this block. Can also block normal item use (containers should block when opening the menu, this prevents the player from placing a block when opening it for instance).
      interaction - the interaction details
      true to let the block interaction happens, false to cancel
    • onTouch

      default void onTouch(@NotNull @NotNull BlockHandler.Touch touch)
      Defines custom behaviour for entities touching this block.
      touch - the contact details
    • tick

      default void tick(@NotNull @NotNull BlockHandler.Tick tick)
    • isTickable

      default boolean isTickable()
    • getBlockEntityTags

      @NotNull default @NotNull Collection<Tag<?>> getBlockEntityTags()
      Specifies which block entity tags should be sent to the player.
      The list of tags from this block's block entity that should be sent to the player
      See Also:
    • getBlockEntityAction

      default byte getBlockEntityAction()
    • getNamespaceId

      @NotNull @NotNull NamespaceID getNamespaceId()
      Gets the id of this handler.

      Used to write the block entity in the anvil world format.

      the namespace id of this handler