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

Get NBT enchant levels instead of potentially event-modified levels #1472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TheWinABagel
Copy link

Currently, the disenchanting lens uses ItemStack#getAllEnchantments, which may not be accurate to the NBT level (due to potential modification from GetEnchantmentLevelEvent).

This PR swaps it over to ItemStack#getTagEnchantments instead, as it ignores the event.

@MichaelHillcox
Copy link
Collaborator

I don't know much about the event in question but if an event is pushing Enchantments onto an Item, would that not mean they should also be removed?

I'd guess what's happening here is that events are being used to push extra fake enchants onto items to provide temporary enhancements?

Copy link
Collaborator

@Mrbysco Mrbysco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Has it been tested to work?

@Shadows-of-Fire
Copy link
Collaborator

Shadows-of-Fire commented Jan 7, 2025

I don't know much about the event in question but if an event is pushing Enchantments onto an Item, would that not mean they should also be removed?

No, enchantments from the event are transient and only for gameplay purposes. When removing the enchantments from the item, you should be using getTagEnchantments (or more generically, EnchantmentHelper.getEnchantmentsForCrafting).

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.

4 participants