Change Minecraft game rules without commands

Turn on keep_inventory or change any other game rule by editing the world's files, with the three storage formats Java has used and the renamed rule names.

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

VersionFile and locationRule namesValues
1.21.10 and olderlevel.dat › Data › GameRuleskeepInventoryText: "true", "false", "3"
1.21.11level.dat › Data › game_rulesminecraft:keep_inventoryByte 1 or 0 for on/off rules, Int for numbers
26.1 and laterdata/minecraft/game_rules.dat in the world folderminecraft:keep_inventoryByte 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.

1.21.11 level.dat (values from a real file)
  • { }Data
    • { }game_rules
      • Bminecraft:advance_time1
      • Bminecraft:keep_inventory1
      • Bminecraft:mob_griefing1
      • Iminecraft:players_sleeping_percentage100
      • Iminecraft:random_tick_speed3

Change a rule

  1. Close Minecraft or stop the server, then back up the world folder.
  2. Open the file for your version in the editor: level.dat up to 1.21.11, or data/minecraft/game_rules.dat from 26.1.
  3. Find the rule. In the tree, use the search box at the top right to jump to it by name.
  4. Set the value: true/false in the old String format, 1/0 in the newer Byte format, or a number for numeric rules.
  5. 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.10From 1.21.11TypeDefault
keepInventoryminecraft:keep_inventoryBon/off0
doDaylightCycleminecraft:advance_timeBon/off1
doWeatherCycleminecraft:advance_weatherBon/off1
mobGriefingminecraft:mob_griefingBon/off1
doMobSpawningminecraft:spawn_mobsBon/off1
doInsomniaminecraft:spawn_phantomsBon/off1
doImmediateRespawnminecraft:immediate_respawnBon/off0
naturalRegenerationminecraft:natural_health_regenerationBon/off1
showDeathMessagesminecraft:show_death_messagesBon/off1
announceAdvancementsminecraft:show_advancement_messagesBon/off1
doMobLootminecraft:mob_dropsBon/off1
doTileDropsminecraft:block_dropsBon/off1
randomTickSpeedminecraft:random_tick_speedInumber3
playersSleepingPercentageminecraft:players_sleeping_percentageInumber100
spawnRadiusminecraft:respawn_radiusInumber10
doFireTickminecraft:fire_spread_radius_around_playerInumber128
disableRaidsminecraft:raidsBon/off1

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.

Ready to edit?Open the file in the editor: every value keeps its NBT type and the file is saved in its original format.