/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"}}}}
Store the values in armor stands and switch the armor stands' name when saving and loading a state.
The armor stands' name will be n, where N equals the id of the set. When using the data pull it from set 0 and when saving/loading switch the names of the desired set with set 0.
Switch sets:
/entitydata @e[type=ArmorStand,name=0] {CustomName:9999}
/entitydata @e[type=ArmorStand,name=<id of desired set>] {CustomName:0}
/entitydata @e[type=ArmorStand,name=9999] {CustomName:<id of desired set>}
Best Answer
Loot tables can't contain XP.
The best you can do is to make an advancement with the
minecraft:player_killed_entity
trigger (archive), the conditions you need and experience points as a reward (archive). The advantage or disadvantage, depending on what you want, is that the XP won't be dropped as an item, but given directly.If you want to drop the XP, you have to do what you already knew: Detect the kill and summon XP orbs yourself.