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 Details

    • loadChunk

      boolean loadChunk​(@NotNull Instance instance, int chunkX, int chunkZ, @Nullable ChunkCallback callback)
      Loads a Chunk, all blocks should be set since the ChunkGenerator is not applied.
      Parameters:
      instance - the Instance where the Chunk belong
      chunkX - the chunk X
      chunkZ - the chunk Z
      callback - the callback executed when the Chunk is done loading, never called if the method returns false. Can be null.
      Returns:
      true if the chunk loaded successfully, false otherwise
    • saveChunk

      void saveChunk​(@NotNull Chunk chunk, @Nullable java.lang.Runnable callback)
      Saves a Chunk with an optional callback for when it is done.
      Parameters:
      chunk - the Chunk to save
      callback - the callback executed when the Chunk is done saving, should be called even if the saving failed (you can throw an exception). Can be null.
    • 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 save
      callback - the callback executed when the Chunk is done saving, should be called even if the saving failed (you can throw an exception). Can be null.
    • supportsParallelSaving

      default boolean supportsParallelSaving()
      Does this IChunkLoader allow for multi-threaded saving of Chunk?
      Returns:
      true if the chunk loader supports parallel saving
    • supportsParallelLoading

      default boolean supportsParallelLoading()
      Does this IChunkLoader allow for multi-threaded loading of Chunk?
      Returns:
      true if the chunk loader supports parallel loading