jacky8399 / BalancedVillagerTrades

Balance 1.14+ trades
GNU General Public License v3.0
6 stars 1 forks source link

How can I make villagers ask for emerald blocks when prices are over 64 emeralds? #2

Closed Gabo6480 closed 2 years ago

Gabo6480 commented 2 years ago

For example, in theory an enchanted book of Efficiency V can cost up to 71 emeralds, however the price is capped at 64 emeralds. I would like to allow villagers to ask for a roughly equivalent payment in emerald blocks instead of capping the price in emeralds when the prices exceed 64 emeralds. For the example of the Efficiency V enchanted book, ideally the villager would ask for 8 emerald blocks as payment for the enchanted book ( 71 / 9 = 7.888 rounding up to 8 cuz villagers are greedy ).

jacky8399 commented 2 years ago

I don't think it is possible to recover the original price, since it is generated when the villager unlocked that trade. I can try to make the prices (min and max price) available and we'll see what we can do with that information.

Gabo6480 commented 2 years ago

Well, maybe we can use the min and max price to "re-roll" the price of the item and then use it to replace the original one in the ItemStack of the MerchantRecipe, since it allows to store values higher than 64, but the original price gets clamped down to 64 upon acquisition. Then we can have access to that value instead to make the calculations.

jacky8399 commented 2 years ago

Thank you for the suggestion! This feature has been added in beta6 with this example. It rerolls level 5 enchantment books once, and if it costs more than 64 emeralds, the cost is replaced with emerald blocks instead. From my own tests: bvt (the item is renamed to avoid rerolling the cost every time a player interacts with the villager)

If you need help changing the cost formula to further "balance" the trades, feel free to leave a comment.

Gabo6480 commented 2 years ago

I'm getting the following error:

[21:13:09 WARN]: [BalancedVillagerTrades] [Script Error] com.jacky8399.balancedvillagertrades.luaj.vm2.LuaError: result_item = trade.result if result_item.name ~= nil and result_item.name:find("Libro Encantado") then return end

trade.result.name = "Libro Encantado Equisde":2 vm error: java.lang.NullPointerException: Cannot invoke "Object.toString()" because "value" is null

jacky8399 commented 2 years ago

Sorry, this has been fixed in beta 7