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:54] – mysterious_dev | tutorial:gamerule [2021/12/24 22:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | ==== Creating your gamerule | + | ==== Registering a Gamerule |
| - | WIP | + | To create a gamerule, register it using the '' |
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | // Create and register a boolean game rule with the name " | ||
| + | public static final GameRules.Key< | ||
| + | GameRuleRegistry.register(" | ||
| + | </ | ||
| + | |||
| + | ==== Using the gamerule ==== | ||
| + | |||
| + | To get access to the value of a game rule you need to get the server world: | ||
| + | |||
| + | <code java [enable_line_numbers=" | ||
| + | world.getGameRules().getBoolean(SHOULD_PIGS_FLY) | ||
| + | </ | ||
| + | |||
| + | ==== Translation ==== | ||
| + | |||
| + | The registered gamerule now shows up untranslated in the game rule list, which can be opened in the world creation screen. | ||
| + | To translate the name, add a '' | ||
| + | |||
| + | <code json> | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | </ | ||
tutorial/gamerule.1612036470.txt.gz · Last modified: 2021/01/30 19:54 by mysterious_dev