When selecting a trade without having enough materials, it will still show subsequent trades the player can afford. However, if you choose a trade that's further down the list without having enough materials, it will not show trades the player can afford (intended behaviour).
To reproduce
Summon a villager with the following command:
/summon villager ~ ~1 ~ {VillagerData:{profession:librarian,level:2,type:plains},PersistenceRequired:1,Offers:{Recipes:[{buy:{id:book,count:1},buyB:{id:emerald,count:10},sell:{id:diamond_hoe,count:1},rewardExp:0b,maxUses:9999999},{buy:{id:book,count:1},buyB:{id:emerald,count:5},sell:{id:golden_hoe,count:1},rewardExp:0b,maxUses:9999999}]}}
With 1 book and 5 emeralds in your inventory, select the first trade
-> It will show the item of the 2nd trade.
Alternatively, to do it in survival (The steps below was provided by @unknown in this comment.)
Find a villager who offers multiple trades:
The first trade
(E.g: 36 Emeralds + 1 Book => 1 Enchanted Book)One or more other trades with the same first item, but at a lower cost
(E.g.: 22 Emeralds + 1 Book => 1 Another Enchanted Book; 9 Emeralds => 1 Bookshelf)
Don't have enough items in your inventory to successfully buy the 1st trade offer
Select the first trade (it only occurs with the first trade)
Actual Behaviour
It will select the first trade for which you have enough items (E.g.: The 9 Emeralds => 1 Bookshelf if you don't have a book)
Expected Behaviour
It should not select any trade (The right side of the trade should stay empty)
Video
[media]Linked issues
is duplicated by 3
Attachments
Comments 12
I have experienced this same issue in the past, and I found the cause of the problem was that I did not have a book in my inventory. Without this, it will place the emerald in the trading menu (without the book) which causes the villager to offer a bookshelf. Please let me know, if this is the issue or not.
This issue is not limited to the Librarian, but it's more common with them.
How to reproduce this:
Find a villager who offers multiple trades:
The first trade
(E.g: 36 Emeralds + 1 Book => 1 Enchanted Book)One or more other trades with the same first item, but at a lower cost
(E.g.: 22 Emeralds + 1 Book => 1 Another Enchanted Book; 9 Emeralds => 1 Bookshelf)
Don't have enough items in your inventory to successfully buy the 1. trade offer
Select the first trade (it only occurs with the first trade)
Actual Behavior:
It will select the first trade for which you have enough items (E.g.: The 9 Emeralds => 1 Bookshelf if you don't have a book)
Expected Behavior:
It should not select any trade (The right side of the trade should stay empty)
This is still reproducible in 20w51a
This also affects Shift-Click Trading, if you pass multiple books.
In the above example: If you add more than 58 Emeralds and at least 2 Books and then buy with a shift-click, you will get 1x Enchanted Book + 1x Another Enchanted Book.
I have experienced this, but is more so common with villagers that are spawned in with a spawn egg. It is not limited to any value...If I take the price of the first book and add the price of the second book and put that many emeralds into the slot and shift click, I will get both books. One thing I have noticed is that the item that I first select, doesn't stay highlighted to indicate that is the trade that I am interested in.
Maybe the summary "Clicking on the first trade, when not enough items are available, will select the next trade for which enough items are present." describes this issue better?
I think this would also cover MC-215441
Just ran into this bug on my server and made a bug report. I was referred to this one. I can confirm this is still in 1.17.1 My bug report is here: MC-240568
Do you have a book for the trade?