Class VanillaGameEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.VanillaGameEvent

public class VanillaGameEvent extends net.minecraftforge.eventbus.api.Event
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 MinecraftForge.EVENT_BUS.

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

    • level

      private final Level level
    • cause

      @Nullable private final Entity cause
    • vanillaEvent

      private final GameEvent vanillaEvent
    • position

      private final BlockPos position
  • Constructor Details

  • Method Details

    • getLevel

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

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

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

      public BlockPos getEventPosition()
      Returns:
      The position the event took place at. This may be a block or the block position of the entity targeted.