Paper icon indicating copy to clipboard operation
Paper copied to clipboard

1.18.2 Paper Server Wipes NBT Data in Villager Trades

Open bryanmcgrane opened this issue 3 years ago • 5 comments

Expected behavior

I believe I found an issue with Paper 1.18.2. Upgrading from a vanilla server to Paper totally broke my quests, so I had to roll back to vanilla. I have a hunch it's a bug in the way Paper reads and stores NBT data.

So on my server, I have custom items that are used in quests. These items can look like this: /give @p copper_ore{display:{Name:'{"text":"Super Copper"}',Lore:['{"text":"It's amazing"}']},Enchantments:[{}]} 1

Notice - this copper ore has Enchantments:[{}] - this is to give it a glint without actually giving it any other enchantments.

Now, when players receive these items through the quests, they'll trade them into villagers that look like this: /summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:"minecraft:copper_ore",Count:1b,tag:{display:{Name:'{"text":"Super Copper"}',Lore:['{"text":"It's amazing"}']},Enchantments:[{}]}},sell:{id:"minecraft:iron_axe",Count:1b}}]}}

It seems when a player opens a dialog with this villager and attempts to trade, sometimes the Enchantments:[{}] tag information will be removed from either the trading item or the villager trade itself. This means the quest is completely broken and / or the player loses their quest item.

Is this a known issue? I am happy to provide as much detail as required, as I am unable to use Paper right now, and I need to for the chunk loading optimizations.

Observed/Actual behavior

What I observed is the NBT data is altered when trading with a villager.

In vanilla, this does not occur.

Steps/models to reproduce

Give yourself and item:

/give @p copper_ore{display:{Name:'{"text":"Super Copper"}',Lore:['{"text":"It\'s amazing"}']},Enchantments:[{}]} 1

Create a villager:

/summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:"minecraft:copper_ore",Count:1b,tag:{display:{Name:'{"text":"Super Copper"}',Lore:['{"text":"It\'s amazing"}']},Enchantments:[{}]}},sell:{id:"minecraft:iron_axe",Count:1b}}]}}

Attempt to trade with this villager several times.

Plugin and Datapack List

None

Paper version

I did not capture the exact version, as I am now rolled back: 1.18.2

Other

No response

bryanmcgrane avatar Apr 18 '22 01:04 bryanmcgrane

I was trying to look into this issue, its related to https://github.com/PaperMC/Paper/issues/7631, but might be fixable now, or might be a later thing like the other issue. But when I try to spawn a villager with that command, and try to open the gui, it just closes instantly so I can't even try to trade. any suggestions?

Machine-Maker avatar Apr 22 '22 21:04 Machine-Maker

My mistake. Please try this villager. I verified it in vanilla.

/summon villager ~ ~ ~ {Willing:1b,VillagerData:{level:99,profession:"minecraft:armorer"},Offers:{Recipes:[{buy:{id:'minecraft:copper_ore',Count:1b,tag:{display:{Name:'{"text":"Super Copper"}',Lore:["{\"text\":\"It's amazing\"}"]},Enchantments:[{}]}},sell:{id:'minecraft:iron_axe',Count:1b}}]}}

bryanmcgrane avatar Apr 26 '22 16:04 bryanmcgrane

Yeah ok, I can replicate the issue. For future reference, the item meta is reformatted lossily when you drag to place the item (which happens if you move the cursor even 1 pixel between clicking down and up). But this is probably a future thing to fix too as its just a symptom of craftbukkits itemmeta structure.

Machine-Maker avatar Apr 26 '22 23:04 Machine-Maker

Still an issue in 1.19.1. Generally, proper glint support in paper would fix that if paper used the dummy enchantment {} for glinting. Right now, the dummy enchant is simply not parsed, yielding an empty enchantment list instead of one with the dummy enchantment. Or in NBT words Enchantments:[{}] becomes Enchantments:[]

lynxplay avatar Aug 07 '22 22:08 lynxplay

How easy is the fix? I'd love to move to a paper server from vanilla!

bryanmcgrane avatar Aug 22 '22 00:08 bryanmcgrane