// Original voxel geometry. Native block textures are referenced, not redistributed. import {mkdir,writeFile} from 'node:fs/promises'; import {fileURLToPath} from 'node:url'; import path from 'node:path'; import {redPandaJerboaModels} from './build-jerboa-red-panda.mjs'; const root=fileURLToPath(new URL('../DuneRealmsGUI/ecology/models/',import.meta.url)); const faces=texture=>Object.fromEntries(['north','south','east','west','up','down'].map(face=>[face,{texture:'#'+texture,uv:[0,0,16,16]}])); const box=(from,to,texture)=>({from,to,faces:faces(texture)}); export function faunaModels(){ const worm=[]; for(let i=0;i<7;i++){const width=7-i*.55,z=4+i*3.2;worm.push(box([8-width/2,2+i*.08,z],[8+width/2,2+width,z+3.2],i%2?'ridge':'body'));} worm.push(box([3,2,0],[13,11,4],'body'),box([4,3,-.1],[12,10,.1],'mouth'),box([6,5,-.2],[10,8,0],'throat')); for(let i=0;i<4;i++){worm.push(box([4.5+i*1.8,3,-.4],[5.3+i*1.8,4.5,.1],'tooth'),box([4.5+i*1.8,8.5,-.4],[5.3+i*1.8,10,.1],'tooth'));} const models={ ...redPandaJerboaModels(), tiny_worm:{textures:{body:'minecraft:block/terracotta',ridge:'minecraft:block/brown_terracotta',mouth:'minecraft:block/black_concrete',throat:'minecraft:block/orange_terracotta',tooth:'minecraft:block/bone_block_side'},elements:worm} }; for(const [name,model] of Object.entries(models))model.textures.particle=name==='tiny_worm'?'#body':'#fur'; return models; } export function faunaSpriteAtlasEntries(){ const sprite='dunerealms:entity/jerboa'; const source={sources:[{type:'minecraft:single',resource:sprite,sprite}]}; return new Map(['blocks','items'].map(atlas=>[`assets/minecraft/atlases/${atlas}.json`,Buffer.from(JSON.stringify(source))])); } export async function buildFaunaModels(output=root){await mkdir(output,{recursive:true});for(const [name,model]of Object.entries(faunaModels()))await writeFile(path.join(output,name+'.json'),JSON.stringify({ambientocclusion:false,...model})+'\n');} if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url))await buildFaunaModels();