fix: trades

This commit is contained in:
hyper 2025-12-02 13:22:03 +08:00
parent aa0d1fe5a5
commit 79631b6eb6
2 changed files with 45 additions and 16 deletions

View File

@ -21,7 +21,7 @@
- [x] common villager trades - [x] common villager trades
- [x] villager explorer map trades - [x] villager explorer map trades
- [ ] villager diet update - [x] villager diet update
- a village biome specific main crop that everybody eats - a village biome specific main crop that everybody eats
- more random snacks / drinks / beer on the second slot - more random snacks / drinks / beer on the second slot
- add more of farmer's complex food (4+ ingredients, cooked, etc) - add more of farmer's complex food (4+ ingredients, cooked, etc)

View File

@ -75,7 +75,7 @@ const consumables = {
fisherman: ['2x aquaculture:fish_bones', '3x aquaculture:leech', '5x aquaculture:worm', '8x aquaculture:box', fisherman: ['2x aquaculture:fish_bones', '3x aquaculture:leech', '5x aquaculture:worm', '8x aquaculture:box',
'5x aquaculture:lockbox', '2x aquaculture:treasure_chest'], '5x aquaculture:lockbox', '2x aquaculture:treasure_chest'],
// various potion arrows, bows, crossbows // various potion arrows, bows, crossbows
fletcher: [], fletcher: ['8x arrow', '4x caverns_and_chasms:large_arrow', '16x caverns_and_chasms:blunt_arrow', '8x savage_and_ravages:mischief_arrow'],
// leather armor, bedrolls // leather armor, bedrolls
leatherworker: ['leather_helmet', 'leather_chestplate', 'leather_leggings', 'leather_boots'], leatherworker: ['leather_helmet', 'leather_chestplate', 'leather_leggings', 'leather_boots'],
// various dyes // various dyes
@ -101,7 +101,6 @@ const consumables = {
const enchant_consumables = { const enchant_consumables = {
armorer: 1, armorer: 1,
fletcher: 1,
leatherworker: 2, leatherworker: 2,
toolsmith: 3, toolsmith: 3,
weaponsmith: 2 weaponsmith: 2
@ -111,17 +110,13 @@ const enchant_consumables = {
const food_list = [ const food_list = [
'8x minecraft:apple', '8x minecraft:apple',
'8x minecraft:beetroot', '8x minecraft:beetroot',
'8x minecraft:baked_potato',
'8x minecraft:bread',
'8x minecraft:carrot',
'8x minecraft:melon_slice', '8x minecraft:melon_slice',
'8x minecraft:sweet_berries', '8x minecraft:sweet_berries',
'8x farmersdelight:pumpkin_slice',
'8x farmersdelight:cabbage_leaf', '8x farmersdelight:cabbage_leaf',
'8x farmersdelight:tomato', '8x farmersdelight:tomato',
'8x farmersdelight:cooked_rice',
'8x farmersdelight:fried_egg', '8x farmersdelight:fried_egg',
'8x farmersdelight:onion',
'8x neapolitan:strawberries', '8x neapolitan:strawberries',
'8x neapolitan:banana', '8x neapolitan:banana',
@ -134,8 +129,29 @@ const food_list = [
'8x atmospheric:dragon_fruit', '8x atmospheric:dragon_fruit',
'8x atmospheric:candied_orange_slices', '8x atmospheric:candied_orange_slices',
'8x atmospheric:roasted_yucca_fruit', '8x atmospheric:roasted_yucca_fruit',
'brewinandchewin:beer',
'brewinandchewin:vodka',
'brewinandchewin:mead',
'brewinandchewin:rice_wine',
'brewinandchewin:pale_jane',
'brewinandchewin:egg_grog',
'brewinandchewin:bloody_mary',
'brewinandchewin:salty_folly',
'brewinandchewin:saccharine_rum',
]; ];
const main_diet = {
'minecraft:desert': '8x #forge:milk',
'minecraft:plains': '8x bread',
'minecraft:savanna': '8x carrot',
'minecraft:snowy': '8x pumpkin_slice',
'minecraft:taiga': '8x baked_potato',
'minecraft:jungle': '8x farmersdelight:cooked_rice',
'minecraft:swamp': '8x mushroom_stew',
'atmospheric:scrubland': '8x atmospheric:dragon_fruit',
default: '8x bread'
}
/** /**
* @param {string[]} list * @param {string[]} list
@ -318,6 +334,27 @@ MoreJSEvents.villagerTrades((event) => {
offer.setVillagerExperience(1); offer.setVillagerExperience(1);
offer.setPriceMultiplier(0.2); offer.setPriceMultiplier(0.2);
}); });
// 1 level 1 trade
event.addCustomTrade(prof, 1, (offer, entity, random) => {
offer.setFirstInput(roll(food_list, random));
offer.setOutput('1x emerald');
offer.setMaxUses(1);
offer.setVillagerExperience(5);
offer.setPriceMultiplier(0.05);
});
// 1 diet trade
event.addCustomTrade(prof, 1, (offer, entity, random) => {
/** @type {$Villager} */
const villager = entity;
const villagerData = villager.getVillagerData();
const biome = villagerData.getType().toString();
const diet = main_diet[biome] || main_diet.default;
offer.setFirstInput(diet);
offer.setOutput('1x emerald');
offer.setMaxUses(1);
offer.setVillagerExperience(5);
offer.setPriceMultiplier(0.05);
});
// 2 for the rest // 2 for the rest
for(let i = 0; i < 2; i ++) { for(let i = 0; i < 2; i ++) {
// level 4 // level 4
@ -347,14 +384,6 @@ MoreJSEvents.villagerTrades((event) => {
offer.setVillagerExperience(1); offer.setVillagerExperience(1);
offer.setPriceMultiplier(0.05); offer.setPriceMultiplier(0.05);
}); });
// level 1
event.addCustomTrade(prof, 1, (offer, entity, random) => {
offer.setFirstInput(roll(food_list, random));
offer.setOutput('1x emerald');
offer.setMaxUses(1);
offer.setVillagerExperience(5);
offer.setPriceMultiplier(0.05);
});
} }
}); });
}); });