Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/gamerule: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
Line 4: Line 4:
* 2 {{only|java|short=1}}
* 2 {{only|java|short=1}}
* 1 {{only|bedrock|short=1}}
* 1 {{only|bedrock|short=1}}
|others=Cheat only for some rules{{only|bedrock|short=1}}
|others=[[Minecraft:Cheat]] only for some rules{{only|bedrock|short=1}}
}}
}}


Sets or queries a game rule value.
Sets or queries a [[Minecraft:game rule]] value.


==Syntax==
==Syntax==
Line 17: Line 17:
: <code>gamerule <rule: BoolGameRule> [value: Boolean]</code>
: <code>gamerule <rule: BoolGameRule> [value: Boolean]</code>
: <code>gamerule <rule: IntGameRule> [value: int]</code><!--
: <code>gamerule <rule: IntGameRule> [value: int]</code><!--
: {{MC/In|bedrock}}, gamerules can also be changed in the world options and certain gamerules can be toggled on and off with the command without cheats enabled. This only works in singleplayer, server gamerules and server settings cannot be adjusted using the client settings, even if a player is opped.-->
: {{IN|bedrock}}, gamerules can also be changed in the world options and certain gamerules can be toggled on and off with the command without cheats enabled. This only works in singleplayer, server gamerules and server settings cannot be adjusted using the client settings, even if a player is opped.-->


==Arguments==
==Arguments==


Arguments {{MC/In|java}} are case sensitive. Arguments {{MC/In|bedrock}} are shown for tab autocompletion as lowercase, but when typed are case-insensitive.  
Arguments {{in|java}} are case sensitive. Arguments {{in|bedrock}} are shown for tab autocompletion as lowercase, but when typed are case-insensitive.  


{{MC/El|je|short=1}}: {{MC/Argument|''rule name''}}<br>
{{el|je|short=1}}: {{argument|''rule name''}}<br>
{{MC/El|be|short=1}}: {{MC/Argument|be=1|rule: BoolGameRule|enum}} and {{MC/Argument|be=1|rule: IntGameRule|enum}}
{{el|be|short=1}}: {{argument|be=1|rule: BoolGameRule|enum}} and {{argument|be=1|rule: IntGameRule|enum}}
: Specifies the game rule to set or query.
: Specifies the game rule to set or query.
: Must be one of the predefined game rules; see Game rule.
: Must be one of the predefined game rules; see [[Minecraft:Game rule]].


{{MC/El|je|short=1}}: {{MC/Argument|value}}<br>
{{el|je|short=1}}: {{argument|value}}<br>
{{MC/El|be|short=1}}: {{MC/Argument|be=1|value: Boolean|enum}} and {{MC/Argument|be=1|value: int|int}}
{{el|be|short=1}}: {{argument|be=1|value: Boolean|enum}} and {{argument|be=1|value: int|int}}
: Specifies the value to set the game rule to. If not specified, queries the value of the game rule instead of setting it.
: Specifies the value to set the game rule to. If not specified, queries the value of the game rule instead of setting it.
: Only <code>true</code> or <code>false</code> specified for predefined game rules can affect gameplay, except in the case of <code>maxEntityCramming</code>, <code>randomTickSpeed</code>, <code>spawnRadius</code>, <code>playersSleepingPercentage</code>, <code>functionCommandLimit</code> and <code>maxCommandChainLength</code> where any integer (-2147483648~2147483647) affects gameplay; see Game rule.
: Only <code>true</code> or <code>false</code> specified for predefined game rules can affect gameplay, except in the case of <code>maxEntityCramming</code>, <code>randomTickSpeed</code>, <code>spawnRadius</code>, <code>playersSleepingPercentage</code>, <code>functionCommandLimit</code> and <code>maxCommandChainLength</code> where any integer (-2147483648~2147483647) affects gameplay; see [[Minecraft:Game rule]].


==Result==
==Result==
Line 42: Line 42:
== Output ==
== Output ==


{{MC/Output table}}
{{Output table}}
{{MC/Output table|edition=je|On success|1|1|the current value of the game rule}}
{{Output table|edition=je|On success|1|1|the current value of the game rule}}
{{MC/Output table|edition=be|On success|1}}
{{Output table|edition=be|On success|1}}
{{MC/Output table}}
{{Output table}}


==Examples==
==Examples==


* To stop the day-night cycle: <code>gamerule advance_time false</code>
* To stop the [[Minecraft:Daylight cycle|day-night cycle]]: <code>gamerule advance_time false</code>
* To stop natural healing: <code>gamerule natural_health_regeneration false</code>
* To stop natural healing: <code>gamerule natural_health_regeneration false</code>
* To stop creepers, ghasts and other [[Minecraft:mob]]s from modifying blocks: <code>gamerule mob_griefing false</code>
* To stop creepers, ghasts and other [[Minecraft:mob]]s from modifying blocks: <code>gamerule mob_griefing false</code>
* To stop the natural cycle of weather: <code>gamerule advance_weather false</code>
* To stop the natural cycle of [[Minecraft:weather]]: <code>gamerule advance_weather false</code>
* To make players keep all of their valuables when they die: <code>gamerule keep_inventory true</code>
* To make players keep all of their valuables when they die: <code>gamerule keep_inventory true</code>
* To stop [[Minecraft:TNT]] from exploding: <code>gamerule tnt_explodes false</code>
* To stop [[Minecraft:TNT]] from exploding: <code>gamerule tnt_explodes false</code>
* To stop command blocks from showing what they do: <code>gamerule command_block_output false</code>
* To stop [[Minecraft:command block]]s from showing what they do: <code>gamerule command_block_output false</code>
*To stop phantoms spawning:<code>gamerule spawn_phantoms false</code>
*To stop [[Minecraft:phantom]]s spawning:<code>gamerule spawn_phantoms false</code>


== History ==
== History ==
=== ''Java Edition'' ===
=== ''Java Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.4.2|dev=12w32a|Added {{MC/Cmd|gamerule|link=none}}.}}
|{{HistoryLine||1.4.2|dev=12w32a|Added {{cmd|gamerule|link=none}}.}}
|{{MC/HistoryLine||1.8|dev=14w29a|Added the ability to create custom dummy gamerules.}}
|{{HistoryLine||1.8|dev=14w29a|Added the ability to create custom dummy gamerules.}}
|{{HistoryLine||1.13|dev=17w45a|{{MC/Cmd|gamerule|link=none}} no longer accepts unknown values (dummy gamerules).
|{{HistoryLine||1.13|dev=17w45a|{{cmd|gamerule|link=none}} no longer accepts unknown values (dummy gamerules).
|Values to {{MC/Cmd|gamerule|link=none}} are now type-checked.}}
|Values to {{cmd|gamerule|link=none}} are now type-checked.}}
}}
}}


=== ''Bedrock Edition'' ===
=== ''Bedrock Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|pocket}}
|{{HistoryLine|pocket}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{MC/Cmd|gamerule|link=none}}.}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{cmd|gamerule|link=none}}.}}
|{{MC/HistoryLine|bedrock}}
|{{HistoryLine|bedrock}}
|{{MC/HistoryLine||?|Command segments <code>rule: BoolGameRule</code> or <code>rule: IntGameRule</code> no longer accept dummy gamerules.}}
|{{HistoryLine||?|Command segments <code>rule: BoolGameRule</code> or <code>rule: IntGameRule</code> no longer accept dummy gamerules.}}
}}
}}


==See also==
==See also==
* {{MC/Cmd|mobevent}} – a command {{MC/In|bedrock}} for controlling the spawning of raids, patrols, and wandering traders
* {{cmd|mobevent}} – a command {{in|bedrock}} for controlling the spawning of raids, patrols, and wandering traders


== External links ==
== External links ==
Line 84: Line 84:


== Navigation ==
== Navigation ==
{{MC/Navbox commands}}
{{Navbox commands}}


de:Befehl/gamerule
[[Minecraft:de:Befehl/gamerule]]
es:Comandos/gamerule
[[Minecraft:es:Comandos/gamerule]]
ja:コマンド/gamerule
[[Minecraft:fr:Commandes/gamerule]]
ko:명령어/gamerule
[[Minecraft:ja:コマンド/gamerule]]
pl:Polecenia/gamerule
[[Minecraft:ko:명령어/gamerule]]
pt:Comandos/gamerule
[[Minecraft:pl:Polecenia/gamerule]]
ru:Команды консоли/gamerule
[[Minecraft:pt:Comandos/gamerule]]
uk:Команди консолі/gamerule
[[Minecraft:ru:Команды консоли/gamerule]]
zh:命令/gamerule
[[Minecraft:uk:Команди консолі/gamerule]]
[[Minecraft:zh:命令/gamerule]]

Latest revision as of 11:03, 17 May 2026

Template:Infobox command

Sets or queries a Minecraft:game rule value.

Syntax

  • Java Edition
gamerule <rule name> [<value>]
  • Bedrock Edition
gamerule <rule: BoolGameRule> [value: Boolean]
gamerule <rule: IntGameRule> [value: int]

Arguments

Arguments Template:In are case sensitive. Arguments Template:In are shown for tab autocompletion as lowercase, but when typed are case-insensitive.

Template:El: Template:Argument
Template:El: Template:Argument and Template:Argument

Specifies the game rule to set or query.
Must be one of the predefined game rules; see Minecraft:Game rule.

Template:El: Template:Argument
Template:El: Template:Argument and Template:Argument

Specifies the value to set the game rule to. If not specified, queries the value of the game rule instead of setting it.
Only true or false specified for predefined game rules can affect gameplay, except in the case of maxEntityCramming, randomTickSpeed, spawnRadius, playersSleepingPercentage, functionCommandLimit and maxCommandChainLength where any integer (-2147483648~2147483647) affects gameplay; see Minecraft:Game rule.

Result

Template:Result table Template:Result table Template:Result table Template:Result table

Output

Template:Output table Template:Output table Template:Output table Template:Output table

Examples

  • To stop the day-night cycle: gamerule advance_time false
  • To stop natural healing: gamerule natural_health_regeneration false
  • To stop creepers, ghasts and other Minecraft:mobs from modifying blocks: gamerule mob_griefing false
  • To stop the natural cycle of Minecraft:weather: gamerule advance_weather false
  • To make players keep all of their valuables when they die: gamerule keep_inventory true
  • To stop Minecraft:TNT from exploding: gamerule tnt_explodes false
  • To stop Minecraft:command blocks from showing what they do: gamerule command_block_output false
  • To stop Minecraft:phantoms spawning:gamerule spawn_phantoms false

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

See also

External links

Navigation

Template:Navbox commands

Minecraft:de:Befehl/gamerule Minecraft:es:Comandos/gamerule Minecraft:fr:Commandes/gamerule Minecraft:ja:コマンド/gamerule Minecraft:ko:명령어/gamerule Minecraft:pl:Polecenia/gamerule Minecraft:pt:Comandos/gamerule Minecraft:ru:Команды консоли/gamerule Minecraft:uk:Команди консолі/gamerule Minecraft:zh:命令/gamerule