修复渲染联测的两个阻断缺陷(之前 5/7 → 现 7/7)

## ① natives 必须平铺,不能保留包路径

natives-linux jar 里的路径是 `linux/x64/org/lwjgl/<module>/lib*.so`,
而 LWJGL 经 java.library.path / LD_LIBRARY_PATH 按**文件名**找库 ——
嵌套一层的目录它找不到。实测:

  UnsatisfiedLinkError: Failed to locate library: liblwjgl.so
    at RenderSystem.<clinit> → Tesselator.<clinit>

build.sh 原来直接 `unzip -d $OUT/natives`(保留包路径)⇒ 产物不可用。
改为解到临时目录再 `find -name '*.so' -exec cp` 平铺。
(已用新逻辑重铺 store/vanilla-1.20.1/.mcfold/natives,7 个 .so 在根下。)

## ② api_notes 应为 staticmethod

35534b1 把世代分派改成类级调用后,`api_notes` 仍是实例方法,
测试里 `Gen_1_20.api_notes()` 直接 TypeError。它不读 self ⇒ 一律 staticmethod。
这也是它能"不启动后端就做世代对照"的前提。

## ③ classpath.txt 的语义写进注释

它**只含第三方 libraries**;client-named.jar 与 classes/ 由使用方拼接
(build.sh:88 自己拼,测试/后端从各自路径取)。
在 build.sh 里注明,避免下一个人以为它是"完整运行 classpath"。

## 验证

  ./run_tests.sh                    → 62 项全绿
  .mcfold classpath + 平铺 natives  → 渲染联测 **7/7 全绿**
    (injected=49 chunks=31 colors=11714 / placed=1003716 chunks=25 colors=4540)
This commit is contained in:
JianFeeeee
2026-09-26 06:53:30 +08:00
parent 35534b1564
commit a1ce560c05
4 changed files with 25 additions and 6 deletions

View File

@ -426,8 +426,13 @@ class RenderBackend:
# ---------------- 元信息 ----------------
def api_notes(self) -> dict:
"""本世代的 API 特征(子类覆写)。"""
@staticmethod
def api_notes() -> dict:
"""本世代的 API 特征(子类覆写)。
★ 静态信息(不依赖实例)⇒ 定义成 staticmethod,
这样才能在**不启动后端**的前提下做世代对照(测试用)。
"""
return {}
def describe(self) -> str:

View File

@ -28,7 +28,8 @@ class Gen_1_20(RenderBackend):
# 判据类(用于自动识别)
markers: tuple[str, ...] = ()
def api_notes(self) -> dict:
@staticmethod
def api_notes() -> dict:
return {
"setLevel": "Minecraft.setLevel(ClientLevel)",
"render": "GameRenderer.render(float, long, boolean)",

View File

@ -26,7 +26,8 @@ class Gen_1_21(RenderBackend):
java_dir = "java/gen_1_21"
markers = ("net/minecraft/client/DeltaTracker.class",)
def api_notes(self) -> dict:
@staticmethod
def api_notes() -> dict:
return {
"setLevel": "Minecraft.setLevel(ClientLevel, ReceivingLevelScreen$Reason)",
"render": "GameRenderer.render(DeltaTracker, boolean)",

View File

@ -74,12 +74,24 @@ else
fi
# ── 4. classpath(去 asm 重复,Fabric 需要) + natives ────────
# classpath.txt **只含第三方 libraries** —— client-named.jar 与 classes/ 由使用方拼接
# (build.sh 自己在下面拼,测试/后端则从各自路径取)。
# ★ 别在这里把 named/classes 也写进去:那会让「libraries 清单」与「运行 classpath」
# 两个概念混成一列,而 Fabric 路线需要把 asm 从 libraries 里剔掉后**另行**拼 8 个库。
find "$STORE/libraries" -name "*.jar" ! -name "*-sources.jar" ! -name "*natives*" 2>/dev/null \
| grep -vE "minecraftforge|neoforge" > "$OUT/classpath.txt"
NATLIST=$(find "$STORE/libraries" -name "*natives-linux*.jar" 2>/dev/null)
if [ -n "$NATLIST" ]; then
rm -rf "$OUT/natives/linux"; mkdir -p "$OUT/natives"
while read -r j; do [ -f "$j" ] && unzip -o -q "$j" -d "$OUT/natives" 2>/dev/null || true; done <<< "$NATLIST"
rm -rf "$OUT/natives"; mkdir -p "$OUT/natives"
# ★ 必须**平铺**。natives jar 里的路径是 linux/x64/org/lwjgl/<module>/lib*.so,
# 而 LWJGL 是经 java.library.path/LD_LIBRARY_PATH 按**文件名**找库的 ——
# 嵌套一层的目录它**找不到**(实测 UnsatisfiedLinkError: Failed to locate library: liblwjgl.so)。
while read -r j; do
[ -f "$j" ] || continue
unzip -o -q "$j" -d "$OUT/natives.tmp" 2>/dev/null || true
done <<< "$NATLIST"
find "$OUT/natives.tmp" -name '*.so' -exec cp {} "$OUT/natives/" \; 2>/dev/null
rm -rf "$OUT/natives.tmp"
fi
echo "[4/5] 库 $(wc -l < "$OUT/classpath.txt") 个, natives $(find "$OUT/natives" -name '*.so' | wc -l) 个"