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

Fix a few issues with ItemMeta #10740

Merged
merged 1 commit into from
May 25, 2024
Merged

Conversation

Lulu13022002
Copy link
Contributor

@Lulu13022002 Lulu13022002 commented May 17, 2024

NPEs:

  • OminousBottleMeta#getAmplifier when ominous_bottle_amplifier data component is absent from the patch
  • TropicalFishBucketMeta when variant is null for almost all the color getter
  • AxolotlBucketMeta#getVariant when variant is null
  • ItemMeta#getAttributeModifiers(Attribute) when attribute modifiers is null
  • SpawnEggMeta#getSpawnedEntity when entityTag is null

Codec/item validation:
This often kick the player holding the bad item instantly without saving the last data.

  • FoodComponent#addEffect with out of bound probability (outside 0-1)
  • the default food component created by Spigot (ItemMeta#getFood) is invalid since 'eat_seconds' cannot be equals to zero
  • ItemMeta#set(Max)Damage doesn't check the range
  • BundleMeta#addItem/setItems with empty item (amount=0)
  • FireworkMeta#setPower takes 0-255 (fixes FireworkMeta inconsistencies with vanilla #7427)

ItemMeta bad equality:
This breaks the contract of equals that say x.equals(y) == y.equals(x)

  • CraftMetaEntityTag (equals)
  • CraftMetaSpawnEgg (equals)
  • CraftMetaArmorStand (equals, hashCode), Paper only: doesn't check entityTag and is not consistent with hashCode
  • CraftItemMeta (hashCode) handles the max damage as a simple boolean and not as an integer

Misc:

  • empty fireworks effect is cleared by the item meta conversion (firework_rocket[minecraft:fireworks={}])
  • firework effect with no main color got white added to it
  • charged projectile for CrossbowMeta should allow other items and not only arrow or fireworks especially since now the picked up item is custom
  • AxolotlBucketMeta#setVariant is not null but yet allow null to be handled as LUCY variant
  • ItemMeta#getAttributeModifiers(EquipmentSlot) create an empty attribute_modifiers component, but getter shouldn't affect the underlying data
  • FireworkMeta is not applied to firework because of the empty default item
  • damage component can change if out of bound
  • invalid colors are cleared when only the top byte should be ignored (not cleared) (PotionMeta, FireworkMeta/FireworkEffectMeta, ColorableArmorMeta, LeatherArmorMeta, MapMeta)
  • mitigate crashes of Custom banners patterns cause several bugs and crashes. (MC 1.20.5/1.20.6) #10677, pattern is lost however
  • book page limit is infinite however internal still limit to 100 pages for writable book
Known issues (unfixed): - No way to set some components: base_color (shield), intangible_projectile (for crossbow, in charged_projectiles component), tool, debug_stick_state etc...
- The LeatherArmorMeta fallback to the default leather color even for wolf armor which doesn't make sense
- Shield with base_color component gets an empty banner_patterns components once moved into the inventory

Opened this as a draft since there are more stuff to check

@electronicboy
Copy link
Member

having a skim, so far outside of what MM has pointed to, this generally looks fine; I'd need to double check that API def of that method, however

@Machine-Maker
Copy link
Member

having a skim, so far outside of what MM has pointed to, this generally looks fine; I'd need to double check that API def of that method, however

Yeah, we don't have to change the API, but then we have to change where that method is used in the implementation so that in hashCode and equals and serialization they aren't treated the same.

@electronicboy
Copy link
Member

Concern is more "what's empty" for me

@Lulu13022002 Lulu13022002 force-pushed the fix/item-meta branch 2 times, most recently from 8ba2d00 to 6182df2 Compare May 19, 2024 17:53
@Machine-Maker
Copy link
Member

  • Shield with base_color component gets an empty banner_patterns components once moved into the inventory

I think this is fixed in #10731 but I would appreciate you testing this as well. That PR should fix a lot of issues that are on itemtypes that can hold BlockEntities.

@lynxplay lynxplay marked this pull request as ready for review May 21, 2024 22:31
@lynxplay lynxplay requested a review from a team as a code owner May 21, 2024 22:31
@lynxplay
Copy link
Contributor

Moved to ready for review, further changes can be their own PR.

@kennytv kennytv added the priority: high This issue is either a gamebreaking bug or crash and needs to be addressed soon. label May 23, 2024
@lynxplay lynxplay merged commit 535dca5 into PaperMC:master May 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high This issue is either a gamebreaking bug or crash and needs to be addressed soon.
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

FireworkMeta inconsistencies with vanilla
5 participants