Skip to content

重写 RegistrateLib 1.21.1 并迁移到 Kotlin - #9

Merged
QiuYe-QAQ merged 28 commits into
1.21from
qy/registratelib-rewrite-1.21.1
Nov 21, 2026
Merged

QiuYe-QAQ merged 28 commits into
1.21from
qy/registratelib-rewrite-1.21.1

Conversation

@QiuYe-QAQ

Copy link
Copy Markdown
Member

What / 目的

完成 RegistrateLib 的 1.21.1 首版重写。目标环境为 Minecraft 1.21.1、NeoForge 21.1.265、Java 21 与 Kotlin 2.4.21。

Implementation Details / 实现细节

  • 注册条目通过 RegistryEntry.metadata() 暴露 DataGen 和本地化声明。重复 ID 在注册提交时报告,条目回调在 Holder 绑定后执行。
  • DataGen 按侧和 Provider 依赖调度。Builder、手动声明、@Trans 和 @TransVariants 汇总到 Minecraft 原生语言 JSON。解析阶段处理优先级、冲突、Minecraft 占位符及 en_ud。
  • 独立的 localization-processor 子模块提供 JSR 269 与 KSP。DataGen 从所属模组读取索引并合并声明。
  • 注册器、Builder、Provider 和更新工具迁到 Kotlin。RegistrateLib 与 TestMod 采用 Java 的 @Mod 入口。测试模组的 Java 和 Kotlin 注册共用由 TestMod 创建的 Registrate。

Outcome / 结果

  • 离线 build 通过,其中包含 Spotless 检查。
  • runGameTestServer 的 7 个用例全部通过,覆盖混合源码注册、重复 ID、原生翻译 Key 和两种编译期索引。
  • 两个样例模组的 runTestdata --all 执行到所有 Provider 完成。

Potential Compatibility Issues / 潜在兼容性问题

  • 生成语言数据的模组需要调用 sourceLocale(MinecraftLocale)。.lang(String) 与 addRawLang 使用该 Locale。
  • 使用本地化注解的下游模组可按源码语言配置 annotationProcessor 或 ksp。
  • NullableSupplier、NullableType 和 FieldsAreNonnullByDefault 已移除。原有调用方需调整空值声明和供应器类型。
  • 迁移示例和注册兼容性见本地化迁移说明。

@QiuYe-QAQ
QiuYe-QAQ requested review from a team as code owners November 21, 2026 06:11
@github-actions github-actions Bot added the 1.21 label Nov 21, 2026
@QiuYe-QAQ QiuYe-QAQ added type: refactor Suggestion to refactor a section of code Release: API - X.0.0 Major Breaking Refactors that MUST be in a API-Breaking Release labels Nov 21, 2026
@github-actions github-actions Bot added the Tests: Passed Game Tests have passed on this PR label Nov 21, 2026
@QiuYe-QAQ
QiuYe-QAQ merged commit 7260636 into 1.21 Nov 21, 2026
4 checks passed
@QiuYe-QAQ
QiuYe-QAQ deleted the qy/registratelib-rewrite-1.21.1 branch November 21, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.21 Release: API - X.0.0 Major Breaking Refactors that MUST be in a API-Breaking Release Tests: Passed Game Tests have passed on this PR type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant