/summon
doesn't take a a target to summon the mob at, so you'll need to use /execute
, and selectors can't select items by type, so you'll need to use /scoreboard players set
(which can set a score for items with specific NBT data) to set the entity's score first, and then select it based on that scoreboard objective.
First, set up a dummy scoreboard objective that we will use to keep track of items that are iron ingots:
/scoreboard objectives add isIronIngot dummy
Then run this on a clock, to set all dropped iron ingot's isIronIngot
score to 1:
/scoreboard players set @e[type=Item] isIronIngot 1 {Item:{id:"minecraft:iron_ingot"}}
Now, whenever you want to spawn a zombie at the iron ingots, use this command:
/execute @e[score_isIronIngot_min=1] ~ ~ ~ /summon Zombie
Which will make anything with an isIronIngot score of (at least) 1 summon a zombie.
To have this only work with ingots named "Zombie", replace the second command with:
/scoreboard players set @e[type=Item] isIronIngot 1 {Item:{id:"minecraft:iron_ingot",tag:{display:{Name:"Zombie"}}}}
Adding Tags
to the item will not be set as the entity's Tags
data. All the item data itself will be lost except for Potion
and CustomPotionEffects
, which are copied to the arrow entity if existent.
Tipped arrows will be necessary, but you can apply custom effects to reduce any issues should it strike a player or mob, such as setting the duration to 0. Currently the Instant Healing effect does not function on tipped arrows, but you may need to switch to something else should it work in the future.
The amplifier would be how you'd differentiate arrows from one another.
Example arrows to provide:
/give @p minecraft:tipped_arrow 64 0 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:0b}]}
/give @p minecraft:tipped_arrow 64 0 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:1b}]}
Then you'd label those arrows based on the effects it has, with the amplifier making each one unique:
/scoreboard players tag @e[type=Arrow,tag=!tntarrow] add tntarrow {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:0b}]}
/scoreboard players tag @e[type=Arrow,tag=!custom2] add custom2 {CustomPotionEffects:[{Id:6b,Duration:0,Amplifier:1b}]}
And finally, target based on that label:
/say @e[type=Arrow,tag=tntarrow] is a "tntarrow".
Best Answer
Item data that is not the root
id
,Damage
,Count
, andSlot
, must be placed within a singletag
compound: