Class 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
- Direct Known Subclasses:
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis event is fired on both sides when the player right clicks an entity.static classThis event is fired on both sides whenever a player right clicks an entity.static classThis event is fired when a player left clicks while targeting a block.static classThis event is fired on the client side when the player left clicks empty space with any ItemStack.static classThis event is fired on both sides whenever the player right clicks while targeting a block.static classThis event is fired on the client side when the player right clicks empty space with an empty hand.static classThis event is fired on both sides before the player triggersItem.use(Level, Player, InteractionHand).Nested classes/interfaces inherited from class 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.TabListNameFormatNested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingUpdateEvent, LivingEvent.LivingVisibilityEventNested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.CanUpdate, EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.SizeNested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate InteractionResultprivate final Directionprivate final InteractionHandprivate final BlockPos -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, Direction face) -
Method Summary
Modifier and TypeMethodDescriptiongetFace()getHand()getPos()If the interaction was on an entity, will be a BlockPos centered on the entity.getSide()getWorld()voidSet the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.Methods inherited from class net.minecraftforge.event.entity.player.PlayerEvent
getPlayerMethods inherited from class net.minecraftforge.event.entity.living.LivingEvent
getEntityLivingMethods inherited from class net.minecraftforge.event.entity.EntityEvent
getEntityMethods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getParentListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult, setup
-
Field Details
-
hand
-
pos
-
face
-
cancellationResult
-
-
Constructor Details
-
PlayerInteractEvent
private PlayerInteractEvent(Player player, InteractionHand hand, BlockPos pos, @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.EMPTYif 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.
-
getWorld
- Returns:
- Convenience method to get the world of this interaction.
-
getSide
- Returns:
- The effective, i.e. logical, side of this interaction. This will be
LogicalSide.CLIENTon the client thread, andLogicalSide.SERVERon the server thread.
-
getCancellationResult
- Returns:
- 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.
-