PGChunk (Pre-generate Chunk)
Pregenerate chunks at world creation and predictively load them ahead of players to eliminate chunk-generation lag in multiplayer.
Why?
Does the game stutter whenever players explore new land? That's usually not your graphics. It's the game building new terrain for several players at once.
PGChunk builds the world before you need it, so exploring stays smooth.
What it does
- Build the world in advance When creating a world, choose how far out you want it ready. The mod builds that area for you, even while you're already playing.
- Stays one step ahead It notices which way each player is heading and prepares the land in front of them.
- Faster loading on servers With the mod on your game too, the server sends you nearby land before you get there.
- Quick return to places you've been Places you visit often, like your base, are kept ready in memory so they load instantly.
- Optional world border Puts a border at the edge of the prepared area, so the game never has to build brand new land mid-session.
How to use
- Install PGChunk with Fabric API and Fabric Language Kotlin.
- Create a new world and open the More tab.
- Set the Initial generation radius and click Create.
- A short loading screen appears, then you can start playing. A boss bar shows the rest of the progress.
Playing on a server? Install it on the server. Installing it on each player's game as well makes loading even smoother, but players without it can still join.
Details
Initial Pregeneration
- Adds "Initial generation radius (chunks)" and "Set world border to radius" options to the More tab of the Create World screen.
- Dedicated servers can set them in
config/pgchunk.json(initialRadiusChunks,autoWorldBorder). - Chunks are generated in a spiral from spawn. The first 5% (
blockingPercent) is generated on the loading screen, and the rest is generated in the background while you play. - A boss bar shows background progress, with completed / total chunks, percentage and time remaining.
- Background generation slows down automatically when the server is under load (
throttleMspt, 45 ms by default). - Progress is saved, so generation resumes after a server restart.
- While pregeneration is still running, the server's pause-when-empty setting is turned off so generation doesn't stop.
Predictive Generation (Rolling Buffer)
- Ungenerated chunks ahead of each player's direction of travel are generated in advance, based on their speed and heading.
- When a player is standing still or changing direction often, a ring of chunks just outside their view distance is generated instead.
- Per-player limits stop one player from taking the whole generation queue.
Chunk Prefetch (server → client, requires the mod on the client)
- Chunks the player is moving toward are sent to clients that have the mod before they come into view.
- When a prefetched chunk comes into view unchanged, the server sends a short confirmation instead of the full chunk packet, which saves bandwidth.
- If a block changes after a chunk was prefetched, the server invalidates the client's copy so it never shows outdated data.
- Limits on bandwidth (
prefetchMaxKBps), chunks per tick and client memory (prefetchClientBudgetMB).
Cold Chunk Cache
- Unloaded chunks are kept compressed in memory and read from there instead of from disk when they load again.
- Disk writes always happen first (write-through), so the cache never holds newer data than the disk.
- Chunks are scored by distance, how recently they were visited and how often. When the memory budget (
coldBudgetMB, 128 MB by default) is exceeded, the lowest-scoring chunks are removed first.
Commands
/pgchunk status(operators only): shows Cold cache hit rate and memory use, prefetch statistics and pregeneration progress.
Security
- Prefetch is limited to the server's
view-distanceby default, so clients can't receive chunk contents beyond the view distance (useful against base scouting and X-ray). SetprefetchBeyondViewChunksabove 0 to allow more.
Notes
- This is a pre-release. Back up your worlds before using it.
- Requires Java 25, Fabric Loader 0.20.1+, Fabric API and Fabric Language Kotlin.
- Prefetch is turned off in singleplayer by default, because the vanilla chunk transfer there is already instant.
- Changes to the Cold cache settings take effect after a server restart.