Skip to main content
Version: 26.2

Interaction Events

dev.architectury.event.events.common.InteractionEvent

Fires when a player clicks blocks, entities, items, or the air. These are the hooks for right-click / left-click behavior.

Events

EventListener methodReturns
LEFT_CLICK_BLOCKclick(Player, InteractionHand, BlockPos, Direction face)EventResult
RIGHT_CLICK_BLOCKclick(Player, InteractionHand, BlockPos, Direction face)EventResult
RIGHT_CLICK_ITEMclick(Player, InteractionHand)EventResult
INTERACT_ENTITYinteract(Player, Entity, InteractionHand)EventResult
FARMLAND_TRAMPLEtrample(Level, BlockPos, BlockState, double distance, Entity)EventResult
CLIENT_LEFT_CLICK_AIRclick(Player, InteractionHand)void - client only
CLIENT_RIGHT_CLICK_AIRclick(Player, InteractionHand)void - client only

Examples

Right-clicking a specific block opens your custom UI:

InteractionEvent.RIGHT_CLICK_BLOCK.register((player, hand, pos, face) -> {
BlockState state = player.level().getBlockState(pos);
if (state.is(MyBlocks.MY_MACHINE.get())) {
// ...open your menu...
return EventResult.interruptTrue(); // handled - stop here
}
return EventResult.pass();
});

Cancel interacting with a protected entity:

InteractionEvent.INTERACT_ENTITY.register((player, entity, hand) -> {
if (isProtected(entity)) {
return EventResult.interruptFalse();
}
return EventResult.pass();
});
warning

CLIENT_LEFT_CLICK_AIR and CLIENT_RIGHT_CLICK_AIR only fire on the client, and the player is always the LocalPlayer. Only register them from client-side code.