Class PlayerInteractEvent.EntityInteractSpecific
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
net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.EntityInteractSpecific
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Enclosing class:
PlayerInteractEvent
public static class PlayerInteractEvent.EntityInteractSpecific
extends PlayerInteractEvent
implements net.neoforged.bus.api.ICancellableEvent
This event is fired on both sides whenever a player right clicks an entity.
"Interact at" is an interact where the local vector (which part of the entity you clicked) is known.
The state of this event affects whether
Entity.interactAt(Player, Vec3, InteractionHand)
is called.
Let result be the return value of Entity.interactAt(Player, Vec3, InteractionHand)
, or cancellationResult
if the event is cancelled.
If we are on the client and result is not InteractionResult.SUCCESS
, the client will then try PlayerInteractEvent.EntityInteract
.-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.event.entity.player.PlayerInteractEvent
PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItem
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
Modifier and TypeFieldDescriptionprivate InteractionResult
private final Vec3
private final Entity
-
Constructor Summary
ConstructorDescriptionEntityInteractSpecific
(Player player, InteractionHand hand, Entity target, Vec3 localPos) -
Method Summary
Modifier and TypeMethodDescriptionReturns the local interaction position.void
Set 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.neoforged.neoforge.event.entity.player.PlayerInteractEvent
getFace, getHand, getItemStack, getLevel, getPos, getSide
Methods inherited from class net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
cancellationResult
-
localPos
-
target
-
-
Constructor Details
-
EntityInteractSpecific
-
-
Method Details
-
getLocalPos
Returns the local interaction position. This is a 3D vector, where (0, 0, 0) is centered exactly at the center of the entity's bounding box at their feet. This means the X and Z values will be in the range [-width / 2, width / 2] while Y values will be in the range [0, height]- Returns:
- The local position
-
getTarget
-
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.
-