Class 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.

  • Constructor Details

    • Pre

      @Internal public Pre(Player player, int oldSlotIndex, int newSlotIndex)
  • 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:
      setCanceled in interface net.neoforged.bus.api.ICancellableEvent