Class GameRuleRegistry
java.lang.Object
net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry
A utility class which allows for registration of game rules.
Note game rules with duplicate keys are not allowed.
Checking if a game rule key is already taken can be done using
hasRegistration(String)
.
Creation of rule types is done using GameRuleFactory
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
hasRegistration
(String ruleName) Checks if a name for a game rule is already registered.static <T extends net.minecraft.world.GameRules.Rule<T>>
net.minecraft.world.GameRules.Key<T>register
(String name, CustomGameRuleCategory category, net.minecraft.world.GameRules.Type<T> type) Registers aGameRules.Rule
with a custom category.static <T extends net.minecraft.world.GameRules.Rule<T>>
net.minecraft.world.GameRules.Key<T>register
(String name, net.minecraft.world.GameRules.Category category, net.minecraft.world.GameRules.Type<T> type) Registers aGameRules.Rule
.
-
Method Details
-
register
public static <T extends net.minecraft.world.GameRules.Rule<T>> net.minecraft.world.GameRules.Key<T> register(String name, net.minecraft.world.GameRules.Category category, net.minecraft.world.GameRules.Type<T> type) Registers aGameRules.Rule
.- Type Parameters:
T
- the type of rule- Parameters:
name
- the name of the rulecategory
- the category of this ruletype
- the rule type- Returns:
- a rule key which can be used to query the value of the rule
- Throws:
IllegalStateException
- if a rule of the same name already exists
-
register
public static <T extends net.minecraft.world.GameRules.Rule<T>> net.minecraft.world.GameRules.Key<T> register(String name, CustomGameRuleCategory category, net.minecraft.world.GameRules.Type<T> type) Registers aGameRules.Rule
with a custom category.- Type Parameters:
T
- the type of rule- Parameters:
name
- the name of the rulecategory
- the category of this ruletype
- the rule type- Returns:
- a rule key which can be used to query the value of the rule
- Throws:
IllegalStateException
- if a rule of the same name already exists
-
hasRegistration
Checks if a name for a game rule is already registered.- Parameters:
ruleName
- the rule name to test- Returns:
- true if the name is taken.
-