How can I join two lines of conditional chain command blocks without resorting to redstone?

How can I join two lines of conditional chain command blocks without resorting to redstone? - Gray Steel Chain on Orange Surface

After reading this question and the answer by Simon Meusel I started to wonder how one would go and join two lines of conditional command blocks.

As an example, let's say that I want to run a series of commands at dawn (daytime 0-1000) and dusk (12000-13000). I use the /stats command to store the value of /time query daytime in a dummy objective (daytime) on a dummy player (#DAYTIME).

I set up two command blocks to test if the daytime is correct:

/scoreboard players test #DAYTIME daytime 0 1000
/scoreboard players test #DAYTIME daytime 12000 13000

I can use conditional chain command blocks to run whatever I'd like from here. But if there's a lot of commands, I'd rather not place every command block twice. Is there a way to join two conditional command block lines, i.e. create a logical OR using command blocks, without resorting to comparators, redstone dust, or the laggy like? Summoning redstone blocks is okay, as long as it is properly reset every tick.



Best Answer

One way is to create an old-fashioned /setblock clock to trigger a new line of command blocks.

We need 4 lines of command blocks for this:

  • Two (or more) for checking conditions
  • One for running our commands
  • One line for the reset

In the following, X Y Z are the coordinates of a block next to the main command line's first command block.

The reset line is just a single repeating1 command block that is always on, running

/setblock X Y Z minecraft:stone

The conditional lines are using a repeat and a chain command block each. The repeating blocks are used to run your conditions. The chain command block is set to conditional and runs:

/setblock X Y Z minecraft:redstone_block

(replace the first command with your condition).

The main line starts with an impulse command block, set to require redstone. The redstone block will be set and replaced every tick by the other command blocks, so there's no need to use a repeating command block here (shouldn't matter, actually). Every other command you want to run is chained from this one.

1 If you want this to only run once, you can replace all repeating command blocks by impulse ones.




Pictures about "How can I join two lines of conditional chain command blocks without resorting to redstone?"

How can I join two lines of conditional chain command blocks without resorting to redstone? - Numbers Wall Decor
How can I join two lines of conditional chain command blocks without resorting to redstone? - 123 Cutout Decor on Red Surface
How can I join two lines of conditional chain command blocks without resorting to redstone? - Hairless aged ethnic male in casual outfit touching bag while sitting against mesh fence with beer can



How do you chain a command block together?

The command to get a command block is: "/give @s command_block" or "/setblock ~ ~ ~ command_block". A chain command block is essentially the opposite of an impulse command block. Impulse command blocks will only execute once when it is activated. Chain command blocks will execute every time it is triggered.

Do chain command blocks run on the same tick?

Chained command blocks execute simultaneously in the same game tick in the order they are chained.

How do conditional chain command blocks work?

"Conditional": A command block in conditional mode will only execute its command after the command block behind it has executed successfully. ("behind it" in the sense of opposite to the direction the command block is facing, regardless of chain direction or even if chaining is occurring).

How do you link command blocks in Minecraft?

How to get a Command Block
  • Enable cheats in your world or Realm settings.
  • Turn on Creative Mode in your world or Realm settings.
  • Open the chat box and enter \u201c/give [your username] command_block\u201d
  • Place the block where you want it.




  • Conditional Chain Command Block Tutorial




    More answers regarding how can I join two lines of conditional chain command blocks without resorting to redstone?

    Answer 2

    You can store the result of your conditionals using a scoreboard tag

    Create a single line of command blocks, starting with a repeating (or impulse) command block, followed by chain command blocks. We'll be using the fact that unconditional chain command blocks execute even when conditional command blocks earlier in the line aren't run because their condition wasn't met.

    Start the line by untagging the player(s):

    /scoreboard players tag @a[tag=conditionTrue] remove conditionTrue
    

    Now, for each condition, place two chain command blocks. The first one is unconditional and runs your condition. Set the second one to conditional and put

    /scoreboard players tag @a[tag=!conditionTrue] add conditionTrue
    

    After placing down all your conditions, put one more unconditional chain block, running

    /testfor @a[tag=conditionTrue]
    

    followed by your commands, which are all run by conditional chain blocks.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Miguel Á. Padriñán, Magda Ehlers, Magda Ehlers, Nicola Barts