Villager trade with same items but different NBT data
The bug
When a villager with custom trade is created which requires the same type of item in both slots, but with differing NBT data, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
How to reproduce
- Create a villager with a custom trade like this:
/summon villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}→ The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
/give @s paper{display:{Lore:["A"]}} 5 /give @s paper{display:{Lore:["B"]}} 5→ The villager will allow the trade
- Pickup the result item.
→ Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
→ It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead)
Code analysis
Based on 1.12.2 decompiled using MCP 9.40
The method net.minecraft.inventory.SlotMerchantResult.doTrade(MerchantRecipe, ItemStack, ItemStack) does not check for the NBT data of the items.
Linked Issues
Created Issue:
Villager trade with same items but different lore
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (https://bugs.mojang.com/browse/MC-81687), which seems to be similar, but is slightly different (not item data involved), and fixed.
The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this: /summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display: {Lore:["A"]}
}},buyB:{id:"paper",Count:1,tag:{display:
{Lore:["B"]}}},maxUses:9999999,sell:
{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (https://bugs.mojang.com/browse/MC-81687), which seems to be similar, but is slightly different (no
titem data involved), and fixed.The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this: /summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display: {Lore:["A"]}
}},buyB:{id:"paper",Count:1,tag:{display:
{Lore:["B"]}}},maxUses:9999999,sell:
{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (https://bugs.mojang.com/browse/MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.
The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this: /summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display: {Lore:["A"]}
}},buyB:{id:"paper",Count:1,tag:{display:
{Lore:["B"]}}},maxUses:9999999,sell:
{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (https://bugs.mojang.com/browse/MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.
The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this:
/summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (
https://bugs.mojang.com/browse/MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this:
/summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (
MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this:
/summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}
- The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (
MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
Steps to reproduce:
- Create a villager with a custom trade like this:
/summon Villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}
The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
- The villager will allow the trade. Pickup the result item.
- Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
- -> It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (
MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.The issue: When a villager with custom trade is created which requires the same type of item in both slots, but with differing lore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
This issue might not be limited to the lore data, but that's what I tested it with.
How to reproduce
- Create a villager with a custom trade like this:
/summon villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}→ The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
< 17w45a/give @s paper 5 0 {display:{Lore:["A"]}} /give @s paper 5 0 {display:{Lore:["B"]}}>= 17w45a/give @s paper{display:{Lore:["A"]}} 5 /give @s paper{display:{Lore:["B"]}} 5→ The villager will allow the trade
- Pickup the result item.
→ Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
→ It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).
Villager trade with same items but differentloreVillager trade with same items but different NBT data
Other tickets: I did a quick search and could not find a ticket about this issue yet. There exists this ticket (
MC-81687), which seems to be similar, but is slightly different (no item data involved), and fixed.
The issue:When a villager with custom trade is created which requires the same type of item in both slots, but with differinglore, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.This issue might not be limited to the lore data, but that's what I tested it with.
How to reproduce
- Create a villager with a custom trade like this:
/summon villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}→ The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
< 17w45a/give @s paper 5 0 {display:{Lore:["A"]}} /give @s paper 5 0 {display:{Lore:["B"]}}>= 17w45a/give @s paper{display:{Lore:["A"]}} 5 /give @s paper{display:{Lore:["B"]}} 5→ The villager will allow the trade
- Pickup the result item.
→ Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
→ It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).The bug
When a villager with custom trade is created which requires the same type of item in both slots, but with differing NBT data, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
How to reproduce
- Create a villager with a custom trade like this:
/summon villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}→ The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
< 17w45a/give @s paper 5 0 {display:{Lore:["A"]}} /give @s paper 5 0 {display:{Lore:["B"]}}>= 17w45a/give @s paper{display:{Lore:["A"]}} 5 /give @s paper{display:{Lore:["B"]}} 5→ The villager will allow the trade
- Pickup the result item.
→ Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
→ It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).Code analysis
Based on 1.12.2 decompiled using MCP 9.40
The method net.minecraft.inventory.SlotMerchantResult.doTrade(MerchantRecipe, ItemStack, ItemStack) does not check for the NBT data of the items.
relates to
The bug
When a villager with custom trade is created which requires the same type of item in both slots, but with differing NBT data, and then specific (see example below) quantities of those items are provided but in reverse order, the villager will pickup the wrong items when being traded with.
How to reproduce
- Create a villager with a custom trade like this:
/summon villager ~1 ~ ~ {Offers:{Recipes:[{buy:{id:"paper",Count:5,tag:{display:{Lore:["A"]}}},buyB:{id:"paper",Count:1,tag:{display:{Lore:["B"]}}},maxUses:9999999,sell:{id:"stone",Count:1},rewardExp:false}]}}→ The villager now requires: Item1: x5 paper lore:A, Item2: x1 paper lore:B
- Insert the following items in the trading menu: Slot1: x5 paper lore:B, Slot2: x5 paper lore:A
< 17w45a/give @s paper 5 0 {display:{Lore:["A"]}} /give @s paper 5 0 {display:{Lore:["B"]}}>= 17w45a/give @s paper{display:{Lore:["A"]}} 5 /give @s paper{display:{Lore:["B"]}} 5→ The villager will allow the trade
- Pickup the result item.
→ Resulting items remaining in the trading menu: Slot1: empty, Slot2: x4 paper lore:A
→ It has picked up 4 additional items with lore B, but left 4 items with lore A (which he should have taken instead).Code analysis
Based on 1.12.2 decompiled using MCP 9.40
The method net.minecraft.inventory.SlotMerchantResult.doTrade(MerchantRecipe, ItemStack, ItemStack) does not check for the NBT data of the items.
Confirmed for 1.13.1.
Is this still an issue in 20w22a or later?
Tested on 20w22a with two items with names A and B and trading removed the correct items in correct quantities. So this seems to be fixed.