Discounting villager prices

Started by Marmations on

Topic category: Help with MCreator software

Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Discounting villager prices

I was wondering if there is any way to discount the trade prices of a villager for a specific player, just like how things work with the Hero of the Village effect. I'm not sure if it's as easy as editing some NBT data of the villager with a few procedures, or if that behavior of discounting prices is hardcoded into the actual villager's code itself.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't think prices are…
Fri, 12/29/2023 - 15:16

I don't think prices are hardcoded into villagers themselves, though the hero-of-the-village mechanic probably is. It's probably an NBT, as I know you can spawn villagers with custom trades, and there doesn't appear to be any loot table files for it. (This Mob Summoning Generator seems to think so too.) If it is NBT, you can override it using the /data command, or manually with procedures.

Adding trades should be easy enough, the difficult part will be modifying existing ones. You essentially need to get the existing NBT data, translate it into variables you can use, and then return a series of trade NBT tags that's based off of the originals. (Not impossible, but will involve a lot of finicking with text functions.) And of course, the changes will still be permanent. (Though you could theoretically make some sort of status effect or number-nbt timer that reverts the trades after it expires, but you would either need to decrease everything by a predetermined amount, or also save the original trades as nbt tags in order to know what to restore.)