Replace weapon pose jitter with native swings and timed slash trails
This commit is contained in:
@@ -28,7 +28,7 @@ def main():
|
||||
band=max(0,1-abs(r-(.85+frame*.012))/.16)
|
||||
sweep=max(0,1-abs(angle-(-1.0+frame*.5))/2.25)
|
||||
# Use an opaque core: vanilla item cutout discards a translucent-only crescent.
|
||||
alpha=255 if band*sweep > .18+frame*.09 else 0
|
||||
alpha=255 if band*sweep > .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)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
"""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<tail<1.65:continue
|
||||
width=.09*(1-tail/1.65)*(1-frame*.13)
|
||||
outer=.87+frame*.02
|
||||
if outer-width<r<outer:
|
||||
core=(outer-r)<width*.4
|
||||
rgb=((255,247,205) if core else (255,158,45)) if fiery else ((255,255,255) if core else (185,180,221))
|
||||
im.putpixel((x,y),(*rgb,255))
|
||||
path=D/f'textures/item/v2/{name}.png';path.parent.mkdir(parents=True,exist_ok=True);im.save(path)
|
||||
write(D/f'models/v2/{name}.json',{'textures':{'slash':f'astraweapons:item/v2/{name}','particle':f'astraweapons:item/v2/{name}'},
|
||||
'elements':[{'from':[0,8,0],'to':[16,8,16],'shade':False,'light_emission':15,'faces':{
|
||||
'up':{'texture':'#slash','uv':[0,0,16,16]},'down':{'texture':'#slash','uv':[0,0,16,16],'rotation':180}}}]})
|
||||
write(D/f'items/v2/{name}.json',{'model':model(f'astraweapons:v2/{name}')})
|
||||
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()
|
||||
@@ -11,7 +11,7 @@ $run = Join-Path $repo ('build/weapons-capture-' + (Get-Date -Format 'yyyyMMdd-H
|
||||
$serverRun = Join-Path $run 'server'
|
||||
$clientRun = Join-Path $run 'client'
|
||||
New-Item -ItemType Directory -Path "$serverRun/mods", "$clientRun/resourcepacks" -Force | Out-Null
|
||||
Copy-Item -LiteralPath $AstraPlusJar, "$repo/build/libs/AstraWeapons-0.1.0.jar", "$repo/build/libs/AstraWeapons-0.1.0-verification.jar" -Destination "$serverRun/mods"
|
||||
Copy-Item -LiteralPath $AstraPlusJar, "$repo/build/libs/AstraWeapons-0.1.1.jar", "$repo/build/libs/AstraWeapons-0.1.1-verification.jar" -Destination "$serverRun/mods"
|
||||
New-Item -ItemType Directory -Path "$serverRun/astraplus" -Force | Out-Null
|
||||
$serverRoot = (Resolve-Path -LiteralPath $ServerDirectory).Path.Replace('\','/')
|
||||
$argsText = (@(foreach ($line in (Get-Content "$ServerDirectory/libraries/net/neoforged/neoforge/26.2.0.79/win_args.txt")) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
param(
|
||||
[string]$CaptureDirectory = (Get-Content "$PSScriptRoot/../build/active-weapons-capture.txt"),
|
||||
[string]$Ffmpeg = 'C:/Users/ScarPC/Documents/Plugins/PixelBanners/.codex-work/packs-smoke/plugins/ItemsAdder/storage/cache/ffmpeg/windows/ffmpeg.exe'
|
||||
)
|
||||
$ErrorActionPreference='Stop'
|
||||
$repo=Split-Path $PSScriptRoot -Parent
|
||||
$output=Join-Path $repo 'build/animation-review-0.1.1.mp4'
|
||||
$ffargs=@('-hide_banner','-loglevel','error','-y')
|
||||
foreach($stage in 0..3){$ffargs+=@('-framerate','20','-i',"$CaptureDirectory/client/screenshots/weapons-$stage-%03d.png")}
|
||||
$filter='[0:v]scale=640:360[a];[1:v]scale=640:360[b];[2:v]scale=640:360[c];[3:v]scale=640:360[d];[a][b]hstack[top];[c][d]hstack[bottom];[top][bottom]vstack[v]'
|
||||
$ffargs+=@('-filter_complex',$filter,'-map','[v]','-c:v','libx264','-crf','18','-pix_fmt','yuv420p','-movflags','+faststart',$output)
|
||||
& $Ffmpeg @ffargs
|
||||
if($LASTEXITCODE -ne 0){throw 'Review video encoding failed'}
|
||||
Write-Output $output
|
||||
@@ -1,12 +1,12 @@
|
||||
param([string]$ServerDirectory = 'C:/Users/ScarPC/Documents/NeoForge Server 26.2')
|
||||
param([string]$ServerDirectory = 'C:/Users/ScarPC/Documents/NeoForge Server 26.2', [switch]$IncludeAstraPlus)
|
||||
$ErrorActionPreference='Stop'
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
$repo=Split-Path $PSScriptRoot -Parent
|
||||
$mods=(Resolve-Path -LiteralPath (Join-Path $ServerDirectory 'mods')).Path
|
||||
$jobs=@(
|
||||
@{Id='astraplus';Jar=(Join-Path (Split-Path $repo -Parent) 'AstraPlus/build/libs/AstraPlus-0.5.67.jar')},
|
||||
@{Id='astraweapons';Jar=(Join-Path $repo 'build/libs/AstraWeapons-0.1.0.jar')}
|
||||
@{Id='astraweapons';Jar=(Join-Path $repo 'build/libs/AstraWeapons-0.1.1.jar')}
|
||||
)
|
||||
if($IncludeAstraPlus){$jobs=@(@{Id='astraplus';Jar=(Join-Path (Split-Path $repo -Parent) 'AstraPlus/build/libs/AstraPlus-0.5.67.jar')})+$jobs}
|
||||
function Get-ModIds([string]$Jar) {
|
||||
$zip=[IO.Compression.ZipFile]::OpenRead($Jar)
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,7 @@ $ErrorActionPreference = 'Stop'
|
||||
$repo = Split-Path $PSScriptRoot -Parent
|
||||
$run = Join-Path $repo ('build/verify-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,6))
|
||||
New-Item -ItemType Directory -Path "$run/mods", "$run/config" -Force | Out-Null
|
||||
Copy-Item -LiteralPath $AstraPlusJar,"$repo/build/libs/AstraWeapons-0.1.0.jar","$repo/build/libs/AstraWeapons-0.1.0-verification.jar" -Destination "$run/mods"
|
||||
Copy-Item -LiteralPath $AstraPlusJar,"$repo/build/libs/AstraWeapons-0.1.1.jar","$repo/build/libs/AstraWeapons-0.1.1-verification.jar" -Destination "$run/mods"
|
||||
$serverRoot = (Resolve-Path -LiteralPath $ServerDirectory).Path.Replace('\','/')
|
||||
$argsText = (@(foreach ($line in (Get-Content "$ServerDirectory/libraries/net/neoforged/neoforge/26.2.0.79/win_args.txt")) {
|
||||
if ($line -eq '-DlibraryDirectory=libraries') { '"-DlibraryDirectory=' + $serverRoot + '/libraries"' }
|
||||
|
||||
Reference in New Issue
Block a user