Skip to content

Fix HIDE_ATTRIBUTES flag not working for items without attributes set#11088

Closed
NewwindServer wants to merge 1 commit into
PaperMC:masterfrom
NewwindServer:fix-hide-attributes
Closed

Fix HIDE_ATTRIBUTES flag not working for items without attributes set#11088
NewwindServer wants to merge 1 commit into
PaperMC:masterfrom
NewwindServer:fix-hide-attributes

Conversation

@NewwindServer
Copy link
Copy Markdown
Contributor

Fixes #10744

Currently, on paper, when you add HIDE_ATTRIBUTES flag to an item, e.g. a diamond sword, it incorrectly still shows the "When in main hand 7 attack damage..." default attributes, which are supposed to be hidden.

On spigot, however, these default attributes are correctly hidden, upon investigation, the general-itemmeta-fixes patch breaks this functionality, This PR fixes the functionality and brings it back in line with spigot/pre 1.20.5 behaviour.

Note, on #10744 there is a comment stating that having empty attributes defined on the item overrides the default attributes, but from my testing this does not appear to be the case.

@NewwindServer NewwindServer requested a review from a team as a code owner July 16, 2024 11:11
@lynxplay
Copy link
Copy Markdown
Contributor

This was an intentional change. Have you tested this with non-armor items? (Those have special handling on the client to fallback to their default when empty attribute modifiers are defined)

@electronicboy
Copy link
Copy Markdown
Member

This just relies on highly inconsistent behavior which seems to confuse everybody who ends up touching it.

Adding a component will override the default component, mojang has some logic that they scatter around which is smart enough in some cases to get the default values, but, there are many cases where they just don't, and so you end up with an item which will behave unpredictably in many cases. I think that the best solution here would be to allow people to explicitly opt into having an empty component, however, ItemMeta doesn't exactly handle that well and just further perpetuates the potential headaches of promising sane behavior around such a clugy API.

@NewwindServer
Copy link
Copy Markdown
Contributor Author

Armor was tested and worked fine, however, upon further investigation, behaviour for weapons is indeed inconsistent.

A workaround would be to send the empty attributes NBT only to the client, as client-side it doesn't cause any issues, since attributes appear to be server-sided, however, this will likely change due to https://bugs.mojang.com/browse/MC-272517

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

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Hide attributes not working in 1.20.6

3 participants