Recently, there were a few posts about creating custom gamerules, but no question or answer covered the creation and usage of custom gamerules. This post tries to uncover this, but it's just a link-only answer to a tutorial I didn't understand.

From version 1.9 (or maybe earlier), you can create custom gamerules, eg.

/gamerule customGamerule false

This will create a gamerule named customGamerule, currently set to false. It can be changed to true and Bach, but without effect. How can one add an effect to a custom gamerule?

  • Custom GameRules no longer exist in 1.13 – pppery Aug 10 '18 at 16:45
  • @ppperry Oh. I guess one can still use a series of scoreboard commands to have the same result. Did those change in 1.13? – RudolfJelin Aug 11 '18 at 9:13
  • The syntax of /scoreboard changed in a few ways in 1.13, and some of it was split into new commands, but the core functionality remained – pppery Aug 11 '18 at 19:21

In order to detect the value of any gamerule (both default and custom), CommandStats must be used, which will set the value of the gamerule as a score. Only the QueryResult trigger will be provided with a return value when running /gamerule <name>.


Objective to hold the value.

/scoreboard objectives add Gamerules dummy

The target of CommandStats must be tracked in the objective in order to obtain the return value. In this case, a fake player named "$customGamerule" will be used to hold the value.

/scoreboard players set $customGamerule Gamerules 0

You can set the custom gamerule's value to any numerical value for detection. If you set it to "true" or "false", it will be interpreted as 1 and 0 respectively. If you set it to any other string, it will be 0.

/gamerule customGamerule 0
/gamerule customGamerule 1
/gamerule customGamerule 100
/gamerule customGamerule true


Repeating > Chain > Conditional Chain

  1. Stand on top of the command block and run the following yourself.

    /stats block ~ ~-1 ~ set QueryResult $customGamerule Gamerules

    Now every time the command block executes a command that provides a QueryResult return value, fake player "$customGamerule" will have their "Gamerules" score set equal to that value.

    The command that will be placed within that command block, which queries the value of the gamerule:

    /gamerule customGamerule
  2. In order to detect the fake player's value, /scoreboard players test must be used.

    /scoreboard players test $customGamerule Gamerules 1 1
  3. Conditional. Command to run if the "customGamerule" gamerule is set to 1.

    /say "customGamerule" is set to 1.

As long as the gamerule is set to "1" or "true", the /say command will execute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.