Minecraft – Messing with Mob Equipment in Vanilla

minecraft-commandsminecraft-java-edition

I'm wondering if anyone knows of a way to equip a mob with an item that already exists using vanilla minecraft 1.8 commands. Specifically, if an Item entity is on the ground, is there a way to put that into an Equipment slot on a mob?

This would be infinitely useful, as I'm trying to find a way to add enchantments and attributes while a mob is wearing the item, or at least place a an item with a large number of possible combination of enchantments on a mob.

To be absolutely clear, I'm aware of the /replaceitem command, which is the closest thing I could find to what I'm looking for in order to accomplish what I want. The {Equipment:[{},{},{},{},{}]} NBT tag doesn't allow you to access 1 slot without changing the rest of the items, which doesn't work for what I'm trying to do.

Best Answer

To make a mob able to pick up gear:

/entitydata @e[name=ENTITYNAME] {CanPickUpLoot:1b}

If the mob already has something in the slot you want to fill, use /replaceitem to get rid of it:

/replaceitem entity @e[name=ENTITYNAME] slot.armor.head air

Then teleport the item to the mob:

/tp @e[type=Item] @e[name=ENTITYNAME]

You'll probably want to put more arguments into the item selector to only select the item you want.