Skip to content

Chunk management

Load/Save Steps

When trying to load a chunk, the instance container does multiple checks in this order:

  1. Verify if the chunk is already loaded (stop here if yes)
  2. Try to load the chunk from the instance IChunkLoader using IChunkLoader#loadChunk (stop here if the chunk loading is successful)
  3. Create a new chunk and execute the instance ChunkGenerator (if any) to it to generate all the chunk's blocks.

When trying to save a chunk, IChunkLoader#saveChunk is called.

Default behavior

AnvilLoader is the default chunk loader used by all InstanceContainer

Create your own chunk type

Chunk is an abstract class, you can simply create a new class extending it to create your own implementation.

Making your own chunk implementation allows you to customize how you want blocks to be stored, how you want chunks tick to happen, etc...

How to make my instance use my implementation

If you are using a simple InstanceContainer with the default IChunkLoader you will just need to change the instance's chunk supplier

java
instanceContainer.setChunkSupplier(YOUR_CHUNK_SUPPLIER);

It will be called when a chunk object needs to be provided.