Commands/infobox
Sets or queries a game rule value.
- Syntax
- Java Edition
gamerule <rule name> [value]
- Pocket Edition
gamerule <rule: string> <value: bool>gamerule <rule: string> <value: int>gamerule [rule: string]
- Arguments
- rule name (PE: rule: string)
- Specifies the game rule to set or query. May be any value, but only certain predefined game rules will affect gameplay (see Predefined Game Rules below).
- value (PE: value: bool or value: int) (optional)
- Specifies the value to set the game rule to. May be any value, though only
trueorfalsespecified for predefined game rules will really affect gameplay, except in the case ofmaxEntityCramming,randomTickSpeedandspawnRadius, where any integer 0 or greater will affect gameplay (see Predefined Game Rules below).
- Specifies the value to set the game rule to. May be any value, though only
Predefined Game Rules
Rule Name
Description
Default Value
Java Edition
Pocket Edition
announceAdvancements
Whether advancements should be announced in chat
true
Yes
No
commandBlockOutput
(PE: commandblockoutput)
Whether command blocks should notify admins when they perform commands
true
Yes
Yes
disableElytraMovementCheck
Whether the server should skip checking player speed when the player is wearing elytra. Often helps with jittering due to lag in multiplayer, but may also be used to travel unfairly long distances in survival mode (cheating).
false
Yes
No
doDaylightCycle
(PE: dodaylightcycle)
Whether the day-night cycle and moon phases progress
true
Yes
Yes
doEntityDrops
(PE: doentitydrops)
Whether entities that are not mobs should have drops
true
Yes
Yes
doFireTick
(PE: dofiretick)
Whether fire should spread and naturally extinguish
true
Yes
Yes
doLimitedCrafting
Whether players should only be able to craft recipes that they've unlocked first
false
Yes
No
doMobLoot
(PE: domobloot)
Whether mobs should drop items
true
Yes
Yes
doMobSpawning
(PE: domobspawning)
Whether mobs should naturally spawn. Does not affect monster spawners.
true
Yes
Yes
doTileDrops
(PE: dotiledrops)
Whether blocks should have drops
true
Yes
Yes
doWeatherCycle
(PE: doweathercycle)
Whether the weather will change
true
Yes
Yes
drowningdamage
Whether the player should take damage when drowning
true
No
Yes
falldamage
Whether the player should take fall damage
true
No
Yes
firedamage
Whether the player should take fire damage
true
No
Yes
gameLoopFunction
The function to run every game tick
-
Yes
No
keepInventory
(PE: keepinventory)
Whether the player should keep items in their inventory after death
false
Yes
Yes
logAdminCommands
Whether to log admin commands to server log
true
Yes
No
maxCommandChainLength
Determines the number at which the chain command block acts as a "chain".
65536
Yes
No
maxEntityCramming
The maximum number of other pushable entities a mob or player can push, before taking 3
suffocation damage per half-second. Setting to 0 disables the rule. Damage affects survival-mode or adventure-mode players, and all mobs but bats. Pushable entities include non-spectator-mode players, any mob except bats, as well as boats and minecarts.
24
Yes
No
mobGriefing
(PE: mobgriefing)
Whether creepers, zombies, endermen, ghasts, withers, ender dragons, rabbits, sheep, and villagers should be able to change blocks and whether villagers, zombies, skeletons, and zombie pigmen can pick up items
true
Yes
Yes
naturalRegeneration
Whether the player can regenerate health naturally if their hunger is full enough (doesn't affect external healing, such as golden apples, the Regeneration effect, etc.)
true
Yes
No
pvp
Whether the player can fight with other player
true
No
Yes
randomTickSpeed
How often a random block tick occurs (such as plant growth, leaf decay, etc.) per chunk section per game tick. 0 will disable random ticks, higher numbers will increase random ticks. Setting to a high integer results in high speeds of decay and growth
3
Yes
No
reducedDebugInfo
Whether the debug screen shows all or reduced information; and whether the effects of F3 + B (entity hitboxes) and F3 + G (chunk boundaries) are shown.
false
Yes
No
sendCommandFeedback
(PE: sendcommandfeedback)
Whether the feedback from commands executed by a player should show up in chat. Also affects the default behavior of whether command blocks store their output text
true
Yes
Yes
showDeathMessages
Whether death messages are put into chat when a player dies. Also affects whether a message is sent to the pet's owner when the pet dies.
true
Yes
No
spawnRadius
The number of blocks outward from the world spawn coordinates that a player will spawn in when first joining a server or when dying without a spawnpoint.
10
Yes
No
spectatorsGenerateChunks
Whether players in spectator mode can generate chunks
true
Yes
No
- Result
- Fails if rule name is not defined and value is not provided (i.e., attempting to query an undefined game rule).
- On success, returns the value of the game rule (if value is not provided) or sets the game rule to the specified value (if value is provided).
- New game rules may be defined and set (by providing a value) or queried (by not providing a value).
- Examples
- To stop the day-night cycle:
gamerule doDaylightCycle false
- To stop natural healing:
gamerule naturalRegeneration false
- To define a new game rule called
myNewRule and sets its value to 10: gamerule myNewRule 10