Commands/gamerule

From Minecraft Wiki
Jump to: navigation, search
gamerule
Restrictions

Operator

First introduced

1.4.2 (12w32a)
PE 1.0.5 (PE 1.0.5 build 1)

Sets or queries a game rule value.

Syntax
  • Java Edition
gamerule <rule name> [value]
Arguments in Java Edition are case sensitive.
  • Bedrock Edition
gamerule <rule: string> <value: bool>
gamerule <rule: string> <value: int>
gamerule [rule: string]
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[until 1.13], 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[until 1.13], though only true or false specified for predefined game rules will really affect gameplay, except in the case of maxEntityCramming, randomTickSpeed and spawnRadius, where any integer 0 or greater will affect gameplay (see Predefined Game Rules below).
Predefined Game Rules
Rule Name Description Default Value Type Java Edition Bedrock Edition
announceAdvancements Whether advancements should be announced in chat true Bool Yes No
commandBlockOutput Whether command blocks should notify admins when they perform commands true Bool Yes Yes
disableElytraMovementCheck 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). false Bool Yes No
doDaylightCycle Whether the day-night cycle and moon phases progress true Bool Yes Yes
doEntityDrops Whether entities that are not mobs should have drops true Bool Yes Yes
doFireTick Whether fire should spread and naturally extinguish true Bool Yes Yes
doLimitedCrafting Whether players should only be able to craft recipes that they've unlocked first false Bool Yes No
doMobLoot Whether mobs should drop items true Bool Yes Yes
doMobSpawning Whether mobs should naturally spawn. Does not affect monster spawners. true Bool Yes Yes
doTileDrops Whether blocks should have drops true Bool Yes Yes
doWeatherCycle Whether the weather will change true Bool Yes Yes
drowningdamage Whether the player should take damage when drowning true Unknown No Yes
falldamage Whether the player should take fall damage true Unknown No Yes
firedamage Whether the player should take fire damage true Unknown No Yes
gameLoopFunction[until 1.13] The function to run every game tick - Function Yes No
keepInventory Whether the player should keep items in their inventory after death false Bool Yes Yes
logAdminCommands Whether to log admin commands to server log true Bool Yes No
maxCommandChainLength Determines the number at which the chain command block acts as a "chain". 65536 Int Yes No
maxEntityCramming The maximum number of other pushable entities a mob or player can push, before taking 3 (Heart.svgHalf Heart.svg) 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. 24 Int Yes No
mobGriefing 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 true Bool Yes Yes
naturalRegeneration 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.) true Bool Yes Yes
pvp Whether the player can fight with other player true Unknown No Yes
randomTickSpeed 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 3 Int Yes No
reducedDebugInfo Whether the debug screen shows all or reduced information; and whether the effects of F3+B (entity hitboxes) and F3+G (chunk boundaries) are shown. false Bool Yes No
sendCommandFeedback 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 true Bool Yes Yes
showcoordinates Whether the player's coordinates are displayed true Bool No Yes
showDeathMessages 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. true Bool Yes No
spawnRadius 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. 10 Int Yes No
spectatorsGenerateChunks Whether players in spectator mode can generate chunks true Bool Yes No
tntexplodes Whether TNT will explode true Bool No Yes
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).[until 1.13][Java Edition only]
Examples
  • To stop the day-night cycle: gamerule doDaylightCycle false
  • To stop natural healing: gamerule naturalRegeneration false
  • To define a new game rule called myNewRule and sets its value to 10: gamerule myNewRule 10[until 1.13]
  • To stop creepers, ghasts and other block changing things: gamerule mobGriefing false
  • To stop the natural cycle of weather: gamerule doWeatherCycle false
  • To keep all of your valuables when you die: gamerule keepInventory True


Promotional Content