2

I am trying to build a table with people (armor stands) which have heads that follow you. Basically, you walk into the room and then everyone keeps following you with their heads.

If it is possible I'd love that the armor stands only can turn their heads 90 degrees, but that isn't that important.

Hopefully that doesn't take that many command blocks!

Thanks in advance!

2
  • Do you need whole commands or is the idea enough? Basically you can use the dx/dy/dz selector arguments to find the player in the four coordinate system quadrants and then turn the head of the armor stand to 45, 135, 225 or 315 degrees using the "pose" tag documented here: minecraft.gamepedia.com/Chunk_format#Other . Commented Jul 14, 2017 at 14:45
  • I am not that good at command blocks so if it is possible i would like whole commands. I do know how to use the POSE tag but not the dx/dy/dz
    – Matt
    Commented Jul 15, 2017 at 15:53

2 Answers 2

1

These commands let every armor stand in a 200x200 area around a player rotate their head to the player with 90° precision (condition: it is looking at positive z):

Initialization:

scoreboard objectives add rotation dummy

Loop: scoreboard players set @e[type=armor_stand,tag=!rotation] rotation 0 scoreboard players tag @e[type=armor_stand,tag=!rotation] add rotation execute @p ~1 ~ ~-1 entitydata @e[type=armor_stand,y=0,dx=100,dy=256,dz=-100,score_rotation_min=1] {Pose:{Head:[0f,45f,0f]}} execute @p ~1 ~ ~1 entitydata @e[type=armor_stand,y=0,dx=100,dy=256,dz=100,score_rotation=0] {Pose:{Head:[0f,135f,0f]}} execute @p ~1 ~ ~1 entitydata @e[type=armor_stand,y=0,dx=100,dy=256,dz=100,score_rotation_min=2] {Pose:{Head:[0f,135f,0f]}} execute @p ~-1 ~ ~1 entitydata @e[type=armor_stand,y=0,dx=-100,dy=256,dz=100,score_rotation=1] {Pose:{Head:[0f,225f,0f]}} execute @p ~-1 ~ ~1 entitydata @e[type=armor_stand,y=0,dx=-100,dy=256,dz=100,score_rotation_min=3] {Pose:{Head:[0f,225f,0f]}} execute @p ~-1 ~ ~-1 entitydata @e[type=armor_stand,y=0,dx=-100,dy=256,dz=-100,score_rotation=2] {Pose:{Head:[0f,315f,0f]}} execute @p ~1 ~ ~-1 scoreboard players set @e[type=armor_stand,y=0,dx=100,dy=256,dz=-100,score_rotation_min=1] rotation 0 execute @p ~1 ~ ~1 scoreboard players set @e[type=armor_stand,y=0,dx=100,dy=256,dz=100,score_rotation=0] rotation 1 execute @p ~1 ~ ~1 scoreboard players set @e[type=armor_stand,y=0,dx=100,dy=256,dz=100,score_rotation_min=2] rotation 1 execute @p ~-1 ~ ~1 scoreboard players set @e[type=armor_stand,y=0,dx=-100,dy=256,dz=100,score_rotation=1] rotation 2 execute @p ~-1 ~ ~1 scoreboard players set @e[type=armor_stand,y=0,dx=-100,dy=256,dz=100,score_rotation_min=3] rotation 2 execute @p ~-1 ~ ~-1 scoreboard players set @e[type=armor_stand,y=0,dx=-100,dy=256,dz=-100,score_rotation=2] rotation 3

This rotates the armor stands to your quadrant and then assigns a scoreboard value to them so that they don't keep rotating to you every tick (would create more lag). Instead of executing everything from the armor stand I noticed that it's way easier to execute everything from the player. Usually I try to make my command stuff multiplayer compatible, but here I use @p, because the only good solution if one armor stand is supposed to look at two people in different directions would be to select the closest one. That would require to execute everything from the armor stand again, which complicates things and requires more tags/scoreboards. If you need that, tell me, but this system here works very well for one player. Selecting smaller ranges than 90° would be much more complicated. Here I profit from the dx dy dz selectors that select a rectangle, so I just check a rectangle far into the positive x and z direction, one far into the postitive x+negative z direction and so on and find an armor stand there. To avoid buggyness, I had to make it so that the armor stand ignores you if you're exactly on the same x or z value as it. But in that case there won't be a good direction for it to rotate to, so it doesn't really matter. I could add special cases for that, but it doesn't make it much better and complicates the commands that are already there.

...and just before sending I noticed that this all breaks if you don't add a value to the rotation score in the beginning, so I added the first two commands. They will only execute once for every armor stand.

If you have any more questions to how this works, ask in the comments and I can explain. It was a fun challenge!

0

1.13+ To start, you must look directly at the armor stand and type: /tag, don't press enter then you will see a list that says: @a @e @p @r @s [long list of numbers and letters] you must click that list of letters and numbers and then type: add 1 and press enter

it will look something like this:

/tag [long list of numbers and letters] add 1

then type this into a repeating command block that's on

execute as @e[tag=1] at @s anchored feet run tp @s ~ ~ ~ facing entity [player-name]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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