类 PlayerInteractEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.LivingEvent
net.minecraftforge.event.entity.player.PlayerEvent
net.minecraftforge.event.entity.player.PlayerInteractEvent
- 直接已知子类:
PlayerInteractEvent.EntityInteract
,PlayerInteractEvent.EntityInteractSpecific
,PlayerInteractEvent.LeftClickBlock
,PlayerInteractEvent.LeftClickEmpty
,PlayerInteractEvent.RightClickBlock
,PlayerInteractEvent.RightClickEmpty
,PlayerInteractEvent.RightClickItem
PlayerInteractEvent is fired when a player interacts in some way.
All subclasses are fired on
MinecraftForge.EVENT_BUS
.
See the individual documentation on each subevent for more details.-
嵌套类概要
嵌套类修饰符和类型类说明static class
This event is fired on both sides when the player right clicks an entity.static class
This event is fired on both sides whenever a player right clicks an entity.static class
This event is fired when a player left clicks while targeting a block.static class
This event is fired on the client side when the player left clicks empty space with any ItemStack.static class
This event is fired on both sides whenever the player right clicks while targeting a block.static class
This event is fired on the client side when the player right clicks empty space with an empty hand.static class
This event is fired on both sides before the player triggersItem.use(Level, Player, InteractionHand)
.从类继承的嵌套类/接口 net.minecraftforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemPickupEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
从类继承的嵌套类/接口 net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingTickEvent, LivingEvent.LivingVisibilityEvent
从类继承的嵌套类/接口 net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing
从类继承的嵌套类/接口 net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
字段概要
字段修饰符和类型字段说明private InteractionResult
private final @Nullable Direction
private final InteractionHand
private final BlockPos
-
构造器概要
构造器限定符构造器说明private
PlayerInteractEvent
(Player player, InteractionHand hand, BlockPos pos, @Nullable Direction face) -
方法概要
修饰符和类型方法说明@Nullable Direction
getFace()
@NotNull InteractionHand
getHand()
@NotNull ItemStack
getLevel()
@NotNull BlockPos
getPos()
If the interaction was on an entity, will be a BlockPos centered on the entity.getSide()
void
Set the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.从类继承的方法 net.minecraftforge.event.entity.player.PlayerEvent
getEntity
从类继承的方法 net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
字段详细资料
-
hand
-
pos
-
face
-
cancellationResult
-
-
构造器详细资料
-
PlayerInteractEvent
private PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @Nullable @Nullable Direction face)
-
-
方法详细资料
-
getHand
- 返回:
- The hand involved in this interaction. Will never be null.
-
getItemStack
- 返回:
- The itemstack involved in this interaction,
ItemStack.EMPTY
if the hand was empty.
-
getPos
If the interaction was on an entity, will be a BlockPos centered on the entity. If the interaction was on a block, will be the position of that block. Otherwise, will be a BlockPos centered on the player. Will never be null.- 返回:
- The position involved in this interaction.
-
getFace
- 返回:
- The face involved in this interaction. For all non-block interactions, this will return null.
-
getLevel
- 返回:
- Convenience method to get the level of this interaction.
-
getSide
- 返回:
- The effective, i.e. logical, side of this interaction. This will be
LogicalSide.CLIENT
on the client thread, andLogicalSide.SERVER
on the server thread.
-
getCancellationResult
- 返回:
- The InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
method of the event. By default, this is
InteractionResult.PASS
, meaning cancelled events will cause the client to keep trying more interactions until something works.
-
setCancellationResult
Set the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event. Note that this only has an effect onPlayerInteractEvent.RightClickBlock
,PlayerInteractEvent.RightClickItem
,PlayerInteractEvent.EntityInteract
, andPlayerInteractEvent.EntityInteractSpecific
.
-