Skip to content

Port math lib and registrum alias api to 1.21.11 移植数学库和注册库别名API到1.21.11 - #131

Merged
WhereisFff merged 4 commits into
Anvil-Dev:dev/1.21.11from
QiuShui1012:port/1.21.11
Sep 28, 2026
Merged

WhereisFff merged 4 commits into
Anvil-Dev:dev/1.21.11from
QiuShui1012:port/1.21.11

Conversation

@QiuShui1012

Copy link
Copy Markdown
Contributor

No description provided.

QiuShui1012 and others added 2 commits September 25, 2026 12:21
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.
@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ⚪ Skipped —
collision ⚪ Skipped —
cube ⚪ Skipped —
config ⚪ Skipped —
integration ⚪ Skipped —
moveable-entity-block ⚪ Skipped —
network ⚪ Skipped —
rendering ⚪ Skipped —
space-select ⚪ Skipped —
font ⚪ Skipped —
util ⚪ Skipped —
explosion ⚪ Skipped —
rpc ⚪ Skipped —
math ⚪ Skipped —
multiblock ⚪ Skipped —
recipe ⚪ Skipped —
registrum ⚪ Skipped —
sync ⚪ Skipped —
wheel ⚪ Skipped —
main ⚪ Skipped —

Full CSVs: see the Artifacts section of this workflow run.

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.
@Gugle2308

Copy link
Copy Markdown

⚠️ Dangerous command requires approval:

cd /opt/data/workspace/AnvilLib && for r in rv130src26 rv130src261 rv130base rv125head pr132head pr132base; do echo "=== $r $(git rev-parse --short $r 2>/dev/null)"; git grep -c "addAlias" $r -- "*.ja...

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.
Safer: tirith run https://api.github.com/repos/Anvil-Dev/AnvilLib/pulls?state=open&per_page=20 — or: vet https://api.github.com/repos/Anvil-Dev/AnvilLib/pulls?state=open&per_page=20 (https://getvet.sh); script execution via -e/-c flag

Reply /approve to execute, /approve session to approve this pattern for the session, /approve always to approve permanently, or /deny to cancel.

@Gugle2308

Copy link
Copy Markdown

代码审查摘要 — PR #131(AnvilLib:math 模块 + registrum 别名 API 移植到 1.21.11)

操作: synchronize(head 3e95996e / base a16a074d,dev/1.21.11)
范围: 48 文件 / +6269 −1(37 新增,0 删除,无 ghost 文件、无缺 EOF 换行)
module.math 新模块(26 主源码 + 8 测试 + 4 资源)、module.registrum 别名 API(5 java)、以及 gradle / CI / README 接线。
PR 标题准确(英中双语、与内容相符),未作修改。


🧭 移植来源与保真度(本 PR 的核心)

用具名 ref 拉取权威源逐文件对账(不使用 FETCH_HEAD):

对比基准 结果
dev/26.1(301dcb25) 37 个 math 文件清单完全一致,内容仅 3 处差异:util 依赖坐标 26.1→1.21.11、MathTestBootstrap/ParseCacheTest 两处注释里的版本号
dev/1.21.1(892ef231,含已合并的 #122 math + #128 别名 API) 20 处文件有差异,全部是 API 改名,无逻辑差异:ResourceLocation→Identifier(新增行 57 处)、javax.annotation.Nullable→org.jspecify.annotations.Nullable(13 处)、ResourceKey#location()→identifier()、Registry#getHolderOrThrow→HolderGetter#getOrThrow
别名 API 5 个文件逐方法对账(归一化 ResourceLocation→Identifier 后 diff) 逻辑行零差异,只有 javadoc 换行风格差异

✅ 新增行里无 javax. / org.jetbrains 残留、无 ResourceLocation 残留、无 TODO/调试输出。

✅ 1.21.11 API 可用性(官方 1.21.11 client_mappings + NeoForge 21.11.40-beta patch/sources 实测)

用法 结论
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 指向真实文件 ✅。


⚠️ 提醒(合并前建议确认,非代码缺陷)

  1. 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 核过了,没发现会编译不过的点)。
  2. 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 往返的最小运行时校验。

💡 建议(可选)

  1. PR 描述为空。纯移植 PR 建议写明来源(如 math 来自 dev/26.1 301dcb25、别名 API 来自 dev/1.21.1 892ef231),便于后续按版本回溯与对账。
  2. 「新名未注册」目前只打 debug 日志:rename 时名字写错会静默失效(行为上是安全的,但排查困难)。如果希望这类显式误用更容易被发现,可把该分支提到 warn。
  3. .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 审查

@Gugle2308

Copy link
Copy Markdown

💾 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).

@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ⚪ Skipped —
collision ⚪ Skipped —
cube ⚪ Skipped —
config ⚪ Skipped —
integration ⚪ Skipped —
moveable-entity-block ⚪ Skipped —
network ⚪ Skipped —
rendering ⚪ Skipped —
space-select ⚪ Skipped —
font ⚪ Skipped —
util ⚪ Skipped —
explosion ⚪ Skipped —
rpc ⚪ Skipped —
math ⚪ Skipped —
multiblock ⚪ Skipped —
recipe ⚪ Skipped —
registrum ⚪ Skipped —
sync ⚪ Skipped —
wheel ⚪ Skipped —
main ⚪ Skipped —

Full CSVs: see the Artifacts section of this workflow run.

@WhereisFff
WhereisFff merged commit 1336bef into Anvil-Dev:dev/1.21.11 Sep 28, 2026
42 checks passed
@Gugle2308

Copy link
Copy Markdown

已跳过审查 — PR #131 状态为 closed(且已于 2026-09-28T01:30:34Z 合并)

依据 webhook 审查约定(github-code-review 技能 §7):

  • closed / labeled 类事件不产出审查意见,避免对已关闭/已合并的 PR 发表无意义评论。
  • 已通过公开 API 二次确认:state: closed、merged: true、merged_at: 2026-09-28T01:30:34Z,标题为 Port math lib and registrum alias api to 1.21.11 移植数学库和注册库别名API到1.21.11,作者 QiuShui1012,port/1.21.11 -> dev/1.21.11。标题格式已符合「英文 + 中文」要求,无需 gh pr edit 修改。

本次未下载 diff、未执行任何评论/发表命令,也未触碰任何 token 相关操作。如需对已合并的该移植 PR 做事后复审(例如核对数学库与 registrum alias API 在 1.21.11 分支上的迁移完整性),请以开放的 PR 或明确指示触发。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants