Minecraft – Summon armorstands recursively from an origin with only one armorstand per block

minecraft-commandsminecraft-java-edition

I want to summon a flat area of armorstands like demonstrated here in minecraft 1.9:

  3    
 323
32123
 323
  3

Every number represents an armorstand, the number itself the tick in which the armorstand was summoned. Ofcourse I would add a limitation to this myself to prevent the mechanism to spawn infinite amounts of armorstands.

My problem is to only spawn one armorstand on each block, here's what I have so far. This spawns more than one armorstand on each block. First a single armorstand is placed in the world, then the following chain is executed by a repeating command block:

/execute @e[type=ArmorStand,name=move] ~ ~ ~ /summon ArmorStand ~1 ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move] ~ ~ ~ /summon ArmorStand ~-1 ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move] ~ ~ ~ /summon ArmorStand ~ ~ ~1 {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move] ~ ~ ~ /summon ArmorStand ~ ~ ~-1 {NoGravity:1b,CustomName:"move"}

I would also be fine with a solution which temporarily spawns more than one armorstand per block, but it should leave a area of one armorstand per block behind. If you think that this is impossible it would be nice if you could leave a comment.

Best Answer

This solution is really resource intensive, there may be a better one!

Actually i just simplified the problem to 2D, here's a working solution for 3D:

Once:

/scoreboard objectives add dir dummy
/summon ArmorStand ~ ~5 ~ {NoGravity:1b,CustomName:"move"}

Repeat:

/scoreboard players set @e[type=ArmorStand,name=move] dir 0

/execute @e[type=ArmorStand,name=move,score_dir=0] ~1 ~ ~ summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"
/execute @e[type=ArmorStand,name=move,score_dir=0] ~1 ~ ~ scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 1
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~1 ~ summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~1 ~ scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 2
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~ ~1 summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~ ~1 scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 3
/execute @e[type=ArmorStand,name=move,score_dir=0] ~-1 ~ ~ summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move,score_dir=0] ~-1 ~ ~ scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 4
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~-1 ~ summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~-1 ~ scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 5
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~ ~-1 summon ArmorStand ~ ~ ~ {NoGravity:1b,CustomName:"move"}
/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~ ~-1 scoreboard players set @e[type=ArmorStand,name=move,r=0,c=-1] dir 6

/execute @e[type=ArmorStand,name=move,score_dir=0] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=1]
/execute @e[type=ArmorStand,name=move,score_dir=1] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=2]
/execute @e[type=ArmorStand,name=move,score_dir=2] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=3]
/execute @e[type=ArmorStand,name=move,score_dir=3] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=4]
/execute @e[type=ArmorStand,name=move,score_dir=4] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=5]
/execute @e[type=ArmorStand,name=move,score_dir=5] ~ ~ ~ kill @e[type=ArmorStand,name=move,r=0,score_dir_min=6]