The bug
Having items in your main hand or offhand will consume, charge or use that item when opening the trading GUI with a villager.
How to reproduce
Summon a villager
/summon villager ~ ~1 ~ {NoAI:1,Offers:{Recipes:[{buy:{id:air,Count:0},sell:{id:air,Count:0}}]}}
Run
/effect give @s minecraft:hunger 5 255
(Only needed for food items)Pick an item from "Affected Items"
Right click the summoned villager
Wait (If the item is a food or potion)
→ ❌ You will consume, charge or use the item
Affected Items
Food and potions (Causes you to consume the item)
Fishing rod in main hand or offhand (Causes you to use the fishing rod)
Trident in offhand (Causes you to charge the trident)
Bow in offhand (Causes you to charge the bow)
See
[media]if you have trouble reproducing.
Related issues
is duplicated by
relates to
Attachments
Comments


Or does this only happen to farmers? Or is it because the farmer now wears a diamond...?
I can't reproduce, but did the item seemingly get consumed instantly? If so it's probably MC-849

No, it could be cancelled and it had an animation, sounds et cetera.

Please check if that's still an issue in the latest 1.14 development snapshot.

This is still an issue in 1.14 release.
I run Arch Linux, Oracle Java 8.

Issue reopened as there is extra information was added which came fromy bug report.

Happens in 1.14.2 - Pre-Release 3

This also affects the scoreboard minecraft.used:minecraft.carrot_on_a_stick. If you are holding one when right clicking a villager the number goes up.

Shields are also affected by this issue.

Affects 1.14.2. (Pro tip ... do not have a Power V bow active in either hand when trading with villagers.)

It also happens in 1.14.4, I don't want to kill my villagers, this bug is very annoying

Crazy new info on this! If you right click a villager with a signed written book, it opens the book instead. After doing so, a few strange things happen! One is that you can't open the villagers trading at all. The other is that hot keying anything into the offhand slot turns invisible. Weirdest of all is that if you hot key something into the offhand slot then go into your inventory and place a different item into the offhand slot, that item you hot keyed will be completely deleted!
This effect goes away either by saving and quitting, waiting for a bit.

Can confirm the weird behavior when interacting with a villager while holding a signed book in hand. MC 1.15.1. Does not affect villagers without profession / trades.

Alex Smith, your comment sounds like MC-166959, but your comment lists additional details. I’ve left a comment on that ticket linking to your comment.

Can confirm this bug still exists in 20w07a

Can confirm for 20w09a

I just recorded a little video demonstrating what happens.
https://www.youtube.com/watch?v=o-grR3yJcSo
I couldn't get it to replicate as perfect as I wanted, but basically it shows a freshly spawned entity (eventually) has the bug where opening its trading GUI will consume an item, such as food or equip armor. However, saving & exiting to the main menu and re-joining the world fixes it. This also happens on Multiplayer, however the difference is the server needs to be saved, stopped, and restarted and the same effect will occur.
While this video was recorded on 1.15.2, this problem still persists in 20w10a.

Can confirm for 20w13b

I made another bug report that is related to this one. MC-177872

@Your Coal
I tried to reproduce it in the steps you did in your video, and I found that if you click on a villager constantly until it gets a profession, then the item gets consumed when opening the GUI. However when doing so after the villager has gotten the profession, this issue does not persist. Very strange!

This is in effect in 20w18a

This is a major problem, especially when the held item is a well-enchanted bow 😞
The issue does not always occur for me, but is quite common

Interestingly, this issue does not affect wandering traders.

Is this still happening in 1.16-pre2? I tested against 20w22a and replicated this, but I cannot repro it in the pres, so I think it may have been fixed incidentally.

Cannot reproduce in 1.16 pre-2

Unable to reproduce in 1.16-pre2 either.

Realy mad bug.
I could reproduce thus problem with a bow in version 1.15.2.
The bow was charging while i was trading, and after closing the trade, the bow fired and killed my villager (with mending, feather falling III and infinity trades 😞 )