Enum Class GameType

java.lang.Object
java.lang.Enum<GameType>
net.minecraft.world.level.GameType
All Implemented Interfaces:
Serializable, Comparable<GameType>, Constable, StringRepresentable

public enum GameType extends Enum<GameType> implements StringRepresentable
  • Enum Constant Details

    • SURVIVAL

      public static final GameType SURVIVAL
    • CREATIVE

      public static final GameType CREATIVE
    • ADVENTURE

      public static final GameType ADVENTURE
    • SPECTATOR

      public static final GameType SPECTATOR
  • Field Details

  • Constructor Details

    • GameType

      private GameType(int pId, String pName)
  • Method Details

    • values

      public static GameType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static GameType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getId

      public int getId()
    • getName

      public String getName()
    • getSerializedName

      public String getSerializedName()
      Specified by:
      getSerializedName in interface StringRepresentable
    • getLongDisplayName

      public Component getLongDisplayName()
    • getShortDisplayName

      public Component getShortDisplayName()
    • updatePlayerAbilities

      public void updatePlayerAbilities(Abilities pAbilities)
      Configures the player abilities based on the game type
    • isBlockPlacingRestricted

      public boolean isBlockPlacingRestricted()
    • isCreative

      public boolean isCreative()
    • isSurvival

      public boolean isSurvival()
    • byId

      public static GameType byId(int pId)
      Gets the game type by its ID. Will be survival if none was found.
    • byName

      public static GameType byName(String pGamemodeName)
      Gets the game type registered with the specified name. If no matches were found, survival will be returned.
    • byName

      @Nullable @Contract("_,!null->!null;_,null->_") public static GameType byName(String pTargetName, @Nullable GameType pFallback)
    • getNullableId

      public static int getNullableId(@Nullable GameType pGameType)
    • byNullableId

      @Nullable public static GameType byNullableId(int pId)