3

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.

  • I think the best approach would be to teleport the item to a space above a hopper that feeds into a dispenser (I think) that's part of an armour station, then teleport the mob to that armour station. The only issue is if the mob is wearing something in that slot already. – MBraedley Apr 4 '15 at 2:53
  • You could test for an item within the vicinity of a mob. The mob then gets that item placed into the respective equipment slot using /replaceitem. Then, the item is deleted. Also, you can set single equipment slots using slot codes (ie /replaceitem entity @e[type=Zombie,r=1] slot.armor.chest diamond_helmet). Of course, this would need logic to determine the initial item, but this might be a good starting place. – Kaz Wolfe Apr 4 '15 at 3:03
  • @MBraedley the CanPickUpLoot NBT tag can be put on all mobs, so your idea would work, except I ran into another issue which is that there is no way to edit an item's enchantments using NBT tags without wiping all enchantments when editing the tag, even with the /entitydata command. This eliminates the original theory of my post and makes mob loot pick up less useful than I had thought. @Whaaaaaat I thought of something like this actually. I tried editing UUIDLeast & UUIDMost tags to see if equipping a mob with an item with those UUID's would work, except UUID's don't work like that :( – Polaris Apr 4 '15 at 3:57
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.