Refactor CFA 重构锻星砧 - #4480
Conversation
- 拆分搜索、引力、库存编解码、天体快照和搜索历史逻辑,统一 CFA 状态持久化与服务端同步 - 新增巨构定义模型、注册表和内置巨构注册,支持稳定 ID、前置条件、环层模型、材料、旋转规则及处理器工厂 - 保留旧版巨构名称与索引兼容逻辑,支持旧存档和扩展模组平滑迁移 - 将星球资源配方改为构建器 API,支持物品/流体便捷注册、嵌套加权选项及 offerings 宝石随机选择 - 将物流与热力提示改为版本化 RPC 按需同步,增加客户端缓存刷新与等待同步提示,并移除旧热力同步数据包 - 统一 CFA 方块实体追踪同步,完善伽马激光、虫洞激光状态持久化和相关渲染逻辑 - 更新 CFA 方块掉落表、模型注册、语言资源及星球资源生成数据,保留拆除时所需的方块实体数据
- 为特殊天体配方增加可序列化的登陆与返回规则,支持同坐标、缩放、固定位置和随机出生点,并兼容旧版 NBT、网络数据及 travel 字段 - 新增天体返回门、方块实体和服务端旅行管理器,处理安全落点、跨维度实体移动、传送冷却、返回门复用与重复门清理,并在无安全地形时生成紧急黑曜石平台 - 添加独立的 `anvilcraft:overworld_like` 维度和原版生物群系源,通过独立种子、原版生成设置及结构集合筛选保持稳定且隔离的世界生成 - 新增褐矮星戴森球巨构,接入巨构注册、重构选项、模型渲染和界面文本,实现原始物质分级供给、稳定 40gt 后的发电倍率,以及过量物质累积至 12800B 后转化为特殊红矮星 - 扩展恒星与巨行星数据模型,持久化特殊红矮星标记和褐矮星能量,调整环位、引力控制、增幅器要求及相关巨构前置条件 - 改进锻星砧传送门和流体接口的独立运行、批量排液与同步逻辑,并补充接口占位方块碰撞形状 - 将创造发电机功率上限提升至 65536,并同步服务端校验、滑杆界面和中英文提示文本 - 注册返回门方块实体、世界生成组件和 Mixin,更新方块模型、方块状态、免疫标签、特殊天体配方及生成语言资源
|
Only 3 missing-newline markers (generated/translation files), well within normal bounds. No ghost files flagged by the scale check. This is a large but well-structured refactor. Let me produce the final review. PR #4480 审查 — Refactor CFA 重构锻星砧审查规模:86 个文件 / 10,703 行 diff(73 个 Java,21 个新增,1 个删除,3 处缺失 EOF 换行,均在生成/翻译文件中,正常)。 整体评价:这是一次大规模、结构良好的 CFA 模块重构。拆除旧的硬编码 if/else 链,改为注册表驱动的巨构定义模型( 🔴 需要确认的行为变更1. return this.legacyActiveMegastructureIndex >= 0 || this.activeMegastructureId != null
? Math.max(this.legacyActiveMegastructureIndex, 0) : -1;对于只有稳定 ID(无旧索引)的新存档, 2. 褐矮星戴森球被排除出
旧代码用 3. 拆除锻星砧后掉落不再保留活动巨构(行为变更) 🟡 观察/提示(非阻塞)4. 配方 codec 的 CelestialTravelData.CODEC.optionalFieldOf("travel").forGetter(recipe -> Optional.empty())编码时该字段永远得到 5. 增速器 26.1 兼容的少数行为差异(均已注释说明)
✅ 做得好的地方
结论整体质量高,架构方向正确。三个红色标注项( 无新增测试覆盖这些新状态机(搜索、旅行、按需 RPC、褐矮星分层发电)的边界——考虑到复杂度,建议至少为 |
|
💾 Self-improvement review: Patched SKILL.md in skill 'data-migration-pr-review' (1 replacement). |
|
I have completed my analysis. Let me write up the comprehensive review. 代码审查摘要 — PR #4480操作: review_requested 这是一个设计良好、结构清晰的大型重构。核心架构改动( 🔴 关键问题暂无致命的正确性 bug。以下为需在合并前确认/修复的高优先级项。
|
| 声称 | 状态 | 对应文件 |
|---|---|---|
| 拆分搜索/引力/库存编解码/快照/历史逻辑 | ✅ | CfaSearchController, CfaGravityController, CfaInventoryCodec, CelestialSnapshotCodec, CelestialSearchHistory |
| 巨构定义模型/注册表/内置注册 | ✅ | Megastructure, ModRegistries(MEGASTRUCTURE), ModMegastructures, ModRegistryKeys |
| 旧名称/索引兼容 | ✅ | CfaMegastructureManager, CelestialRefactorRegistry.findLegacyId/ByIndex |
| 星球资源配方改构建器 API + offerings 宝石 | ✅ | PlanetResourceRecipe (+WeightedEntry/WeightedChoice), PlanetResourceRecipeLoader |
| 物流/热力改 RPC 按需同步 + 等待提示 | CfaLogisticsInterfaceTooltipProvider (RPC 完成;「等待同步」zh 翻译缺失) | |
| CFA 方块实体统一追踪同步 | ✅ | CfaBlockEntitySync, 各 CFA BE |
| 伽马/虫洞激光状态持久化 | ✅ | CfaGammaLaserEffects, CelestialForgingAnvilPortalBlockEntity, BaseLaserBlockEntity, RubyPrismBlockEntity |
| 行星资源掉落表/模型/语言 | ✅ | loot_table, blockstates, models, lang |
| 可序列化登陆/返回规则 | ✅ | CelestialTravelData (CODEC/STREAM_CODEC/toTag/fromTag, legacy travel 别名) |
| 天体返回门 + 旅行管理器 + 安全落点 + 紧急平台 | ✅ | CelestialBackGateBlock(+Entity), CelestialTravelManager |
| overworld_like 维度 + 独立种子 + 生物群系源 | ✅ | Meteor… (dimension json), VanillaOverworldBiomeSource, ModBiomeSources, 3 个 Mixin |
| 褐矮星戴森球(40gt 稳定、12800B 转红矮星) | ✅ | DysonSphereHandler, ModMegastructures.DYSON_SPHERE_BROWN_DWARF |
| 恒星/巨行星数据模型扩展 | ✅ | StarData, GiantPlanetData (specialRedDwarf, brownDwarf, energy) |
| 锻星砧传送门/流体接口独立运行、批量排液 | ✅ | CelestialForgingAnvilPortalBlockEntity, FluidInterfaceBlockEntity, InterfacePlaceholderBlock |
| 创造发电机 65536 上限 | ✅ | CreativeGeneratorBlockEntity(MAX_POWER=65536), SliderScreen, lang |
| 返回门 BE/世界生成组件/Mixin 注册 | ✅ | ModBlockEntities, ModBiomeSources, ChunkGeneratorMixin 等 |
🧪 测试建议
| 被测目标 | 推荐测试场景 | 优先级 |
|---|---|---|
CelestialTravelManager.tryReturn/tryLand |
跨维度往返、安全落点无解 → 紧急平台、重复门清理不误删同门 | 🔴 |
DysonSphereHandler |
40gt 稳定供给翻倍边界、过量物质 12800B 转红矮星(数值累加溢出)、convertToRedDwarf 后字段重置 |
🔴 |
CelestialSearchHistory |
MAX_ENTRIES=10 越界、browse 游标越界、previous/next 环回与 originalEntry 还原 | 🟡 |
CfaMegastructureManager.loadAdditional |
旧 name/index/ring 存档 → 惰性解析为 stable ID、注册表空时注册 fallback handler | 🟡 |
WeightedEntry.select |
totalWeight=0 兜底、负权重忽略、单选择直接返回 | 🟡 |
CelestialTravelData.fromTag |
legacy travel key 别名、非法 dimension 字符串吞异常返回 null |
🟢 |
CelestialSnapshotCodec.save |
黑洞/中子星禁止写入 disk 的极端天体守卫 | 🟢 |
结论: COMMENT — 架构与迁移实现质量高,无致命正确性缺陷。合并前请处理:① Nullness 注解改为 JSpecify(违反 AGENTS.md 硬性规范);② 补 zh_cn 缺失的两个 key;③ 确认增幅搜索功耗 4000→32000 的改动是否有意。SliderScreen 的 +1 与 getActiveIndex 哨兵值为非阻塞建议。
由 Hermes Agent 审查
|
I have thoroughly reviewed this PR. It's a very large and comprehensive CFA refactor (~10.7K lines, 86 files, 21 new files, 1 deletion). Let me write up the review. Key findings:
Let me write the review as the final response. 代码审查摘要 — PR #4480操作: review_requested 这是一次针对锻星砧 (CFA) 的大规模重构:拆分搜索/引力/库存/天体快照/搜索历史逻辑、新增巨构注册表与内置巨构、褐矮星戴森球、天体旅行门/跨维度传送、 🔴 关键 (需确认/修复后合并)1. Wormhole 传送门位置持久化 — BE
|
| 声称 | 状态 | 对应文件 |
|---|---|---|
| 拆分搜索/引力/库存/快照/历史逻辑 | ✅ | CfaSearchController, CfaGravityController, CfaInventoryCodec, CelestialSnapshotCodec, CelestialSearchHistory |
| 统一 CFA 状态持久化与服务端同步 | ✅ | CfaMegastructureManager, CfaBlockEntitySync, 各 BE save/load |
| 巨构定义模型/注册表/内置注册 (稳定 ID、前置、环层、材料、旋转、处理器工厂) | ✅ | Megastructure, ModMegastructures, ModRegistries, ModRegistryKeys |
| 旧版名称与索引兼容迁移 | ✅ | build/findLegacyId/findLegacyIdByIndex/loadActiveIdentity |
| 星球资源配方→构建器 API (物品/流体/嵌套加权/offerings 随机) | ✅ | PlanetResourceRecipe(EntriesBuilder/ChoiceBuilder/select), offering.json |
| 物流/热力→版本化 RPC 按需同步 + 缓存刷新 + 等待提示 | ✅ | CfaLogisticsInterfaceTooltipProvider, HeatableBlockTooltipProvider, HeatableBlockEntity, 移除 HeatableSyncPacket |
| 统一 CFA 方块实体追踪同步 | ✅ | CfaBlockEntitySync |
| 伽马/虫洞激光状态持久化与渲染 | ✅ | BaseLaserBlockEntity, CfaGammaLaserEffects, Portal/LaserInterface BE, LaserState |
| CFA 掉落表/模型/语言/星球生成数据 | ✅ | CelestialForgingAnvilBlock.getDrops, RegisterAdditionalEventListener, lang, loot |
| 特殊天体登陆/返回规则 (同坐标/缩放/固定/随机/旧NBT+tracel 兼容) | ✅ | CelestialTravelData, SpecialCelestialBodyRecipe/Data |
| 返回门 + 服务端旅行管理器 (安全落点/跨维度/冷却/复用/清理/紧急平台) | ✅ | CelestialBackGate(Block/BlockEntity), CelestialTravelManager |
独立 overworld_like 维度 + 原版生物群系源 |
✅ | VanillaOverworldBiomeSource, ModBiomeSources, dimension json, ServerLevel/MinecraftServer/ChunkGenerator Mixin |
| 褐矮星戴森球 (原始物质分级、40gt 稳定、12800B 转红矮) | ✅ | ModMegastructures, DysonSphereHandler |
| 恒星/巨行星数据扩展 (红矮星标记、褐矮星能量、环位/引力/前置) | ✅ | StarData(energy/specialRedDwarf), GiantPlanetData(energy), Megastructure 前置 |
| 锻星砧传送门/流体接口独立运行、批量排液、占位碰撞 | ✅ | Portal BE, FluidInterfaceBE.drainFluid, InterfacePlaceholderBlock 碰撞体 |
| 创造发电机上限 65536 服务端/滑杆/文案 | ✅ | CreativeGeneratorBlockEntity, SliderScreen, en/zh tooltip |
| 返回门 BE/世界生成组件/Mixin/模型/免疫标签/语言注册 | ✅ | ModBlockEntities, ModBlocks, mixins.json, collision/dragon/wither tags, lang |
结论: 需要修改 (REQUEST_CHANGES / 有条件的 COMMENT)
建议合并前重点确认 #1 (虫洞 portals 持久化) 与 #2 (waiting 中文),并对 #5 (新维度种子遮挡) 做一次运行时验证。其余为低风险改进/风格建议。
🧪 测试建议
| 被测目标 | 推荐测试场景 | 优先级 |
|---|---|---|
CelestialTravelManager.tryLand/tryReturn |
跨维度往返、同坐标/缩放/固定/随机出生点、冷却内重复、无安全地形紧急平台、重复门清理 | 🔴 |
overworld_like 维度 |
不同世界种子下地形/生物群系/结构一致性、getSeed 与 BiomeManager 遮挡对齐 |
🔴 |
WormholeStabilizerHandler |
存档重载后已连接虫洞传送门是否保留、portals 恢复 |
🔴 |
DysonSphereHandler |
40gt 稳定分级、250→2000mB 供给、12800B 累积转红矮、能量/尺寸边界 | 🟡 |
CfaMegastructureManager |
旧存档 (index/name) 迁移、auxiliary 与主结构共存、build/canBuild 竞态 | 🟡 |
HeatableBlockTooltipProvider/物流 RPC |
频繁切换目标、玩家离开交互范围后 RPC 被拒、版本号缓存命中 | 🟡 |
getDrops/prepareForPermanentRemoval |
移除带回天体/巨构数据的掉落,重放置后恢复;无 Inventory 双份掉落 | 🟡 |
由 Hermes Agent 审查
I've completed a thorough review of this large CFA refactor. The review is ready to be delivered via the webhook.
Reason: script execution via -e/-c flag Reply |
|
I have a complete picture. Let me compile the final review. The One thing worth checking: the I'm confident in my analysis now. Compiling the final review. 代码审查摘要 — PR #4480 (Refactor CFA 重构锻星砧)概览操作: edited 这是一次架构级的、整体质量很高的重构。核心设计( 🔴 关键问题未发现会阻断合并的编译错误或数据丢失级 bug。以下是需在合并前重点核实的两处行为回归风险(建议确认,非必然 bug):
|
| 声称 | 状态 | 主要文件 |
|---|---|---|
| 拆分搜索/引力/库存/快照/历史 + 统一持久化同步 | ✅ | CfaSearchController, CfaGravityController, CfaInventoryCodec, CelestialSnapshotCodec, CelestialSearchHistory, CfaBlockEntitySync |
| 巨构定义模型+注册表+内置注册 | ✅ | Megastructure, ModMegastructures, CelestialRefactorRegistry, CfaMegastructureManager |
| 保留旧名/索引兼容 | ✅ | CfaMegastructureManager (findLegacyId), loadActiveIdentity |
| 星球资源配方→构建器 API + offerings 宝石随机 | ✅ | PlanetResourceRecipe, PlanetResourceGenerator, ChoiceBuilder/select() |
| 物流/热力→RPC 按需同步 + 缓存刷新 | ✅ | HeatableBlockEntity, HeatableBlockTooltipProvider, CfaLogisticsInterfaceTooltipProvider, 删除 HeatableSyncPacket |
| 伽马/虫洞激光持久化 | ✅ | CelestialForgingAnvilPortalBlockEntity, CfaGammaLaserEffects, BaseLaserBlockEntity |
| 天体登陆/返回规则 + 兼容旧 | ✅ | CelestialTravelData, CelestialTravelManager, SpecialCelestialBodyData/Recipe |
| 返回门+旅行管理器+安全落点+紧急平台 | ✅ | CelestialBackGate(BE), CelestialTravelManager |
| overworld_like 维度+生物群系源 | ✅ | dimension JSON, VanillaOverworldBiomeSource, ModBiomeSources, ServerLevel/MinecraftServer Mixin |
| 褐矮星戴森球+红矮星转化 | ✅ | DysonSphereHandler, StarData/GiantPlanetData, ModMegastructures |
| 锻星砧传送门/流体接口独立运行 | ✅ | CelestialForgingAnvilPortalBlockEntity, FluidInterfaceBlockEntity |
| CG 功率上限 65536 | ✅ | CreativeGeneratorBlockEntity, SliderScreen |
| resolved #3737/#4423/#4429 | 无法从 diff 直接验证 issue 关闭,需人工确认 |
结论: COMMENT(建议合并)
这是高质量的大型重构。设计合理、兼容性处理细致、逻辑自洽,未发现会破坏存档或导致崩溃的关键缺陷。合并前请重点确认两点:(1) heatable 时长在移除周期推送后,客户端非 tooltip 路径是否还有依赖(以及 setDuration 相等短路对客户端动画的影响);(2) getActiveIndex() 语义弱化对第三方调用的影响。若这两点确认无碍,即可合并。
🧪 测试建议
| 被测目标 | 推荐测试场景 | 优先级 |
|---|---|---|
CfaMegastructureManager |
旧 index NBT 存档 → 新 ID 迁移;add-on 移除后 ID 失效回退 | 🔴 |
DysonSphereHandler |
褐矮星 40gt 稳定供给倍率阶梯;过量物质 ≥12800B 红矮星转化 + NBT 持久化回读 | 🔴 |
CelestialTravelManager.tryLand/tryReturn |
SAME/SCALED/FIXED/RANDOM_SPAWN 各坐标规则;无安全地形紧急平台;重复门清理;传送冷却 | 🔴 |
HeatableBlockEntity RPC |
客户端 tooltip 拉取、超时/异常回退、reach 校验拒绝 | 🟡 |
PlanetResourceRecipe.WeightedEntry.select() |
嵌套权重随机命中边界;直接条目往返 JSON 编解码不变性 | 🟡 |
CelestialTravelData codec/STREAM_CODEC |
landing/travel 双字段、旧 NBT 兼容、非法字符串参数回退 |
🟡 |
由 Hermes Agent 审查
|
💾 Self-improvement review: Patched SKILL.md in skill 'data-migration-pr-review' (1 replacement). |
|
1、返回传送门会被流体冲毁 |
|
I have a comprehensive understanding. Let me write the review now. The review is ready to be posted as the comment (the webhook will publish the reply automatically). I'll write it in Chinese to match the project's convention. 审查意见:PR #4480 — Refactor CFA 重构锻星砧规模:92 个文件、+6273/−1856 行(仅 12 个生成/语言资源文件,其余 78 个为 Java,逻辑审查为主)。整体是一次高质量、面向扩展的架构重构:把锻星砧状态拆分成独立控制器(搜索/引力/库存编解码/天体快照/搜索历史),用 ✅ 做得好的地方
|
|
💾 Self-improvement review: Patched SKILL.md in skill 'data-migration-pr-review' (1 replacement). |
|
Confirmed my analysis. The drop strip of I have everything I need. Let me write the comprehensive review. 代码审查总结结论:已审查 💬(2 个警告,5 条建议,1 个待确认) PR: #4480 — synchronize: Refactor CFA 重构锻星砧 这是一个规模巨大、架构质量很高的重构 PR。核心是把 CFA 的巨构系统从「BlockEntity 内硬编码 + 索引」重构为「注册表驱动的
|
| 被测目标 | 推荐测试场景 | 优先级 |
|---|---|---|
CelestialRefactorRegistry.findLegacyIdByIndex |
旧 1.21 存档 activeMegastructure 索引在增幅/非增幅、不同天体下解析到稳定 ID;索引越界返回 null 不崩 |
🔴 |
DysonSphereHandler.transformToRedDwarf |
褐矮星累积 12800B 过量物质后转红矮星:StarData.specialRedDwarf=true、资源集清空、energy 由 effectiveEnergy 决定 |
🔴 |
CfaMegastructureManager.resolveLegacyIdentity |
name+ring、index 两条旧路径均能迁移;新存档直接从 ID 读取不回退 | 🔴 |
CelestialTravelManager.tryLand |
落点为海中时生成应急平台;返回门复用(同源端口 8gt 半径内复用而非新建);重复门仅清理同源 | 🟡 |
BaseLaserBlockEntity.emitGammaLaserBeam |
伽马目标查找、棱镜销毁、CfaGammaLaserEffects.damageEntities 伤害计算、余烬金属区域加热 |
🟡 |
HeatableBlockEntity.getDuration RPC |
超 8gt 距离/未加载区块/非 heatable 时报错或返回 -1,不破环校验 | 🟡 |
TempleHandler 存根 |
重构后 quickMoveStack 是否仍正确(非 return getSlot(i).getItem() 吞物品) |
🟢 |
由 Hermes Agent 审查
|
💾 Self-improvement review: Skill 'registry-driven-refactor-pr-review' created. |
anvilcraft:overworld_like维度和原版生物群系源,通过独立种子、原版生成设置及结构集合筛选保持稳定且隔离的世界生成