Minecraft – Can multiple command blocks feed into a chain

minecraft-commandsminecraft-java-edition

I have 3 command blocks that are activated individually, and occasionally two or all three of them are activated in the same tick. What I need is for the 3 command blocks to execute some command, then execute a chain of commands only once. The chain has to execute after the 3 impulse blocks execute their commands. If two command blocks are activated at the same time, then the chain should still only execute once.

What I'm wondering is if the design in the screenshot below does what I need, or if I should look for another method.

enter image description here

The two chain command blocks on the left are empty, while the chain command block in the middle above the impulse block contains the first command.

Best Answer

On the tick that a command block is powered, it is queued for the next tick to run its command and then moves along the chain blocks and also queues them for the next tick. If a chain block found during the trail of activation is already queued, then it doesn't need to queue again.

As such, if all 3 of those command blocks are powered during the same tick, then every chain block will run only a single time.

However, the order of the queue is dependent on the order the impulse blocks activated.

Numbered alternative

If command block a is activated first, then the order of operation for the chain blocks will always be 1, 2, 3, 4. If any of the other impulse blocks activate after, the chain blocks were already queued so cannot be queued again.

If command block b is activated first and followed by c and then a, the order of operation for the chain blocks is 2, 3, 4, 1. Impulse block c is essentially does nothing to the chain since the chain blocks it would queue have already been queued.

And if command block c is activated first, followed by b and then a, the order of operation is 3, 4, 2, 1.

But since you have those chain blocks blank, then that will not matter, and chain blocks 3 and 4+ will always activate only once as desired.