DGuard

Game rules (/gamerule) on a Minecraft server

Game rules are switches for world mechanics: whether players keep items on death, whether mobs break blocks, whether fire spreads, how many players must sleep. Here's the /gamerule command, the rules that matter on a server with their defaults, and the big change of recent versions: since 1.21.11 every rule has a new name.

The DGuard team6 min read

In short: /gamerule <rule> <value> changes a rule, and without a value it shows the current one. Since 1.21.11 rule names use underscores: keepInventory became keep_inventory, doInsomnia became spawn_phantoms. On Paper each world has its own rules, so set the Nether and the End separately.

The /gamerule command

The command needs operator level 2: run it from the server console or in chat as an operator. On Paper its permission is minecraft.command.gamerule, so you can give it to a moderator through a permissions plugin instead of OP — see LuckPerms. Arguments are case-sensitive in Java Edition.

server console (in game, with a slash)
gamerule keep_inventory          # show the value
gamerule keep_inventory true     # turn it on
gamerule players_sleeping_percentage 50

A rule is either a boolean (true or false) or a number. Changes apply at once, no restart needed. On Paper the command changes the rule of the world it runs in; from the console that's the main world. For other worlds use execute in:

the same rule in the Nether and the End
execute in minecraft:the_nether run gamerule keep_inventory true
execute in minecraft:the_end run gamerule keep_inventory true

Since 1.21.11 the rules have new names

In 1.21.11 Mojang moved game rules into a registry, and they all switched from camel case to lowercase names with underscores. Many were also renamed after their labels in the world creation menu, and a few had their value flipped: disableRaids became raids, so "raids on" is now true.

Before 1.21.11Since 1.21.11
keepInventorykeep_inventory
mobGriefingmob_griefing
doFireTickremoved, replaced by fire_spread_radius_around_player
doInsomniaspawn_phantoms
spawnRadiusrespawn_radius
announceAdvancementsshow_advancement_messages
doDaylightCycle, doWeatherCycleadvance_time, advance_weather
doMobSpawningspawn_mobs
commandBlocksEnabledcommand_blocks_work
disableElytraMovementCheckelytra_movement_check (value flipped)
Part of the rename list, from the Minecraft Wiki. The full list is in the history section of its game rule page.

Game rules worth knowing on a server

RuleDefaultWhat it changes
keep_inventoryfalsePlayers keep their items and experience on death. Health, hunger and effects still reset
mob_griefingtrueMobs change blocks and pick up items: creepers blow up terrain, endermen carry blocks off, villagers farm. false turns all of it off at once, including piglins bartering for dropped gold
fire_spread_radius_around_player128How far from a player fire can spread. 0 stops fire spread, -1 means no limit. Added in 1.21.11 to replace doFireTick
spawn_phantomstrueWhether phantoms spawn at night for players who haven't slept
players_sleeping_percentage100What percentage of players in the Overworld must sleep to skip the night. 0 means one is enough, over 100 means the night is never skipped
respawn_radius10How far from the world spawn a new player, or one without a personal spawnpoint, appears
pvptrueWhether players can damage each other. Since 1.21.9, replaces pvp in server.properties
spawn_monsterstrueWhether monsters spawn naturally. Since 1.21.9, replaces spawn-monsters
command_block_outputtrueWhether command blocks notify admins about the commands they run — on a server with command blocks it floods the chat
show_advancement_messagestrueWhether advancements are announced in chat
show_death_messagestrueWhether player death messages appear in chat
locator_bartrueThe locator bar that points toward other players (since 1.21.6)
spectators_generate_chunkstrueWhether players in Spectator mode generate new chunks
random_tick_speed3Random tick speed: plant growth, leaf decay. Higher means faster farms and more work for the server
Names and values for Java Edition 1.21.11 and newer, from the Minecraft Wiki

The rules servers change most are players_sleeping_percentage (so the night can be skipped without everyone online), spawn_phantoms, mob_griefing and command_block_output. Lobbies and minigames also freeze time and weather: advance_time false, advance_weather false. On a big world spectators_generate_chunks false helps: spectators stop generating new chunks — more on that load in pregenerating the world.

The vanilla server's movement checks

Two rules are the server's built-in speed checks: player_movement_check (player speed) and elytra_movement_check (speed on elytra). Both are on by default. The Minecraft Wiki notes that turning the elytra check off often helps with jittering from lag, which is why owners sometimes disable them.

Know the consequence: without them the server no longer stops too-fast movement by itself, and stopping speed cheats is entirely the anticheat's job. Before you turn them off, make sure your anticheat catches these cheats:

CheatDGuardGrimACVulcanPolarIntaveMatrix
Speedfaster than the game allows
Flyflies without elytra or creative
ElytraFlycontrolled elytra flightpartly: not named — the simulation recreates 'most' movements
Timerspeeds the game up
Speed and flight are the anticheat's job: who checks these cheatsAll 47 kinds of cheats in the comparison

Game rules and the anticheat

Game rules set the conditions, not fair play. keep_inventory changes the stakes: when death costs nothing, fights happen more often. fall_damage false makes NoFall pointless, but no rule turns off KillAura or Reach — the fight still goes to whoever runs the cheat. DGuard — the best anticheat for a modern Minecraft server — catches cheats in combat, movement, packets, inventory, building and the world under any rules, gathers evidence without rushing to a verdict, and you set how strict the punishments are.

Game rules aren't the same as server rules for players: what's forbidden and how it's punished is your call, and it's worth writing down. The free rules generator helps.

FAQ

How do I turn on keepInventory on a server?

On 1.21.11 and newer run /gamerule keep_inventory true, on older versions /gamerule keepInventory true. On Paper each world has its own rule: for the Nether and the End run it through execute in.

Why does /gamerule keepInventory give an error?

Since 1.21.11 the rules are renamed: it's keep_inventory now. Also check the letter case — command arguments are case-sensitive in Java Edition.

How do I stop fire from spreading?

On 1.21.11 and newer run /gamerule fire_spread_radius_around_player 0. Before 1.21.11 /gamerule doFireTick false did the same.

How do I let one sleeping player skip the night?

Set /gamerule players_sleeping_percentage 0: at 0 or below, one sleeping player skips the night. A value over 100 stops the night from being skipped at all.

Sources

All sections

Run the best anticheat for modern Minecraft

DGuard catches all 47 kinds of cheats in our comparison — the closest rival, Intave, has 27. Full protection on every plan, free up to 30 players online.