Minecraft – How to add attributes to existing items

minecraft-commandsminecraft-java-edition

The /give and /replaceitem commands are fine if I want to create a new item with a custom attribute, but is there a command to add an attribute to an existing item?

The closest I've gotten to this is adding attributes to an entity representing a dropped item, but the attributes do not carry over to the item once picked up:

/entitydata @e[type=Item,r=1] {AttributeModifiers:[{...}]}

Thanks in advance!

Best Answer

Yup! What you're doing works just fine, with some minor tweaks.

To apply the attribute modifier to the item, you need to do this instead:

/entitydata @e[type=Item,r=1] {Item:{tag:{AttributeModifiers:[{<attribute stuffs>}]}}}