代码库初始化
This commit is contained in:
1 parent
07786ab323
commit
4334694551
851 files changed
+42626
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import zipfile, os, subprocess, re, 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'
|
||||
|
||||
# 候选:所有渲染/HUD/overlay 类
|
||||
cands = []
|
||||
with zipfile.ZipFile(jar) as z:
|
||||
for n in z.namelist():
|
||||
if n.endswith('.class') and ('/render/' in n or '/renderer/' in n or '/event/' in n or '/tooltip/' in n or 'Overlay' in n or 'Hud' in n or 'HUD' in n or 'Gui' in n):
|
||||
cands.append(n)
|
||||
|
||||
javap = r'D:\我的世界\bin\javap.EXE'
|
||||
if not os.path.exists(javap):
|
||||
javap = shutil.which('javap')
|
||||
|
||||
const_pat = re.compile(r'(?:ldc|ldc_w)\s+#\d+\s+// String (.+)')
|
||||
skip = {'minecraft','sa_combat','sa_core','sa_survival','sa_decor','nails','textures/'}
|
||||
report = []
|
||||
for t in sorted(cands):
|
||||
p = os.path.join(out, t.replace('/', os.sep))
|
||||
os.makedirs(os.path.dirname(p), exist_ok=True)
|
||||
with zipfile.ZipFile(jar) as z:
|
||||
try:
|
||||
with open(p, 'wb') as f:
|
||||
f.write(z.read(t))
|
||||
except KeyError:
|
||||
continue
|
||||
cname = t[:-6].replace('/', '.')
|
||||
r = subprocess.run([javap, '-c', '-p', '-classpath', out, cname], capture_output=True, text=True, encoding='utf-8', errors='replace')
|
||||
text = r.stdout if r.returncode == 0 else r.stderr
|
||||
consts = [m.group(1) for m in const_pat.finditer(text)]
|
||||
# 过滤明显非显示文本
|
||||
interesting = []
|
||||
for s in consts:
|
||||
if s in skip or s.startswith('textures/'):
|
||||
continue
|
||||
if s.isdigit() or (len(s) < 4):
|
||||
continue
|
||||
interesting.append(s)
|
||||
if interesting:
|
||||
report.append('== %s ==' % cname)
|
||||
for s in interesting:
|
||||
report.append(' ' + s)
|
||||
|
||||
with open(r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\_tmp\consts_render.txt', 'w', encoding='utf-8') as f:
|
||||
f.write('\n'.join(report))
|
||||
print('\n'.join(report[:400]))
|
||||
Reference in new issue
Block a user