Class GameruleUtilities

java.lang.Object
com.glektarssza.expandedgamerules.GameruleUtilities

public final class GameruleUtilities extends Object
A collection of utilities for interacting with Minecraft's gamerules.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final boolean
    getBooleanGamerule(net.minecraft.world.level.Level level, String id)
    Get the boolean value associated with a gamerule.
    static final boolean
    getBooleanGamerule(net.minecraft.world.level.Level level, net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue> key)
    Get the boolean value associated with a gamerule.
    static final int
    getIntegerGamerule(net.minecraft.world.level.Level level, String id)
    Get the integer value associated with a gamerule.
    static final int
    getIntegerGamerule(net.minecraft.world.level.Level level, net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue> key)
    Get the integer value associated with a gamerule.
    static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue>
    register(String name, CustomCategory category, boolean defaultValue)
    Register a new gamerule.
    static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue>
    register(String name, CustomCategory category, int defaultValue)
    Register a new gamerule.
    static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue>
    register(String name, net.minecraft.world.level.GameRules.Category category, boolean defaultValue)
    Register a new gamerule.
    static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue>
    register(String name, net.minecraft.world.level.GameRules.Category category, int defaultValue)
    Register a new gamerule.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GameruleUtilities

      public GameruleUtilities()
  • Method Details

    • register

      public static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue> register(String name, net.minecraft.world.level.GameRules.Category category, boolean defaultValue)
      Register a new gamerule.
      Parameters:
      name - The name of the gamerule to register. Must be unique.
      category - The category to put the gamerule under.
      defaultValue - The value to set the gamerule to by default.
      Returns:
      A key that can be used to access the gamerule.
    • register

      public static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue> register(String name, CustomCategory category, boolean defaultValue)
      Register a new gamerule.
      Parameters:
      name - The name of the gamerule to register. Must be unique.
      category - The category to put the gamerule under.
      defaultValue - The value to set the gamerule to by default.
      Returns:
      A key that can be used to access the gamerule.
    • register

      public static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue> register(String name, net.minecraft.world.level.GameRules.Category category, int defaultValue)
      Register a new gamerule.
      Parameters:
      name - The name of the gamerule to register. Must be unique.
      category - The category to put the gamerule under.
      defaultValue - The value to set the gamerule to by default.
      Returns:
      A key that can be used to access the gamerule.
    • register

      public static final net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue> register(String name, CustomCategory category, int defaultValue)
      Register a new gamerule.
      Parameters:
      name - The name of the gamerule to register. Must be unique.
      category - The category to put the gamerule under.
      defaultValue - The value to set the gamerule to by default.
      Returns:
      A key that can be used to access the gamerule.
    • getBooleanGamerule

      public static final boolean getBooleanGamerule(net.minecraft.world.level.Level level, net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.BooleanValue> key)
      Get the boolean value associated with a gamerule.
      Parameters:
      level - The level to retrieve the gamerule value from.
      key - The key to retrieve the gamerule for.
      Returns:
      The boolean value for the gamerule.
    • getBooleanGamerule

      public static final boolean getBooleanGamerule(net.minecraft.world.level.Level level, String id)
      Get the boolean value associated with a gamerule.
      Parameters:
      level - The level to retrieve the gamerule value from.
      id - The id to retrieve the gamerule for.
      Returns:
      The boolean value for the gamerule.
    • getIntegerGamerule

      public static final int getIntegerGamerule(net.minecraft.world.level.Level level, net.minecraft.world.level.GameRules.Key<net.minecraft.world.level.GameRules.IntegerValue> key)
      Get the integer value associated with a gamerule.
      Parameters:
      level - The level to retrieve the gamerule value from.
      key - The key to retrieve the gamerule for.
      Returns:
      The integer value for the gamerule.
    • getIntegerGamerule

      public static final int getIntegerGamerule(net.minecraft.world.level.Level level, String id)
      Get the integer value associated with a gamerule.
      Parameters:
      level - The level to retrieve the gamerule value from.
      id - The id to retrieve the gamerule for.
      Returns:
      The integer value for the gamerule.