The bug
Since 1.13 the color of the "attribute modifier" of a sword is green. See screenshot 1.
But if I use a command (/data merge
, /give
, /summon
, etc.) with attribute modifier the color is blue. See screenshot 2.
How to reproduce
Use this command for example:
/give @s diamond_sword{AttributeModifiers:[{AttributeName:"generic.attack_damage",Slot:"mainhand",Amount:7,Operation:0,UUID:[I;1,2,3,4]},{AttributeName:"generic.attack_speed",Slot:"mainhand",Amount:1.6,Operation:0,UUID:[I;5,6,7,8]}]}
Look at the sword
Attachments
Comments 8
Confirmed 21w06a.
In regards to Nguyen Thanh's statement, I am unable to find any documented way to 'set' attributes on an item, only modify an item or set for an entity (No, this does not work for an item entity.)
Temporary workaround, since player attributes are static for the most part: Use attribute modifiers to adjust the base player stats to the correct adjustment, hide flags, and use custom lore tags to re-create the display.
Confirmed 21w15a
Additionally I have found that existing tools are not actually setting the player's attributes, they're modifying them. Tested by changing the player's base attributes and then getting the totals when holding a tool. (They do not match)
Command is now outdated, use this instead:
/give @p netherite_sword[attribute_modifiers=[{type:"generic.attack_damage",name:"generic.attack_damage",amount:8,operation:"add_value",uuid:[I;-1778600166,-1827323489,-1384588009,190260635],slot:"hand"},{type:"generic.attack_speed",name:"generic.attack_speed",amount:1.6,operation:"add_value",uuid:[I;-574244440,-370652253,-2103956968,1378443475],slot:"hand"}]] 1
This is actually NOT a bug, and you CAN make the text green, its based on attribute ID.
Any base game ID will give you a green text. @Hardel
Tested in: 1.21.3
Example command: /give @p iron_pickaxe[attribute_modifiers=[{id:"minecraft:base_attack_damage",type:"attack_damage",amount:3.0,operation:"add_value",slot:"mainhand"},{id:"attack_damage",type:"attack_damage",amount:3.0,operation:"add_value",slot:"mainhand"}]] 1
This is NOT a bug. The reason why your attributes are blue are because you are not "setting" the attributes, you are "adding" the attribute. For example, the attack speed in that command actually sets the player's attack speed to 5.6, NOT 1.6, because the player's default attack speed is 4, and in the command it said the item to "add" 1.6 attack speed, making a 5.6. This also applies for all other attributes, which also means that the attack damage you set is actually adding 7 into the player's attack damage, which makes an 8, but normally a diamond sword only deals 7 damage, which includes the player's attack damage, or an equivalent of adding 6 attack damage.