Reopen - 1.21.1 Bug: ItemDefinition::addAttributeModifier replaces all existing modifiers instead of adding.
Silvertide7 opened this issue ยท 2 comments
Issue description
Sorry, I don't have permissions to reopen the old ticket and I don't know if you get comments on those or not.
I just downloaded the latest CraftTweaker (21.0.26) and it still didn't work with the fixes. Just wanted to let you know!
I am trying to add a modifier to an existing item, say a netherite chestplate. Here is the data on that before any modification:

I am using this method:
function applyModifier(itemDef as ItemDefinition, attribute as Attribute, value as double, operation as AttributeOperation, slot as EquipmentSlotGroup) as void {
val modifier = AttributeModifier.create(<resource:reverie:modification>, value, operation);
itemDef.addAttributeModifier(attribute, modifier, slot);
}
applyModifier(<item:minecraft:netherite_chestplate>, <attribute:minecraft:generic.armor>, 2.0, <constant:minecraft:attribute/operation:add_value>, <constant:minecraft:equipmentslot/group:chest>);
I am adding this modifier under the reverie:modification resource path to ideally add a new attribute.
Here is the item after the modification:
It completely removes ALL other attributes, not just the armor, and replaces it with my new armor modification. I do realize I added it to the head equipment slot instead of chest in this picture, but I tried it again right after with chest and it did the same thing.
I would assume that all old attributes, including the old armor attribute, would still be applied to the item, and my new armor attribute modification would be added on, resulting in 10.0 total armor.
It would be nice however to be able to overwrite the existing modifications as well. Say if I had used the namespace minecraft:armor.chestplate as my resource key for my modifier it would replace the existing one there.
Steps to reproduce
No response
Script used
above
The crafttweaker.log file
none
Minecraft version
1.21.1
Modloader
All
Modloader version
21.1.145
CraftTweaker version
21.0.26
Other relevant information
No response
The latest.log file
none
You could have just re-opened the old issue.
This has been properly fixed and tested this time.
