mojira.dev
MC-310962

The trading UI opens and immediately closes when interacting with a villager whose trades were altered with commands

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

  1. Run the command: /summon villager ~ ~ ~

  2. 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}}]}}

  3. Attempt to right-click the villager to open the trading interface.

Method 2: Setting trades within the /summon command

  1. Run the command: /summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:emerald,count:1},sell:{id:book,count:1}}]}}

  2. 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:

  1. 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.

  2. This bug has been present since version 1.21.5 and remains unfixed.

  3. 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.

  4. Very Important: if you exit and re-join the world, this bug will still exist.

Attachments

Comments 2

Thank you for helping us improve Minecraft! We saved your files:

[media]

I’m tested on 23w18a, can confirm.

It’s mean 1.20.x-1.21.x both exist this bug.

GetSoftwares

etanaratsastaja

Confirmed

Platform HC

Normal

Trading

26.2, 26.3 Snapshot 7

26.3 Snapshot 9

Retrieved