Arqade is a question and answer site for passionate videogamers on all platforms. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I make some Command Blocks with commands (let's say say whatever), connect them with redstone dust (you can place redstone dust on Command Blocks by holding Shift), then produce a redstone signal to trigger them at the same time, is there a specific order in which they are executed? Does it depend on coordinates, directions, or what?

share|improve this question
2  
it'll be unpredictable, IIRC the redstone updates are put in a HashMap and then iterated over, so it'll depend on the size of the map (how many updates are triggered at the same time since the server started) and the coordinates – ratchet freak Mar 17 '13 at 13:07
    
@ratchetfreak That sounds like an answer. – SevenSidedDie Mar 19 '13 at 17:44
up vote 5 down vote accepted

This is not a good idea. If you have commands that must be executed in a specific order, separate them with repeaters or comparators so that they execute in a specific order.

If you trigger a lot of command blocks with interfering actions at the same time, they will execute in a specific order, but you can't know what this is in advance, it may change without notice (if the server is restarted for instance), and will almost certainly cause you a lot of headaches.

share|improve this answer

In Minecraft 1.9 command blocks get an overhaul.
There will be three modes of command blocks:

  • Impulse: Regular behavior, command gets activated via redstone
  • Repeat: The command in this command block gets activated every tick (superfast clock)
  • Chain: This is the one you're looking for, see below

Command blocks also have a direction now, they can face north, south, east, west, up or down, this is important for the chain command blocks.

When any command block gets activated, it will activate the chain command block that it is pointing into. This means you can build chains out of command blocks, whose commands get activated in the order they are pointing into each other.

share|improve this answer

It starts with the lowest z coordinate, then runs them in order of increasing x coordinate, then starts again with the next z coordinate. I do not know how the y coordinate is involved.

share|improve this answer
    
Good answer! Do you have any references that prove your answer? – Timtech Feb 24 '14 at 23:58
1  
@Fredley This is the answer you're looking for. But it appears this user hasn't been on StackExchange lately. – aytimothy Sep 14 '15 at 9:08
    
Lowest y to highest y – ModDL Sep 20 '15 at 5:03

You really don't want to be using redstone dust in your command block contraptions, or in this case, even repeaters. I discuss this further in this answer. There are much better solutions these days, and even better solutions to come in the near future.

So for 1.8, what you want to be using is a 20Hz fill clock. There are 2 great features about fill clocks, plus some other advantages. The first feature is that every command runs every game tick, i.e. 20 times a second. The second feature is that execution is well defined, at least when everything is in the same chunk. If your command blocks are in a single line along the X or Z axis, the command blocks will be executed from low coordinate to high coordinate. One of the other advantages is that fill clocks generally produce less lag than redstone.

But fill clocks are old hat now. The new hotness is command block chaining, which is coming in 1.9, and is available now in snapshots. These are even better than fill clocks because while both run at 20Hz, the new command blocks produce even less lag and command execution is even easier to determine. If you're working with command blocks, you should be using 1.9, even though, at the time of writing, it hasn't been fully released.

share|improve this answer

In fact, it is actually the lowest z, then executes that row of x, then goes +z by 1, then executes that row of x and so on... for y-execution, it goes bottom-up, so it starts at the lowest point, then goes to the lowest z point, the executes that row of x. It's actually not that hard, and really compact instead of a line of repeaters running from each command block.

share|improve this answer

If the command blocks trigger each other by placing and removing redstone blocks, wires, circuit-breaking opaque blocks and/or inputless torches, then they're predictable (at least as long as the chunks never unload -- see https://bugs.mojang.com/browse/MC-711). They'll be triggered from bottom to top, then from west to east, then north to south (ascending order of Y, then X, then Z), and a command block will run each game tick if its signal has switched from off to on at least once since it last ran. (The same rule applies to note blocks, which are the only type of output block that can run at more than 5 Hz.) This is what makes 20Hz /setblock clocks possible. It's only when you use repeaters, comparators, switching torches, or moving parts that the unpredictability arises.

share|improve this answer

TL;DR: The answer varies from where you activate the command blocks.

I did an experiment with these where all command blocks are programmed with/say Whatever at and then their coordinates.

enter image description here

Next I activated them from all sides.

The lever at 165 -245: enter image description here

The lever at 169 -240: enter image description here

The lever at 173 -245: enter image description here

The lever at 169 -250: enter image description here

Then, I made sure the test was consistent. enter image description here

As you can see, the first time it activated in this order:

  1. 166 -245
  2. 168 -245
  3. 167 -245
  4. 169 -245
  5. 169 -244
  6. 169 -246
  7. 170 -245
  8. 169 -243
  9. 169 -242
  10. 169 -241
  11. 169 -247
  12. 169 -248
  13. 169 -249
  14. 172 -245
  15. 171 -245

The second time it activated in this order:

  1. 166 -245
  2. 168 -245
  3. 167 -245
  4. 169 -245
  5. 169 -244
  6. 169 -246
  7. 170 -245
  8. 169 -243
  9. 169 -242
  10. 169 -241
  11. 169 -247
  12. 169 -248
  13. 169 -249
  14. 172 -245
  15. 171 -245

Those two are exactly the same.

In conclusion, the order depends on where the signal was activated.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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