Minecraft gamerules: keep inventory and other useful settings
Gamerules are the rules of the game for a world. Type them in the panel console without a slash, or in game as an operator with a slash. They take effect immediately, no restart needed.
Important: the names depend on the game version
In Minecraft 1.21.11 the gamerule names changed. For example, keepInventory is now keep_inventory. Use the old name on an older version and the new one on a newer version. Not sure which one you have? Type /gamerule in the chat and press Tab, and the game lists the names it accepts.
The ones used most often
| What it does | 1.21.11 and newer | Older versions |
|---|---|---|
| players keep their items when they die | keep_inventory true | keepInventory true |
| no phantoms | spawn_phantoms false | doInsomnia false |
| creepers and endermen do not break blocks | mob_griefing false | mobGriefing false |
| one sleeping player skips the night | players_sleeping_percentage 1 | playersSleepingPercentage 1 |
| stops the day and night cycle | advance_time false | doDaylightCycle false |
| stops the weather cycle | advance_weather false | doWeatherCycle false |
| mobs do not spawn on their own | spawn_mobs false | doMobSpawning false |
| no advancement messages in the chat | show_advancement_messages false | announceAdvancements false |
Put gamerule in front of each of them, for example:
gamerule keep_inventory true
On an older version: gamerule keepInventory true. To check the current value, type just the name, for example gamerule keep_inventory.
mob_griefing false) also stops villagers from picking up items and mobs from trampling crops. On a server with plugins, creeper protection is better set up in WorldGuard.Several worlds
On Paper a gamerule applies to the world you are in. The Nether and the End have their own settings, so run the command there as well, for example with execute in minecraft:the_nether run gamerule keep_inventory true.
Frequently asked questions
keepInventory does not work and I get a command error.
You are on 1.21.11 or newer, so type gamerule keep_inventory true. On older versions watch the capital letters: keepInventory, not keepinventory.
Do gamerules stay after a restart?
Yes, they are saved in the world. After a world reset you need to set them again.
Pepe