Compare commits
3 Commits
29fe7de4dd
...
dfd0f54ef4
| Author | SHA1 | Date |
|---|---|---|
|
|
dfd0f54ef4 | |
|
|
72fccde017 | |
|
|
1f76541b84 |
|
|
@ -42,9 +42,9 @@ const enchantment_list = {
|
|||
shepherd: ['knockback', 'aqua_affinity'],
|
||||
toolsmith: ['silk_touch', 'fortune'],
|
||||
weaponsmith: ['sharpness', 'fire_aspect'],
|
||||
'chefsdelight:delightchef': ['flame', 'fire_aspect'],
|
||||
'chefsdelight:delightcook': ['flame', 'fire_aspect'],
|
||||
'sawmill:carpenter': ['knockback', 'fortune'],
|
||||
delightchef: ['flame', 'fire_aspect'],
|
||||
delightcook: ['flame', 'fire_aspect'],
|
||||
carpenter: ['knockback', 'fortune'],
|
||||
};
|
||||
|
||||
// level 2 villagers sell consumables for 2 emerald
|
||||
|
|
@ -84,11 +84,11 @@ const consumables = {
|
|||
// sword, axe
|
||||
weaponsmith: ['iron_sword', 'iron_axe', 'golden_sword', 'golden_axe'],
|
||||
// rice, spaghetti, dough, crust
|
||||
'chefsdelight:delightchef': ['8x farmersdelight:rice', '10x farmersdelight:raw_pasta', '10x farmersdelight:crust', '16x sugar'],
|
||||
delightchef: ['8x farmersdelight:rice', '10x farmersdelight:raw_pasta', '10x farmersdelight:crust', '16x sugar'],
|
||||
// cut raw meat
|
||||
'chefsdelight:delightcook': ['16x bowl', '16x glass_bottle', '1x bucket', '8x farmersdelight:minced_beef', '8x farmersdelight:bacon'],
|
||||
delightcook: ['16x bowl', '16x glass_bottle', '1x bucket', '8x farmersdelight:minced_beef', '8x farmersdelight:bacon'],
|
||||
// planks
|
||||
'sawmill:carpenter': ['32x oak_planks', '32x spruce_planks', '32x birch_planks', '32x jungle_planks', '32x pine_planks', '32x bamboo_planks',
|
||||
carpenter: ['32x oak_planks', '32x spruce_planks', '32x birch_planks', '32x jungle_planks', '32x pine_planks', '32x bamboo_planks',
|
||||
'32x cherry_planks'],
|
||||
};
|
||||
|
||||
|
|
@ -136,6 +136,7 @@ const food_list = [
|
|||
* @returns {string}
|
||||
*/
|
||||
function roll(list, random){
|
||||
if (list == null) throw new Error("list not valid...");
|
||||
return list[Math.floor(random.nextFloat() * list.length)];
|
||||
}
|
||||
|
||||
|
|
@ -183,8 +184,14 @@ MoreJSEvents.villagerTrades((event) => {
|
|||
event.removeVanillaTrades();
|
||||
event.removeModdedTrades();
|
||||
const professions = VillagerUtils.getProfessions();
|
||||
for(const prof of professions){
|
||||
professions.forEach(prof => {
|
||||
const profName = prof.name();
|
||||
if(profName === 'nitwit') return;
|
||||
const rolls = enchant_consumables[profName] || 0;
|
||||
const enchantments = enchantment_list[profName];
|
||||
const staples = consumables[profName];
|
||||
if(!enchantments) throw new Error("No enchantments for " + profName);
|
||||
if(!staples) throw new Error("No staples for " + profName);
|
||||
// 1 level 5 trade
|
||||
event.addCustomTrade(prof, 5, (offer, entity, random) => {
|
||||
offer.setFirstInput(roll(feast_list, random));
|
||||
|
|
@ -205,20 +212,18 @@ MoreJSEvents.villagerTrades((event) => {
|
|||
});
|
||||
// level 3
|
||||
event.addCustomTrade(prof, 3, (offer, entity, random) => {
|
||||
const rolls = 1 + (enchant_consumables[profName] || 0);
|
||||
offer.setFirstInput(roll(gems, random));
|
||||
offer.setSecondInput('8x emerald');
|
||||
offer.setOutput(genEnchanted(['enchanted_book'], enchantment_list[profName], rolls, random, false));
|
||||
offer.setOutput(genEnchanted(['enchanted_book'], enchantments, rolls+1, random, false));
|
||||
offer.setMaxUses(1);
|
||||
offer.setVillagerExperience(1);
|
||||
offer.setPriceMultiplier(1);
|
||||
});
|
||||
// level 2
|
||||
event.addCustomTrade(prof, 2, (offer, entity, random) => {
|
||||
const rolls = enchant_consumables[profName] || 0;
|
||||
offer.setFirstInput('2x emerald');
|
||||
if(rolls > 0) offer.setOutput(genEnchanted(consumables[profName], enchantment_list[profName], rolls, random, true));
|
||||
else offer.setOutput(roll(consumables[profName], random));
|
||||
if(rolls > 0) offer.setOutput(genEnchanted(staples, enchantments, rolls, random, true));
|
||||
else offer.setOutput(roll(staples, random));
|
||||
offer.setMaxUses(1);
|
||||
offer.setVillagerExperience(1);
|
||||
offer.setPriceMultiplier(1);
|
||||
|
|
@ -232,5 +237,5 @@ MoreJSEvents.villagerTrades((event) => {
|
|||
offer.setPriceMultiplier(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue