Mojira Archive
MC-349

Villagers ignore data tags in trading


Re-opening applies specifically to data tags such as having a custom name

Villagers will only check an item's ID, not its damage value or any other data, in determining whether they will accept it. This leads to interesting situations where a priest will fully restore an item's durability when enchanting it, and a modified villager requesting bonemeal will just as easily accept ink sacs.

This bug also prevents map makers from designating custom items for villager trade (e.g. a piece of glowstone with a custom name and enchantment will be treated the same as an ordinary piece of glowstone).

What I expected to happen was...:
The villager would only accept the item if it was the same as the item they request - not if it merely shared the same data value.

What actually happened was...:
Priests would accept damaged tools and fully restore them when enchanting them. Modified wool-buyers were colorblind. Names and enchantments on items were ignored.

Steps to Reproduce:
1. Find a priest with an offer to enchant an item. Enchantment offers are rarer than other offers, so this can take some time/spawning.
2. Attempt to enchant a badly damaged tool using this priest.
3. Observe that the item has been enchanted, and has also been restored to its maximum durability.

3b. If you attempt to enchant a previously enchanted item with this priest, you will observe that the old enchantment is ignored and the new one is placed. However, normally it is not possible to unenchant an item, and even anvils will charge extra for overwritten enchantments, so this behavior is not consistent.

Caveat to fixing:
Although making trades strict would fix the issues outlined above, it would cause other issues. Farmers would then only accept white wool, and it would be impossible to fulfill a librarian's request for a Written Book.

Instead, it may be preferable (if anything is done about this issue at all) to add a new tag to an offer, determining whether it is to be considered strict. Thus, among vanilla Minecraft offers, the priest's enchantment offers would be marked 'strict', requiring unenchanted items at full durability. As this would be an NBT tag, map-makers would also be able to make use of it to prevent the aforementioned issues in custom traders.