How to use gamerules on a Minecraft server (keepInventory and more)
Turn on keepInventory, stop mob griefing, skip nights faster and more with Minecraft gamerules on your Java server.
Updated · 2 min read
Game rules change how the world behaves, such as whether players keep items on death. Set them with gamerule <rule> <value> in the Schokr console, or /gamerule in-game as an op. They save with the world, so they survive restarts.
Turn on keepInventory
gamerule keepInventory true
Players now keep their items and XP when they die. To turn it off again, use false.
Run a rule with no value to see its current setting:
gamerule keepInventory
Rule names on newer versions
Recent Minecraft versions have started renaming game rules to lowercase names with underscores (for example keep_inventory instead of keepInventory) and moving a few server.properties settings into game rules. If a command below is rejected, type /gamerule in-game and press Tab to see the exact names your version uses. The Game rule page on the Minecraft Wiki lists every rule per version.
Popular game rules
| Rule | Default | What it does |
|---|---|---|
keepInventory | false | Keep items and XP on death |
mobGriefing | true | Creepers blow up blocks, endermen pick up blocks, and so on. false stops it (also stops villagers farming) |
playersSleepingPercentage | 100 | Percent of players that must sleep to skip the night. 0 means one is enough |
doDaylightCycle | true | false freezes the time of day |
doWeatherCycle | true | false freezes the weather |
doFireTick | true | false stops fire spreading |
doInsomnia | true | false stops phantoms spawning |
doMobSpawning | true | false stops natural mob spawning |
announceAdvancements | true | Show advancements in chat |
showDeathMessages | true | Show death messages in chat |
naturalRegeneration | true | Regenerate health from food |
spawnRadius | 10 | How far from world spawn new players can appear |
randomTickSpeed | 3 | Crop and plant growth speed. Raising it a lot causes lag |
doImmediateRespawn | false | Skip the death screen |
commandBlockOutput | true | Show command block output to ops in chat |
Examples for common server styles
A relaxed friends server:
gamerule keepInventory true
gamerule playersSleepingPercentage 0
gamerule doInsomnia false
gamerule mobGriefing false
A build server with constant daytime and clear weather:
time set day
gamerule doDaylightCycle false
weather clear
gamerule doWeatherCycle false
gamerule doMobSpawning false
Game rules are per world
Game rules are saved in the world's level.dat. On Paper, the Nether and End are separate worlds with their own rules. Running gamerule from the console applies it to the overworld only. To set it for another dimension, run it in-game while standing in that dimension, or use execute:
execute in minecraft:the_nether run gamerule keepInventory true
execute in minecraft:the_end run gamerule keepInventory true
If you generate a new world, set your game rules again, because the new world starts with defaults.
Permissions
Using /gamerule in-game needs op level 2 or higher. See ops and op levels.