Game Rule Factory
public final class GameRuleFactory
Content copied to clipboard
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.BooleanRule> createBooleanRule(boolean defaultValue)
Content copied to clipboard
static GameRules.Type<GameRules.BooleanRule> createBooleanRule(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanRule> changedCallback)
Content copied to clipboard
createDoubleRule
Link copied to clipboard
static GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue)
Content copied to clipboard
static GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Content copied to clipboard
static GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, double maximumValue)
Content copied to clipboard
static GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Content copied to clipboard
static GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, double maximumValue, BiConsumer<MinecraftServer, DoubleRule> changedCallback)
Content copied to clipboard
createEnumRule
Link copied to clipboard
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue, BiConsumer<MinecraftServer, EnumRule<E>> changedCallback)
Content copied to clipboard
static GameRules.Type<EnumRule<E>> createEnumRule<E extends Enum<E>>(E defaultValue, Array<E> supportedValues, BiConsumer<MinecraftServer, EnumRule<E>> changedCallback)
Content copied to clipboard
createIntRule
Link copied to clipboard
static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue)
Content copied to clipboard
static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Content copied to clipboard
static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue)
Content copied to clipboard
static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Content copied to clipboard
static GameRules.Type<GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue, @Nullable() BiConsumer<MinecraftServer, GameRules.IntRule> changedCallback)
Content copied to clipboard
Sources
jvm source
Link copied to clipboard