All Superinterfaces:
AutoCloseable, Closeable, IBindable, IDhApiOverrideable
All Known Implementing Classes:
AbstractDhApiChunkWorldGenerator

public interface IDhApiWorldGenerator extends Closeable, IDhApiOverrideable
Since:
API 1.0.0
  • Method Details

    • getSmallestDataDetailLevel

      default byte getSmallestDataDetailLevel()
      Defines the smallest datapoint size that can be generated at a time.
      Minimum detail level is 0 (1 block)
      Default detail level is 0
      For more information on what detail levels represent see: EDhApiDetailLevel.

      TODO: System currently only supports 1x1 block per data.
      Since:
      API 1.0.0
      See Also:
    • getLargestDataDetailLevel

      default byte getLargestDataDetailLevel()
      Defines the largest datapoint size that can be generated at a time.
      Minimum detail level is 0 (1 block)
      Default detail level is 0
      For more information on what detail levels represent see: EDhApiDetailLevel.
      Since:
      API 1.0.0
      See Also:
    • getMinGenerationGranularity

      default byte getMinGenerationGranularity()
      When creating generation requests the system will attempt to group nearby tasks together.

      What is the minimum size a single generation call can batch together?
      Minimum detail level is 4 (the size of a MC chunk)
      Default detail level is 4
      For more information on what detail levels represent see: EDhApiDetailLevel.
      Since:
      API 1.0.0
      See Also:
    • getMaxGenerationGranularity

      default byte getMaxGenerationGranularity()
      When creating generation requests the system will attempt to group nearby tasks together.

      What is the maximum size a single generation call can batch together?
      Minimum detail level is 4 (the size of a MC chunk)
      Default detail level is 6 (4x4 chunks)
      For more information on what detail levels represent see: EDhApiDetailLevel.
      Since:
      API 1.0.0
      See Also:
    • isBusy

      boolean isBusy()
      Returns:
      true if the generator is unable to accept new generation requests.
      Since:
      API 1.0.0
    • generateChunks

      default CompletableFuture<Void> generateChunks(int chunkPosMinX, int chunkPosMinZ, byte granularity, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode, ExecutorService worldGeneratorThreadPool, Consumer<Object[]> resultConsumer)
      This method is called by Distant Horizons to generate terrain over a given area when getReturnType() returns EDhApiWorldGeneratorReturnType.VANILLA_CHUNKS.

      After a chunk has been generated it (and any necessary supporting objects as listed below) should be passed into the resultConsumer's Consumer.accept(T) method. If the Consumer is given the wrong data type(s) it will disable the world generator and log an error with a list of objects it was expecting.
      Note: these objects are minecraft version dependent and will change without notice! Please run your generator in game at least once to confirm the objects you are returning are correct.

      Consumer expected inputs for each minecraft version (in order):
      1.16, 1.17, 1.18, 1.19, 1.20:
      - [net.minecraft.world.level.chunk.ChunkAccess]
      - [net.minecraft.world.level.ServerLevel] or [net.minecraft.world.level.ClientLevel]
      Parameters:
      chunkPosMinX - the chunk X position closest to negative infinity
      chunkPosMinZ - the chunk Z position closest to negative infinity
      granularity - TODO find a central location to store the definition of granularity. For now it is stored in the Core method: WorldGenerationQueue#startGenerationEvent
      targetDataDetail - the LOD Detail level requested to generate. See EDhApiDetailLevel for additional information.
      generatorMode - how far into the world gen pipeline this method run. See EDhApiDistantGeneratorMode for additional documentation.
      worldGeneratorThreadPool - the thread pool that should be used when generating the returned CompletableFuture.
      resultConsumer - the consumer that should be fired whenever a chunk finishes generating.
      Returns:
      a future that should run on the worldGeneratorThreadPool and complete once the given generation task has completed.
      Since:
      API 1.0.0
      Implementation Note:
      the default implementation of this method throws an UnsupportedOperationException, and must be overridden when getReturnType() returns EDhApiWorldGeneratorReturnType.VANILLA_CHUNKS. since getReturnType() returns EDhApiWorldGeneratorReturnType.VANILLA_CHUNKS by default, this method must also be overridden when getReturnType() is NOT overridden.
    • generateApiChunks

      default CompletableFuture<Void> generateApiChunks(int chunkPosMinX, int chunkPosMinZ, byte granularity, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode, ExecutorService worldGeneratorThreadPool, Consumer<DhApiChunk> resultConsumer)
      This method is called by Distant Horizons to generate terrain over a given area when getReturnType() returns EDhApiWorldGeneratorReturnType.API_CHUNKS.

      After the DhApiChunk has been generated, it should be passed into the resultConsumer's Consumer.accept(Object) method.
      Parameters:
      chunkPosMinX - the chunk X position closest to negative infinity
      chunkPosMinZ - the chunk Z position closest to negative infinity
      granularity - TODO find a central location to store the definition of granularity. For now it is stored in the Core method: WorldGenerationQueue#startGenerationEvent
      targetDataDetail - the LOD Detail level requested to generate. See EDhApiDetailLevel for additional information.
      generatorMode - how far into the world gen pipeline this method run. See EDhApiDistantGeneratorMode for additional documentation.
      worldGeneratorThreadPool - the thread pool that should be used when generating the returned CompletableFuture.
      resultConsumer - the consumer that should be fired whenever a chunk finishes generating.
      Returns:
      a future that should run on the worldGeneratorThreadPool and complete once the given generation task has completed.
      Since:
      API 2.0.0
      Implementation Note:
      the default implementation of this method throws an UnsupportedOperationException, and must be overridden when getReturnType() returns EDhApiWorldGeneratorReturnType.API_CHUNKS.
    • getReturnType

      default EDhApiWorldGeneratorReturnType getReturnType()
      This method controls how Distant Horizons requests generated chunks. By default, the return value is EDhApiWorldGeneratorReturnType.VANILLA_CHUNKS, which means that generateChunks(int, int, byte, byte, EDhApiDistantGeneratorMode, ExecutorService, Consumer) will be invoked whenever Distant Horizons wants to generate terrain with this world generator.
      Since:
      API 2.0.0
    • preGeneratorTaskStart

      void preGeneratorTaskStart()
      Called before a new generator task is started.
      This can be used to run cleanup on existing tasks before new tasks are started.
      Since:
      API 1.0.0
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable