← Назад к ресурсам

Aeronautics Display Link Fix

Fixes a bug where Display Link's TargetOffset gets corrupted during physics assembly/disassembly when the display link and its target sign are on the same contraption in Create: Aeronautics.

Modrinth game-mechanics utility

Описание

# Aeronautics Display Link Fix [ADLF] # 航空学显示链接器修复 [ADLF] [中文](#chinese) | [English](#english) --- ## 中文 ### 简介 修复 Create: Aeronautics(机械动力航空学)中显示链接器(Display Link)在物理化/反物理化后 TargetOffset 被损坏的问题。**覆盖所有场景**:无论告示牌在飞行器上、在地面、还是在另一飞行器上。 ### 问题根源 Sable 物理化时通过 `saveWithFullMetadata` / `loadWithComponents` 搬运方块实体。 物理化空间中,DisplayLink 的 `target()` 方法使用物理化空间坐标计算相对偏移: ``` offset = 告示牌物理化坐标 - DisplayLink物理化坐标 → 产生巨大异常值(如 -20481038) ``` 这个损坏的偏移被持久化到 NBT 中,反物理化后带回真实世界,导致 DisplayLink 无法正确寻址告示牌。 ### 修复原理 通过 Mixin 注入 Sable 的 `SubLevelAssemblyHelper.moveBlocks()`: 1. **Phase 1**(`loadWithComponents` 之前):捕获所有正在移动的 DisplayLink 的原始 TargetOffset, 并预计算正确的旋转结果 `correctedOffset = originalOffset.rotate(rot)` 2. **Phase 2**(`moveBlocks` TAIL):无条件将每个 DisplayLink 的 TargetOffset 恢复为正确值 **不再需要 Case 3 检测**——任何被物理化的 DisplayLink 都要保护。 ### 特性 - ✅ **全面覆盖**:修复所有场景(DL 在飞行器上,告示牌在任意位置) - ✅ **旋转感知**:正确应用 Sable 装配旋转变换 - ✅ **零误判**:无 Case 1/2/3 分类,无条件修复 - ✅ **高性能**:只处理 DisplayLink 本身,与结构大小无关 - ✅ **可配置日志**:`adlf-common.toml` 中 `debug = true` 开启详细追踪 ### 版本历史 | 版本 | 说明 | |------|------| | **v1.3** | 全面保护:移除 Case 3 检测,无条件保护所有 DisplayLink | | v1.2.3 | 大型结构性能优化(O(n²) → O(n)) | | v1.2 | 旋转感知偏移修正 + 配置文件 | | v1.1 | 初始修复:双层 Case 3 判定 | ### 构建 ```bash # 前置条件:JDK 21 git clone cd Aeronautics-display-link-fix ./gradlew build # jar 输出:build/libs/aeronautics_display_link_fix-.jar ``` ### 依赖 - Minecraft 1.21.1 + NeoForge 21.1.233 - Create 6.0.10 - Sable 1.2.2 - Create: Simulated 1.2.1 - Create: Aeronautics 1.2.1 ### 注意事项 - 🧠 **本项目由 AI 辅助编写**,代码结构和实现细节由 AI 辅助生成。 - 🔧 由于作者不保证持续维护,后续版本兼容性可能滞后。 - 🏢 **Create / Sable / Aeronautics 官方未来可能会在架构层面修复此 Bug**, 届时本 Mod 将不再需要。请关注官方更新日志。 --- ## English ### Overview Fixes a bug in Create: Aeronautics where the Display Link's `TargetOffset` gets corrupted during physics assembly/disassembly. **Covers all scenarios**: regardless of whether the target sign is on the same contraption, on the ground, or on a different contraption. ### Root Cause During physics assembly, Sable moves block entities via `saveWithFullMetadata` / `loadWithComponents`. In the physics sublevel space, the DisplayLink's `target()` method computes its relative offset using sublevel coordinates: ``` offset = signSublevelPos - DLSublevelPos → huge garbage value (e.g. -20481038) ``` This corrupted offset gets persisted in NBT and carried back to the real world after disassembly, breaking the DisplayLink's targeting. ### How It Works A Mixin injects into Sable's `SubLevelAssemblyHelper.moveBlocks()`: 1. **Phase 1** (before `loadWithComponents`): Captures the original TargetOffset of every moving DisplayLink and pre-computes the correct rotated value: `correctedOffset = originalOffset.rotate(rot)` 2. **Phase 2** (`moveBlocks` TAIL): Unconditionally restores each DisplayLink's TargetOffset to the correct value **No more Case 3 detection** — every DisplayLink being moved needs protection. ### Features - ✅ **Universal coverage**: Fixes all scenarios (DL on contraption, sign anywhere) - ✅ **Rotation-aware**: Correctly applies Sable's assembly rotation transforms - ✅ **Zero false positives**: No Case 1/2/3 classification, unconditional fix - ✅ **High performance**: Only processes DisplayLinks themselves, O(1) w.r.t. structure size - ✅ **Configurable logging**: Toggle `debug = true` in `adlf-common.toml` for detailed tracing ### Version History | Version | Description | |---------|-------------| | **v1.3** | Universal protection: removed Case 3 detection, protect all DisplayLinks unconditionally | | v1.2.3 | Large structure performance optimization (O(n²) → O(n)) | | v1.2 | Rotation-aware offset correction + config file | | v1.1 | Initial fix: two-layer Case 3 detection | ### Build ```bash # Prerequisites: JDK 21 git clone cd Aeronautics-display-link-fix ./gradlew build # Output: build/libs/aeronautics_display_link_fix-.jar ``` ### Dependencies - Minecraft 1.21.1 + NeoForge 21.1.233 - Create 6.0.10 - Sable 1.2.2 - Create: Simulated 1.2.1 - Create: Aeronautics 1.2.1 ### Notes - 🧠 **This mod was developed with AI assistance** — some of the code structure and implementation details were AI-generated. - 🔧 The author does not guarantee ongoing maintenance. Future version compatibility may lag behind. - 🏢 **Create / Sable / Aeronautics may fix this bug at the architecture level in the future**, at which point this mod will no longer be needed. Please check official changelogs.