Alex's Caves Optimization
A performance addon for Alex's Caves. It speeds up chunk generation around and inside the cave biomes and removes several wasteful per-tick calculations of Alex's Caves mobs and blocks. World generation results stay exactly the same as without this mod.
Benchmarks
Chunk generation speed measured with Chunky pre-generation (chunks per second, higher is better). Forge 1.20.1 server, Alex's Caves 2.0.2, Ryzen 7 7730U, single run per case (about ±10% noise).
| Scenario | Without Alex's Caves | Alex's Caves | Alex's Caves + this mod | Gain |
|---|---|---|---|---|
| Normal area, default config | 60.9 | 41.4 | 58.8 | +42% |
| Primordial Caves filling the underground | 53.0 | 23.1 | 29.8 | +29% |
| Magnetic Caves filling the underground | 53.0 | 41.8 | 48.3 | +16% |
| Toxic Caves filling the underground | 53.0 | 23.1 | 31.5 | +36% |
| Abyssal Chasm filling the underground | 53.0 | 22.7 | 37.0 | +63% |
| Forlorn Hollows filling the underground | 53.0 | 23.1 | 29.8 | +29% |
| Candy Cavity filling the underground | 53.0 | 16.5 | 21.7 | +32% |
In normal areas, which is most of the world with the default config, this mod recovers about 90% of the chunk generation speed lost to Alex's Caves.
Share of server tick time spent in individual hot spots (spark profiler):
| Hot spot | Before | After |
|---|---|---|
| Magnetism of magnetic entities | 12.0% | 5.8% |
| Trilocaris wandering | 7.1% | 3.6% |
| Vesper attack AI | 6.5% | 0.6% |
| Nuclear Siren block entity | 3.4% | 0.8% |
| Notor hologram AI | 3.3% | 0.8% |
Optimizations
World generation
| Optimization | What it does | Effect on the game | Config option |
|---|---|---|---|
| Surface rule skip | Alex's Caves puts its cave surface rules in front of all Overworld surface rules, so every stone block checks its biome first. Blocks that cannot be inside a cave biome skip these rules. | None, result unchanged | worldgen.surfaceRuleSkip |
| Uniform biome lookup | Blocks deep inside a cave biome get their biome directly instead of running the fuzzy biome calculation. | None, result unchanged | worldgen.uniformBiomeLookup |
| Noise cache | Cave structures sample the same noise values again and again while carving; repeated samples come from a cache. | None, result unchanged | worldgen.noiseCache |
Entities
| Optimization | What it does | Effect on the game | Config option |
|---|---|---|---|
| Magnet lookup | Magnetic entities only scan the chunk sections within range instead of whole chunk columns. | None, result unchanged | entities.magnetPoiQuery |
| Moving-block collision | Every entity move looked for magnetically moved blocks; the lookup is skipped while none exist. | None, result unchanged | entities.movingBlockCollisionSkip |
| Pathfinding throttle | Trilocaris, Radgill, Vesper and Notor recalculated their path every tick in some AI goals; now at most once every 5 ticks. | AI timing changes slightly | entities.pathfindingThrottle, pathfindingThrottleTicks |
| Gloomoth light search | Search range for light sources reduced from 32 (65×65×65 blocks) to 16. | Distant lights may be ignored | entities.gloomothLightSearch, gloomothLightSearchRange |
| Underzealot light search | Search range for lights to break reduced from 32 to 16. | Distant lights may not be broken | entities.underzealotLightSearch, underzealotLightSearchRange |
Blocks
| Optimization | What it does | Effect on the game | Config option |
|---|---|---|---|
| Nuclear Siren search | Searches a 128-block radius for critical furnaces every 100 ticks instead of every 20. | Sirens may start up to 4 seconds later | blocks.sirenSearchThrottle, sirenSearchInterval |
Configuration
Every optimization can be turned on or off separately in config/alexscavesopt-common.toml. The ranges and intervals in the tables above are the defaults and can be changed there.
Compatibility
- Install together with Alex's Caves and Citadel.
- The two surface rule optimizations only apply when every surface rule registered through Citadel is a plain "if biome, then rule" entry, which is what Alex's Caves registers. If another mod registers a different kind of rule through Citadel, they switch off automatically and the original logic is used.
Alex's Caves 优化
Alex's Caves(Alex 的洞穴) 的性能附属模组。加快洞穴群系周围和群系内部的区块生成速度,并去掉 Alex's Caves 生物和方块每 tick 的一些多余计算。世界生成的结果和不装本模组时完全相同。
测试数据
用 Chunky 预生成测量区块生成速度(区块/秒,越高越好)。Forge 1.20.1 服务端,Alex's Caves 2.0.2,Ryzen 7 7730U,每组测一次(误差约 ±10%)。
| 场景 | 不装 Alex's Caves | 装了,未优化 | 装了,优化后 | 提升 |
|---|---|---|---|---|
| 普通区域(出生点附近,默认配置) | 60.9 | 41.4 | 58.8 | +42% |
| 原始洞穴铺满 | 53.0 | 23.1 | 29.8 | +29% |
| 磁力洞穴铺满 | 53.0 | 41.8 | 48.3 | +16% |
| 辐射洞穴铺满 | 53.0 | 23.1 | 31.5 | +36% |
| 深渊裂谷铺满 | 53.0 | 22.7 | 37.0 | +63% |
| 荒芜空洞铺满 | 53.0 | 23.1 | 29.8 | +29% |
| 糖果洞穴铺满 | 53.0 | 16.5 | 21.7 | +32% |
默认配置下世界的大部分地方都是普通区域,本模组在这里补回了 Alex's Caves 损失的约 90% 的区块生成速度。
各热点占服务端 tick 时间的比例(spark 采样):
| 热点 | 优化前 | 优化后 |
|---|---|---|
| 磁力实体的磁力计算 | 12.0% | 5.8% |
| 三叶虫闲逛 | 7.1% | 3.6% |
| Vesper 攻击 AI | 6.5% | 0.6% |
| 核警报器方块实体 | 3.4% | 0.8% |
| Notor 全息投影 AI | 3.3% | 0.8% |
优化内容
世界生成
| 优化 | 做了什么 | 对游戏的影响 | 配置项 |
|---|---|---|---|
| 地表规则跳过 | Alex's Caves 把洞穴地表规则插在所有主世界地表规则前面,每个石头方块都要先查一次群系。不可能处在洞穴群系里的方块直接跳过这些规则。 | 无,结果不变 | worldgen.surfaceRuleSkip |
| 统一群系快速路径 | 洞穴群系深处的方块直接得出群系,不再做模糊群系采样计算。 | 无,结果不变 | worldgen.uniformBiomeLookup |
| 噪声缓存 | 洞穴结构挖掘时反复采样相同的噪声值,重复的采样直接用缓存。 | 无,结果不变 | worldgen.noiseCache |
生物
| 优化 | 做了什么 | 对游戏的影响 | 配置项 |
|---|---|---|---|
| 磁铁查找 | 磁力实体只扫描范围内的区段,不再扫描整列区块。 | 无,结果不变 | entities.magnetPoiQuery |
| 移动方块碰撞 | 实体每次移动都要查找被磁力推动的方块,世界里没有这种方块时跳过查找。 | 无,结果不变 | entities.movingBlockCollisionSkip |
| 寻路限频 | 三叶虫、辐射鳃鱼、Vesper、Notor 的部分 AI 每 tick 都重新寻路,现在最多每 5 tick 一次。 | AI 反应时机略有不同 | entities.pathfindingThrottle、pathfindingThrottleTicks |
| Gloomoth 找光源 | 找光源的范围从 32(65×65×65 格)缩到 16。 | 太远的光源可能找不到 | entities.gloomothLightSearch、gloomothLightSearchRange |
| 地底狂信者找光源 | 寻找要破坏的光源的范围从 32 缩到 16。 | 太远的光源可能不会被破坏 | entities.underzealotLightSearch、underzealotLightSearchRange |
方块
| 优化 | 做了什么 | 对游戏的影响 | 配置项 |
|---|---|---|---|
| 核警报器搜索 | 在 128 格半径内搜索临界熔炉的间隔从 20 tick 改为 100 tick。 | 警报最多晚 4 秒响起 | blocks.sirenSearchThrottle、sirenSearchInterval |
配置
每项优化都可以在 config/alexscavesopt-common.toml 中单独开关。上表中的范围和间隔是默认值,也可以在这个文件里修改。
兼容性
- 需要和 Alex's Caves、Citadel 一起安装。
- 地表规则的两项优化要求通过 Citadel 注册的地表规则全部是「如果是某群系,就用某规则」的形式,Alex's Caves 注册的就是这种。如果别的模组通过 Citadel 注册了其他形式的规则,这两项会自动停用,改走原逻辑。