Commands/gamerule

Sets or queries a game rule value.


 * Syntax


 * Java Edition


 * Bedrock Edition


 * Arguments


 * Arguments in Bedrock Edition are shown for tab autocompletion as lowercase, but when typed are case-insensitive.


 * rule name (BE: 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 (BE: value: bool or value: int) (optional)
 * Specifies the value to set the game rule to. May be any value, though only  or   specified for predefined game rules will really affect gameplay, except in the case of ,   and  , where any integer 0 or greater will affect gameplay (see Predefined Game Rules below).


 * {| class=wikitable

! Rule Name ! 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 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 the day-night cycle and moon phases progress
 * style="text-align:center" |
 * Bool
 * Bool
 * Whether fire should spread and naturally extinguish
 * style="text-align:center" |
 * Bool
 * Whether players should only be able to craft 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
 * Whether blocks should have drops
 * style="text-align:center" |
 * Bool
 * Whether the weather will change
 * style="text-align:center" |
 * Bool
 * Whether the player should take damage when drowning
 * style="text-align:center" |
 * Whether the player should take fall damage
 * style="text-align:center" |
 * Whether the player should take fire damage
 * style="text-align:center" |
 * The function to run every game tick
 * style="text-align:center" |
 * Function
 * 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, and villagers should be able to change blocks and whether villagers, zombies, skeletons, and zombie pigmen can pick up items
 * 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 player
 * style="text-align:center" |
 * 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
 * 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 will spawn in when first joining a server or when dying without a spawnpoint.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * style="text-align:center" |
 * Bool
 * }
 * style="text-align:center" |
 * Whether the player should take fire damage
 * style="text-align:center" |
 * The function to run every game tick
 * style="text-align:center" |
 * Function
 * 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, and villagers should be able to change blocks and whether villagers, zombies, skeletons, and zombie pigmen can pick up items
 * 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 player
 * style="text-align:center" |
 * 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
 * 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 will spawn in when first joining a server or when dying without a spawnpoint.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * 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 player
 * style="text-align:center" |
 * 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
 * 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 will spawn in when first joining a server or when dying without a spawnpoint.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * 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 will spawn in when first joining a server or when dying without a spawnpoint.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * style="text-align:center" |
 * Bool
 * }
 * 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.
 * style="text-align:center" |
 * Int
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * style="text-align:center" |
 * Bool
 * }
 * Whether players in spectator mode can generate chunks
 * style="text-align:center" |
 * Bool
 * Whether TNT will explode
 * style="text-align:center" |
 * Bool
 * }
 * Whether TNT will explode
 * 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).


 * 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:
 * To stop natural healing:
 * To define a new game rule called  and sets its value to 10:
 * To stop creepers, ghasts and other block changing things:
 * To stop the natural cycle of weather:
 * To keep all of your valuables when you die: