Class PlayerSwitchHotbarSlotEvent.Pre
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.PlayerSwitchHotbarSlotEvent
net.neoforged.neoforge.event.entity.player.PlayerSwitchHotbarSlotEvent.Pre
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Enclosing class:
PlayerSwitchHotbarSlotEvent
public static class PlayerSwitchHotbarSlotEvent.Pre
extends PlayerSwitchHotbarSlotEvent
implements net.neoforged.bus.api.ICancellableEvent
Fired after the server receives the packet and is about to perform the slot switching logic. If you cancel this event, the logic will not be performed, and listeners will receive neither the pre event nor the post event.
Vanilla logic is shown here.
-
Nested Class Summary
Nested classes/interfaces inherited from class PlayerSwitchHotbarSlotEvent
PlayerSwitchHotbarSlotEvent.Post, PlayerSwitchHotbarSlotEvent.PreNested 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCanceled(boolean canceled) Cancels the event, preventing any further slot switching logic to be performed.Methods inherited from class PlayerSwitchHotbarSlotEvent
getNewSlotIndex, getOldSlotIndexMethods 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
-
Constructor Details
-
Pre
-
-
Method Details
-
setCanceled
public void setCanceled(boolean canceled) Cancels the event, preventing any further slot switching logic to be performed. Listeners will not receive this event after the cancellation.- Specified by:
setCanceledin interfacenet.neoforged.bus.api.ICancellableEvent
-