Java: a GameRules compound of strings
In Java Edition, Data → GameRules holds one TAG_String per rule, keyed by the exact name /gamerule uses, with the value written as text: "true", "false" or a number. Rules the world has never set are simply absent and fall back to their defaults — adding the tag with the correct name and a string value works exactly like running the command.
| Rule | Value | Effect |
keepInventory | "true" | Keep items on death |
doDaylightCycle | "false" | Freeze the time of day |
doWeatherCycle | "false" | Freeze the weather |
mobGriefing | "false" | Stop creepers and endermen changing blocks |
doMobSpawning | "false" | Stop natural mob spawning |
doFireTick | "false" | Fire stops spreading |
commandBlockOutput | "false" | Silence command block chat spam |
randomTickSpeed | "3" | Crop growth and fire spread rate |
playersSleepingPercentage | "50" | Share of players needed to skip the night |
spawnRadius | "10" | Spread of the spawn area |
Case matters. keepinventory in a Java file is not the same tag as keepInventory and will be ignored.
Bedrock does not group rules. Each one is a TAG_Byte at the root of level.dat, named in lowercase, holding 1 or 0 — keepinventory, domobspawning, domobloot, dodaylightcycle, doweathercycle, mobgriefing, firedamage, falldamage, drowningdamage, pvp, showcoordinates, commandblockoutput, sendcommandfeedback, naturalregeneration, tntexplodes, respawnblocksexplode, showdeathmessages, doimmediaterespawn. Numeric rules such as randomtickspeed and functioncommandlimit are TAG_Int instead.
Setting a rule that is not yet present means adding the tag with the right type: Byte for a toggle, Int for a number. A rule stored with the wrong type is ignored, or refuses to load.
When editing the file beats the command
- Cheats are off and you do not want to toggle them on and off to run one command.
- The world will not load — a rule such as
doImmediateRespawn can be set before the first join.
- You are preparing a template world to be copied for many servers, and want the rules baked into the copy.
- A plugin changed a rule and you want to see what is actually stored rather than what a command reports.
- Bulk edits. Setting a dozen rules across several worlds is faster in the file than in chat.
Stop the server first, as with any level.dat edit — a running world rewrites the file on save and will discard the change.