Class PlayerInteractEvent.EntityInteract
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.EntityInteract
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Enclosing class:
PlayerInteractEvent
public static class PlayerInteractEvent.EntityInteract
extends PlayerInteractEvent
implements net.neoforged.bus.api.ICancellableEvent
This event is fired on both sides when the player right clicks an entity.
It is responsible for all general entity interactions.
This event is fired only if the result of the above
PlayerInteractEvent.EntityInteractSpecific
is not InteractionResult.SUCCESS
.
This event's state affects whether Entity.interact(Player, InteractionHand)
and
Item.interactLivingEntity(ItemStack, Player, LivingEntity, InteractionHand)
are called.
Let result be InteractionResult.SUCCESS
if Entity.interact(Player, InteractionHand)
or
Item.interactLivingEntity(ItemStack, Player, LivingEntity, InteractionHand)
return true,
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.RightClickItem
.-
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
FieldsModifier and TypeFieldDescriptionprivate net.minecraft.world.InteractionResult
private final net.minecraft.world.entity.Entity
-
Constructor Summary
ConstructorsConstructorDescriptionEntityInteract
(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.entity.Entity target) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.InteractionResult
net.minecraft.world.entity.Entity
void
setCancellationResult
(net.minecraft.world.InteractionResult result) 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
private net.minecraft.world.InteractionResult cancellationResult -
target
private final net.minecraft.world.entity.Entity target
-
-
Constructor Details
-
EntityInteract
public EntityInteract(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.world.entity.Entity target)
-
-
Method Details
-
getTarget
public net.minecraft.world.entity.Entity getTarget() -
getCancellationResult
public net.minecraft.world.InteractionResult 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
public void setCancellationResult(net.minecraft.world.InteractionResult result) Set the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.
-