Minecraft – How to get nearest players head onto armorstand with summon

minecraft-commandsminecraft-java-edition

I'm making another map and in this one I need to get the nearest players skull on an armor stand. How would I do that and how would the target selector for putting the nearest players head on an armorstand work?

Best Answer

As of Minecraft 1.8 and the upcoming 1.9 (currently snapshot 15w43c), there is no way to do this in vanilla Minecraft, short of a customized command for every single player.

It would require the use of placeholders/variables in NBT data, for which there is just no way.


That said, if the list of player usernames is known and fixed, you could use one command per player, executing only if that player is the one closest to the execution point.

/execute @p ~ ~ ~ execute @p[name=Alice,r=0] ~ ~ ~ summon ArmorStand ~ ~ ~ {Equipment:[{},{},{},{},{id:"skull",Damage:3,tag:{SkullOwner:"Alice"}}]}
/execute @p ~ ~ ~ execute @p[name=Bob,r=0] ~ ~ ~ summon ArmorStand ~ ~ ~ {Equipment:[{},{},{},{},{id:"skull",Damage:3,tag:{SkullOwner:"Bob"}}]}
...
/execute @p ~ ~ ~ execute @p[name=Zuul,r=0] ~ ~ ~ summon ArmorStand ~ ~ ~ {Equipment:[{},{},{},{},{id:"skull",Damage:3,tag:{SkullOwner:"Zuul"}}]}