Package net.minestom.server.instance
Class MinestomBasicChunkLoader
java.lang.Object
net.minestom.server.instance.MinestomBasicChunkLoader
- All Implemented Interfaces:
IChunkLoader
public class MinestomBasicChunkLoader extends java.lang.Object implements IChunkLoader
A
IChunkLoader
used by InstanceContainer
which is based on the StorageLocation
and ChunkSupplier
associated to it.
It simply save chunk serialized data from Chunk.getSerializedData()
and deserialize it later with Chunk.readChunk(BinaryReader, ChunkCallback)
.
The key used in the StorageLocation
is defined by getChunkKey(int, int)
and should NOT be changed.
-
Constructor Summary
Constructors Constructor Description MinestomBasicChunkLoader(InstanceContainer instanceContainer)
Creates anIChunkLoader
which use aStorageLocation
. -
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.boolean
supportsParallelLoading()
Does thisIChunkLoader
allow for multi-threaded loading ofChunk
?boolean
supportsParallelSaving()
Does thisIChunkLoader
allow for multi-threaded saving ofChunk
?
-
Constructor Details
-
MinestomBasicChunkLoader
Creates anIChunkLoader
which use aStorageLocation
.The
ChunkSupplier
is used to customize which type ofChunk
this loader should use for loading.WARNING:
Chunk
implementations do not need to have the same serializing format, be careful.- Parameters:
instanceContainer
- theInstanceContainer
linked to this loader
-
-
Method Details
-
saveChunk
Description copied from interface:IChunkLoader
Saves aChunk
with an optional callback for when it is done.- Specified by:
saveChunk
in interfaceIChunkLoader
- Parameters:
chunk
- theChunk
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.
-
loadChunk
public boolean loadChunk(@NotNull Instance instance, int chunkX, int chunkZ, @Nullable ChunkCallback callback)Description copied from interface:IChunkLoader
Loads aChunk
, all blocks should be set since theChunkGenerator
is not applied.- Specified by:
loadChunk
in interfaceIChunkLoader
- Parameters:
instance
- theInstance
where theChunk
belongchunkX
- the chunk XchunkZ
- the chunk Zcallback
- the callback executed when theChunk
is done loading, never called if the method returns false. Can be null.- Returns:
- true if the chunk loaded successfully, false otherwise
-
supportsParallelSaving
public boolean supportsParallelSaving()Description copied from interface:IChunkLoader
Does thisIChunkLoader
allow for multi-threaded saving ofChunk
?- Specified by:
supportsParallelSaving
in interfaceIChunkLoader
- Returns:
- true if the chunk loader supports parallel saving
-
supportsParallelLoading
public boolean supportsParallelLoading()Description copied from interface:IChunkLoader
Does thisIChunkLoader
allow for multi-threaded loading ofChunk
?- Specified by:
supportsParallelLoading
in interfaceIChunkLoader
- Returns:
- true if the chunk loader supports parallel loading
-