User Tools

Site Tools


tutorial:gamerule

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:gamerule [2025/12/09 18:57] – [Registering a Gamerule] solacekairostutorial:gamerule [2025/12/09 19:10] (current) – 1.21.11 lang-file change for gamerules' identifier(s) solacekairos
Line 17: Line 17:
 ==== Using the gamerule ==== ==== Using the gamerule ====
  
-To get access to the value of a game rule you need to get the server world:+To get access to the value of a gamerule, use a server-world:
  
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
-world.getGameRules().getBoolean(SHOULD_PIGS_FLY)+serverWorld.getGameRules().getValue(CUSTOM_GAMERULE);
 </code> </code>
  
 ==== Translation ==== ==== Translation ====
  
-The registered gamerule now shows up untranslated in the game rule list, which can be opened in the world creation screen. +The registered gamerule shows up untranslated in the gamerule list, which can be opened in the world creation screen. 
-To translate the name, add a ''gamerule.gameruleName'' entry (see [[tutorial:lang|lang]] for more info):+To translate the name, add an entry in the lang-file (see [[tutorial:lang|lang]] for more info):
  
 <code json> <code json>
 { {
-  "gamerule.shouldPigsFly": "Pigs should fly"+  "gamerule.custom_mod_name.gamerule_name": "Gamerule Name"
 } }
 </code> </code>
tutorial/gamerule.1765306622.txt.gz · Last modified: 2025/12/09 18:57 by solacekairos