/gamerule
Sets or queries a game rule. Game rules control various world behaviors like mob griefing, fire spread, keep inventory, and many more.
Overview
Sets or queries a game rule. Game rules control various world behaviors like mob griefing, fire spread, keep inventory, and many more. In vanilla Minecraft Java Edition it is one of the gameplay commands, first added in 1.4.2.
It is invoked as /gamerule <rule> [<value>] and accepts one required argument (<rule>) and one optional argument ([value]).
Common rules in Java 1.21.11 and later: keep_inventory, mob_griefing, advance_time, advance_weather, spawn_mobs, spawn_phantoms, command_block_output, send_command_feedback, players_sleeping_percentage and fire_spread_radius_around_player, which replaced doFireTick (0 stops fire spreading). Before 1.21.11 the same rules were camelCase: keepInventory, doDaylightCycle, doWeatherCycle, doInsomnia and so on.
Since Java 1.21.11 rule names are snake_case (keep_inventory, mob_griefing, advance_time); older versions and most older tutorials use camelCase. Boolean rules take true/false; numeric rules such as random_tick_speed take an integer.
Syntax & Arguments
/gamerule <rule> [<value>]The full syntax is /gamerule <rule> [<value>]. Angle brackets < > mark required arguments and square brackets [ ] mark optional ones; a vertical bar | between words means you pick exactly one of those literals. You must always supply <rule>. The argument [value] may be omitted, in which case the documented default applies.
- rule
- Required, of type a game_rule. The game rule to query or modify, for example keep_inventory, mob_griefing or advance_time. Java 1.21.11 renamed every rule to snake_case; older versions use camelCase names such as keepInventory.
- value
- Optional, of type a boolean|integer. The value to set. Boolean rules accept true/false. Integer rules accept a number. If omitted, the current value is displayed.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| rule | game_rule | Required | The game rule to query or modify, for example keep_inventory, mob_griefing or advance_time. Java 1.21.11 renamed every rule to snake_case; older versions use camelCase names such as keepInventory. |
| value | boolean|integer | Optional | The value to set. Boolean rules accept true/false. Integer rules accept a number. If omitted, the current value is displayed. |
Examples
The 3 examples below are ready to copy and adapt. For instance, /gamerule keep_inventory true players keep their inventory and XP when they die. Each example varies the arguments to show a different real use of /gamerule; read the note under every snippet to see exactly what changes.
/gamerule keep_inventory truePlayers keep their inventory and XP when they die.
/gamerule advance_time falseStops the day-night cycle, freezing time at the current position.
/gamerule random_tick_speed 10Increases the random tick speed to 10 (default 3), making crops grow faster.
Permission Level & Requirements
/gamerule sits at permission Level 2 - Game Master / Cheats, which means it needs permission level 2, the level cheats grant to single-player worlds and that operators hold by default.
In a single-player world you must have "Allow Cheats" turned on (or open the world to LAN with cheats) before it will run; on a multiplayer server the player needs to be an operator at the matching level.
This reference describes the Java Edition 1.21 form of the command; Bedrock Edition may use slightly different argument formats.
Common Mistakes
- Copying a rule name from an older tutorial. Since Java 1.21.11 the names are snake_case, so keepInventory is now keep_inventory and doDaylightCycle is now advance_time.
- Setting random_tick_speed very high. Every chunk section gets that many random ticks per game tick, so big values cause lag.
Notes
Common rules in Java 1.21.11 and later: keep_inventory, mob_griefing, advance_time, advance_weather, spawn_mobs, spawn_phantoms, command_block_output, send_command_feedback, players_sleeping_percentage and fire_spread_radius_around_player, which replaced doFireTick (0 stops fire spreading). Before 1.21.11 the same rules were camelCase: keepInventory, doDaylightCycle, doWeatherCycle, doInsomnia and so on.
Related Commands
If /gamerule is part of your toolkit, the commands below are the ones you will most often reach for alongside it: /difficulty, /time, and /weather. They cover closely related tasks, so the links above jump straight to each one.
Frequently Asked Questions about /gamerule
What does the /gamerule command do in Minecraft?
Sets or queries a game rule. Game rules control various world behaviors like mob griefing, fire spread, keep inventory, and many more. It belongs to the gameplay command group and was first added in Java Edition 1.4.2.
What is the correct syntax for /gamerule?
/gamerule <rule> [<value>]. The required argument is rule, and the optional one is value.
What permission level does /gamerule need?
It requires permission Level 2 - Game Master / Cheats. On a server the player must be an operator at that level, or have cheats enabled in single-player.
What is a common mistake when using /gamerule?
Copying a rule name from an older tutorial. Since Java 1.21.11 the names are snake_case, so keepInventory is now keep_inventory and doDaylightCycle is now advance_time.
Can you give an example of /gamerule in use?
Yes. /gamerule advance_time false: stops the day-night cycle, freezing time at the current position.
How do I keep my items when I die?
Run /gamerule keep_inventory true (on versions before 1.21.11 the rule is called keepInventory). Players then keep their items and experience when they die. Set it back to false to get the normal drops again.
Need a Minecraft server?
Try these commands on Astroworld or host your own server.
Try Astroworld Hosting