4

I have a villager with trades involving tattered written books. The reason I'm using them is that they're unclonable, ensuring their scarcity.

To obtain the written books, players can trade in regular items obtainable in survival - e.g., no NBT whatsoever, just the default item.

Afterwards however, this book that the player received cannot be used to trade with the villager anymore - despite having the same NBT data, the ordering seems to matter - I had to give the player a new item with the NBT reordered to match what /data get entity tells me the villager expects. Afterwards, I found that written books that have been read carry an extra tag, yet again foiling the trade.

I generated the books and villagers with mcstacker, which seems to sort NBT tags alphabetically. From the generation site's perspective, the NBT data matches up perfectly.

Is there a way to make custom villager trades less frustrating to make (the villagers and books were made in 1.20.2, and I'm pretty sure it works fine back then when I tested it - the server has just updated to 1.20.4)? Ideally, I would like it to do partial matching (e.g., must contain at least the specified NBT, but more are allowed) and order insensitive (e.g., {Enchantments:[{id:"aqua_affinity",lvl:1},{id:"protection",lvl:4}]} should match {Enchantments:[{id:"protection",lvl:4},{id:"aqua_affinity",lvl:1}]} and any other permutations possible that lead to the same effective NBT).

2
  • Check if this still happens in the latest snapshot. There was a change to this recently. Commented Mar 25 at 4:28
  • @FabianRöling Thanks, but those versions won't be releasing any time soon - and even when they do, the server is unlikely to update immediately. Thus I would like to search for solutions for 1.20.4, the current server version. Commented Mar 25 at 6:44

0

You must log in to answer this question.

Browse other questions tagged .