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

Add mixins for FabricItem.getAttributeModifiers (1.21) #3809

Merged
merged 1 commit into from
May 29, 2024

Conversation

opekope2
Copy link
Contributor

Added an ItemStack mixin to call FabricItem.getAttributeModifiers(ItemStack).
Similar to #3797, but for 1.21.
Resolves #3787

I tested it on a dev client&server and a prod client&server, and I didn't encounter any issue.

@modmuss50
Copy link
Member

I will merge this in 1.21 now, and get the 1.20.6 PR out another time 👍

@modmuss50 modmuss50 merged commit 29e5f1d into FabricMC:1.21 May 29, 2024
4 checks passed
@modmuss50
Copy link
Member

This fix is broken (#3812) FabricItem.getAttributeModifiers should be tottaly removed as you can now use the component. I will revert and deprecate for 1.20.6, and remove fully in 1.21

@opekope2
Copy link
Contributor Author

This API allowed Items to override attribute modifiers based on certain conditions of the ItemStack. Here's an example where I override it, which delegates to AnvilHandler and other classes. The alternative I see is changing the attribute modifier where I modify the ItemStack, but that only gets called when a player presses a key, and not when /give is used, so initially it would not be functional as intended, only after the player presses the key. NeoForge supports this using IItemExtension.getAttributeModifiers(ItemStack) as of 1.20.6, but I don't know about their future.

@modmuss50
Copy link
Member

Unfortunately I'm struggling to follow the Kotlin code sorry, you can set the default item componet in the Item settings, this would then apply to /give.

The vanilla none stack aware method is deprecated, and ingored if the stack has a attribute modifier component.

@opekope2
Copy link
Contributor Author

My use case is to change the attribute modifiers based on my custom attribute modifier. For /give, I'll try Item.postProcessComponents(ItemStack)

@opekope2
Copy link
Contributor Author

The removal makes sense if I look at mojmap

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.

3 participants