Class PlayerInteractEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.player.PlayerEvent
net.neoforged.neoforge.event.entity.player.PlayerInteractEvent
- Direct Known Subclasses:
PlayerInteractEvent.EntityInteract
,PlayerInteractEvent.EntityInteractSpecific
,PlayerInteractEvent.LeftClickBlock
,PlayerInteractEvent.LeftClickEmpty
,PlayerInteractEvent.RightClickBlock
,PlayerInteractEvent.RightClickEmpty
,PlayerInteractEvent.RightClickItem
,UseItemOnBlockEvent
PlayerInteractEvent is fired when a player interacts in some way.
All subclasses are fired on
NeoForge.EVENT_BUS
.
See the individual documentation on each subevent for more details.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic 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)
.Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
PlayerInteractEvent
(Player player, InteractionHand hand, BlockPos pos, @Nullable Direction face) -
Method Summary
Methods inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
-
Field Details
-
hand
-
pos
-
face
-
-
Constructor Details
-
PlayerInteractEvent
protected PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @Nullable @Nullable Direction face)
-
-
Method Details
-
getHand
- Returns:
- The hand involved in this interaction. Will never be null.
-
getItemStack
- Returns:
- 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.- Returns:
- The position involved in this interaction.
-
getFace
- Returns:
- The face involved in this interaction. For all non-block interactions, this will return null.
-
getLevel
- Returns:
- Convenience method to get the level of this interaction.
-
getSide
public net.neoforged.fml.LogicalSide getSide()- Returns:
- The effective, i.e. logical, side of this interaction. This will be
LogicalSide.CLIENT
on the client thread, andLogicalSide.SERVER
on the server thread.
-