Interface BlockHandler
- All Known Implementing Classes:
BlockHandler.Dummy
public interface BlockHandler
Interface used to provide block behavior. Set with
Block.withHandler(BlockHandler).
Implementations are expected to be thread safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic final classHandler used for loaded blocks with unknown namespace in order to do not lose the information while saving, and for runtime debugging purpose.static final classstatic classRepresents an object forwarded toonPlace(Placement).static final classstatic final classstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptiondefault bytedefault Collection<Tag<?>> Specifies which block entity tags should be sent to the player.getKey()Gets the id of this handler.default booleandefault voidonDestroy(BlockHandler.Destroy destroy) Called when a block has been destroyed or replaced.default booleanonInteract(BlockHandler.Interaction interaction) Handles interactions with this block.default voidonPlace(BlockHandler.Placement placement) Called when a block has been placed.default voidonTouch(BlockHandler.Touch touch) Defines custom behaviour for entities touching this block.default voidtick(BlockHandler.Tick tick)
-
Method Details
-
onPlace
Called when a block has been placed.- Parameters:
placement- the placement details
-
onDestroy
Called when a block has been destroyed or replaced.- Parameters:
destroy- the destroy details
-
onInteract
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).- Parameters:
interaction- the interaction details- Returns:
- true to let the block interaction happens, false to cancel
-
onTouch
Defines custom behaviour for entities touching this block.- Parameters:
touch- the contact details
-
tick
-
isTickable
default boolean isTickable() -
getBlockEntityTags
Specifies which block entity tags should be sent to the player.- Returns:
- The list of tags from this block's block entity that should be sent to the player
- See Also:
-
getBlockEntityAction
default byte getBlockEntityAction() -
getKey
Key getKey()Gets the id of this handler.Used to write the block entity in the anvil world format.
- Returns:
- the key of this handler
-