Game rule

Game rules are a set of customizable options for a specific in-game world.

Modifying game rules
$$, game rules can be changed using toggle buttons on the "Edit Game Rules" menu built into the "Create World" screen. The game rules are split into categories named "Player", "Mobs", "Spawning", "Drops", "World updates", "Chat", and "Miscellaneous".

$$, many (about half) of the game rules can be changed using toggles on the "World settings" and "Cheats" sections of the world's Game settings screen. The remainder can only be changed with commands.

When in-game, game rules can be changed using the command, using the syntax, where  is the name of the game rule and  is an allowed value, which depends on the type of the game rule. The types are boolean (where the allowed values are either ) and integer (where any whole number is able to be entered).

List of game rules
The following is a list of game rules available in-game, their allowed values, and their availability in and.

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 still drop themselves and their items.
 * When false, the player still loses air, but does not take damage when the air is depleted.
 * When false, the player may still be set on fire, but does not take damage when on fire.
 * Every neutral mob that can be aggravated will remain so even after the offending player dies, with the exception of Piglins when a player does not wear golden armor and Iron Golems when it is created from a village where the player is unpopular.
 * When true, players 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.
 * Trampling turtle eggs.
 * Picking up items.
 * Destroying blocks.
 * Blazes from creating fire or lighting campfires.
 * Creepers from destroying blocks when they explode, although they still damage entities.
 * End crystals 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.
 * Evoker from turning blue sheep red.
 * Foxes from picking sweet berries from a sweet berry bush.
 * Ghast fireballs from exploding blocks and creating fire. They still damage entities.
 * Piglins from attempting to barter by picking up dropped items; using the item on them still works.
 * 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 still act as if they are eating the grass and regrow their wool upon doing so, but the grass remains and the grass breaking sound does not play.
 * Silverfish from hiding in stone and destroying those blocks when hatching.
 * 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 are still damaged, and a wither rose drops as an item.
 * Zombies from breaking doors and attacking turtle eggs.
 * Has no effect on the player.
 * When set to, night is skipped immediately without the falling asleep transition.
 * When set to a number greater than, night will not be skipped no matter how many players are sleeping.
 * Does not affect:
 * Formation of snow and ice.
 * Still affects the melting of snow and ice.
 * Cauldrons filling with water or powder snow while raining or snowing.
 * Still affects filling of water and lava in cauldrons below pointed dripstone.
 * Death of coral blocks, coral and coral fan.
 * Every neutral mob that can be aggravated will target all nearby players whenever they are aggravated.
 * Bees attack all nearby players when their beehive is broken, regardless of the setting of this gamerule.
 * Bees becoming angry when attacked works as expected.
 * When set to a number greater than, night will not be skipped no matter how many players are sleeping.
 * Does not affect:
 * Formation of snow and ice.
 * Still affects the melting of snow and ice.
 * Cauldrons filling with water or powder snow while raining or snowing.
 * Still affects filling of water and lava in cauldrons below pointed dripstone.
 * Death of coral blocks, coral and coral fan.
 * Every neutral mob that can be aggravated will target all nearby players whenever they are aggravated.
 * Bees attack all nearby players when their beehive is broken, regardless of the setting of this gamerule.
 * Bees becoming angry when attacked works as expected.
 * Bees attack all nearby players when their beehive is broken, regardless of the setting of this gamerule.
 * Bees becoming angry when attacked works as expected.