Repository navigation
Port math lib and registrum alias api to 1.21.11 移植数学库和注册库别名API到1.21.11 - #131
Conversation
Cherry-pick of 7285ae1 (Add math lib 添加数学库 (Anvil-Dev#122)) adapted to 1.21.11: - Identifier naming, same as 26.1 - test wiring for the 1.21.11 module.gradle layout
Cherry-pick of 892ef23 (Add alias api for Registrum 向Registrum加入别名API (Anvil-Dev#128)) adapted to this version.
🌿 Roseau API Breaking Change Report
|
The module build script used jarJar(implementation project(...)) for util, while every other module in this branch uses jarJar(api project(...)). The math API exposes util types (IFunction.Type extends dev.anvilcraft.lib.v2.util.ISerializer), so a downstream project depending on math alone could not see them at compile time. The test comments describing MappedRegistry and RegistryLookup named 26.1 even though the behaviour is the same here; they now name this version.
The Math entries added in the port were missing from README.en.md. Both are packaged into the jar, so English readers had no math coordinates.
Reason: Security scan — [HIGH] Pipe to interpreter: curl | python3: Command pipes output from 'curl' directly to interpreter 'python3'. Downloaded content will be executed without inspection. Reply |
代码审查摘要 — PR #131(AnvilLib:math 模块 + registrum 别名 API 移植到 1.21.11)操作: 🧭 移植来源与保真度(本 PR 的核心)用具名 ref 拉取权威源逐文件对账(不使用
✅ 新增行里无 ✅ 1.21.11 API 可用性(官方 1.21.11
|
| 用法 | 结论 |
|---|---|
Registry#addAlias / #resolve |
属于 NeoForge IRegistryExtension(Registry.java.patch 让 Registry extends IRegistryExtension),21.11.40-beta 存在 ✅ |
applyAliases 里 registry.resolve(old).equals(new) 守卫是否必要 |
必要且正确:BaseMappedRegistry#addAlias 在「同 from 同 to」二次调用时会走到 resolve(from).equals(to) → 抛 IllegalStateException("Infinite alias loop detected"),正是注释里说的「applying one twice throws」✅ |
Identifier.withPrefix/withSuffix/parse/fromNamespaceAndPath |
✅ |
Registry#getOrThrow(ResourceKey) |
继承自 HolderGetter(Registry implements HolderLookup.RegistryLookup, HolderGetter)✅ |
RegistryBuilder#sync/maxId/create、DataPackRegistryEvent.dataPackRegistry(key, codec, networkCodec)、DeferredRegister.create(Registry, String) |
✅ |
OnDatapackSyncEvent#getPlayer()(null = 全员同步 → /reload)、ClientPlayerNetworkEvent.LoggingOut |
✅ 语义与注释一致 |
测试基建反射目标:Bootstrap.isBootstrapped、Holder.Reference#bindValue(Object) |
✅ 存在(bindValue 确有方法体,反射改绑成立) |
RegistryAccess#lookup/registries、RegistryAccess.RegistryEntry(key, registry)、RegistryFriendlyByteBuf(ByteBuf, RegistryAccess) |
✅ |
MappedRegistry.register 重复键抛异常(注释由 26.1 改为 1.21.11) |
✅ 1.21.11 仍抛 Adding duplicate key,注释改得对 |
Registry 自身即 HolderLookup.RegistryLookup(ParseCacheTest 注释) |
✅ 1.21.11 成立,注释准确 |
modDevGradle 2.0.141 是否有 addModdingDependenciesTo |
✅ ModDevExtension 中存在 |
✅ 别名逻辑审查
aliasFrom()只登记旧名,AbstractBuilder#register()里逐名调addAliases,真正施加在onRegisterLate(EventPriority.LOWEST,到FMLCommonSetupEvent才注销)→ 每个注册表都能在自身事件结束时拿到完整注册结果 ✅- 所有
register()覆写(BlockBuilder / BlockEntityBuilder / ItemBuilder / FluidBuilder / SelfBuilder…)都调super.register(),别名不会漏 ✅ FluidBuilder.addAliases:builder 名带flowing_前缀,withPrefix("flowing_")/withSuffix("_bucket")+sourceName与 flowing / source / fluid_type / block / bucket 五类登记名一一对应 ✅;blockCreated/bucketCreated在block()/bucket()内置位,而FluidBuilder.register()先跑默认 block/bucket 再super.register(),施加别名时标志位已就绪 ✅BlockBuilder:item / block entity 与 block 同名,标志位控制只在真创建时别名 ✅- 没有遗漏 EntityBuilder 覆写:1.21.11 的
EntityBuilder已无spawnEgg(...)/defaultSpawnEgg(...)(只剩@Deprecated空实现injectSpawnEggType),没有_spawn_egg衍生条目可别名 —— 与dev/1.21.1的差异是分支本身差异,不是移植遗漏 ✅ - 三种异常情形(旧名仍注册 / 新名未注册 / 已别名同目标)分别 warn/debug 跳过 + 冲突时 error,降级安全,不会崩 ✅
✅ 集成完整性
settings.gradle include + 改名 → .github/modules.json 加 math(needs:["util"]) → generate-matrix.js 拓扑排序把 math 放到 level 2(head 的 check-runs 里确实出现 build-l2 (math, anvillib-math, anvillib_math))→ toml.gradle 据此自动为主模块生成 anvillib_math 依赖、为 math 生成 anvillib_util 依赖(与两处 jarJar(api …) 一致)✅。module.main/build.gradle 的 NOT_DEV 发布物与本地 project 两条分支都加了 math ✅。README.md / README.en.md 的模块表、用法示例、依赖片段齐全,内建函数清单与 LibBuiltInFunctions 枚举逐项一致 ✅。测试接进 CI(:anvillib-math-neoforge-1.21.11:build,useJUnitPlatform + math.fuzz.rounds 与 FlatExpressionTest 读取的属性名一致)✅。anvillib_math.mixins.json 与其它模块模板一致、mods.toml 指向真实文件 ✅。
⚠️ 提醒(合并前建议确认,非代码缺陷)
- CI 尚未出结果:本次审查时 head
3e95996e的 check-runs 中build-l2 (math…)仍是queued(build-l2 (registrum…)也还在跑)。也就是说「1.21.11 上能编译 + 8 个单测(含 2 万轮随机往返 fuzz)全绿」还没有实际证据,合并前请确认这两条 check 变绿(我这边已把 API 逐个对着 1.21.11 mappings / NeoForge 21.11.40-beta 核过了,没发现会编译不过的点)。 module.test未纳入新模块:本分支的移植冒烟验证 mod(PortVerification/PortRuntimeVerification/portSmoke跑客户端并校验port-smoke-result.txt)依赖了除 math 外的全部兄弟模块,新增的anvillib_math不在其中,于是「math 的注册表创建 / 数据包注册表 / codec 在真实游戏里能否跑起来」这类问题冒烟测不到(1.21.1、26.1 分支也同样没加,属既有惯例)。建议顺手补一行
implementation project(":anvillib-math-neoforge-1.21.11"),可选再加一条IExpression往返的最小运行时校验。
💡 建议(可选)
- PR 描述为空。纯移植 PR 建议写明来源(如 math 来自
dev/26.1301dcb25、别名 API 来自dev/1.21.1892ef231),便于后续按版本回溯与对账。 - 「新名未注册」目前只打
debug日志:rename 时名字写错会静默失效(行为上是安全的,但排查困难)。如果希望这类显式误用更容易被发现,可把该分支提到warn。 .gitignore的*.log→*.log*与本 PR 主题(math/别名 API)无关,是随分支带入的改动,注意别在后续回溯里被误归因到本次移植。
📋 声称验证表
| PR 标题声称 | 状态 | 对应文件 |
|---|---|---|
| 移植 math 库到 1.21.11 | ✅ | module.math 37 文件(与 dev/26.1 逐文件一致,仅 3 处版本相关改动) |
| 移植 registrum 别名 API 到 1.21.11 | ✅ | AbstractRegistrum / AbstractBuilder / BlockBuilder / FluidBuilder / Builder(与 dev/1.21.1 逻辑等价) |
| 模块/构建/CI/文档接线 | ✅ | settings.gradle、.github/modules.json、module.main/build.gradle、README.md、README.en.md |
结论:APPROVE(待 CI 绿灯)—— 两处移植都是逐行级保真,仅做了该版本必需的 API 改名(Identifier / jspecify / identifier() / getOrThrow),别名 API 的重名守卫所需的 NeoForge 语义、以及 1.21.11 上全部被调用 API 都已实测核对通过;唯一实质建议是把新模块纳入 module.test 的冒烟覆盖。
由 Hermes Agent 审查
|
💾 Self-improvement review: Patched SKILL.md in skill 'reverse-port-pr-review' (1 replacement). · Patched references/new-module-port-and-build-script-copy-paste.md in skill 'reverse-port-pr-review' (1 replacement). |
🌿 Roseau API Breaking Change Report
|
|
已跳过审查 — PR #131 状态为 closed(且已于 2026-09-28T01:30:34Z 合并) 依据 webhook 审查约定(github-code-review 技能 §7):
本次未下载 diff、未执行任何评论/发表命令,也未触碰任何 token 相关操作。如需对已合并的该移植 PR 做事后复审(例如核对数学库与 registrum alias API 在 1.21.11 分支上的迁移完整性),请以开放的 PR 或明确指示触发。 |
No description provided.