"""Build deterministic vanilla item pose models and an original pixel crescent texture. The gauntlet geometry/textures are imported separately and remain unchanged. Only Minecraft JSON display transforms are authored here (no client mod required). """ from pathlib import Path import json, math from PIL import Image ROOT=Path(__file__).resolve().parents[1]/'src/main/resources' D=ROOT/'defaults/resources/assets/astraweapons' def write(path,value): path.parent.mkdir(parents=True,exist_ok=True) path.write_text(json.dumps(value,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') def model(name):return {'type':'minecraft:model','model':name} def main(): # Vertical PNG strip gives the crescent a five-tick expanding/tapering sweep. for fiery in (False,True): size=128; image=Image.new('RGBA',(size,size*5)) for frame in range(5): for y in range(size): for x in range(size): dx=(x+.5-size/2)/(size/2); dz=(y+.5-size/2)/(size/2) r=math.hypot(dx,dz);angle=math.atan2(dx,dz) # Local +Z front half circle. Thin bright edge with a broader transparent tail. if dz>=0 and .58+frame*.035 .18+frame*.09 else 0 image.putpixel((x,y+frame*size),(255,184,79,alpha) if fiery else (222,208,255,alpha)) name='slash_fire' if fiery else 'slash' (D/'textures/item').mkdir(parents=True,exist_ok=True) image.save(D/f'textures/item/{name}.png') write(D/f'textures/item/{name}.png.mcmeta',{'animation':{'frametime':1,'interpolate':False}}) write(D/f'models/effect/{name}.json',{'textures':{'slash':f'astraweapons:item/{name}','particle':f'astraweapons:item/{name}'},'elements':[ {'from':[0,8,0],'to':[16,8,16],'shade':False,'faces':{ 'up':{'texture':'#slash','uv':[0,0,16,16]},'down':{'texture':'#slash','uv':[0,0,16,16],'rotation':180}}}]}) write(D/f'items/{name}.json',{'model':model(f'astraweapons:effect/{name}')}) base=json.loads((D/'models/item/iron_gauntlet_3d.json').read_text()) twin=json.loads((ROOT/'defaults/resources/assets/astraplus/models/item/netherite_twinblade.json').read_text()) for pose in ('jab','hook','uppercut','lunge','twinblade'): for frame in range(6): t=frame/5 pulse=math.sin(math.pi*t) displays={} for side,sign in [('righthand',1),('lefthand',-1)]: if pose=='twinblade': yaw=[-15,-40,0,55,90,20][frame] roll=[15,30,10,-30,-60,-15][frame] for view in ('firstperson_','thirdperson_'): src=twin['display'][view+side] rot=src['rotation'].copy();trans=src['translation'].copy() rot[1]+=sign*yaw;rot[2]+=sign*roll trans[0]-=sign*6*pulse;trans[1]+=pulse;trans[2]-=2*pulse displays[view+side]={'rotation':rot,'translation':trans,'scale':src['scale']} else: for view in ('firstperson_','thirdperson_'): src=base['display'][view+side] rot=src.get('rotation',[0,0,0]).copy(); trans=src.get('translation',[0,0,0]).copy() if pose=='jab':trans[2]-=9*pulse;rot[0]-=18*pulse elif pose=='hook':trans[0]-=sign*8*pulse;trans[2]-=5*pulse;rot[2]+=sign*60*pulse;rot[1]+=sign*50*pulse elif pose=='uppercut':trans[1]+=3.5*pulse;trans[2]-=6*pulse;rot[0]-=35*pulse else:trans[2]-=13*pulse;trans[1]-=2*pulse;rot[0]-=30*pulse displays[view+side]={'rotation':rot,'translation':trans,'scale':src.get('scale',[1,1,1])} name=f'{pose}_{frame}' parent='astraplus:item/netherite_twinblade' if pose=='twinblade' else 'astraweapons:item/iron_gauntlet_3d' write(D/f'models/animation/{name}.json',{'parent':parent,'display':displays,'textures':{'particle':'#layer0' if pose=='twinblade' else '#0'}}) gui='astraplus:internal/twinblade_gui' if pose=='twinblade' else 'astraweapons:item/iron_gauntlet_2d' tree={'type':'minecraft:select','property':'minecraft:display_context','cases':[{'when':'gui','model':model(gui)}], 'fallback':model(f'astraweapons:animation/{name}')} write(D/f'items/animation/{name}.json',{'hand_animation_on_swap':False,'model':tree}) write(D/'items/gauntlet_offhand.json',{'hand_animation_on_swap':False,'model':{'type':'minecraft:select','property':'minecraft:display_context', 'cases':[{'when':'gui','model':model('astraweapons:item/iron_gauntlet_2d')}], 'fallback':model('astraweapons:item/iron_gauntlet_3d')}}) index=sorted(str(f.relative_to(ROOT/'defaults')).replace('\\','/') for f in (ROOT/'defaults').rglob('*') if f.is_file()) (ROOT/'weapons-index.txt').write_text('\n'.join(index)+'\n',encoding='utf-8') if __name__=='__main__':main()