Class PlayerEvent.PlayerChangeGameModeEvent

All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
PlayerEvent

public static class PlayerEvent.PlayerChangeGameModeEvent extends PlayerEvent implements net.neoforged.bus.api.ICancellableEvent
Fired when the game type of a server player is changed to a different value than what it was previously. Eg Creative to Survival, not Survival to Survival. If the event is cancelled the game mode of the player is not changed and the value of newGameMode is ignored.
  • Field Details

    • currentGameMode

      private final net.minecraft.world.level.GameType currentGameMode
    • newGameMode

      private net.minecraft.world.level.GameType newGameMode
  • Constructor Details

    • PlayerChangeGameModeEvent

      public PlayerChangeGameModeEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.GameType currentGameMode, net.minecraft.world.level.GameType newGameMode)
  • Method Details

    • getCurrentGameMode

      public net.minecraft.world.level.GameType getCurrentGameMode()
    • getNewGameMode

      public net.minecraft.world.level.GameType getNewGameMode()
    • setNewGameMode

      public void setNewGameMode(net.minecraft.world.level.GameType newGameMode)
      Sets the game mode the player will be changed to if this event is not cancelled.