refactor: carpenter

This commit is contained in:
hyper 2025-12-02 12:51:03 +08:00
parent fad3864d55
commit aa0d1fe5a5
2 changed files with 55 additions and 12 deletions

View File

@ -29,10 +29,3 @@
- [x] add configs for tidal towns - [x] add configs for tidal towns
- they're just another plains village - they're just another plains village
- [ ] map atlases no longer need paper
- just remove all maintainence cost
- [ ] spyglass can be used from inventory & activates jade
- [ ] bottle of dimension tears required for nether portal

View File

@ -1,4 +1,5 @@
const { $RandomSource } = require("packages/net/minecraft/util/$RandomSource"); const { $RandomSource } = require("packages/net/minecraft/util/$RandomSource");
const { $Villager } = require("packages/net/minecraft/world/entity/npc/$Villager");
// level 5 just eat feast for 5 emeralds // level 5 just eat feast for 5 emeralds
const feast_list = [ const feast_list = [
@ -8,6 +9,11 @@ const feast_list = [
'farmersdelight:stuffed_pumpkin_block', 'farmersdelight:stuffed_pumpkin_block',
'farmersdelight:roast_chicken_block', 'farmersdelight:roast_chicken_block',
'farmersdelight:pasta_with_meatballs', 'farmersdelight:pasta_with_meatballs',
'abnormals_delight:perch_with_mushrooms',
'abnormals_delight:pike_with_beetroot',
'abnormals_delight:vension_with_bamboo_shoots',
'abnormals_delight:passion_fruit_glazed_duck',
]; ];
// level 4 helps you with block collection // level 4 helps you with block collection
@ -69,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: ['bow', 'bow', 'bow', 'crossbow', 'crowssbow'], fletcher: [],
// 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
@ -82,16 +88,15 @@ const consumables = {
// wool, eggs, milk, honey, slime ball // wool, eggs, milk, honey, slime ball
shepherd: ['3x white_wool', '8x environmental:duck_egg', '8x autumnity:turkey_egg', '4x environmental:yak_hair'], shepherd: ['3x white_wool', '8x environmental:duck_egg', '8x autumnity:turkey_egg', '4x environmental:yak_hair'],
// shovel, pick // shovel, pick
toolsmith: ['iron_shovel', 'iron_pickaxe', 'golden_shovel', 'golden_pickaxe'], toolsmith: ['iron_shovel', 'iron_pickaxe', 'iron_hoe', 'golden_shovel', 'golden_pickaxe', 'golden_hoe'],
// sword, axe // sword, axe
weaponsmith: ['iron_sword', 'iron_axe', 'golden_sword', 'golden_axe'], weaponsmith: ['iron_sword', 'iron_axe', 'golden_sword', 'golden_axe', 'bow', 'crossbow'],
// rice, spaghetti, dough, crust // rice, spaghetti, dough, crust
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 // cut raw meat
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 // planks
carpenter: ['32x oak_planks', '32x spruce_planks', '32x birch_planks', '32x jungle_planks', '32x pine_planks', '32x bamboo_planks', carpenter: [],
'32x cherry_planks'],
}; };
const enchant_consumables = { const enchant_consumables = {
@ -221,6 +226,28 @@ const village_structures = {
'mmv:village_swamp': 1, 'mmv:village_swamp': 1,
"atmospheric:village_scrubland" : 1 "atmospheric:village_scrubland" : 1
}; };
const village_logs = {
'minecraft:desert': 'minecraft:cactus',
'minecraft:plains': 'minecraft:oak_log',
'minecraft:savanna': 'minecraft:acacia_log',
'minecraft:snowy': 'minecraft:spruce_log',
'minecraft:taiga': 'minecraft:birch_log',
'minecraft:jungle': 'minecraft:jungle_log',
'minecraft:swamp': 'minecraft:dark_oak_log',
'atmospheric:scrubland': 'atmospheric:yucca_log'
};
// various saplings
const carpenter_trades = [
'minecraft:oak_sapling',
'minecraft:spruce_sapling',
'minecraft:birch_sapling',
'minecraft:acacia_sapling',
'minecraft:jungle_sapling',
'minecraft:dark_oak_sapling',
'minecraft:mangrove_sapling',
'minecraft:cherry_sapling',
'minecraft:azalea_sapling',
];
/** /**
* @param {Record<string, number>} map * @param {Record<string, number>} map
*/ */
@ -236,6 +263,7 @@ MoreJSEvents.villagerTrades((event) => {
event.removeVanillaTrades(); event.removeVanillaTrades();
event.removeModdedTrades(); event.removeModdedTrades();
// cartographers: explorer maps
const villages = make_weighted_list(village_structures) const villages = make_weighted_list(village_structures)
const villageTrade = VillagerUtils.createStructureMapTrade(['2x emerald', 'map'], villages); const villageTrade = VillagerUtils.createStructureMapTrade(['2x emerald', 'map'], villages);
villageTrade.maxUses(1); villageTrade.maxUses(1);
@ -251,6 +279,28 @@ MoreJSEvents.villagerTrades((event) => {
progressionTrade.maxUses(1); progressionTrade.maxUses(1);
event.addTrade('cartographer', 2, progressionTrade); event.addTrade('cartographer', 2, progressionTrade);
// carpenters: logs, saplings, planks, tree barks
event.addCustomTrade('sawmill:carpenter', 2, (offer, entity, random) => {
/** @type {$Villager} */
const villager = entity;
const villagerData = villager.getVillagerData();
const biome = villagerData.getType().toString();
const log = village_logs[biome] || 'minecraft:oak_log';
offer.setFirstInput('2x emerald');
offer.setOutput('16x ' + log);
offer.setMaxUses(1);
offer.setVillagerExperience(1);
offer.setPriceMultiplier(0.05);
});
event.addCustomTrade('sawmill:carpenter', 2, (offer, entity, random) => {
offer.setFirstInput('2x emerald');
offer.setOutput(roll(carpenter_trades, random));
offer.setMaxUses(1);
offer.setVillagerExperience(1);
offer.setPriceMultiplier(0.05);
});
const professions = VillagerUtils.getProfessions(); const professions = VillagerUtils.getProfessions();
professions.forEach(prof => { professions.forEach(prof => {
const profName = prof.name(); const profName = prof.name();