Trying to give myself a diamond sword that gives it's wielder 2 additional hearts. But adding the attribute also seems to remove the sword's damage, making it do just 1 damage per hit. Does anyone know how to avoid this?

give @p diamond_sword 1 0 {AttributeModifiers:[{Slot:"mainhand",AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:4,Operation:0,UUIDLeast:894654,UUIDMost:2872}]}

Sure I could just add +7 attack damage as an attribute, but that just seems unnecessary and doesn't look good in the item's description.

2 Answers 2


It is not possible to prevent deletion of default modifiers, which occurs when the AttributeModifiers tag is specified. If the default modifiers were not deleted, then we would potentially be incapable of managing certain attributes on an item depending on the default operation used, so it is good that they are deleted since we can manually add them back ourselves without conflict.

Note that the default modifiers shown on the item's tooltip are showing the "final" result of applying the modifier to the player's base attribute value, rather than the actual value of the modifier:

Diamond sword stating 1.6 attack speed, 7 attack damage,

The player's base value for generic.attackDamage is 1, so the modifier you apply is +6, not +7, to reach a final value of 7. The player's base value for generic.attackSpeed is 4.0, so the modifier you'd apply is -2.4 to reach a final value of 1.6.

Example command, which includes both modifiers:

give @p diamond_sword 1 0 {AttributeModifiers:[{Slot:"mainhand",AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:4.0,Operation:0,UUIDLeast:894654,UUIDMost:2872},{Slot:"mainhand",AttributeName:"generic.attackSpeed",Name:"generic.attackSpeed",Amount:-2.4,Operation:0,UUIDLeast:1,UUIDMost:1},{Slot:"mainhand",AttributeName:"generic.attackDamage",Name:"generic.attackDamage",Amount:6.0,Operation:0,UUIDLeast:2,UUIDMost:2}]}

I have no idea if this will still be helpful to you, since this is an older post, but if you want to specify specific modifier values that will appear, you can put any attribute modifiers you like in and use the HideFlags tag to make them not appear.


If you actually want specific values to appear, you can use the "Lore" option that goes into the "display" NBT tag, which allows you to leave custom text on an item, and then just type in what you wish to appear manually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .