Skip to content

BreakBlockEvent

Package: com.hypixel.hytale.server.core.event.events.ecs Extends: CancellableEcsEvent Implements: ICancellableEcsEvent Cancellable: Yes

ECS event dispatched when a player finishes mining a block and the block is about to be destroyed. Cancelling this event prevents the block from being broken, leaving it intact at the target position.

This event is the terminal event in the block-mining lifecycle. Each mining tick fires a DamageBlockEvent first; once cumulative damage meets the threshold, BreakBlockEvent fires for the final destruction.

FieldTypeAccessorMutableNullable
itemInHandItemStackgetItemInHand()NoYes
targetBlockVector3igetTargetBlock()YesNo
blockTypeBlockTypegetBlockType()NoNo
  • itemInHand — The item the player is holding when breaking the block. May be null if the player is empty-handed.
  • targetBlock — The world-space coordinates of the block being broken. Mutable — changing this redirects which block is destroyed.
  • blockType — The type of the block being broken.
  • BlockHarvestUtils (line 581) via entityStore.invoke(ref, event) — ECS dispatch when a player finishes mining a block and the harvest succeeds.

ECS events are handled by EntityEventSystem subclasses, not by getEventRegistry().register().

public class MyBreakBlockHandler extends EntityEventSystem<EntityStore, BreakBlockEvent> {
@Override
public Query<EntityStore> getQuery() {
return MY_COMPONENT_TYPE;
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> chunk,
Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer,
BreakBlockEvent event) {
BlockType blockType = event.getBlockType();
Vector3i target = event.getTargetBlock();
// Example: prevent breaking bedrock
if (blockType == BlockType.BEDROCK) {
event.setCancelled(true);
}
}
}
// Register in plugin setup():
getEntityStoreRegistry().registerSystem(new MyBreakBlockHandler());
  • DamageBlockEvent — Fired for each mining progress tick before the block breaks. Part of the block-mining lifecycle.
  • PlaceBlockEvent — The inverse operation: fired when a player places a block.
  • UseBlockEvent — Fired when a player interacts with (uses) a block rather than mining it.