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.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | the attacker |
target | EntityView | the 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_BLOCK | EventKey<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_ITEM | EventKey<UseItemListener> | A player right-clicks with an item in the air (not at a block or entity), before the item reacts. |
USE_ENTITY | EventKey<UseEntityListener> | A player right-clicks an entity, before the entity or the held item reacts. |
ATTACK_ENTITY | EventKey<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.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | who clicked; player.world() is the world of the block |
hand | Hand | the hand the game is trying |
stack | ItemStackRef | the live stack in that hand, possibly empty |
pos | BlockPos | the clicked block |
face | Direction | the 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.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | who clicked |
hand | Hand | the hand the game is trying |
stack | ItemStackRef | the live stack in that hand, possibly empty |
target | EntityView | the 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.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | who used the item |
hand | Hand | the hand holding it |
stack | ItemStackRef | the 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