Class UseItemOnBlockEvent

All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class UseItemOnBlockEvent extends PlayerInteractEvent implements net.neoforged.bus.api.ICancellableEvent

Fires on both the client and server thread when a player interacts with a block.

The event fires in three phases, corresponding with the three interaction behaviors: IItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext), BlockBehaviour.useItemOn(net.minecraft.world.item.ItemStack, net.minecraft.world.level.block.state.BlockState, net.minecraft.world.level.Level, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player, net.minecraft.world.InteractionHand, net.minecraft.world.phys.BlockHitResult), and Item.useOn(net.minecraft.world.item.context.UseOnContext).

The event fires after the interaction logic decides to run the particular interaction behavior, as opposed to PlayerInteractEvent.RightClickBlock which fires once-per-right-click, before the behavior-choosing logic.

If the event is cancelled via cancelWithResult(net.minecraft.world.ItemInteractionResult), then the normal interaction behavior for that phase will not run, and the specified InteractionResult will be returned instead.