Class VanillaGameEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.VanillaGameEvent
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class VanillaGameEvent extends net.neoforged.bus.api.Event implements net.neoforged.bus.api.ICancellableEvent
VanillaGameEvent is fired on the server whenever one of Vanilla's GameEvents fire.

This allows for listening to Vanilla's events in a more structured and global way that is not tied to needing a block entity listener.

This event is fired on the NeoForge.EVENT_BUS.

Cancel this event to prevent Vanilla from posting the GameEvent to all nearby GameEventListeners.
  • Field Details

  • Constructor Details

  • Method Details

    • getLevel

      public Level getLevel()
      Returns:
      The level the Vanilla GameEvent occurred.
    • getCause

      @Nullable public @Nullable Entity getCause()
      Returns:
      The entity that was the source or "cause" of the GameEvent.
    • getVanillaEvent

      public Holder<GameEvent> getVanillaEvent()
      Returns:
      The Vanilla event.
    • getEventPosition

      public Vec3 getEventPosition()
      Returns:
      The position the event took place at.
    • getContext

      public GameEvent.Context getContext()
      Returns:
      the context of the vanilla event