I am experimenting with NBT tags, and I tried to summon a villager with custom trades (via NBT tags). It did not give me an error; it successfully summoned a villager, but when I opened its trading menu, it immediately closed. This issue repeated every single time I tried to trade with the villager.
I ran this command:
/summon villager ~ ~ ~ {Offers:{Recipes:[{buy:{id:dirt,Count:6}, sell:{id:diamond_block,Count:64}, maxUses:9999999}]}}
I do not know what was wrong with the villager, and I read something on the Mojang forum for Java edition about this, and it did not help much, as it was for naturally spawned villagers with occupations. I gave the villagers a composter, so that they would get an occupation (fixing the issue described on the Mojang forum), but that cleared their trades. Although they would open the trade menu when I did this, I do not know how to use the data command to modify their NBT tags directly.
How can I do this correctly?
I am using Java edition 1.20.4.
Would you mind trying to put the items id's between quotation marks?
Let me know if you still encounter the error