Class PlayerInteractEvent.RightClickItem
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.RightClickItem
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Enclosing class:
PlayerInteractEvent
public static class PlayerInteractEvent.RightClickItem
extends PlayerInteractEvent
implements net.neoforged.bus.api.ICancellableEvent
This event is fired on both sides before the player triggers
Item.use(Level, Player, InteractionHand).
Note that this is NOT fired if the player is targeting a block PlayerInteractEvent.RightClickBlock or entity PlayerInteractEvent.EntityInteract PlayerInteractEvent.EntityInteractSpecific.
Let result be the return value of Item.use(Level, Player, InteractionHand), or cancellationResult if the event is cancelled.
If we are on the client and result is not InteractionResult.SUCCESS, the client will then continue to other hands.-
Nested Class Summary
Nested classes/interfaces inherited from class PlayerInteractEvent
PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItemNested classes/interfaces inherited from class 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.TabListNameFormatNested classes/interfaces inherited from class LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEventNested classes/interfaces inherited from class EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSet 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 PlayerInteractEvent
getFace, getHand, getItemStack, getLevel, getPos, getSideMethods inherited from class PlayerEvent
getEntityMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
cancellationResult
-
-
Constructor Details
-
RightClickItem
-
-
Method Details
-
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.
-