tutorial:gamerule
This is an old revision of the document!
Table of Contents
Adding a Gamerule
Registering a Gamerule
To create a gamerule you have to register it using the GameRuleRegistry
of the Fabric API:
public static final GameRules.Key<GameRules.BooleanRule> DO_SLEEP_CLEAR_WEATHER = GameRuleRegistry.register("clearWeatherAfterSleep", Category.PLAYER, GameRuleFactory.createBooleanRule(false));
Using the gamerule
To get access to the value of a game rule you need to get the server world:
world.getGameRules().getBoolean(KeepTheRain.DO_SLEEP_CLEAR_WEATHER)
tutorial/gamerule.1632412868.txt.gz · Last modified: 2021/09/23 16:01 by jummit