Skip to content

PlaceBlockEvent

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

ECS event dispatched when a player places a block in the world. Cancelling this event prevents the block from being placed.

FieldTypeAccessorMutableNullable
itemInHandItemStackgetItemInHand()NoYes
targetBlockVector3igetTargetBlock()YesNo
rotationRotationTuplegetRotation()YesNo
  • itemInHand — The item the player is holding when placing the block. May be null if the placement is triggered programmatically without an item context.
  • targetBlock — The world-space coordinates where the block will be placed. Mutable — changing this redirects the placement location.
  • rotation — The rotation applied to the placed block. Mutable — changing this alters the block’s orientation.
  • BlockPlaceUtils (line 102) via entityStore.invoke(ref, event) — ECS dispatch when a player places a block into the world.

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

public class MyPlaceBlockHandler extends EntityEventSystem<EntityStore, PlaceBlockEvent> {
@Override
public Query<EntityStore> getQuery() {
return MY_COMPONENT_TYPE;
}
@Override
public void handle(int index, ArchetypeChunk<EntityStore> chunk,
Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer,
PlaceBlockEvent event) {
Vector3i target = event.getTargetBlock();
ItemStack item = event.getItemInHand();
// Example: prevent placing blocks above Y=200
if (target.y() > 200) {
event.setCancelled(true);
}
}
}
// Register in plugin setup():
getEntityStoreRegistry().registerSystem(new MyPlaceBlockHandler());
  • BreakBlockEvent — The inverse operation: fired when a player finishes mining a block.
  • DamageBlockEvent — Fired for each mining progress tick. Part of the block-mining lifecycle.
  • UseBlockEvent — Fired when a player interacts with (uses) a block rather than placing one.