Files
agentmc/mcfold/backends/gen_1_21.py
JianFeeeee a1ce560c05 修复渲染联测的两个阻断缺陷(之前 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)
2026-09-26 06:53:30 +08:00

38 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""1.21+ 渲染后端。
对应 Java 源码:scaffold/java/gen_1_21/
编译目标:1.21.x 的 client jar(重映射为可读名后)
API 特征(实测,与世代 A 的差异):
setLevel(ClientLevel, ReceivingLevelScreen$Reason) ← 多一个参数
GameRenderer.render(DeltaTracker, boolean) ← 签名整个换了
Minecraft.getTimer() → DeltaTracker ← 1.21 引入
LevelRenderer.countRenderedSections() ← 1.20.2 起改名
★ 这些差异**无法**写在与 1.20 相同的源码里:
DeltaTracker 在 1.20.x 的 jar 中不存在 ⇒ 编译期即失败。
"""
from __future__ import annotations
from .base import RenderBackend
class Gen_1_21(RenderBackend):
"""1.21+ 系列。"""
generation = "gen_1_21"
min_mc_version = "1.21"
max_mc_version = ""
java_dir = "java/gen_1_21"
markers = ("net/minecraft/client/DeltaTracker.class",)
@staticmethod
def api_notes() -> dict:
return {
"setLevel": "Minecraft.setLevel(ClientLevel, ReceivingLevelScreen$Reason)",
"render": "GameRenderer.render(DeltaTracker, boolean)",
"count": "LevelRenderer.countRenderedSections()",
"deltaTracker": True,
"source": "Minecraft.getTimer()",
}