Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.event.interaction

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
AttackEntityListenerfunctional interfaceListener for InteractionEvents.ATTACK_ENTITY.
InteractionEventsclassA player interacting with the world: right-clicking blocks, items, and entities, and attacking entities.
UseBlockListenerfunctional interfaceListener for InteractionEvents.USE_BLOCK.
UseEntityListenerfunctional interfaceListener for InteractionEvents.USE_ENTITY.
UseItemListenerfunctional interfaceListener for InteractionEvents.USE_ITEM.

AttackEntityListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface AttackEntityListener

Listener for InteractionEvents.ATTACK_ENTITY.

onAttackEntity(PlayerView, EntityView)​

EventResult onAttackEntity(PlayerView player, EntityView target)

Since 0.1.0-alpha.4 or earlier

Called on the server thread. The views are valid only during the call.

ParameterTypeDescription
playerPlayerViewthe attacker
targetEntityViewthe attacked entity

Returns EventResult — DENY to cancel the attack (no damage, knockback, or durability loss); ALLOW or PASS to let it happen

InteractionEvents​

class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public final class InteractionEvents

A player interacting with the world: right-clicking blocks, items, and entities, and attacking entities. Fired on the server thread when the server handles the player's action, for connected and mock players alike. The client's own prediction of the click is not an event yet; when a listener refuses an action the server corrects the client as it does for any refused action.

Results: these are decision events (see EventResult): listeners run in priority order until one decides. The use events take a InteractionResult: PASS lets the next listener and then the game handle the click; SUCCESS or CONSUME ends it as handled, so the game's own behaviour (opening a chest, placing a block, eating) does not happen; FAIL ends it as refused. The attack event takes an EventResult: DENY cancels the attack.

Fabric API: UseBlockCallback, UseItemCallback, UseEntityCallback, AttackEntityCallback. NeoForge: PlayerInteractEvent.RightClickBlock, RightClickItem, EntityInteract, AttackEntityEvent.

Constant or fieldTypeDescription
USE_BLOCKEventKey<UseBlockListener>A player right-clicks a block, before the held item or the block reacts. Fired once per hand the game tries: the main hand first, then the off hand when the main hand passed.
USE_ITEMEventKey<UseItemListener>A player right-clicks with an item in the air (not at a block or entity), before the item reacts.
USE_ENTITYEventKey<UseEntityListener>A player right-clicks an entity, before the entity or the held item reacts.
ATTACK_ENTITYEventKey<AttackEntityListener>A player attacks (left-clicks) an entity, before damage and knockback.

UseBlockListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface UseBlockListener

Listener for InteractionEvents.USE_BLOCK.

onUseBlock(PlayerView, Hand, ItemStackRef, BlockPos, Direction)​

InteractionResult onUseBlock(PlayerView player, Hand hand, ItemStackRef stack, BlockPos pos, Direction face)

Since 0.1.0-alpha.4 or earlier

Called on the server thread. The views are valid only during the call.

ParameterTypeDescription
playerPlayerViewwho clicked; player.world() is the world of the block
handHandthe hand the game is trying
stackItemStackRefthe live stack in that hand, possibly empty
posBlockPosthe clicked block
faceDirectionthe clicked face of the block

Returns InteractionResult — PASS to let others and the game handle it; anything else ends the click

UseEntityListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface UseEntityListener

Listener for InteractionEvents.USE_ENTITY.

onUseEntity(PlayerView, Hand, ItemStackRef, EntityView)​

InteractionResult onUseEntity(PlayerView player, Hand hand, ItemStackRef stack, EntityView target)

Since 0.1.0-alpha.4 or earlier

Called on the server thread. The views are valid only during the call.

ParameterTypeDescription
playerPlayerViewwho clicked
handHandthe hand the game is trying
stackItemStackRefthe live stack in that hand, possibly empty
targetEntityViewthe clicked entity

Returns InteractionResult — PASS to let others and the game handle it; anything else ends the click, so the entity's reaction (trading, mounting, shearing) does not happen

UseItemListener​

functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface UseItemListener

Listener for InteractionEvents.USE_ITEM.

onUseItem(PlayerView, Hand, ItemStackRef)​

InteractionResult onUseItem(PlayerView player, Hand hand, ItemStackRef stack)

Since 0.1.0-alpha.4 or earlier

Called on the server thread, also for an empty hand. The views are valid only during the call.

ParameterTypeDescription
playerPlayerViewwho used the item
handHandthe hand holding it
stackItemStackRefthe live stack in that hand, possibly empty

Returns InteractionResult — PASS to let others and the game handle it; anything else ends the use, so the item's own behaviour (eating, throwing, drawing a bow) does not start

Buy me a coffee