Class CustomGameRuleCategory

java.lang.Object
net.fabricmc.fabric.api.gamerule.v1.CustomGameRuleCategory

public final class CustomGameRuleCategory extends Object
Utility class for creating custom game rule categories outside of the categories Minecraft provides.
  • Constructor Details

    • CustomGameRuleCategory

      public CustomGameRuleCategory(net.minecraft.util.Identifier id, net.minecraft.text.Text name)
      Creates a custom game rule category.
      Parameters:
      id - the id of this category
      name - the name of this category
  • Method Details

    • getId

      public net.minecraft.util.Identifier getId()
    • getName

      public net.minecraft.text.Text getName()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getCategory

      public static <T extends net.minecraft.world.GameRules.Rule<T>> Optional<CustomGameRuleCategory> getCategory(net.minecraft.world.GameRules.Key<T> key)
      Gets the custom category a game rule key is registered to.
      Type Parameters:
      T - the type of value the rule holds
      Parameters:
      key - the rule key
      Returns:
      the custom category this rule belongs to. Otherwise empty