Block Events
dev.architectury.event.events.common.BlockEvent
Events about blocks being broken, placed, or landed on by a falling block.
Events
| Event | Listener method | Returns |
|---|---|---|
BREAK | breakBlock(Level, BlockPos, BlockState, ServerPlayer) | EventResult - interrupt to cancel the break. |
PLACE | placeBlock(Level, BlockPos, BlockState, Entity placer) | EventResult - interrupt to cancel the placement. |
FALLING_LAND | onLand(Level, BlockPos, BlockState fallState, BlockState landOn, FallingBlockEntity) | void (notification). |
For PLACE, the placer may be null (for example, when a dispenser places the block).
Examples
Protect bedrock from being broken:
BlockEvent.BREAK.register((level, pos, state, player) -> {
if (state.is(Blocks.BEDROCK)) {
return EventResult.interruptFalse(); // deny the break
}
return EventResult.pass();
});
React to a falling block landing:
BlockEvent.FALLING_LAND.register((level, pos, fallState, landOn, entity) -> {
// e.g. spawn particles where the block landed
});