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

$$, 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 be changed only 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, the Bad Omen effect is not removed from a player when entering a village.
 * Stops a raid if set to while a raid is in progress, but the existing raid mobs do not despawn.
 * When, items cannot be removed from item frames.
 * Does not affect the dropping of wither roses when mobs are killed by the wither.
 * Affects only natural mob spawning. Mobs from structures, monster spawners, and events still spawn when set to.
 * When, containers still drop their contents, but not themselves.
 * Shulker boxes do not drop anything, causing the items in them to be lost.
 * When, destroying an armor stand does not drop it nor any armor it had equipped.
 * When, item frames still drop themselves and their items.
 * When, infested blocks do not spawn silverfish when broken.
 * When, the player still loses air, but does not take damage when the air is depleted.
 * When, the player may still be set on fire, but does not take damage when on fire.
 * Every neutral mob that can be aggravated remain aggravated 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, players also retain their experience upon death.
 * When, health and hunger are still reset as normal upon death.
 * When, all effects are still removed upon death.
 * When, items enchanted with Curse of Vanishing do not disappear upon death.
 * When, prevents all mobs from modifying the environment in any way. This includes trampling crops and turtle eggs, picking up items, destroying blocks, or moving blocks. Specifically, it prevents:
 * Allays from picking up dropped items
 * 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 infested blocks 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, at least one player is still required to sleep to skip the night.
 * When set to a number greater than, night is not skipped no matter how many players are sleeping.
 * Does not affect:
 * Formation of snow and ice.
 * Still affects the melting of snow and ice under high light levels.
 * 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.
 * Hatching of frogspawn and sniffer eggs.
 * When set to, snow layers do not form at all.
 * When set to or higher, snow forms up to the level of a full block, but no greater than that.
 * Every neutral mob that can be aggravated targets 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.
 * Does not affect:
 * Formation of snow and ice.
 * Still affects the melting of snow and ice under high light levels.
 * 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.
 * Hatching of frogspawn and sniffer eggs.
 * When set to, snow layers do not form at all.
 * When set to or higher, snow forms up to the level of a full block, but no greater than that.
 * Every neutral mob that can be aggravated targets 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.