public final class GameRuleFactory extends Object
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 GameRuleRegistry.register(String, GameRules.Category, GameRules.Type)
.
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, GameRuleRegistry.register(String, CustomGameRuleCategory, GameRules.Type)
should be used.
GameRuleRegistry
Modifier and Type | Method and Description |
---|---|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.BooleanRule> |
createBooleanRule(boolean defaultValue)
Creates a boolean rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.BooleanRule> |
createBooleanRule(boolean defaultValue,
BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.BooleanRule> changedCallback)
Creates a boolean rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue)
Creates a double rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue,
BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
Creates a double rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue,
double minimumValue)
Creates a double rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue,
double minimumValue,
BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
Creates a double rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue,
double minimumValue,
double maximumValue)
Creates a double rule type.
|
static net.minecraft.world.GameRules.Type<DoubleRule> |
createDoubleRule(double defaultValue,
double minimumValue,
double maximumValue,
BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
Creates a double rule type.
|
static <E extends Enum<E>> |
createEnumRule(E defaultValue)
Creates an enum rule type.
|
static <E extends Enum<E>> |
createEnumRule(E defaultValue,
BiConsumer<net.minecraft.server.MinecraftServer,EnumRule<E>> changedCallback)
Creates an enum rule type.
|
static <E extends Enum<E>> |
createEnumRule(E defaultValue,
E[] supportedValues)
Creates an enum rule type.
|
static <E extends Enum<E>> |
createEnumRule(E defaultValue,
E[] supportedValues,
BiConsumer<net.minecraft.server.MinecraftServer,EnumRule<E>> changedCallback)
Creates an enum rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue)
Creates an integer rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue,
BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
Creates an integer rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue,
int minimumValue)
Creates an integer rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue,
int minimumValue,
BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
Creates an integer rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue,
int minimumValue,
int maximumValue)
Creates an integer rule type.
|
static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> |
createIntRule(int defaultValue,
int minimumValue,
int maximumValue,
@Nullable BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
Creates an integer rule type.
|
public static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.BooleanRule> createBooleanRule(boolean defaultValue)
defaultValue
- the default value of the game rulepublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.BooleanRule> createBooleanRule(boolean defaultValue, BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.BooleanRule> changedCallback)
defaultValue
- the default value of the game rulechangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue)
defaultValue
- the default value of the game rulepublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue, int minimumValue)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptpublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptchangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptmaximumValue
- the maximum value the game rule may acceptpublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue, BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
defaultValue
- the default value of the game rulechangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<net.minecraft.world.GameRules.IntRule> createIntRule(int defaultValue, int minimumValue, int maximumValue, @Nullable @Nullable BiConsumer<net.minecraft.server.MinecraftServer,net.minecraft.world.GameRules.IntRule> changedCallback)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptmaximumValue
- the maximum value the game rule may acceptchangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue)
defaultValue
- the default value of the game rulepublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptpublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptchangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, double maximumValue)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptmaximumValue
- the maximum value the game rule may acceptpublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
defaultValue
- the default value of the game rulechangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static net.minecraft.world.GameRules.Type<DoubleRule> createDoubleRule(double defaultValue, double minimumValue, double maximumValue, BiConsumer<net.minecraft.server.MinecraftServer,DoubleRule> changedCallback)
defaultValue
- the default value of the game ruleminimumValue
- the minimum value the game rule may acceptmaximumValue
- the maximum value the game rule may acceptchangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static <E extends Enum<E>> net.minecraft.world.GameRules.Type<EnumRule<E>> createEnumRule(E defaultValue)
All enum values are supported.
E
- the type of enum this game rule storesdefaultValue
- the default value of the game rulepublic static <E extends Enum<E>> net.minecraft.world.GameRules.Type<EnumRule<E>> createEnumRule(E defaultValue, BiConsumer<net.minecraft.server.MinecraftServer,EnumRule<E>> changedCallback)
All enum values are supported.
E
- the type of enum this game rule storesdefaultValue
- the default value of the game rulechangedCallback
- a callback that is invoked when the value of a game rule has changedpublic static <E extends Enum<E>> net.minecraft.world.GameRules.Type<EnumRule<E>> createEnumRule(E defaultValue, E[] supportedValues)
E
- the type of enum this game rule storesdefaultValue
- the default value of the game rulesupportedValues
- the values the game rule may supportpublic static <E extends Enum<E>> net.minecraft.world.GameRules.Type<EnumRule<E>> createEnumRule(E defaultValue, E[] supportedValues, BiConsumer<net.minecraft.server.MinecraftServer,EnumRule<E>> changedCallback)
E
- the type of enum this game rule storesdefaultValue
- the default value of the game rulesupportedValues
- the values the game rule may supportchangedCallback
- a callback that is invoked when the value of a game rule has changed.