====== Adding a Gamerule ====== ==== Registering a Gamerule ==== To create a gamerule, build and register it using the ''GameRuleBuilder'' of the Fabric API: // Create and register a boolean gamerule, enabled by default private static final Identifier GAMERULE_IDENTIFIER = Identifier.of("custom_mod_name","gamerule_name"); public static final GameRule CUSTOM_BOOLEAN_GAMERULE = GameRuleBuilder .forBoolean(true) //default value declaration .category(GameRuleCategory.MISC) .buildAndRegister(GAMERULE_IDENTIFIER) ; ==== Using the gamerule ==== To get access to the value of a gamerule, use a server-world: serverWorld.getGameRules().getValue(CUSTOM_GAMERULE); ==== Translation ==== The registered gamerule shows up untranslated in the gamerule list, which can be opened in the world creation screen. To translate the name, add an entry in the lang-file (see [[tutorial:lang|lang]] for more info): { "gamerule.custom_mod_name.gamerule_name": "Gamerule Name" }