The system I'm setting up is supposed to teleport players forward if an armorstand is within a radius, and down if there isn't one (to find a vacant area for the player).

The commands are supposed to run in a loop if it keeps finding armor stands:

Runs on a clock, executes the rest if positive:

/execute @a[paramaters=true] ~ ~ ~ /testfor @e[type=ArmorStand,name=Marker,r=20]

/tp @a[paramaters=true] ~100 245 ~100
/setblock x y z redstone_block                 - this activates another check

/execute @a[paramaters=true] ~ ~ ~ /testforblock ~ 245 ~ minecraft:air - Check for ArmorStand at co-ordinates (looking for a true if not present)

Executes if true:

/scoreboard players set @a[paramaters=true] paramaters (something new)
/tp @a[paramaters=new] ~ 68 ~

So far if there is an armorstand (invisible or not) it is still testing positive for finding air in the same space. I tried going into Creative and standing in the starting point and manually typing the commands:

/summon ArmorStand ~ 245 ~

And then:

/testforblock ~ 245 ~ minecraft:air

The armor stand summons, and then the testforblock return "Successfully found the block...".

I have commands that need to execute on a loop ending in a check for if there is an armor stand present, and separate commands that need to be executed if there isn't one. Is there another way to get a positive result when there is no armor stand present?

I basically need it to do:

01 Check for armorstand within radius

02 If found:

03 tp forward then goto line 01

04 Else:

05 do something else

Is there not a way to find out if there isn't an armor stand nearby?


1 Answer 1


This is easily done with a scoreboard objective (or scoreboard tags in 1.9)

First set up the objective:

scoreboard objectives add ASfound dummy

Now, set the score according to whether or not there is an armor stand at x, y, z relative to the player by running these two commands

scoreboard players set @p ASfound 0
execute @e[type=ArmorStand] ~-x ~-y ~-z scoreboard players set @p[r=2] ASfound 1

Now all you have to do is run the tp commands depending on the score:

tp @a[score_ASfound=0] <downward>
tp @a[score_ASfound_min=1]  <forward>

Replace <downward> and <forward> with relative coordinates as needed.

  • After much experimentation, the logic seems to work, but on a hopper clock it's pretty slow when cycling through the different Armor Stands, and on a redstone clock (setblock redstone_block/setblock stone) it gives a failed to execute error. Do you have any ideas for a possible work around?
    – theBeaks
    Oct 25, 2015 at 1:17
  • @theBeaks You need to ensure the commands are running in the correct order. There is a specific order in which commands are activated in the world. See here for a tutorial. Otherwise, in 1.9, you'd use Chain command blocks to ensure the order of activation is correct rather than relying on /fill clocks.
    – Skylinerw
    Oct 31, 2015 at 10:25
  • @MrLemon That particular /execute chain will not support multiplayer. Only the player nearest (@p) to the armor stand will have their score set, not necessarily the one that ran the /execute command, causing players that were near to not be labeled. Changing the selector to @a[r=2] will technically work since a score is being 'set' rather than 'added' (otherwise scores will be double the number of times as there are players near the armor stand), but will run multiple times. The fix is to reverse the chain: /execute @e[type=ArmorStand] ~ ~ ~ scoreboard players set @a[r=2] ASFound 1
    – Skylinerw
    Oct 31, 2015 at 10:50
  • @Skylinerw I used the say command on he fill clock to confirm the order the commands were being executed, it just seems like it's too fast of a clock to run an /execute ~~~ ... /execute ~~~
    – theBeaks
    Oct 31, 2015 at 18:26
  • @theBeaks Commands are processed one at a time. The /execute chain will finish processing before the next command runs, so it doesn't matter what speed the clock is. I do highly recommend trying 1.9's new Repeating/Chain command blocks, since they allow you to know what order they're being run in (and at 20t/s).
    – Skylinerw
    Oct 31, 2015 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .