Interface IGameruleRegistry

All Known Implementing Classes:
GameruleRegistry

public interface IGameruleRegistry
An interface which defines an object for registering and accessing gamerules.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    getBooleanGamerule(net.minecraft.world.level.Level level, String id)
    Get the current value of a boolean gamerule.
    default int
    getIntegerGamerule(net.minecraft.world.level.Level level, String id)
    Get the current value of an integer gamerule.
    default boolean
    Check if a gamerule exists.
    default <T extends net.minecraft.world.level.GameRules.Value<T>>
    net.minecraft.world.level.GameRules.Key<T>
    register(String id, CustomCategory category, net.minecraft.world.level.GameRules.Type<T> type)
    Register a new gamerule with a custom category.
    default <T extends net.minecraft.world.level.GameRules.Value<T>>
    net.minecraft.world.level.GameRules.Key<T>
    register(String id, net.minecraft.world.level.GameRules.Category category, net.minecraft.world.level.GameRules.Type<T> type)
    Register a new gamerule.
  • Method Details

    • hasGamerule

      default boolean hasGamerule(String id)
      Check if a gamerule exists.
      Parameters:
      id - The ID of the gamerule to look for.
      Returns:
      true if the gamerule exists; false otherwise.
    • getBooleanGamerule

      default boolean getBooleanGamerule(net.minecraft.world.level.Level level, String id)
      Get the current value of a boolean gamerule.
      Parameters:
      id - The resource location of the gamerule to get the boolean value of.
      Returns:
      The boolean value of the gamerule.
    • getIntegerGamerule

      default int getIntegerGamerule(net.minecraft.world.level.Level level, String id)
      Get the current value of an integer gamerule.
      Parameters:
      id - The resource location of the gamerule to get the integer value of.
      Returns:
      The integer value of the gamerule.
    • register

      default <T extends net.minecraft.world.level.GameRules.Value<T>> net.minecraft.world.level.GameRules.Key<T> register(String id, net.minecraft.world.level.GameRules.Category category, net.minecraft.world.level.GameRules.Type<T> type) throws IllegalStateException
      Register a new gamerule.
      Parameters:
      id - The resource location to register the new gamerule at. Must be unqiue.
      category - The category to register the new gamerule under.
      type - The type of gamerule to register.
      Returns:
      The key of the newly registered gamerule.
      Throws:
      IllegalStateException - Thrown if the resource location given is already in use.
    • register

      default <T extends net.minecraft.world.level.GameRules.Value<T>> net.minecraft.world.level.GameRules.Key<T> register(String id, CustomCategory category, net.minecraft.world.level.GameRules.Type<T> type) throws IllegalStateException
      Register a new gamerule with a custom category.
      Parameters:
      id - The resource location to register the new gamerule at. Must be unqiue.
      category - The category to register the new gamerule under.
      type - The type of gamerule to register.
      Returns:
      The key of the newly registered gamerule.
      Throws:
      IllegalStateException - Thrown if the resource location given is already in use.