Commands/gamerule
gamerule
Restrictions | |
---|---|
First introduced |
Java Edition 1.4.2 (Java Edition 12w32a) |
Sets or queries a game rule value.
Syntax[edit]
- Java Edition
gamerule <rule name> [value]
- Arguments in Java Edition are case sensitive.
- Bedrock Edition
gamerule <rule: BoolGameRule> [true|false]
gamerule <rule: IntGameRule> [value: int]
Arguments[edit]
- Arguments in Bedrock Edition are shown for tab autocompletion as lowercase, but when typed are case-insensitive.
- rule name (BE: rule: BoolGameRule)
- Specifies the game rule to set or query. Only certain predefined game rules affect gameplay (see Predefined Game Rules below).
- value (BE: true|false or value: int) (optional)
- Specifies the value to set the game rule to. Only
true
orfalse
specified for predefined game rules can affect gameplay, except in the case ofmaxEntityCramming
,randomTickSpeed
,spawnRadius
, andmaxCommandChainLength
where any integer 0 or greater affects gameplay (see Predefined game rules below).
- Specifies the value to set the game rule to. Only
Predefined game rules Rule name Description Default value Type Java Edition Bedrock Edition announceAdvancements
Whether advancements should be announced in chat true
Bool Yes No commandBlocksEnabled
Whether command blocks should be enabled in-game true
Bool No Yes commandBlockOutput
Whether command blocks should notify admins when they perform commands true
Bool 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
Bool Yes No disableRaids
Whether raids are disabled. false
Bool Yes No doDaylightCycle
Whether the day-night cycle and moon phases progress true
Bool Yes Yes doEntityDrops
Whether entities that are not mobs should have drops true
Bool Yes Yes doFireTick
Whether fire should spread and naturally extinguish true
Bool Yes Yes doInsomnia
Whether phantoms can spawn in the nighttime true
Bool Planned Yes doImmediateRespawn
Players respawn immediately without showing the death screen (Bedrock: immediateRespawn
)false
Bool Planned Yes doLimitedCrafting
Whether players should be able to craft only those recipes that they've unlocked first false
Bool Yes No doMobLoot
Whether mobs should drop items true
Bool Yes Yes doMobSpawning
Whether mobs should naturally spawn. Does not affect monster spawners. true
Bool Yes Yes doTileDrops
Whether blocks should have drops true
Bool Yes Yes doWeatherCycle
Whether the weather can change true
Bool Yes Yes drowningDamage
Whether the player should take damage when drowning true
Bool Planned Yes fallDamage
Whether the player should take fall damage true
Bool Planned Yes fireDamage
Whether the player should take fire damage true
Bool Planned Yes keepInventory
Whether the player should keep items in their inventory after death false
Bool Yes Yes logAdminCommands
Whether to log admin commands to server log true
Bool Yes No maxCommandChainLength
Determines the number at which the chain command block acts as a "chain". 65536
Int Yes Yes 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
Int Yes No mobGriefing
Whether creepers, zombies, endermen, ghasts, withers, ender dragons, rabbits, sheep, villagers, and snow golems should be able to change blocks and whether mobs can pick up items. This also affects the capability of zombie-like creatures like Zombie Pigman and Drowned to pathfind to Turtle Eggs true
Bool 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
Bool Yes Yes pvp
Whether the player can fight with other players true
Bool No Yes randomTickSpeed
How often a random block tick occurs (such as plant growth, leaf decay, etc.) per chunk section per game tick. 0 disables random ticks, higher numbers increase random ticks. Setting to a high integer results in high speeds of decay and growth 1
[BE only]3
[JE only]Int Yes Yes 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
Bool Yes No 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
Bool Yes Yes showCoordinates
Whether the player's coordinates are displayed true
Bool No 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
Bool Yes Yes spawnRadius
The number of blocks outward from the world spawn coordinates that a player spawns in when first joining a server or when dying without a personal spawnpoint. 10
[JE only]5
[BE only]Int Yes Yes spectatorsGenerateChunks
Whether players in spectator mode can generate chunks true
Bool Yes No tntExplodes
Whether TNT explodes after activation true
Bool No Yes
Result[edit]
- Fails if rule name is not defined and value is not provided (i.e., attempting to query an undefined game rule), or if "rule name is not a predefined game rule [Java Edition only].
- 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).
Examples[edit]
- To stop the day-night cycle:
gamerule doDaylightCycle false
- To stop natural healing:
gamerule naturalRegeneration false
- To stop creepers, ghasts and other mobs from modifying blocks:
gamerule mobGriefing false
- To stop the natural cycle of weather:
gamerule doWeatherCycle false
- For the player, so that they can keep all of their valuables when they die:
gamerule keepInventory true
- To stop TNT from exploding:[Bedrock Edition only]
gamerule tntExplodes false
- To make it so the player can't get health back from eating (only from regeneration or healing potions, or golden apples):
gamerule naturalRegeneration false
- To stop the day-night cycle:
Additional behavior[edit]
This section is dedicated to explaining more complex behaviors of certain gamerules.[more information needed]
disableRaids
- When true, the Bad Omen effect is not removed from a player when entering a village.
- Stops a raid if set to true while a raid is in progress, but the existing raid mobs do not despawn.
doEntityDrops
- When false, items cannot be removed from item frames.
doMobSpawning
- Affects only natural mob spawning. Mobs from structures, spawners, and events still spawn when set to false.[more information needed]
doTileDrops
- When false, containers still drop their contents, but not themselves.
- Shulker boxes do not drop anything, causing the items in them to be lost.
- When false, destroying an armor stand does not drop it nor any armor it had equipped.
- When false, containers still drop their contents, but not themselves.
drowningDamage
[Bedrock Edition only][upcoming: JE 1.15]- When false, the player will still lose air, but will not take damage when the air is depleted.
mobGriefing
- When false, prevents:
- All mobs from:
- Trampling crops.
- Picking up items.
- Blazes from creating fire or lighting campfires.
- Creepers from destroying blocks when they explode, although they still damage entities.
- The ender dragon from destroying blocks, causing it to just fly through them instead.
- Endermen from picking up or placing blocks.
- Foxes from picking sweet berries from a sweet berry bush.
- Ghast fireballs from exploding blocks and creating fire. They will still damage entities.
- Rabbits from eating carrot crops.
- Ravagers from destroying crops and leaves.
- Sheep from turning grass blocks into dirt, but does not prevent the regrowth of wool.[more information needed]
- Snow golems from creating snow trails.
- Villagers from farming and picking up items. However, they can still open doors and throw items.
- The wither and its heads from destroying blocks with their explosions. Entities will still be damaged, and wither roses will drop as an item.
- Zombies from breaking doors.
- All mobs from:
- Has no effect on the player.
- When false, prevents:
History[edit]
Java Edition | |||||
---|---|---|---|---|---|
1.4.2 | 12w32a | Added /gamerule .
| |||
Added /gamerule doFireTick .
| |||||
Added /gamerule mobGriefing .
| |||||
Added /gamerule keepInventory .
| |||||
Added /gamerule doMobSpawning .
| |||||
Added /gamerule doMobLoot .
| |||||
Added /gamerule doTileDrops . | |||||
? | Added /gamerule commandBlockOutput . | ||||
1.6.1 | 13w23a | Added /gamerule naturalRegeneration . | |||
13w24a | Added /gamerule doDaylightCycle . | ||||
1.8 | 14w03a | Added /gamerule logAdminCommands . | |||
14w10a | Added /gamerule showDeathMessages . | ||||
14w17a | Added /gamerule randomTickSpeed . | ||||
14w26a | Added /gamerule sendCommandFeedback . | ||||
14w29a | Added the ability to create dummy gamerules. | ||||
1.8.1 | pre1 | Added /gamerule doEntityDrops .
| |||
/gamerule doTileDrops no longer affects entities. | |||||
1.9 | 15w37a | Added /gamerule spectatorsGenerateChunks . | |||
15w51a | Added /gamerule spawnRadius . | ||||
16w07a | Added /gamerule disableElytraMovementCheck . | ||||
1.11 | 16w38a | Added /gamerule doWeatherCycle .
| |||
Added /gamerule maxEntityCramming . | |||||
1.12 | 17w13a | Added /gamerule doLimitedCrafting . | |||
17w16b | Added /gamerule maxCommandChainLength . | ||||
17w18a | Added /gamerule announceAdvancements . | ||||
pre1 | Added /gamerule gameLoopFunction . | ||||
1.13 | 17w45a | /gamerule no longer accepts unknown values (dummy gamerules).
| |||
Values to /gamerule are now type-checked. | |||||
17w49b | Removed /gamerule gameLoopFunction . | ||||
1.14.3 | pre3 | Added /gamerule disableRaids . | |||
? | Added /gamerule reducedDebugInfo . | ||||
Upcoming Java Edition | |||||
1.15 | 19w36a | Added /gamerule doInsomnia .
| |||
Added /gamerule doImmediateRespawn .
| |||||
Added /gamerule drowningDamage .
| |||||
Added /gamerule fallDamage .
| |||||
Added /gamerule fireDamage . | |||||
Pocket Edition | |||||
1.0.5 | alpha 1.0.5.0 | Added /gamerule .
| |||
Added /gamerule drowningDamage .
| |||||
Added /gamerule fallDamage .
| |||||
Added /gamerule fireDamage .
| |||||
Added /gamerule pvp . | |||||
1.1.0 | alpha 1.1.0.0 | Added /gamerule doDaylightCycle .
| |||
Added /gamerule doEntityDrops .
| |||||
Added /gamerule doFireTick .
| |||||
Added /gamerule doMobSpawning .
| |||||
Added /gamerule doMobLoot .
| |||||
Added /gamerule doTileDrops .
| |||||
Added /gamerule doWeatherCycle .
| |||||
Added /gamerule keepInventory .
| |||||
Added /gamerule mobGriefing . | |||||
Bedrock Edition | |||||
1.6.0 | beta 1.6.0.6 | Added /gamerule doInsomnia . | |||
1.7.0 | beta 1.7.0.2 | Added /gamerule commandBlocksEnabled . | |||
1.8.0 | beta 1.8.0.8 | Added /gamerule randomTickSpeed . | |||
1.9.0 | beta 1.9.0.0 | Added /gamerule showDeathMessages .
| |||
Added /gamerule immediateRespawn . | |||||
1.12.0 | beta 1.12.0.2 | Added /gamerule spawnRadius .
| |||
Added /gamerule sendCommandBlockFeedback . | |||||
? | Added /gamerule commandBlockOutput .
| ||||
Added /gamerule maxCommandChainLength .
| |||||
Added /gamerule naturalRegeneration .
| |||||
Added /gamerule sendCommandFeedback .
| |||||
Added /gamerule showCoordinates .
| |||||
Added /gamerule tntExplodes . | |||||
Upcoming Bedrock Edition | |||||
1.14.0 | beta 1.14.0.51 | Added /gamerule showtags . |