Minecraft – How to teleport an armor stand to an item

minecraft-commandsminecraft-java-edition

I am designing a redstone mini-game, and I need the game host to be able to set spawnpoints.

I was thinking that the host would drop an item (say red wool) and an invisible armor stand named "Red" will be spawned there. Same with green wool.

The player (based on team) would then be teleported to the proper armor stand. I just can't figure out how to place the armor stand via a dropped item. Any ideas?

Best Answer

To teleport an armorstand to an item, as you say in your title:

/tp @e[type=ArmorStand,name=Red] @e[type=Item,...]

Where ... is whatever you're using to identify the item (name? scoreboard value? location?).

To spawn an armorstand at an item, as you say in your question:

/execute @e[type=Item,...] ~ ~ ~ /summon ArmorStand ~ ~ ~ {CustomName:"Red"}

Again, where ... is however you're identifying the item. I'd recommend using a scoreboard value based on their item ID, like this:

/scoreboard players set @e[type=Item] isRedWool 1 {Item:{id:"minecraft:wool",Damage:14s}}

Where isRedWool is a dummy objective.