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:
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}]}