How to add an attribute modifier to an item without removing the already present modifiers. (also to update its value)

Started by Teapot5000 on

Topic category: Help with modding (Java Edition)

Last seen on 23:02, 25. Jul 2024
Joined May 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to add an attribute modifier to an item without removing the already present modifiers. (also to update its value)

I have been messing around with some funtions and events in forge api and managed to make something that can allow me to add an attribute modifier to an item
I have tested it and i have seen that it works but im very sure this will case problems with other mods. Is there a way to add an item attribute without removing the already existing attributes, and of course a way to remove this same attribute to update its value to the enchantment value

This is what i have and it works partially (sometimes the attributes are not applied when wearing the item but they update again if the player hovers the mouse over the item again)

https://pastebin.com/cnEffiiS