Gamerule Command Generator

Check or change world rules such as keep inventory and how many players must sleep.

JavaBedrock

Generated command

Find a gamerule

59 of 59 rules

Selected rule

Keep inventory

minecraft:keep_inventory

Keep your items and experience when you die.

Default: false

New value

View command

Keep your gear when you respawn

Turn on keep inventory before you try a risky build, explore the Nether or play with friends who want to keep their gear. Pick Java or Bedrock first. On Java, match Game version to the world or server where you will run the command. The same setting can have a different name in older releases.

  1. Type keep inventory in Search rules and select the match.
  2. Choose Set value, then pick true under New value.
  3. Press Copy command, paste the line into Minecraft chat and run it. Use a world with commands enabled or a server where you have operator permission.

Check a world before you change its rules

If you joined a shared world and want to know whether players keep their items, select the rule and choose Query current. Run the copied line in that world to see its saved value. You can write it down before making a change so you know what to restore later. Choose Use default to put the rule's original Minecraft value in New value. To apply it to your world, run the generated command.

In Java 1.21.11 and newer, keep inventory appears as minecraft:keep_inventory. The older Java form and the Bedrock form use keepInventory. Pick the edition and version first so you can copy a line that matches your game.

Set how many players need to sleep

On a multiplayer world, search for sleeping to find the setting that controls how many players need to sleep to skip the night. On a server with four players counted for sleep, set New value to 50 if you want two of them to be enough. For a one-player test world, keep the original value handy if you plan to use the same setup on a server later.