Trading with villagers that have items with enchantments will not work.
eg: Iron sword with sharpness 1 for 1 apple
Here are the couple of commands that I used
/summon villager ~ ~ ~ {CareerLevel:1,Offers:{Recipes:[{buy:{id:"minecraft:iron_sword",Count:1b,tag:{ench:[{id:16,lvl:1}]}},sell:{id:"minecraft:apple",Count:1b}}]}}
/give @p minecraft:iron_sword 1 0 {ench:[{id:16,lvl:1}]}
Multiverse-Core-2.5
PermissionsEx-1.23.5-SNAPSHOT
This server is running Paper version git-Paper-1247 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
Successful trade with villager that uses enchanted items.
Objects in trade were not accepted but flashed in inventory.
What occurs is that the trade is recognised but not completed for some reason. You can try to accept the item but it returns back to the trader.
Summon villager with custom trades that have enchantments
Trade with villager to obtain item with enchanted item
EDIT:
Works in vanilla MC 1.12.1-1.12.2
Issue is prevalent in Spigot version 1.12.1-1.12.2 and PaperSpigot 1.12.1-1.12.2
Please try to reproduce in vanilla 1.12.2, I think you have to use string ids for enchantments.
It works properly in Vanilla 1.12.2. I'll try using string ids to see if it fixes the issue.
related to #198 ?
That appears to be the case @electronicboy The problem seems similar.
Yes, this is still an issue to this date. I'm using the latest Paper Spigot version currently. After some researching it appears that the enchanted item which is trying to be bought cannot have any enchantment tag. However the items for sale can.
I managed to successfully trade an enchanted item in vanilla for example: Stone with protection 1 for Dirt with Protection 1.
I've also tried this in Spigot and it also has the same issue.
Yeah I recently checked on this and it is confirmed still an issue, but no idea what's causing it or how to fix it.
We need someone who has the time to do some deep investigation.
This post in the comment mentions the problem if it is any help for narrowing down towards a solution.
https://hub.spigotmc.org/jira/browse/SPIGOT-818?focusedCommentId=14732&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14732
But as you said it will require some investigation. Though I'm fairly certain that this is what's causing it..?
Yeah but were still stumped about what CB/Spigot diff causes it, as the ones in those files don't make sense, but it def does appear to be an NBT item mismatch.
If it is simply an empty nbt tag causing it, we may be able to fix that by treating empty compounds as not set.
such as
if ((left is null or (left type == compound and left.isEmpty()( and (right == null or (right type is compound and right.isEmpty())) {
return true;
}
Unable to reproduce. Works fine for me.
Does appear something has fixed this, woot!
Most helpful comment
Yeah but were still stumped about what CB/Spigot diff causes it, as the ones in those files don't make sense, but it def does appear to be an NBT item mismatch.
If it is simply an empty nbt tag causing it, we may be able to fix that by treating empty compounds as not set.
such as
if ((left is null or (left type == compound and left.isEmpty()( and (right == null or (right type is compound and right.isEmpty())) {
return true;
}