Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21] AttributeModifier with the Same ResourceLocation are deduplicated even across Attributes #93

Closed
lcy0x1 opened this issue Aug 30, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@lcy0x1
Copy link

lcy0x1 commented Aug 30, 2024

2 Bugs found for Accessories / CC layer:

  1. Accessory with multiple attribute modifiers for different attributes using the same resource location will only have 1 displayed (probably due to HashMap<ResourceLocation, ...> somewhere)
  2. getAttributesTooltip should receive the original attribute tooltips so that it can modify those generated with default rules. For example, change +0.5 to +50%, change +50% to x1.5, or change tooltip colors. Currently it receives an empty input and only allows appending new lines
@lcy0x1
Copy link
Author

lcy0x1 commented Aug 30, 2024

For problem 1, it's because WrappedCurio::getDynamicModifiers invokes AccessoryAttributeBuilder::addExclusive, which use Map<ResourceLocation, AttributeModificationData>. It should be using Map<Holder<Attribute>, Map<ResourceLocation, AttributeModificationData>> or Table<Holder<Attribute>>, ResourceLocation, AttributeModificationData> instead.

@Dragon-Seeker
Copy link
Member

  1. Is the problem that AttributeModifier across multiple Attribute share the same ResourceLocation or is it the fact that multiple AttributeModifier have the same ResourceLocation for a single Attribute

@lcy0x1
Copy link
Author

lcy0x1 commented Aug 31, 2024

@Dragon-Seeker The problem is having several AttributeModifiers sharing the same ResourceLocation for multiple Attributes

The method provides a ResourceLocation that wants the accessory to use for its attribute modifiers. The issue 1 can technically be solved by appending a different suffix for every modifier, but most mods are not doing that

@Dragon-Seeker
Copy link
Member

Ah, that is really odd and frankly concerning as the ResourceLocation would be unique across all AttributeModifier's but Minecraft doesn't enforce such even though they merged the id and name into one field to uniquely identifier the attribute with info about why or naming the modifier instance so it kind seems lazy to just share across every modifer but I guess since vanilla allows such I will need to adjust such even if I feel that this should not happen its just not enforced.

  1. I did not know the API functioned like such as it is quite odd, to say the least. I understand its reasons but I believe that Accessories should attempt to use the Vanilla method ItemStack.addModifierTooltip and any mods should attempt injection within there to adjust the Attribute tooltips. Understandable that currently, this affects the Curios API but I don't really know exactly fix such an issue as the Accessories API isn't designed for such. Frankly, I don't want to redesign this as it seems like the incorrect method to deal with this.

@Dragon-Seeker Dragon-Seeker self-assigned this Aug 31, 2024
@Dragon-Seeker Dragon-Seeker added the bug Something isn't working label Aug 31, 2024
@Dragon-Seeker Dragon-Seeker changed the title [1.21] 2 Attribute Tooltip bugs for Accessories / CC layer [1.21] AttributeModifier with the Same ResourceLocation are deduplicated even across Attributes Aug 31, 2024
@lcy0x1
Copy link
Author

lcy0x1 commented Sep 1, 2024

The tooltip modification part is there to help with the missing Attribute tooltip customization from Forge/NeoForge. I think there is a PR regarding this in NeoForge currently?

@lcy0x1
Copy link
Author

lcy0x1 commented Sep 1, 2024

If this PR is completed, I wouldn't need to use the odd attribute tooltip method
neoforged/NeoForge#1371

@Dragon-Seeker
Copy link
Member

The accidental deduplication of modifiers has been fixed and the tooltip issue can be fixed by using mixin within Minecraft itemstack method to adjust the tooltip component yourself. Overall this issue is being closed as fixed as best can be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants