/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 and has been available since version 1.4.
It is invoked as /gamerule and accepts one required argument (
There are many game rules in Java Edition. Common ones: keepInventory, mobGriefing, doDaylightCycle, doWeatherCycle, doFireTick, commandBlockOutput, sendCommandFeedback, doInsomnia, playersSleepingPercentage.
Rule names are camelCase (keepInventory, mobGriefing, doDaylightCycle). Boolean rules take true/false; numeric rules such as randomTickSpeed take an integer.
Syntax & Arguments
/gamerule <rule> [<value>]The full syntax is /gamerule . 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
- Required, of type a game_rule. The game rule to query or modify (e.g., keepInventory, mobGriefing, doDaylightCycle).
- 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 (e.g., keepInventory, mobGriefing, doDaylightCycle). |
| 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 keepInventory 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 keepInventory truePlayers keep their inventory and XP when they die.
/gamerule doDaylightCycle falseStops the day-night cycle, freezing time at the current position.
/gamerule randomTickSpeed 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
- Using the wrong case, game rule names are camelCase (keepInventory, not keepinventory).
- Setting randomTickSpeed too high, values over 1000 can cause severe lag from rapid block updates.
Notes
There are many game rules in Java Edition. Common ones: keepInventory, mobGriefing, doDaylightCycle, doWeatherCycle, doFireTick, commandBlockOutput, sendCommandFeedback, doInsomnia, playersSleepingPercentage.
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 added in Java Edition 1.4.
What is the correct syntax for /gamerule?
/gamerule
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?
Using the wrong case, game rule names are camelCase (keepInventory, not keepinventory).
Can you give an example of /gamerule in use?
Yes. /gamerule doDaylightCycle false — stops the day-night cycle, freezing time at the current position.
How do I keep my items when I die?
Run /gamerule keepInventory true. Players then retain their inventory and experience on death. Set it back to false to restore vanilla drop-on-death behaviour.
Need a Minecraft server?
Try these commands on Astroworld or host your own server.
Try Astroworld Hosting