The trading interface immediately closes (flashes and shuts) when a player attempts to open the trades of a villager whose trades were set using the /data command (on a villager with no prior trades) or via the /summon villager command with specified trades. This issue can also be reproduced when trades are set using a command block. Note that the game itself does not crash; only the trading interface fails to stay open.
How to Reproduce:
Method 1: Using the /data command
Run the command:
/summon villager ~ ~ ~Aim the crosshair at the villager spawned in step 1, and run the command:
/data merge entity <Villager's UUID> {Offers:{Recipes:[{buy:{id:emerald,count:1},sell:{id:book,count:1}}]}}Attempt to right-click the villager to open the trading interface.
Method 2: Setting trades within the /summon command
Run the command:
/summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:emerald,count:1},sell:{id:book,count:1}}]}}Attempt to right-click the villager to open the trading interface.
Observed Result:
The trading interface immediately closes (flashes and shuts) upon clicking the villager, while the game remains running.
Expected Result:
The trading interface should open and remain stable without closing.
Additional Information:
There are two workarounds that allow the trading interface to open normally in this scenario: using the /tick freeze command or setting the villager's NoAI tag to 1.
This bug has been present since version 1.21.5 and remains unfixed.
If the villager already has existing trades (typically obtained via a job site block) and the trades are modified using /data modify entity or /data merge entity, the trading interface opens normally without closing.
Very Important: if you exit and re-join the world, this bug will still exist.
Thank you for helping us improve Minecraft! We saved your files: