Minecraft Commands – How to Remove a Specific Trade from a Villager in Minecraft 1.16

minecraft-commandsminecraft-data-packsminecraft-java-edition

I'm trying to make it so that when a villager runs out of stock of a specific trade, it removes that trade from the villager.

I'm stuck at the part where I remove the trade.
So far I can only wipe the villager's trades or add a new trade, but not remove a specific trade.

I've tried using

/data modify with the path : Offers.Recipes[{buy:{id:”minecraft:stone”},sell:{id:”minecraft stone”}}]

I've also tried it with the Count tag, but it does not work either.

Best Answer

Instead of using /data modify, use /data remove.

/data remove @e[type=villager,name="TheVillagerToActUpon",limit=1] Offers.Recipes[{buy:{id:"minecraft:stone"},sell:{id:"minecraft:stone"},Uses:5}]

Replace the 5 in Uses:5 to say how many times the trade can be used. Put the command in a repeating command block.