3

I've been working on a dungeon generator for a while. Recently I noticed, that big commands on impulse (or chain impulse) command blcoks sometimes don't apply instantly. For example I'm executing a command with multiple execute-detects on... about 1024 armor stands, and it makes the activation button stay pressed for much longer than it should be (about 10 sec). I wonder if anyone knows how exatctly it works, and how it affects other command blocks in the world and in the chain.

3

It's server lag; the server is given a huge amount of work and it will take longer to finish the job, which causes most things to grind to a halt until it's finished.

The command parser will separately execute a command for each individual target obtained by a selector.

For example, when running the following while there are 1024 armor stands:

/execute @e[type=ArmorStand] ~ ~ ~ /testfor @e[type=ArmorStand]

There are 1024 /execute commands being processed, and then for each and every /execute command processed there are 1024 /testfor commands processed (totaling 1,048,576 commands processed). This is an extremely large amount of work that needs to be done, and it's only a single /execute.

The more nested executes you use, the worse off it's going to be. Not only do the commands have to be processed thousands of times, the selectors do as well (which comes with some heavy operations, such as sorting all targets by distance before picking from them).

  • Don't worry, I execute the same 1024 ArmorStand 4 times, so it's more like 4096 commands... I think. – Vovalium Jun 3 '16 at 11:28

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.