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?


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.