Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Some items with empty attribute list receive additional data after interacting with them in the inventory

Open Toseflo opened this issue 1 year ago • 5 comments

Expected behavior

Moving an item in an inventory shouldn't change the item data

Observed/Actual behavior

Moving a shield with attribute_modifiers:{show_in_tooltip: 0b, modifiers:[]} adds banner_patterns:[] to the item components

Steps/models to reproduce

As requested in this bug report (https://github.com/PaperMC/Paper/issues/10686), here is the new bug report for the shield issue.

  1. Give yourself a custom shield with /give @p minecraft:shield[minecraft:attribute_modifiers={show_in_tooltip:0b,modifiers:[]}]
  2. Use /data get entity @s SelectedItem to confirm that the shield just has this component
  3. Pick this item up with your cursor and place it in the inventory again
  4. Use /data get entity @s SelectedItem again and notice how the shield now also has the component banner_patterns:[]

Plugin and Datapack List

No plugins or data packs

Paper version

This server is running Paper version git-Paper-64 (MC: 1.20.6) (Implementing API version 1.20.6-R0.1-SNAPSHOT) (Git: 6c02dbc) You are running the latest version Previous version: git-Paper-62 (MC: 1.20.6)

Other

An (incomplete) list of other affected items: shulker_box, chest: receive empty container:[] component potion: receives empty potion_contents:{} component bee_nest, beehive: receive block_entity_data:{id:beehive,Bukkit.MaxEntities:3},bees:[] decorated_pot: receives pot_decorations:[brick,brick,brick,brick],container:[]

Toseflo avatar May 11 '24 19:05 Toseflo

@Toseflo I'd greatly appreciate it if you could download the server linked at the top of this PR, and run it with a plugin that also tests it out. I was no longer able to replicate your issue with it.

Machine-Maker avatar May 16 '24 00:05 Machine-Maker

I just tested it. Shields, shulker_boxes, chests and potions appear to be fixed. Bee_nests, beehives and decorated_pots (and possibly other items) still gain some additional data after interacting with them:

/give @p minecraft:bee_nest[minecraft:attribute_modifiers={show_in_tooltip:0b,modifiers:[]}] bee_nest, beehive: receive block_entity_data:{id:bee_nest/hive,Bukkit.MaxEntities:3}

/give @p minecraft:decorated_pot[minecraft:attribute_modifiers={show_in_tooltip:0b,modifiers:[]}] decorated_pot: receives container:[]

So at least bee_nests and beehives don't get the empty bees list and decorated_pots don't get the default pot_decorations list anymore, which happened without this fix.

This of course is a really unusual use case, because who would even put empty attribute lists on beehives or decorated pots. But yeah, items probably still shouldn't change their data after interacting with them, even if the data is very weird.

Toseflo avatar May 16 '24 16:05 Toseflo

A new (maybe unreleated) issue with changing data I just found: A lodestone compass with empty lodestone_tracker={} loses this component after interacting with the item. This can happen in vanilla after breaking the lodestone of the compass. Or you can use this command /give @p minecraft:compass[minecraft:lodestone_tracker={}]. Pick this item up, place it again and the enchantment glint disappears. In vanilla, the compass stays a lodestone compass.

Interestingly, this component only appears to disappear for a compass and it stays on other kinds of items. And this empty list also causes additional data to appear on bee_nests/hives and decorated pots.

Toseflo avatar May 16 '24 16:05 Toseflo

/give @p minecraft:decorated_pot[minecraft:attribute_modifiers={show_in_tooltip:0b,modifiers:[]}]

While it shows up more in Paper, I think this is actually a vanilla issue. I opened an issue on the mojira and hopefully they pick it up. Not super great for us to fix it.

I pushed a fix for the bee_nest issue, and a separate PR for the compass stuff (since it's a little more involved).

Machine-Maker avatar May 17 '24 01:05 Machine-Maker

Ok, so https://github.com/PaperMC/Paper/pull/10731 has a new build with what I think is a better fix that should handle extra data being added to items that are block entities (which was the source of several of these). There probably are still other places where extra data is added.

Machine-Maker avatar May 20 '24 00:05 Machine-Maker