How to Use /gamerule Commands
Gamerules are world-level switches you flip from the console. One line keeps items on death, another freezes the sun, another stops creepers from cratering your builds. Here are the ones worth changing and the exact syntax.
Start with the big three: keepInventory true ends gear loss, doDaylightCycle false locks time, and mobGriefing false protects your builds. Good extras are doFireTick false (fire stops spreading), doMobSpawning false for a quiet build world, and randomTickSpeed (default 3) which controls how fast crops grow and fire decays. Run a rule with no value to read it before you change it.
Quick answers
+What is the syntax for gamerule?
+Do gamerules need cheats on?
+Does keepInventory affect XP?
+How do I freeze time at day?
+What does mobGriefing false stop?
+Are gamerules per-world?
+What does randomTickSpeed do and is higher safe?
+How do I stop the announce message when a rule changes?
+Can I limit how far commands like /fill reach?
+What gamerule controls fall damage and fire damage for players?
+Why does my gamerule reset after a restart?
Rules people get wrong
Rule names are case sensitive. keepInventory works, keepinventory does not, and the console will not autocorrect it. Tab completion gives you the exact spelling, so use it. Booleans are typed as true or false with no quotes.
doDaylightCycle false stops time from advancing but does not set it. Time stays at whatever value it had, so run /time set day (1000 ticks) or /time set noon (6000) right after. The same applies to doWeatherCycle false, which locks the current weather, so clear it first with /weather clear.
doMobSpawning false stops natural spawns but leaves existing mobs alive and does not block spawn eggs, spawners, or breeding. Clear what is already loaded with /kill @e[type=zombie] or similar. On Bedrock the rule names match Java, but a few rules like showDeathMessages behave the same while others are edition only.
- doInsomnia false stops phantoms spawning from no sleep, better than killing them on sight.
- doImmediateRespawn true skips the respawn screen so players drop straight back in.
- spawnRadius 0 pins everyone to the exact world spawn block instead of a 10 block spread.
- playersSleepingPercentage (default 100) sets the share of players who must sleep to skip night. Set it to 1 so one person can skip for everyone.
Blocks and items in this guide
All 4 of these are named in the guide above, starting with Powder Snow. Look them up in the item database.