본문으로 건너뛰기
버전: Minecraft 26.2

dev.polymodloader.api.event.interaction

자동 생성

이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.

형식종류설명
AttackEntityListener함수형 인터페이스Listener for InteractionEvents.ATTACK_ENTITY.
InteractionEvents클래스A player interacting with the world: right-clicking blocks, items, and entities, and attacking entities.
UseBlockListener함수형 인터페이스Listener for InteractionEvents.USE_BLOCK.
UseEntityListener함수형 인터페이스Listener for InteractionEvents.USE_ENTITY.
UseItemListener함수형 인터페이스Listener for InteractionEvents.USE_ITEM.

AttackEntityListener​

함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface AttackEntityListener

Listener for InteractionEvents.ATTACK_ENTITY.

onAttackEntity(PlayerView, EntityView)​

EventResult onAttackEntity(PlayerView player, EntityView target)

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
playerPlayerViewthe attacker
targetEntityViewthe attacked entity

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

InteractionEvents​

클래스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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.

상수·필드타입설명
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​

함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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)

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
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

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

UseEntityListener​

함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface UseEntityListener

Listener for InteractionEvents.USE_ENTITY.

onUseEntity(PlayerView, Hand, ItemStackRef, EntityView)​

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

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
playerPlayerViewwho clicked
handHandthe hand the game is trying
stackItemStackRefthe live stack in that hand, possibly empty
targetEntityViewthe clicked entity

반환 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​

함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface UseItemListener

Listener for InteractionEvents.USE_ITEM.

onUseItem(PlayerView, Hand, ItemStackRef)​

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

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
playerPlayerViewwho used the item
handHandthe hand holding it
stackItemStackRefthe live stack in that hand, possibly empty

반환 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