User Tools

Site Tools


tutorial:gamerule

This is an old revision of the document!


Adding a Gamerule

Registering a Gamerule

To create a gamerule you have to register it using the GameRuleRegistry of the Fabric API:

  1. public static final GameRules.Key<GameRules.BooleanRule> DO_SLEEP_CLEAR_WEATHER =
  2. 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:

  1. world.getGameRules().getBoolean(KeepTheRain.DO_SLEEP_CLEAR_WEATHER)
tutorial/gamerule.1632412868.txt.gz · Last modified: 2021/09/23 16:01 by jummit