Class PlayerInteractEvent.RightClickBlock

All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
PlayerInteractEvent

public static class PlayerInteractEvent.RightClickBlock extends PlayerInteractEvent implements net.neoforged.bus.api.ICancellableEvent
This event is fired on both sides whenever the player right clicks while targeting a block.
This event controls which of IItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext),
invalid reference
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
, and Item.useOn(UseOnContext) will be called.
Canceling the event will cause none of the above three to be called.

Let result be the first non-pass return value of the above three methods, or pass, if they all pass.
Or cancellationResult if the event is cancelled.
If result equals InteractionResult.PASS, we proceed to PlayerInteractEvent.RightClickItem.

There are various results to this event, see the getters below.
Note that handling things differently on the client vs server may cause desynchronizations!