Skip to content

Chunk Loading Mechanism

Henry Lin edited this page Jan 6, 2024 · 8 revisions

This page covers some general principles of chunk loading that apply to all modes of chunk loading offered by this mod.

This page includes some technical explanations of how this mod works, but you don't need to understand those to use this mod effectively! This is mostly written with server admins/developers in mind.

Chunk Loading Foundation

A detailed explanation of Minecraft's chunk-loading system can be found on the Wiki.

All chunks force-loaded by this mod are entity-ticking, corresponding to a forced ticket with a level of 31 as explained by the article above. Internally, this is achieved via the ForgeChunkManager, which creates the load tickets and handles saving/loading from disk. This has several implications:

  • It works in all dimensions, including custom dimensions (in theory).
  • Loading chunks with this mod has the same effect as loading chunks via the /forceload command, which means chunks remain loaded even if there are no players in the dimension, and the effect persists across game restarts.
  • Force-loading the same chunk in multiple ways does not increase lag.
  • When one chunk is force-loaded, a 7x7 chunk area centered around that chunk is loaded into RAM, with chunks closer to the center having more features enabled.

Power Loader's Implementation

For reliable chunk loading, Power Loader keeps a list of currently force-loaded chunks in each chunk loader block. This ensures that no chunks are lost or left loaded forever when the game is running.

However, this list is not serialized and saved to disk because the ForgeChunkManager already handles this. When the server is restarted, Forge loads the list of force-loaded chunks from disk and hands the list to Power Loader for verification. Chunks loaded by static chunk loaders are verified instantly, and invalid entries are removed/unloaded. Chunks loaded by entities (such as contraptions, trains, and train stations) are verified later when the entity is properly loaded and ticking. If an entity had force-loaded chunks before the server restart, but no longer exists after the restart, those chunks will be unloaded after a short delay.

It is important to note that all chunk-loading logic is server-side only. The lit-up core of a chunk loader block is not a perfectly accurate representation of its status, especially if the client is desynced due to network issues or if the block is under the "unloading grace period". Check the server's debug logs for CPL: entries if you want to know what Power Loader is doing.

Clone this wiki locally