Skip to content

Conversation

@tal5
Copy link
Member

@tal5 tal5 commented Aug 19, 2025

Additions

  • Created a new AttributeUtil class with all the attribute-related util methods, as they were spread around across a couple of property classes and it started getting a little messy.
  • AttributeUtil#addToMap - converts a list of modifiers into a ListTag and adds it into a map under an attribute key. On older versions, this is the Spigot attribute name, while on 1.21+ this is the Minecraft namespaced key name + an extra key->value with the legacy Spigot name if legacy spigot name support is enabled.
  • AttributeUtil#parseModifiers - a generic utility method for parsing attributes and their modifiers from a map & handling both modern and legacy names in the map if legacy spigot names support is on. Used by both item and entity properties.
  • AttributeUtil#modifierToMap - now only adds id and key if includeDeprecated is true, as both of these are replaced by key now.

Changes

  • Moved existing util methods (e.g. EntityAttributeModifiers#mapify) to AttributeUtil, renamed some to have clearer naming, and changed existing code to use AttributeUtil methods.
  • Attribute-related methods now pass around a boolean includeDeprecated, for both attribute names and modifier values to be calculated with.
  • ItemAttributeModifiers now overrides getTagValue, to include deprecated values for tag usage and exclude them from the property value.

Note

There's one niche use case I could think of that might break from this behavior? something like <[item].attribute_modifiers.with[legacy_name].as[new_value]> on an item that already has that attribute may get overridden by the modern attribute in the map?
We could make it prioritize legacy names over modern names, but idk if that'd be worth it - personally I'd rather focus on modern naming rather than legacy for this, specifically since this is fairly niche, but lmk what do you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant