PreGen — Paper 1.20.4 的异步区块预生成器
受够了玩家加入时的卡顿、探索过程中的掉帧,以及每当有人踏入新地形时服务器 CPU 就要熔毁的时刻?PreGen 会在玩家踏入之前预先为你生成世界。流畅的加入体验。丝滑般的探索。毫无痛苦。
为什么选择 PreGen?
区块生成是 Minecraft 服务器最耗资源的操作之一。每次玩家进行探索时,主线程都要费力处理地形塑造、生物群系装饰、结构放置和光照计算。结果呢?TPS 下降、加入延迟,以及那个挥之不去的“正在加载地形...”界面。
PreGen 彻底解决了这个问题——一劳永逸。运行一次,然后走开。回来时你会发现一个已经构建完成的世界,玩家可以以三倍音速在其中飞行。
功能一览
- 螺旋式生成 —— 从出生点向外扩展为整洁的同心环,确保你最常访问的区域优先就绪。
- 异步区块加载 —— 基于 Paper 的现代
getChunkAtAsync API 构建。不会冻结主线程,也不会产生卡顿。
- TPS 感知节流 —— 当服务器负载较高时自动减速,一旦情况平稳便立即加速。
- 防崩溃进度保存 —— 每几百个区块就将进度保存到磁盘。重启服务器、JVM 崩溃或断电——PreGen 都能准确接续之前的进度继续工作。
- 按世界配置 —— 主世界、下界、末地、你的自定义维度——为每个世界设置独立的半径和中心点。
- 内存友好 —— 区块写入磁盘的瞬间即被卸载。再也不会有预生成期间高达 30 GB 的 RAM 峰值。
- 实时进度报告 —— 已完成区块数、百分比、每秒区块数以及实时预计时间(ETA),按照可配置的时间间隔广播给所有管理员。
- 零依赖 —— 把 jar 包丢进去就搞定了。没有外部库,也没有配套插件。
命令
| 命令 |
作用 |
/pregen start [world] [radiusBlocks] [centerX centerZ] |
启动新任务 |
/pregen stop [world] |
停止并保存进度 |
/pregen pause [world] |
暂停(稍后恢复) |
/pregen resume [world] |
恢复已暂停或已保存的任务 |
/pregen status [world] |
查看实时进度 + ETA |
/pregen reset [world] |
清除某个世界的已保存进度 |
别名:/pg, /pregenerate
权限:pregen.use(默认:op)
包含完整的 Tab 补全支持。
使用示例
/pregen start → 当前世界,使用配置的半径
/pregen start world 10000 → 围绕配置中心点 1 万方块半径
/pregen start world_nether 2000 0 0 → 显式指定中心点
/pregen status → 同时查看所有活跃及已保存的任务
/pregen pause world → 休息一下,随时恢复
配置
config.yml 中的所有设置均可根据你的硬件情况进行调整:
parallel-chunks: 8 # 最大并发异步区块加载数
chunks-per-tick: 4 # 每个服务器刻最大提交数
min-tps: 17.0 # TPS 低于此值时暂停
save-every: 200 # 每 N 个区块写入一次进度
auto-resume-on-start: true # 重启后自动接续
broadcast-interval-seconds: 30
unload-after-generate: true # 保持内存占用平稳
worlds:
world: { radius: 10000, center-x: 0, center-z: 0 }
world_nether: { radius: 2000, center-x: 0, center-z: 0 }
world_the_end: { radius: 2000, center-x: 0, center-z: 0 }
性能提示:在高性能硬件上将 parallel-chunks 调至 16,chunks-per-tick 调至 8。如果你设置得过高,TPS 保护机制会介入阻止你。
在以下环境测试通过
PaperMC 1.20.4
Java 17+(推荐 Java 21)
30 秒安装
将 PreGen-1.0.0.jar 放入 plugins/ 文件夹
启动服务器一次以生成 plugins/PreGen/config.yml
为每个世界调整半径(主世界默认为 1 万方块)
运行 /pregen start
去喝杯咖啡。当你回来时,世界就已经准备好了。
为何优于其他替代方案?
轻量级。~20 KB jar 包。五个 Java 文件。五分钟就能读完代码。
无外部库。没有 Adventure 阴影包,没有 Kotlin 运行时,什么都没有。纯 Paper API。
诚实的默认设置。开箱即用不会让你的 TPS 崩盘。保证。
真正可恢复。光标状态(当前环 + 索引)会被持久化,而不仅仅是一个区块计数器。重启时会精确回到正确的区块位置。
支持
发现 Bug?有功能请求?请在 GitHub 上提交 Issue。
如果 PreGen 拯救了你的服务器,请留个赞——这真的很有帮助!
快乐预生成!
PreGen — Async Chunk Pre-Generator for Paper 1.20.4
Tired of laggy player joins, stuttering exploration, and your server's CPU
melting every time someone wanders into fresh terrain? PreGen generates
your world before players ever step foot in it. Smooth joins. Buttery
exploration. Zero pain.
Why PreGen?
Chunk generation is one of the most expensive things a Minecraft server does.
Every time a player explores, the main thread grinds through terrain shaping,
biome decoration, structure placement, and lighting. The result? TPS drops,
join lag, and that "loading terrain..." screen that just won't go away.
PreGen fixes this — once and for all. Run it once. Walk away. Come back to a
fully-built world your players can fly through at Mach 3.
Features at a glance
- Spiral generation — expands outward from spawn in clean concentric
rings, so your most-visited areas are ready first.
- Asynchronous chunk loading — built on Paper's modern
getChunkAtAsync
API. No main-thread freezes. No stutter.
- TPS-aware throttling — automatically slows down when your server is
under load, then speeds back up the moment things calm down.
- Crash-proof progress — every job is saved to disk every few hundred
chunks. Restart the server, crash the JVM, pull the power cord — PreGen
picks up exactly where it left off.
- Per-world configuration — overworld, nether, end, your custom
dimensions — set independent radii and centers for each.
- Memory friendly — chunks are unloaded the instant they're written to
disk. No more 30 GB RAM spikes during pre-gen.
- Live progress reporting — chunks done, percentage, chunks/sec, and a
real-time ETA, broadcast to all ops on a configurable interval.
- Zero dependencies — drop the jar in, you're done. No external libs,
no companion plugins.
Commands
| Command |
What it does |
/pregen start [world] [radiusBlocks] [centerX centerZ] |
Kick off a new job |
/pregen stop [world] |
Stop and save progress |
/pregen pause [world] |
Pause (resume later) |
/pregen resume [world] |
Resume a paused or saved job |
/pregen status [world] |
Live progress + ETA |
/pregen reset [world] |
Wipe saved progress for a world |
Aliases: /pg, /pregenerate
Permission: pregen.use (default: op)
Full tab-completion included.
Example usage
/pregen start → current world, config radius /pregen start world 10000 → 10k-block radius around configured center /pregen start world_nether 2000 0 0 → explicit center /pregen status → see every active + saved job at once /pregen pause world → take a break, resume whenever
Configuration
Everything in config.yml is tunable to your hardware:
parallel-chunks: 8 # max concurrent async chunk loads
chunks-per-tick: 4 # max submissions per server tick
min-tps: 17.0 # pause if TPS drops below this
save-every: 200 # write progress every N chunks
auto-resume-on-start: true # pick up after restarts automatically
broadcast-interval-seconds: 30
unload-after-generate: true # keep memory usage flat
worlds:
world: { radius: 10000, center-x: 0, center-z: 0 }
world_nether: { radius: 2000, center-x: 0, center-z: 0 }
world_the_end: { radius: 2000, center-x: 0, center-z: 0 }
Performance tip: crank parallel-chunks to 16 and chunks-per-tick to 8 on beefy hardware. The TPS gate will catch you if you go too far.
Tested on
PaperMC 1.20.4
Java 17+ (Java 21 recommended)
Install in 30 seconds
Drop PreGen-1.0.0.jar into your plugins/ folder
Start the server once to generate plugins/PreGen/config.yml
Tune the radius for each world (default is 10k blocks for the overworld)
Run /pregen start
Go grab a coffee. The world will be ready when you're back.
Why this over the alternatives?
Lightweight. ~20 KB jar. Five Java files. Read it in five minutes.
No external libraries. No Adventure shading, no Kotlin runtime, no nothing. Pure Paper API.
Honest defaults. It won't kill your TPS out of the box. Promise.
Truly resumable. Cursor state (current ring + index) is persisted, not just a chunk counter. Restarts pick up at exactly the right chunk.
Support
Found a bug? Have a feature request? Open an issue on GitHub.
If PreGen saved your server, leave a like — it really helps!
Happy pre-generating!
评论 0
登录后参与评分
还没有评论,来抢沙发吧