tutorial:gamerule
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:gamerule [2021/01/30 19:51] – mysterious_dev | tutorial:gamerule [2025/12/09 19:10] (current) – 1.21.11 lang-file change for gamerules' identifier(s) solacekairos | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | ==== Creating your gamerule ==== | + | ==== Registering a Gamerule ==== |
| + | |||
| + | To create a gamerule, build and register it using the '' | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | // Create and register a boolean gamerule, enabled by default | ||
| + | private static final Identifier | ||
| + | public | ||
| + | .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: | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | 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: | ||
| + | |||
| + | <code json> | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | </ | ||
tutorial/gamerule.1612036298.txt.gz · Last modified: 2021/01/30 19:51 by mysterious_dev