"""Stable hand models driven by vanilla swing animations, plus timed slash frames.""" 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 hand_item(name, parent, gui, display): write(D/f'models/v2/{name}.json', {'parent':parent, 'display':display}) write(D/f'items/v2/{name}.json', {'hand_animation_on_swap':False, 'model':{ 'type':'minecraft:select','property':'minecraft:display_context', 'cases':[{'when':['gui','ground','fixed'],'model':model(gui)}], 'fallback':model(f'astraweapons:v2/{name}')}}) def main(): # No third-person pose offsets: the glove stays attached to the wrist while # the vanilla STAB/WHACK animation moves the actual arm with frame interpolation. base=json.loads((D/'models/item/iron_gauntlet_3d.json').read_text(encoding='utf-8')) for pose, pitch, roll in [('guard',0,0),('jab',0,0),('hook',0,12),('uppercut',-12,0),('lunge',0,0)]: display={} for side,sign in [('righthand',1),('lefthand',-1)]: src=base['display']['firstperson_'+side] display['firstperson_'+side]={'rotation':[src['rotation'][0]+pitch,0,sign*(-8+roll)], 'translation':[sign*.5,5.0,0], 'scale':[.9,.9,.9]} hand_item(pose,'astraweapons:item/iron_gauntlet_3d','astraweapons:item/iron_gauntlet_2d',display) hand_item('twinblade','astraplus:item/netherite_twinblade','astraplus:internal/twinblade_gui',{ 'firstperson_righthand':{'rotation':[0,-90,55],'translation':[1.1,1.4,0],'scale':[1.85,1.85,.68]}, 'firstperson_lefthand':{'rotation':[0,90,-55],'translation':[1.1,1.4,0],'scale':[1.85,1.85,.68]}}) # Each transient display selects frames by its own age. No globally running # animated texture, so every slash starts at the beginning of the same trail. for fiery in (False, True): for frame in range(4): name=f'slash_{"fire_" if fiery else ""}{frame}' size=192; im=Image.new('RGBA',(size,size)) lead=(-.9,-.15,.6,1.15)[frame] for y in range(size): for x in range(size): dx=(x+.5-size/2)/(size/2);z=(y+.5-size/2)/(size/2) r=math.hypot(dx,z);a=math.atan2(dx,z) tail=lead-a if z<=0 or not 0