Commands/gamerule

Sets or queries a game rule value.

Syntax

 * Java Edition


 * 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 ⇭⇭⇭ are case sensitive. Arguments ⇭⇭⇭ are shown for tab autocompletion as lowercase, but when typed are case-insensitive.

(BE:  or  )
 * Specifies the game rule to set or query. Must be one of predefined game rules in the table below.

(BE:  or  ) (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 the table below).

Additional behavior
This section explains 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, item frames will still drop themselves and their items.
 * When false, the player will still lose air, but will not take damage when the air is depleted.
 * When true, players will also retain their experience upon death.
 * When true, health and hunger are still reset as normal upon death.
 * 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. They will still act as if they are eating the grass and will regrow their wool upon doing so, but the grass will remain and the grass breaking sound does not play.
 * 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.
 * Ravagers from destroying crops and leaves.
 * Sheep from turning grass blocks into dirt, but does not prevent the regrowth of wool. They will still act as if they are eating the grass and will regrow their wool upon doing so, but the grass will remain and the grass breaking sound does not play.
 * 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.

Result
Fails if the arguments are not specified correctly.

On success, returns the value of the game rule (if  is not provided) or sets the game rule to the specified value (if   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:

History
Befehl/gamerule Команды консоли/gamerule Команди консолі/gamerule 命令/gamerule