?⚡Create Optimized Trains
针对 Create Mod 列车的性能优化插件(Forge 1.20.1)。
?依赖项
本模组需要 Create 或 Create Fabric。
- Minecraft 1.20.1
- Forge 47.1.33+
- Create Mod 6.0.8+
- Flywheel 1.0.6+(随 Create 捆绑提供)
?功能
1. 列车 LOD(细节层次)
- FULL — 带有完整物理效果的真实车厢(玩家附近时)
- MEDIUM — 简化物理效果,正常渲染
- LOW — 无物理效果、无碰撞、最小化机械装置更新
- GHOST — 幽灵实体,无渲染,仅保留抽象数据
2. 车厢分组 / 抽象化
- 将多个车厢合并为单个逻辑实体(
TrainGroup)
- 仅存储:长度、速度、位置、以及作为 NBT 数据的车厢列表
- 当玩家靠近时展开还原
3. 安全多线程处理
辅助线程(安全):
- 路线计算
- 碰撞预测
- 时刻表优化
- 优先级管理
- LOD 决策
- 预测性模拟
主线程(必需):
- 实际实体移动
- Create 物理效果
- 渲染
- 方块交互
4. Tick 节流(部分更新)
- FULL:每个 tick
- MEDIUM:每 3 个 tick(可配置)
- LOW:每 8 个 tick
- GHOST:每 20 个 tick
5. 渲染优化
- 禁用远处列车的动画
- 跳过 GHOST LOD 的完整渲染
- 减少粒子与视觉效果
- 不可见时隐藏内部细节
6. 代理实体
- 代表整列列车的轻量级实体
- 取代数十个机械装置
- 保持位置、速度和方向
- 在需要时重建真实车厢
7. 智能区块加载管理
- 仅加载必要的区块
- 提前卸载列车后方的区块
- 预加载列车前方的区块
- 防抖动机制(防止重复的加载/卸载循环)
8. 物理优化
- 简化远处车厢的物理效果
- 在低 LOD 下禁用车厢间的碰撞
- 减少转向架检查
- 距离较远时禁用内部机械装置的物理效果
9. 网络优化
- 仅在速度/方向改变时发送更新
- 打包数据包(增量压缩)
- 减少远处列车的同步频率
10. 优先级系统
- 按类型划分优先级(EXPRESS > PASSENGER > FREIGHT > LOW)
- 路口冲突解决
- 轨道段预留
- 异步冲突分析
11. 动态性能监控器
- NORMAL (TPS >= 18):全保真度
- DEGRADED (15 <= TPS < 18):轻度优化
- CRITICAL (TPS < 15):激进优化,缩短 LOD 距离
?技术性能证书
Create Optimized Trains 经历了一系列内部和社区测试,包括:
压力测试
- 超过 300 格长的列车
- 同时移动的机械装置
- 数百个实体的渲染
- 具有激进预加载的世界
兼容性测试
- Create
- Steam ’n’ Rails
- Embeddium
- Radium
- Copycats+
- Distant Horizons
社区测试
预发布版本已在官方 Discord 上提供,确保每次公开更新都稳定且无回归问题。
⚙️配置
文件:create_optimized_trains-common.toml
所有功能均可单独配置,包括距离、间隔和开关。
?从 Create 6.0.9+ 移植的修复
Create 6.0.9(针对 Minecraft 1.21.1)引入了几项重要的修复,但这些修复从未向后移植到 1.20.1。由于 Create 团队不再对 1.20.1 进行更新,本模组为坚持使用 1.20.1 的用户移植了以下修复:
机械装置碰撞框 GC 压力 (#6902)
原始问题: 当列车在车站开门/关门时,gatherBBsOffThread() 使用 Shapes.joinUnoptimized() 将所有方块的碰撞形状组合成一个单一的 VoxelShape —— 这是一个 O(n²) 的操作,会产生大量临时对象。垃圾回收器无法跟上节奏,导致根据列车复杂程度不同,出现 1-30+ 秒的卡顿。
我们的修复: ContraptionCollisionMixin 用与 Create 6.0.9 中相同的 O(n) 方法替换了碰撞收集算法(commit 8f30c2c)。它不再连接 VoxelShape,而是直接从每个方块的碰撞形状中收集 AABB —— 没有中间分配,没有 GC 压力。还包括相关的重复项:#4607、#5685、#9026、#9389。
来自 carriageWaitingForChunks 的列车卡顿
原始问题: 在 Train.tick() 中,当车厢进入未加载的区块时,Create 会设置 carriageWaitingForChunks,强制将 speed = 0 直到区块完成加载。在拥有大量列车且视距有限的地图中,每次列车跨越区块边界时都会导致 0.5-1.5 秒的卡顿。
我们的修复方案: TrainMixin 重定向了 tick() 中所有对 carriageWaitingForChunks 的读取操作,使其始终返回 -1,从而确保速度永远不会被清零。结合智能区块加载系统(提前为列车预加载区块),列车可以连续移动而不会出现 stutter。
碰撞检测性能
原始问题: collideWithOtherTrains() 会在每一刻为每辆列车执行一次,这在拥有 20 辆以上列车的地图上会变得非常消耗性能。
我们的修复方案: TrainMixin 根据服务器性能自适应地限制碰撞检测的频率——正常情况每 4 刻执行一次,性能下降时每 8 刻执行一次,严重受限时每 12 刻执行一次。每辆列车的检测间隔通过其 UUID 哈希值进行偏移,以均匀分散各刻之间的负载。
?关于我们
发行商:GreenToastSoftware Games® (C)GreenToastSoftware Corporation. All rights reserved 2020-2026.
?⚡Create Optimized Trains
Performance optimization addon for Create Mod trains (Forge 1.20.1).
?Dependencies
This mod requires Create or Create Fabric.
- Minecraft 1.20.1
- Forge 47.1.33+
- Create Mod 6.0.8+
- Flywheel 1.0.6+ (bundled with Create)
?Features
1. LOD (Level of Detail) for Trains
- FULL — Real carriages with full physics (player nearby)
- MEDIUM — Simplified physics, normal rendering
- LOW — No physics, no collisions, minimal contraption updates
- GHOST — Ghost entity, no rendering, abstract data only
2. Carriage Grouping / Abstraction
- Merges multiple carriages into a single logical entity (
TrainGroup)
- Stores only: length, speed, position, carriage list as NBT
- Expands back when the player approaches
3. Safe Multi-threading
Secondary thread (safe):
- Route calculation
- Collision prediction
- Schedule optimization
- Priority management
- LOD decisions
- Predictive simulation
Main thread (required):
- Actual entity movement
- Create physics
- Rendering
- Block interaction
4. Tick Throttling (Partial Updates)
- FULL: every tick
- MEDIUM: every 3 ticks (configurable)
- LOW: every 8 ticks
- GHOST: every 20 ticks
5. Render Optimization
- Disables animations for distant trains
- Skips full rendering for GHOST LOD
- Reduces particles and visual effects
- Hides internal details when not visible
6. Proxy Entities
- Lightweight entity representing the entire train
- Replaces dozens of contraptions
- Keeps position, speed and direction
- Recreates real carriages when needed
7. Smart Chunk Loading Management
- Loads only essential chunks
- Unloads chunks behind the train earlier
- Pre-loads chunks ahead
- Anti-thrashing (prevents repeated load/unload cycles)
8. Physics Optimization
- Simplified physics for distant carriages
- Disables collisions between carriages at low LOD
- Reduces bogie checks
- Disables internal contraption physics when far away
9. Networking Optimization
- Sends updates only when speed/direction changes
- Batches packets (delta compression)
- Reduces sync frequency for distant trains
10. Priority System
- Priority by type (EXPRESS > PASSENGER > FREIGHT > LOW)
- Conflict resolution at junctions
- Track segment reservation
- Async conflict analysis
11. Dynamic Performance Monitor
- NORMAL (TPS >= 18): full fidelity
- DEGRADED (15 <= TPS < 18): light optimizations
- CRITICAL (TPS < 15): aggressive optimizations, reduced LOD distances
? Technical Performance Certificate
Create Optimized Trains has undergone a series of internal and community tests, including:
Stress Tests
- Trains over 300 blocks long
- Simultaneous moving contraptions
- Rendering with hundreds of entities
- Worlds with aggressive preloading
Compatibility Tests
- Create
- Steam ’n’ Rails
- Embeddium
- Radium
- Copycats+
- Distant Horizons
Community Testing
Pre-release versions were made available on the official Discord, ensuring that every public update is stable and free of regressions.
⚙️Configuration
File: create_optimized_trains-common.toml
All features are individually configurable with distances, intervals and toggles.
?Backported Fixes from Create 6.0.9+
Create 6.0.9 (for Minecraft 1.21.1) introduced several important fixes that were never backported to 1.20.1. Since 1.20.1 is no longer receiving updates from the Create team, this mod backports the following fixes for users staying on 1.20.1:
Contraption Collision Box GC Pressure (#6902)
Original problem: When train doors open/close at a station, gatherBBsOffThread() combines ALL block collision shapes into a single VoxelShape using Shapes.joinUnoptimized() — an O(n²) operation that creates massive temporary objects. The garbage collector can't keep up, causing lag spikes of 1-30+ seconds depending on train complexity.
Our fix: ContraptionCollisionMixin replaces the collision gathering algorithm with the same O(n) approach used in Create 6.0.9 (commit 8f30c2c). Instead of joining VoxelShapes, it collects AABBs directly from each block's collision shape — no intermediate allocations, no GC pressure. Also includes related duplicates: #4607, #5685, #9026, #9389.
Train Stutter from carriageWaitingForChunks
Original problem: In Train.tick(), when a carriage enters an unloaded chunk, Create sets carriageWaitingForChunks which forces speed = 0 until the chunk finishes loading. On maps with many trains and limited view distance, this causes 0.5-1.5 second freezes every time a train crosses a chunk boundary.
Our fix: TrainMixin redirects all reads of carriageWaitingForChunks in tick() to always return -1, so speed is never zeroed. Combined with the Smart Chunk Loading system (pre-loading chunks ahead of the train), trains move continuously without stutter.
Collision Check Performance
Original problem: collideWithOtherTrains() runs every tick for every train, which becomes expensive on maps with 20+ trains.
Our fix: TrainMixin throttles collision checks adaptively based on server performance — every 4 ticks normally, every 8 when degraded, every 12 when critical. Each train's check is offset by its UUID hash to distribute the load evenly across ticks.
?About us
Publisher: GreenToastSoftware Games® (C)GreenToastSoftware Corporation. All rights reserved 2020-2026.
评论 0
登录后参与评分
还没有评论,来抢沙发吧