Updated:

The setup by version

SettingJava 1.21.11+Java 1.21.10 and earlierBedrock
Keep inventoryminecraft:keep_inventory truekeepInventory truekeepinventory true
Stop the day cycleminecraft:advance_time falsedoDaylightCycle falsedodaylightcycle false
Stop weather changesminecraft:advance_weather falsedoWeatherCycle falsedoweathercycle false
No natural mob spawningminecraft:spawn_mobs falsedoMobSpawning falsedomobspawning false

Each goes after /gamerule. Java 1.21.11 renamed every game rule and only accepts the new names; see the gamerule list.

Copy-ready sets

# Java 1.21.11+
/gamerule minecraft:keep_inventory true
/gamerule minecraft:advance_time false
/time set day
/weather clear
/gamerule minecraft:advance_weather false
/gamerule minecraft:spawn_mobs false
# Java 1.21.10 and earlier
/gamerule keepInventory true
/gamerule doDaylightCycle false
/time set day
/weather clear
/gamerule doWeatherCycle false
/gamerule doMobSpawning false
# Bedrock
/gamerule keepinventory true
/gamerule dodaylightcycle false
/time set day
/weather clear
/gamerule doweathercycle false
/gamerule domobspawning false

Set the time and weather first, then freeze them. /weather clear alone lasts only a while. Bedrock can also lock daytime with /alwaysday true.

Optional rules for testing

GoalJava 1.21.11+Java 1.21.10 and earlierBedrock
Creepers and endermen do not break blocksminecraft:mob_griefing falsemobGriefing falsemobgriefing false
No fall damageminecraft:fall_damage falsefallDamage falsefalldamage false
Respawn instantlyminecraft:immediate_respawn truedoImmediateRespawn truedoimmediaterespawn true
Quiet command blocksminecraft:command_block_output falsecommandBlockOutput falsecommandblockoutput false

These are handy while building and testing, but turn them back on before others play, since they change normal gameplay.

Java 26.1 time changes

Java 26.1 added /time pause and /time resume, and /time set day now moves forward to the next morning, which can add a day to the day count. The game rule method still works. Details in the time command guide.

When it does not work

Common questions

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.