Stop custom villagers from generating new random trades on their own [duplicate]

So lately I've been working on a minigame map with command blocks and I wanted to create a villager shop. However when I set up some custom trades whenever you traded with him it unlocked new random trades, I don't want this to happen is there a way to prevent this? (Btw I know this similar has been asked before however the answers didn't quite help me so I decide to ask it myself :D )


Solution 1:

As an example, let's say you have this command to spawn a villager:

/summon Villager ~1 ~ ~ {Profession:0,Career:1,Offers:{Recipes:[{buy:{id:"dirt",Count:1},maxUses:9999999,sell:{id:"dirt",Count:2}}]}}

This is a basic command. He will sell 1 dirt for 2 dirt. If you want a villager to not unlocks new trades, you set the CareerLevel higher than its maximum.

The command should look like this now:

/summon Villager ~1 ~ ~ {Profession:0,Career:1,CareerLevel:100,Offers:{Recipes:[{buy:{id:"dirt",Count:1},maxUses:9999999,sell:{id:"dirt",Count:2}}]}}

By setting the CareerLevel to 100, and by having Career set to a value higher than 0 (where a value of 1 works for all professions), we prevented the villager from unlocking new trades upon trading.