0

Using the Offers:{Recipes:... tag, you're able to /summon a villager with custom trades, and limits on those trades.

Problem is, once you start trading with that villager, he starts adding new trades, or reopening trades that previously ran out. Is there any way to prevent this?

That is to say, if my villager has exactly one trade with one use, for instance, can I prevent him from opening new, non-custom trades - or worse, reopening the custom one that should have had just one use?

I'd prefer to keep him around once his trades run out, and simply be unable to trade with him, but if it comes to /killing all villagers that don't have active trades, so be it.

  • For the limiting new trades being added, you could always add an impossible trade at the end, for example, have a player trade nothing for a barrier. The solution below is honestly much better. – David Jul 13 '17 at 21:00
  • @David The trades appear even if the others haven't run out yet. – DonielF Jul 13 '17 at 21:03
  • Please don't ask two questions in one. – pppery Jul 28 '19 at 0:12
  • @pppery Where did I ask a second question? – DonielF Jul 28 '19 at 2:05
  • "How to prevent a villager from adding new trades" and "How to prevent a villager from refreshing its old trades" are two distinct questions with separate answers and should not have been combined into one question. – pppery Jul 28 '19 at 2:17
4

New trades unlocking can be prevented by setting the CareerLevel of the villager to a high number (like 100).

Limiting the trade to X times without it being able to "refesh" (refreshing will also increase the maxUses) is done by setting the "maxUses" to its maximum value and "uses" to X below.

An example:

/summon villager ~ ~1 ~ {Career:1,CareerLevel:100,Offers:{Recipes:[{uses:2147483645,maxUses:2147483647,buy:{id:stone,Count:1},sell:{id:stone,Count:1}},{uses:2147483645,maxUses:2147483647,buy:{id:stone,Count:1},sell:{id:stone,Count:1}}]}}

Since maxUses is set to its maximum, if a refresh is triggered (which will try to increase the maxUses) it will overflow to negatives and lock the trade.In the example, the trade can only be used 2 times (since uses is maxUses-2).

  • 100 is nowhere near high enough. I needed to go all the way to 2^31-1 to get him to stop making trades. He'll still spew purple bubbles as if he's making new trades, but double-checking his GUI, he doesn't actually do so. Thanks! – DonielF Jul 13 '17 at 21:24
  • There's no way the current "vanilla" maximum CareerLevel is higher than 100. – Pepijn Jul 13 '17 at 21:48
  • Hey, I'm just reporting what my experience was. I'm working with vanilla 1.12. – DonielF Jul 13 '17 at 21:49
  • Well, I'm not able to reproduce it... But it doesn't really matter. Using 2^31-1 is just amazing future proofing either way :P. – Pepijn Jul 13 '17 at 21:54
  • You never know. I might still be playing with this map in 3017 and the mobs aren't functioning properly. :P – DonielF Jul 13 '17 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.