1

How to stop command generated villagers changing prices?

I_Like_Nuggets 10/6/19 4:57 am
7.8k
11/30/2019 9:46 am
Hello, I'm making a small adventure map that has custom generated villagers with custom trades and I was wondering if there was any way of making it so that the villager has fixed prices, or any other solutions so that I don't have to put an incredibly inflated amount of currency around the map. For example, the typical price is 3 Nuggets, but one accidental slap to his face and it goes up to 27 Nuggets!
Posted by
I_Like_Nuggets
Level 1 : New Miner
0

  Have something to say?

JoinSign in

8

Bertiecrafter
11/30/2019 9:46 am
Level 72 : Legendary System
history
I revisited this question, because I wanted to do something with custom trades. This is a list of problems and the solutions I found. It might be too late for the project this post was written for, but it's good for future reference (as of 1.14).
  • If a "job site block" is found, trades will restock, making the maxUses tag useless. The "nitwit" profession type doesn't have a job site block, disabling restocks. The "unemployed" profession type also doesn't have a job site block, but doesn't allow opening the trade menu at all and such villager will change it's profession if it finds one.
  • New trades will become available after trading. The nitwit doesn't generate new trades, the level tag is now only used for the visual appearence of their belt badge, ranking and xp bar. Using a level tag with value above maximum (6 or higher), disables the generation of new trades regardless of profession and hides the rank/xp bar in the UI.
  • If a player trades loads or has the "Hero of the Village" effect from defeating a raid, prices will change. All discount tags and the effect only apply to the buy tag (first slot). By putting the costs in the buyB tag (second slot), the costs are never changed. As far as I know, it's not possible to have a static price in the first slot. It's still possible to put a trade with an item count of 1 in the first slot, because discounts never make the item count go below 1.
Other tips for map making:
  • The NoAI tag does not disable trading, nor does it prevent any of the changes mentioned above.
  • If the villager type is not specified, it'll pick the correct type for the biome it's spawned in.
  • A custom name hides the profession name (Not the rank). Once again, use the level tag with a value above maximum (6 or higher) to disable generation of new trades, rank name and xp bar.
Maybe you could change the title to something like "How to prevent custom villager trades from being changed by discounts and leveling up?". It increases the chances of being found by people asking themselves the same thing.
1
HoboMaggot
10/06/2019 8:51 pm
Level 55 : Grandmaster Blob
history
The prices are determined by the villager's gossip.
Slap/kill them, the price goes up.
Save them from raids, cure a zombie villager and let it walk around and trading with them makes the price go down.

However if you look at the nbt tags of the villager, there is no way to change the gossip of a villager without getting your UUIDLeast and UUIDMost. If you dont know what that means: https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2530432-uuidleast-and-uuidmost-what-do-they-truely-do

Maybe you can use the "LastGossipDecay" nbt tag to get rid of good/bad gossips
1
Bertiecrafter
10/06/2019 2:56 pm
Level 72 : Legendary System
It doesn't seem like there's a datatag for it. However, you can use the Invulnerable datatag.
/summon villager ~ ~ ~ {Invulnerable:1b,Offers:{Recipes:[LIST OF TRADES HERE]}}
1
HoboMaggot
10/06/2019 8:53 pm
Level 55 : Grandmaster Blob
Invulnerable wont change if the villager is influenced or not. Even if invincible, prices will go lower if you do good deeds (like trading)
1
Bertiecrafter
10/07/2019 1:10 pm
Level 72 : Legendary System
history
From your other comment you seem to know quite a bit about NBT formatting, so I'm just going to throw some stuff at you.
Use this for NBT tag list:
https://minecraft.gamepedia.com/Chunk_format
Next to priceMultiplier tags it gives the formula for the final price. From this, you can see that you should put priceMultiplier for every trade at 0, because price = buy count + (demand x priceMultiplier). Next to demand it says that the number is updated after every restock and I can't find any tags about modifying that behaviour. This doesn't matter though, because 0 x anything is always 0.

If that doesn't work, try using /data on a loop to clear the gossips list. (Set the "Gossips" path to "[]", two square brackets)
Or maybe try setting the restock and/or demand values at 0 on loop.

If you get things working, you should post an example command that spawns a villager with 1 trade that doesn't change :)
2
HoboMaggot
10/07/2019 8:57 pm
Level 55 : Grandmaster Blob
priceMultiplier does work, however it only works for that 1 trade, so you need to repeat commands like:
/execute as @e[type=minecraft:villager] run data modify entity @s Offers.Recipes[0].priceMultiplier set value 0
/execute as @e[type=minecraft:villager] run data modify entity @s Offers.Recipes[1].priceMultiplier set value 0

Gossips work, but restock only restocks the trade and has no ability to stop the prices from changing and demand has the same probelm as priceMultiplier
1
Bertiecrafter
10/08/2019 12:07 am
Level 72 : Legendary System
Can't you just put the price multiplier in the summon command or is it really necessary to repetitively run a data modify command? Maybe NoAI:1b removes this behaviour as well. Downside is that the villager won't move anymore and idk if the trading interface works at all.
1
HoboMaggot
10/08/2019 12:44 am
Level 55 : Grandmaster Blob
You can put it in the summon command, but with all the testing I tried out, the villager keeps going jobless.
For the adventure map, NoAI villagers would be bad design
1

Welcome