Commands/gamerule

Sets or queries a game rule value.

Syntax

 * Java Edition
 * Arguments $$ are case sensitive.
 * Arguments $$ are case sensitive.


 * Bedrock Edition
 * ⇭⇭⇭⇭⇭, gamerules can also be changed in the world options.
 * ⇭⇭⇭⇭⇭, gamerules can also be changed in the world options.
 * ⇭⇭⇭⇭⇭, gamerules can also be changed in the world options.

Arguments

 * 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  or   specified for predefined game rules can affect gameplay, except in the case of ,  ,  , and   where any integer 0 or greater affects gameplay (see Predefined game rules below).


 * {| class="wikitable sortable"

! Rule name !class="unsortable"| Description ! Default value ! Type ! Java Edition ! Bedrock Edition
 * + Predefined game rules
 * Whether advancements should be announced in chat
 * style="text-align:center" |
 * Bool
 * Whether command blocks should be enabled in-game
 * style="text-align:center" |
 * Bool
 * Whether command blocks should notify admins when they perform commands
 * style="text-align:center" |
 * Bool
 * 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).
 * style="text-align:center" |
 * Bool
 * Whether raids are disabled.
 * style="text-align:center" |
 * Bool
 * Whether the day-night cycle and moon phases progress
 * style="text-align:center" |
 * Bool
 * Whether entities that are not mobs should have drops
 * style="text-align:center" |
 * Bool
 * Whether fire should spread and naturally extinguish
 * style="text-align:center" |
 * Bool
 * Whether phantoms can spawn in the nighttime
 * style="text-align:center" |
 * Bool
 * Players respawn immediately without showing the death screen (Bedrock: )
 * style="text-align:center" |
 * Bool
 * Whether players should be able to craft only those recipes that they've unlocked first
 * style="text-align:center" |
 * Bool
 * Whether mobs should drop items
 * style="text-align:center" |
 * Bool
 * Whether mobs should naturally spawn. Does not affect monster spawners.
 * style="text-align:center" |
 * Bool
 * Controls the spawning of patrols
 * style="text-align:center" |
 * Bool
 * Whether blocks should have drops
 * style="text-align:center" |
 * Bool
 * Controls the spawning of wandering traders
 * style="text-align:center" |
 * Bool
 * Whether the weather can change
 * style="text-align:center" |
 * Bool
 * Whether the player should take damage when drowning
 * style="text-align:center" |
 * Bool
 * Whether the player should take fall damage
 * style="text-align:center" |
 * Bool
 * Whether the player should take fire damage
 * style="text-align:center" |
 * Bool
 * Whether the player should keep items in their inventory after death
 * style="text-align:center" |
 * Bool
 * Whether to log admin commands to server log
 * style="text-align:center" |
 * Bool
 * Determines the number at which the chain command block acts as a "chain".
 * style="text-align:center" |
 * Int
 * The maximum number of other pushable entities a mob or player can push, before taking 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.
 * style="text-align:center" |
 * Int
 * 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 pigmen and drowned to pathfind to turtle eggs. This will also prevent villagers from breeding.
 * style="text-align:center" |
 * Bool
 * 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.)
 * style="text-align:center" |
 * Bool
 * Whether the player can fight with other players
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Int
 * Whether the debug screen shows all or reduced information; and whether the effects of (entity hitboxes) and  (chunk boundaries) are shown.
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Bool
 * Whether the player's coordinates are displayed
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * style="text-align:center" |
 * Bool
 * Whether the weather can change
 * style="text-align:center" |
 * Bool
 * Whether the player should take damage when drowning
 * style="text-align:center" |
 * Bool
 * Whether the player should take fall damage
 * style="text-align:center" |
 * Bool
 * Whether the player should take fire damage
 * style="text-align:center" |
 * Bool
 * Whether the player should keep items in their inventory after death
 * style="text-align:center" |
 * Bool
 * Whether to log admin commands to server log
 * style="text-align:center" |
 * Bool
 * Determines the number at which the chain command block acts as a "chain".
 * style="text-align:center" |
 * Int
 * The maximum number of other pushable entities a mob or player can push, before taking 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.
 * style="text-align:center" |
 * Int
 * 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 pigmen and drowned to pathfind to turtle eggs. This will also prevent villagers from breeding.
 * style="text-align:center" |
 * Bool
 * 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.)
 * style="text-align:center" |
 * Bool
 * Whether the player can fight with other players
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Int
 * Whether the debug screen shows all or reduced information; and whether the effects of (entity hitboxes) and  (chunk boundaries) are shown.
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Bool
 * Whether the player's coordinates are displayed
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * 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 pigmen and drowned to pathfind to turtle eggs. This will also prevent villagers from breeding.
 * style="text-align:center" |
 * Bool
 * 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.)
 * style="text-align:center" |
 * Bool
 * Whether the player can fight with other players
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Int
 * Whether the debug screen shows all or reduced information; and whether the effects of (entity hitboxes) and  (chunk boundaries) are shown.
 * style="text-align:center" |
 * Bool
 * 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
 * style="text-align:center" |
 * Bool
 * Whether the player's coordinates are displayed
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * style="text-align:center" |
 * Bool
 * Whether the player's coordinates are displayed
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Bool
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * Whether TNT explodes after activation
 * style="text-align:center" |
 * Bool
 * style="text-align:center" |
 * Bool
 * }
 * style="text-align:center" |
 * Bool
 * }
 * style="text-align:center" |
 * Bool
 * }
 * }
 * }
 * }

Result

 * 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.
 * 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

 * To stop the day-night cycle:
 * To stop natural healing:
 * To stop creepers, ghasts and other mobs from modifying blocks:
 * To stop the natural cycle of weather:
 * For the player, so that they can keep all of their valuables when they die:
 * To stop TNT from exploding:
 * To make it so the player can't get health back from eating (only from regeneration or healing potions, or golden apples):

Additional behavior
This section is dedicated to explaining more complex behaviors of certain gamerules.
 * 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.
 * When false, items cannot be removed from item frames.
 * Affects only natural mob spawning. Mobs from structures, spawners, and events still spawn when set to false.
 * 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, the player will still lose air, but will not take damage when the air is depleted.
 * 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.
 * 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.
 * Has no effect on the player.
 * Sheep from turning grass blocks into dirt, but does not prevent the regrowth of wool.
 * 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.
 * Has no effect on the player.

History
{{History||1.15|snap=19w36a|Added {{cmd|gamerule|doInsomnia|link=none}}. {{History|upcoming java}} {{History||1.15.2|snap=pre1|Added {{cmd|gamerule|doPatrolSpawning|link=none}}. }}
 * Added {{cmd|gamerule|doImmediateRespawn|link=none}}.
 * Added {{cmd|gamerule|drowningDamage|link=none}}.
 * Added {{cmd|gamerule|fallDamage|link=none}}.
 * Added {{cmd|gamerule|fireDamage|link=none}}.
 * Added {{cmd|gamerule|doTraderSpawning|link=none}}.

{{History|pocket}} {{History||1.0.5|snap=alpha 1.0.5.0|Added {{cmd|gamerule|link=none}}. {{History||1.1.0|snap=alpha 1.1.0.0|Added {{cmd|gamerule|doDaylightCycle|link=none}}. {{History|bedrock}} {{History||1.6.0|snap=beta 1.6.0.6|Added {{cmd|gamerule|doInsomnia|link=none}}.}} {{History||1.7.0|snap=beta 1.7.0.2|Added {{cmd|gamerule|commandBlocksEnabled|link=none}}.}} {{History||1.8.0|snap=beta 1.8.0.8|Added {{cmd|gamerule|randomTickSpeed|link=none}}.}} {{History||1.9.0|snap=beta 1.9.0.0|Added {{cmd|gamerule|showDeathMessages|link=none}}. {{History||1.12.0|snap=beta 1.12.0.2|Added {{cmd|gamerule|spawnRadius|link=none}}. {{History||?|Added {{cmd|gamerule|commandBlockOutput|link=none}}. {{History||1.14.0|Added {{cmd|gamerule|showtags|link=none}}.}} {{History|foot}}
 * Added {{cmd|gamerule|drowningDamage|link=none}}.
 * Added {{cmd|gamerule|fallDamage|link=none}}.
 * Added {{cmd|gamerule|fireDamage|link=none}}.
 * Added {{cmd|gamerule|pvp|link=none}}.}}
 * Added {{cmd|gamerule|doEntityDrops|link=none}}.
 * Added {{cmd|gamerule|doFireTick|link=none}}.
 * Added {{cmd|gamerule|doMobSpawning|link=none}}.
 * Added {{cmd|gamerule|doMobLoot|link=none}}.
 * Added {{cmd|gamerule|doTileDrops|link=none}}.
 * Added {{cmd|gamerule|doWeatherCycle|link=none}}.
 * Added {{cmd|gamerule|keepInventory|link=none}}.
 * Added {{cmd|gamerule|mobGriefing|link=none}}.}}
 * Added {{cmd|gamerule|immediateRespawn|link=none}}.}}
 * Added {{cmd|gamerule|sendCommandBlockFeedback|link=none}}.}}
 * Added {{cmd|gamerule|maxCommandChainLength|link=none}}.
 * Added {{cmd|gamerule|naturalRegeneration|link=none}}.
 * Added {{cmd|gamerule|sendCommandFeedback|link=none}}.
 * Added {{cmd|gamerule|showCoordinates|link=none}}.
 * Added {{cmd|gamerule|tntExplodes|link=none}}.}}

{{Commands}}

Befehl/gamerule 命令/gamerule