fix: more
This commit is contained in:
parent
1f76541b84
commit
72fccde017
|
|
@ -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)];
|
||||
}
|
||||
|
||||
|
|
@ -184,8 +185,16 @@ MoreJSEvents.villagerTrades((event) => {
|
|||
event.removeModdedTrades();
|
||||
const professions = VillagerUtils.getProfessions();
|
||||
let profName = '';
|
||||
let rolls = 0;
|
||||
let enchantments = null;
|
||||
let staples = null;
|
||||
for(const prof of professions) {
|
||||
profName = prof.getName();
|
||||
profName = prof.name();
|
||||
rolls = enchant_consumables[profName] || 0;
|
||||
enchantments = enchantment_list[profName];
|
||||
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));
|
||||
|
|
@ -206,20 +215,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue