NewSchokr 13 is here. A whole new UI, seven locations, snapshots and more. Read more →

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.

RuleDefaultWhat it does
keepInventoryfalseKeep items and XP on death
mobGriefingtrueCreepers blow up blocks, endermen pick up blocks, and so on. false stops it (also stops villagers farming)
playersSleepingPercentage100Percent of players that must sleep to skip the night. 0 means one is enough
doDaylightCycletruefalse freezes the time of day
doWeatherCycletruefalse freezes the weather
doFireTicktruefalse stops fire spreading
doInsomniatruefalse stops phantoms spawning
doMobSpawningtruefalse stops natural mob spawning
announceAdvancementstrueShow advancements in chat
showDeathMessagestrueShow death messages in chat
naturalRegenerationtrueRegenerate health from food
spawnRadius10How far from world spawn new players can appear
randomTickSpeed3Crop and plant growth speed. Raising it a lot causes lag
doImmediateRespawnfalseSkip the death screen
commandBlockOutputtrueShow 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.