Game rules are world settings such as keep inventory, the day and night cycle or mob griefing. You normally change them with /gamerule, which needs cheats. If cheats are off, or you are preparing a world before anyone joins, you can change the rules in the world's files instead.
Java has stored game rules in three different ways in recent years, and a value written in the wrong format is silently ignored. Find your format first.
The three formats
| Version | File and location | Rule names | Values |
|---|---|---|---|
| 1.21.10 and older | level.dat › Data › GameRules | keepInventory | Text: "true", "false", "3" |
| 1.21.11 | level.dat › Data › game_rules | minecraft:keep_inventory | Byte 1 or 0 for on/off rules, Int for numbers |
| 26.1 and later | data/minecraft/game_rules.dat in the world folder | minecraft:keep_inventory | Byte 1 or 0, Int for numbers |
In the oldest format every value is a String, even numbers. Writing a Byte 1 there does nothing; it has to be the text true. The editor keeps each value's type when you edit it, so typing true into a String rule stays a String.
- { }Data
- { }game_rules
- Bminecraft:advance_time1
- Bminecraft:keep_inventory1
- Bminecraft:mob_griefing1
- Iminecraft:players_sleeping_percentage100
- Iminecraft:random_tick_speed3
- { }game_rules
Change a rule
- Close Minecraft or stop the server, then back up the world folder.
- Open the file for your version in the editor: level.dat up to 1.21.11, or
data/minecraft/game_rules.datfrom 26.1. - Find the rule. In the tree, use the search box at the top right to jump to it by name.
- Set the value:
true/falsein the old String format,1/0in the newer Byte format, or a number for numeric rules. - Download, put the file back in the same place with the same name, and start the game.
If a rule you want isn't in the file, the world uses its default value. You can add it: open the ☰ menu on any rule in the list, choose Insert, name the new entry exactly like the others (for example minecraft:keep_inventory) and type 1b as its value, which creates a Byte.
Renamed rules
Java 1.21.11 renamed every game rule from camelCase to a namespaced snake_case name, and several got new words entirely. The table lists the rules people change most. The defaults come from a freshly created 1.21.11 world.
| Up to 1.21.10 | From 1.21.11 | Type | Default |
|---|---|---|---|
keepInventory | minecraft:keep_inventory | Bon/off | 0 |
doDaylightCycle | minecraft:advance_time | Bon/off | 1 |
doWeatherCycle | minecraft:advance_weather | Bon/off | 1 |
mobGriefing | minecraft:mob_griefing | Bon/off | 1 |
doMobSpawning | minecraft:spawn_mobs | Bon/off | 1 |
doInsomnia | minecraft:spawn_phantoms | Bon/off | 1 |
doImmediateRespawn | minecraft:immediate_respawn | Bon/off | 0 |
naturalRegeneration | minecraft:natural_health_regeneration | Bon/off | 1 |
showDeathMessages | minecraft:show_death_messages | Bon/off | 1 |
announceAdvancements | minecraft:show_advancement_messages | Bon/off | 1 |
doMobLoot | minecraft:mob_drops | Bon/off | 1 |
doTileDrops | minecraft:block_drops | Bon/off | 1 |
randomTickSpeed | minecraft:random_tick_speed | Inumber | 3 |
playersSleepingPercentage | minecraft:players_sleeping_percentage | Inumber | 100 |
spawnRadius | minecraft:respawn_radius | Inumber | 10 |
doFireTick | minecraft:fire_spread_radius_around_player | Inumber | 128 |
disableRaids | minecraft:raids | Bon/off | 1 |
Fire changed the most. The on/off doFireTick rule and the related allowFireTicksAwayFromPlayer rule were merged into one number, minecraft:fire_spread_radius_around_player. If you are unsure which value gives the behavior you want, set it once with /gamerule in a test world and look at what was saved.
Commands are still easier when you can use them
If cheats are on, /gamerule keep_inventory true (or /gamerule keepInventory true before 1.21.11) does the same thing without closing the game. Rule names are case-sensitive in Java. To get commands in a world that has them off, see enabling cheats in an existing world.
Upgrading a world keeps its rules
When you open an older world in a newer version, the game converts the rules to the new names and moves them to the new file. Don't add old camelCase names to a converted world: they aren't read.