Chunky Pregenerator

适用于 Minecraft 1.21.11 的 Fabric 模组,使用 Chunky 作为生成后端,自动在玩家周围预生成区块。完全在后台运行,支持螺旋式生成的中途重启,并兼容单人游戏和专用服务器。
由 Claude 辅助编码。采用 MIT 许可证。是的,它非常精致且几乎没有 Bug。
为什么选择此模组而不是 Distant Horizons 自带的预生成器
Distant Horizons (DH) 的预生成器仅在以世界中心为圆心、固定半径的位置触发一次。它不会追踪玩家的实际移动轨迹,无法随玩家移动进行调整,没有优先处理近处地形而非远处地形的概念,且在服务器性能不佳时也无法暂停。一旦触发,便不再变化。
本模组以玩家的实际位置为中心,通过扩展的螺旋环进行生成。靠近玩家的地形总是优先完成。当玩家从上一次生成的中心点移动到足够远的距离时,一个新的生成包会自动触发,并以玩家的新位置为中心重新定位。如果生成期间服务器 TPS 下降,Chunky 会收到暂停指令,直到恢复后再继续。如果在螺旋式生成过程中退出游戏,它会精确保存当前所在的环数,并在重新加入后从该位置继续。Chunky 本身就会跳过环内已生成的区块,因此最多只会损失部分环的工作量。
此外,它在每个生成包的开始时通过短暂扩大和缩小渲染距离来强制重建 Voxy 的 LOD(细节层次)。如果没有这一步骤,Voxy 不会将新预生成的地形识别为 LOD 数据,直到有其他操作触发重建。
功能特性
螺旋批量生成 — 生成包被划分为同心环,使用二次缓入曲线(quadratic ease-in curve)进行分布。环间距在靠近玩家时更紧密,向外逐渐变疏,这符合实际的探索方式。Chunky 会自动跳过每个环内已生成的区块,因此重叠的环几乎不消耗额外资源。
移动触发重新居中 — 当玩家移动超过死区距离(deadzone distance)离开上一个生成中心时,一个新的生成包会以玩家的新位置为中心触发。默认设置为生成半径的一半,因此在您前进的方向上始终有预生成地形的缓冲区。
重新加入时恢复生成 — 环索引、环列表和中心坐标会在每次保存时写入世界数据文件夹。重新加入后,经过设定的延迟时间,它会重新触发当前环的生成。Chunky 会自动跳过已完成的部分。
TPS 自动暂停 — 当服务器 TPS 低于阈值(默认 15 TPS)时,Chunky 会暂停;当 TPS 恢复到阈值以上(默认 18 TPS)时,则继续运行。防止生成过程加剧性能问题。
Voxy LOD 集成 — 启用后,生成半径和死区距离将跟踪 Voxy 的实际渲染距离设置,而不是静态的配置值。通过反射实时读取 Voxy 的配置,如果反射失败则回退到 JSON 解析。此外,在每个生成包开始时触发 Voxy LOD 重建(渲染距离扩大/缩小循环),使 freshly generated terrain(新生成的地形)无需等待即可显示在 LOD 中。
Chunky API 轮询 — 完成检测通过 Chunky 的实际 ChunkyAPI.isRunning() 方法(经由反射调用)进行,而不是依赖日志解析或计时器。只要 Chunky 真正完成,环就会立即推进。需要连续两次读取为 false 才会推进,作为新任务启动后短暂窗口期的防抖处理。
停滞看门狗 — 如果 Chunky 完全静止(连续 10 分钟没有 isRunning()=true 的读数),看门狗会重置状态,防止永远挂起。它测量的是实际的停滞时间而非总运行时间,因此合法的数小时生成过程不会触发此机制。
单会话进度中继 — 抑制 Chunky 每秒输出的大量日志垃圾信息,改为按可配置的时间间隔输出清晰的进度摘要。
下界自动缩放 — 下界的生成半径自动除以 8,以匹配坐标比例。250 区块的主世界半径在下界变为约 31 个区块。
末路传送门门禁 — 在玩家实际访问过末路之地之前,不会预生成末路之地。末路传送门会在首次进入时生成末影龙,你肯定不希望预生成阶段在屏幕外就发生这种情况。
Sodium 设置 UI — 所有设置均在 Sodium 的视频设置中提供专用页面,并带有实时工具提示,显示 Voxy 实际读取到的渲染距离数值。
服务器与单人模式 — 可在专用服务器和单人集成服务器上运行。客户端模组(Sodium、Voxy)为可选。
需求
依赖项 必需 备注
Fabric Loader 是 0.19.3+
Fabric API 是 任何 1.21.11 构建版本
Chunky 是 1.4.55+
Sodium 客户端 用于游戏内设置界面 + LOD 重建循环
Voxy 可选 让 Voxy 的渲染距离驱动生成半径
推荐在单人游戏中与 Chunky 配合使用 Chunky-Offline。它可以在世界加载之间保持 Chunky 的运行。
如果没有安装 Voxy,模组将使用配置文件中的静态 generationRadius 和 triggerDistance。
安装
将 jar 文件放入你的 mods/ 文件夹。配置文件将在首次启动时生成于 config/chunkypregen.json。如果你安装了 Sodium,所有设置都在“选项 > 视频设置 > Chunky Pregenerator”中。在游戏中使用 /chunkypregen reload 命令重载配置。
命令
/chunkypregen status 显示每个维度的状态、当前环数、最后一个中心点以及实时进度
/chunkypregen trigger 手动触发所有已启用维度的生成批次
/chunkypregen trigger <dim> 为指定维度触发
/chunkypregen cancel 取消所有正在进行的 Chunky 任务并重置状态
/chunkypregen reset 清除保存的上次中心位置
/chunkypregen stats 会话统计信息:触发的任务数、预估区块数、活跃时间
/chunkypregen config 将当前配置输出到聊天栏
/chunkypregen debug 切换调试日志记录
/chunkypregen reload 无需重启即可从磁盘重新加载配置
/chunkypregen setworld reset 清除新世界初始化标志,使首次加入时的预生成再次触发
螺旋曲线的工作原理
环的半径遵循公式 radius x ((i+1)/N)^2。环的数量 N 会根据半径和 generationRingStep 自动缩放。在默认步长为 25 的情况下,250 个区块会产生 13 个环;1000 个区块则会产生 20 个环。每个环依次触发,下一个环仅在 isRunning() 确认当前环完成后才开始。
二次曲线意味着第 1 个环覆盖最内层约 1% 的区域,而外层的环逐渐变大。玩家附近的区域总是最先完成生成。
许可证
MIT
Chunky Pregenerator

A Fabric mod for Minecraft 1.21.11 that automatically pre-generates chunks around players using Chunky as the generation backend. Runs completely in the background, survives restarts mid-spiral, and works on both singleplayer and dedicated servers.
Vibecoded using Claude. MIT licensed. Yes, it's incredibly polished and there are minimal bugs.
Why this over Distant Horizons' built-in pregenerator
DH's pregenerator fires once at a fixed radius from the center of the world. It doesn't track where the player actually goes, can't adjust as they move, has no concept of prioritizing nearby terrain over distant terrain, and can't pause when the server is struggling. Once it fires, that's it.
This mod generates in expanding spiral rings centered on the player's actual position. The terrain closest to the player is always done first. When the player moves far enough from the last generation center, a new bundle fires automatically, re-centered on them. If server TPS tanks during generation, Chunky gets told to pause and waits for recovery. When it recovers, it picks back up. If you quit mid-spiral, it saves exactly which ring it was on and resumes from there on rejoin. Chunky naturally skips already-generated chunks within a ring, so you lose at most a partial ring worth of work.
It also forces a Voxy LOD rebuild at the start of each bundle by briefly expanding and collapsing render distance. Without this, Voxy doesn't register newly pre-generated terrain as LOD data until something else triggers a rebuild.
Features
Spiral batch generation — the bundle gets split into concentric rings using a quadratic ease-in curve. Ring spacing is tighter near the player and grows further out, which maps to how exploration actually works. Chunky skips already-generated chunks within each ring automatically, so overlapping rings are essentially free.
Movement-triggered re-center — once the player moves more than the deadzone distance from the last generation center, a new bundle fires centered on their new position. Defaults to half the generation radius, so there's always a buffer of pre-generated terrain ahead of wherever you're going.
Mid-bundle resume on rejoin — ring index, ring list, and center are written to the world's data folder on every save. On rejoin, after the join delay, it re-fires the current ring. Chunky skips the already-done portion automatically.
TPS auto-pause — Chunky pauses when server TPS drops below threshold (default 15 TPS) and resumes when it recovers (default 18 TPS). Prevents generation from compounding a performance problem.
Voxy LOD integration — when enabled, generation radius and deadzone track Voxy's actual render distance setting rather than static config values. Reads Voxy's config live via reflection, falls back to JSON parsing if reflection fails. Also fires a Voxy LOD rebuild (render distance expand/collapse cycle) at the start of each bundle so freshly generated terrain shows up in LOD without waiting.
Chunky API poll — completion detection goes through Chunky's actual ChunkyAPI.isRunning() via reflection rather than relying on log parsing or timers. Ring advance happens the moment Chunky actually finishes. Two consecutive false readings are required before advancing, as a debounce for the brief window right after a new task starts.
Stall watchdog — if Chunky goes completely silent (no isRunning()=true readings) for 10 straight minutes, the watchdog resets state so nothing hangs forever. Measures actual stall time rather than total runtime, so a legitimate multi-hour generation never trips it.
Per-session progress relay — Chunky's per-second log spam is suppressed. A clean progress summary goes out on a configurable interval instead.
Nether auto-scale — Nether generation radius is divided by 8 automatically to match the coordinate scale. A 250-chunk Overworld radius becomes ~31 chunks in the Nether.
End gate — the End won't pre-generate until a player has actually visited it. The End portal spawns the dragon on first entry, and you don't want that happening off-screen during pre-gen.
Sodium settings UI — all settings are exposed in a dedicated page in Sodium's video settings, with live tooltips that show what Voxy's render distance is actually reading as.
Server and singleplayer — runs on dedicated servers and singleplayer integrated servers. Client-side mods (Sodium, Voxy) are optional.
Requirements
Dependency Required Notes
Fabric Loader Yes 0.19.3+
Fabric API Yes Any 1.21.11 build
Chunky Yes 1.4.55+
Sodium Client In-game settings UI + LOD rebuild cycle
Voxy Optional Lets Voxy's render distance drive generation radius
Chunky-Offline is recommended alongside Chunky in singleplayer. It keeps Chunky running between world loads.
Without Voxy, the mod uses the static generationRadius and triggerDistance from config.
Installation
Drop the jar into your mods/ folder. Config generates on first launch at config/chunkypregen.json. If you have Sodium installed, all settings are in Options > Video Settings > Chunky Pregenerator. Reload config in-game with /chunkypregen reload.
Command
/chunkypregen status State per dimension, current ring, last center, live progress
/chunkypregen trigger Manually fire a generation bundle for all enabled dimensions
/chunkypregen trigger <dim> Fire for a specific dimension
/chunkypregen cancel Cancel all active Chunky jobs and reset state
/chunkypregen reset Clear saved last-center positions
/chunkypregen stats Session stats: jobs fired, estimated chunks, active time
/chunkypregen config Dump current config to chat
/chunkypregen debug Toggle debug logging
/chunkypregen reload Reload config from disk without restart
/chunkypregen setworld reset Clear the new-world init flag so first-join pre-gen fires again
How the spiral curve works
Ring radii follow radius x ((i+1)/N)^2. Ring count N scales automatically with radius and generationRingStep. At 250 chunks with default step of 25, you get 13 rings. At 1000 chunks you get 20. Each ring fires sequentially and the next ring only starts after isRunning() confirms the current one is done.
The quadratic curve means ring 1 covers the innermost ~1% of the area and the outer rings get progressively larger. The area near the player is always the first thing finished.
License
MIT
评论 0
登录后参与评分
还没有评论,来抢沙发吧