46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
import zipfile, os, subprocess, shutil
|
|
|
|
jar = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\sa_essentials-forge-1.20.1-1.0.0.jar'
|
|
out = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\_tmp\classes'
|
|
os.makedirs(out, exist_ok=True)
|
|
|
|
targets = [
|
|
'com/ogaba/sa_combat/client/tooltip/BlueprintClientTooltipComponent.class',
|
|
'com/ogaba/sa_combat/client/tooltip/BlueprintClientTooltipComponent$1.class',
|
|
'com/ogaba/sa_combat/item/BlueprintTooltipComponent.class',
|
|
'com/ogaba/sa_combat/item/BlueprintItem.class',
|
|
'com/ogaba/sa_combat/blueprint/BlueprintDefinitionRegistry$Definition.class',
|
|
'com/ogaba/sa_combat/blueprint/BlueprintDefinitionRegistry.class',
|
|
]
|
|
|
|
with zipfile.ZipFile(jar) as z:
|
|
for t in targets:
|
|
data = z.read(t)
|
|
p = os.path.join(out, t.replace('/', os.sep))
|
|
os.makedirs(os.path.dirname(p), exist_ok=True)
|
|
with open(p, 'wb') as f:
|
|
f.write(data)
|
|
print('extracted:', t)
|
|
|
|
# javap 反编译查看渲染逻辑
|
|
javap = shutil.which('javap')
|
|
if javap is None:
|
|
# 尝试常见 JDK 路径
|
|
for cand in [r'C:\Program Files\Java\jdk-17\bin\javap.exe',
|
|
r'C:\Program Files\Java\jdk-21\bin\javap.exe',
|
|
r'C:\Program Files\Microsoft\jdk-17.0.11\bin\javap.exe',
|
|
r'C:\Program Files\Eclipse Adoptium\jdk-17.0.13.11-hotspot\bin\javap.exe']:
|
|
if os.path.exists(cand):
|
|
javap = cand
|
|
break
|
|
print('javap =', javap)
|
|
|
|
if javap:
|
|
for t in targets:
|
|
cname = t[:-6].replace('/', '.')
|
|
r = subprocess.run([javap, '-c', '-p', '-classpath', out, cname], capture_output=True, text=True, encoding='utf-8', errors='replace')
|
|
print('\n' + '='*20, cname, '='*20)
|
|
print(r.stdout[:6000] if r.returncode == 0 else r.stderr[:3000])
|
|
else:
|
|
print('javap NOT FOUND')
|