GameRuleFactory

public final class GameRuleFactory

A utility class containing factory methods to create game rule types. A game rule is a persisted, per server data value which may control gameplay aspects.

Some factory methods allow specification of a callback that is invoked when the value of a game rule has changed. Typically the callback is used for game rules which may influence game logic, such as disabling raids.

To register a game rule, you can use register. For example, to register a game rule that is an integer where the acceptable values are between 0 and 10, one would use the following:

public static final GameRules.Key<GameRules.IntRule> EXAMPLE_INT_RULE = GameRuleRegistry.register("exampleIntRule", GameRules.Category.UPDATES, GameRuleFactory.createIntRule(1, 10));

To register a game rule in a custom category, register should be used.

See also

Functions

createBooleanRule
Link copied to clipboard
static GameRules.Type<GameRules.BooleanRulecreateBooleanRule(boolean defaultValue)
Creates a boolean rule type.
static GameRules.Type<GameRules.BooleanRulecreateBooleanRule(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanRule> changedCallback)
Creates a boolean rule type.
createDoubleRule
Link copied to clipboard
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue)
Creates a double rule type.
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue, double minimumValue)
Creates a double rule type.
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Creates a double rule type.
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue, double minimumValue, double maximumValue)
Creates a double rule type.
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue, double minimumValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Creates a double rule type.
static GameRules.Type<DoubleRulecreateDoubleRule(double defaultValue, double minimumValue, double maximumValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Creates a double rule type.
createEnumRule
Link copied to clipboard
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue)
Creates an enum rule type.
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue, Array<E> supportedValues)
Creates an enum rule type.
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue, BiConsumer<MinecraftServer, EnumRule<E>> changedCallback)
Creates an enum rule type.
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue, Array<E> supportedValues, BiConsumer<MinecraftServer, EnumRule<E>> changedCallback)
Creates an enum rule type.
createIntRule
Link copied to clipboard
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue)
Creates an integer rule type.
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue, int minimumValue)
Creates an integer rule type.
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue, BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Creates an integer rule type.
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue, int minimumValue, int maximumValue)
Creates an integer rule type.
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue, int minimumValue, BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Creates an integer rule type.
static GameRules.Type<GameRules.IntRulecreateIntRule(int defaultValue, int minimumValue, int maximumValue, @Nullable() BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Creates an integer rule type.

Sources

jvm source
Link copied to clipboard