Interface ChunkLoader
- All Known Implementing Classes:
AnvilLoader
See AnvilLoader for the default implementation used in InstanceContainer.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidloadInstance(Instance instance) Loads instance data from the loader.static ChunkLoadernoop()Returns the no op chunk loadervoidSaves aChunkwith an optional callback for when it is done.default voidsaveChunks(Collection<Chunk> chunks) Saves multiple chunks with an optional callback for when it is done.default voidsaveInstance(Instance instance) default booleanSupports for instance/chunk loading in virtual threads.default booleanSupports for instance/chunk saving in virtual threads.default voidunloadChunk(Chunk chunk) Called when a chunk is unloaded, so that this chunk loader can unload any resource it is holding.
-
Method Details
-
noop
Returns the no op chunk loader- Returns:
- the no op loader.
-
loadInstance
Loads instance data from the loader.- Parameters:
instance- the instance to retrieve the data from
-
loadChunk
Loads aChunk, all blocks should be set since theGeneratoris not applied.Implementations must not initiate another chunk load on the same
Instancefrom this method. Doing so re-enters the instance's loading registry and may fail with anIllegalStateException. If loading a chunk requires data associated with neighboring chunks, read that data directly from the backing storage instead of callingInstance.loadChunk(int, int)orInstance.loadOptionalChunk(int, int).A loader must never wait for the same chunk it is currently loading. Requests for an in-progress chunk share the existing future, so waiting for that future from this method would wait for the current invocation.
-
saveInstance
-
saveChunk
-
saveChunks
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 save
-
supportsParallelSaving
default boolean supportsParallelSaving()Supports for instance/chunk saving in virtual threads.- Returns:
- true if the chunk loader supports parallel saving
-
supportsParallelLoading
default boolean supportsParallelLoading()Supports for instance/chunk loading in virtual threads.When true, chunks may load in parallel on virtual threads. When false,
loadChunk(Instance, int, int)runs synchronously on the thread requesting the load. The re-entrant loading restrictions documented onloadChunk(Instance, int, int)apply in either case.- Returns:
- true if the chunk loader supports parallel loading
-
unloadChunk
Called when a chunk is unloaded, so that this chunk loader can unload any resource it is holding. Note: Minestom currently has no way to determine whether the chunk comes from this loader, so you may get unload requests for chunks not created by the loader.- Parameters:
chunk- the chunk to unload
-