Package net.minestom.server.instance
Interface IChunkLoader
- All Known Implementing Classes:
MinestomBasicChunkLoader
public interface IChunkLoader
Interface implemented to change the way chunks are loaded/saved.
See MinestomBasicChunkLoader
for the default implementation used in InstanceContainer
.
-
Method Summary
Modifier and Type Method Description boolean
loadChunk(Instance instance, int chunkX, int chunkZ, ChunkCallback callback)
Loads aChunk
, all blocks should be set since theChunkGenerator
is not applied.void
saveChunk(Chunk chunk, java.lang.Runnable callback)
Saves aChunk
with an optional callback for when it is done.default void
saveChunks(java.util.Collection<Chunk> chunks, java.lang.Runnable callback)
Saves multiple chunks with an optional callback for when it is done.default boolean
supportsParallelLoading()
Does thisIChunkLoader
allow for multi-threaded loading ofChunk
?default boolean
supportsParallelSaving()
Does thisIChunkLoader
allow for multi-threaded saving ofChunk
?
-
Method Details
-
loadChunk
boolean loadChunk(@NotNull Instance instance, int chunkX, int chunkZ, @Nullable ChunkCallback callback)Loads aChunk
, all blocks should be set since theChunkGenerator
is not applied. -
saveChunk
Saves aChunk
with an optional callback for when it is done. -
saveChunks
default void saveChunks(@NotNull java.util.Collection<Chunk> chunks, @Nullable java.lang.Runnable callback)Saves multiple chunks with an optional callback for when it is done.Implementations need to check
supportsParallelSaving()
to support the feature if possible.- Parameters:
chunks
- the chunks to savecallback
- the callback executed when theChunk
is done saving, should be called even if the saving failed (you can throw an exception). Can be null.
-
supportsParallelSaving
default boolean supportsParallelSaving()Does thisIChunkLoader
allow for multi-threaded saving ofChunk
?- Returns:
- true if the chunk loader supports parallel saving
-
supportsParallelLoading
default boolean supportsParallelLoading()Does thisIChunkLoader
allow for multi-threaded loading ofChunk
?- Returns:
- true if the chunk loader supports parallel loading
-