MC/tools/build-planet-datapacks.mjs
2026-11-27 23:43:05 +00:00

38 lines
5.7 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';
const input=process.argv[2],output=process.argv[3];if(!input||!output)throw Error('Usage: input-folder output-folder');
const profiles={caladan:['swamp','mangrove_swamp','sparse_jungle','forest','old_growth_birch_forest','stony_peaks','windswept_forest','lukewarm_ocean','deep_ocean','river','warm_ocean','deep_lukewarm_ocean','stony_shore','jungle','bamboo_jungle','cherry_grove','lush_caves'],kaitain:['flower_forest','meadow','sunflower_plains','birch_forest','savanna','savanna_plateau','windswept_savanna','river','ocean','beach','plains','dark_forest','cherry_grove','taiga'],giedi_prime:['stony_peaks','windswept_gravelly_hills','deep_dark','dripstone_caves','badlands','eroded_badlands','wooded_badlands','pale_garden'],sigma_draconis_iv:['cold_ocean','deep_cold_ocean','old_growth_pine_taiga','old_growth_spruce_taiga','windswept_hills','windswept_gravelly_hills','snowy_plains','snowy_slopes','frozen_river','mushroom_fields','ice_spikes','snowy_taiga','snowy_beach','frozen_peaks','jagged_peaks','frozen_ocean','deep_frozen_ocean','grove']};
const passive=new Set('allay armadillo axolotl bat camel cat chicken cod cow donkey frog glow_squid horse mooshroom mule ocelot parrot pig pufferfish rabbit salmon sheep sniffer snow_golem squid strider tadpole tropical_fish turtle villager wandering_trader'.split(' '));
const nether=new Set('blaze ghast hoglin magma_cube piglin piglin_brute strider wither_skeleton zoglin zombified_piglin skeleton enderman'.split(' '));
const read=name=>JSON.parse(fs.readFileSync(path.join(input,name),'utf8'));
const save=(root,name,data)=>{const file=path.join(root,name);fs.mkdirSync(path.dirname(file),{recursive:true});fs.writeFileSync(file,JSON.stringify(data,null,2)+'\n');};
for(const[planet,biomes]of Object.entries(profiles)){
const root=path.join(output,planet);save(root,'pack.mcmeta',{pack:{pack_format:81,description:'DuneRealms '+planet+' biome ecology and native structures · Minecraft 1.21.8'}});
for(const biome of biomes){
const name='data/minecraft/worldgen/biome/'+biome+'.json',data=read(name);
// Native DuneTerrain ore profiles remain authoritative. Keep stone/dirt veins and decoration.
const isOre=feature=>/minecraft:ore_(?:coal|iron|copper|gold|redstone|diamond|lapis|emerald|ancient_debris|debris|quartz|nether_gold)/.test(feature);
data.features=data.features.map(step=>step.filter(feature=>!isOre(feature)&&!(planet!=='kaitain'&&feature.includes('patch_pumpkin'))&&!(planet!=='caladan'&&feature.includes('patch_melon'))&&!(planet==='giedi_prime'&&/(?:spring_water|lake_water|lake_lava|spring_lava|spring_delta|disk_clay|patch_sugar_cane|patch_waterlily)/.test(feature))&&!(planet==='sigma_draconis_iv'&&/(?:lake_lava|spring_lava)/.test(feature))));
if(planet==='giedi_prime'){
data.has_precipitation=false;data.temperature=1.2;
for(const feature of ['minecraft:monster_room','minecraft:monster_room_deep'])if(!data.features[3].includes(feature))data.features[3].push(feature);
data.features=data.features.map(step=>step.filter(feature=>!feature.includes('trees_badlands')));
}
for(const[category,entries]of Object.entries(data.spawners)){data.spawners[category]=entries.filter(row=>{const mob=row.type.replace('minecraft:','');return planet==='caladan'?mob!=='creeper':planet==='kaitain'?passive.has(mob):planet==='giedi_prime'?nether.has(mob):['skeleton','stray','wither_skeleton','bogged'].includes(mob)||biome==='mushroom_fields'&&mob==='mooshroom';});}
save(root,name,data);
}
if(planet==='giedi_prime'){
save(root,'data/minecraft/tags/worldgen/biome/has_structure/mineshaft.json',{replace:false,values:profiles.giedi_prime.map(b=>'minecraft:'+b)});
const dripstone=read('data/minecraft/worldgen/configured_feature/dripstone_cluster.json');dripstone.config.wetness=0;save(root,'data/minecraft/worldgen/configured_feature/dripstone_cluster.json',dripstone);
}
if(planet==='sigma_draconis_iv'){
const data=read('data/minecraft/worldgen/biome/snowy_plains.json');data.has_precipitation=false;data.temperature=-.7;data.features=data.features.map(step=>step.filter(feature=>!feature.includes('trees_')&&!feature.includes('patch_pumpkin')));data.spawners=Object.fromEntries(Object.entries(data.spawners).map(([k,rows])=>[k,rows.filter(row=>['minecraft:skeleton','minecraft:stray'].includes(row.type))]));save(root,'data/dunerealms/worldgen/biome/frozen_desert.json',data);
save(root,'data/minecraft/tags/worldgen/biome/has_structure/village_taiga.json',{replace:false,values:['minecraft:snowy_taiga','minecraft:old_growth_pine_taiga','minecraft:old_growth_spruce_taiga']});
save(root,'data/minecraft/tags/worldgen/biome/has_structure/igloo.json',{replace:false,values:['dunerealms:frozen_desert']});
const villages=read('data/minecraft/worldgen/structure_set/villages.json');villages.structures=[{structure:'minecraft:village_snowy',weight:1},{structure:'minecraft:village_taiga',weight:1}];save(root,'data/minecraft/worldgen/structure_set/villages.json',villages);
}
if(planet==='kaitain'){
save(root,'data/minecraft/tags/worldgen/biome/has_structure/trail_ruins.json',{replace:false,values:['minecraft:plains','minecraft:taiga','minecraft:birch_forest','minecraft:flower_forest']});
const villages=read('data/minecraft/worldgen/structure_set/villages.json');villages.structures=[{structure:'minecraft:village_plains',weight:1},{structure:'minecraft:village_savanna',weight:1}];villages.placement.spacing=Math.round(villages.placement.spacing*Math.SQRT2);villages.placement.separation=Math.round(villages.placement.separation*Math.SQRT2);save(root,'data/minecraft/worldgen/structure_set/villages.json',villages);
}
console.log(planet,biomes.length,'native biome overrides; native ores suppressed, decoration retained');
}