From 2537c4a25925781219567a01eb05acc592a84572 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 22 Nov 2025 08:16:30 -0600 Subject: [PATCH] Rename IBatchGeneratorEvnWrapper --- .../core/generation/BatchGenerator.java | 28 +++++++++++-------- .../wrapperInterfaces/IWrapperFactory.java | 4 +-- ...=> IBatchGeneratorEnvironmentWrapper.java} | 17 +++++------ 3 files changed, 26 insertions(+), 23 deletions(-) rename core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/{AbstractBatchGenerationEnvironmentWrapper.java => IBatchGeneratorEnvironmentWrapper.java} (76%) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/BatchGenerator.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/BatchGenerator.java index fbb6cfb17..fbff10aa3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/BatchGenerator.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/BatchGenerator.java @@ -26,11 +26,11 @@ import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.util.ExceptionUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IOverrideInjector; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory; -import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper; import com.seibel.distanthorizons.core.logging.DhLogger; import java.util.concurrent.CompletableFuture; @@ -43,10 +43,10 @@ import java.util.function.Consumer; */ public class BatchGenerator implements IDhApiWorldGenerator { - private static final IWrapperFactory FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class); + private static final IWrapperFactory WRAPPER_FACTORY = SingletonInjector.INSTANCE.get(IWrapperFactory.class); private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - public AbstractBatchGenerationEnvironmentWrapper generationEnvironment; + public IBatchGeneratorEnvironmentWrapper generationEnvironment; public IDhLevel targetDhLevel; @@ -58,7 +58,7 @@ public class BatchGenerator implements IDhApiWorldGenerator public BatchGenerator(IDhLevel targetDhLevel) { this.targetDhLevel = targetDhLevel; - this.generationEnvironment = FACTORY.createBatchGenerator(targetDhLevel); + this.generationEnvironment = WRAPPER_FACTORY.createBatchGenerator(targetDhLevel); LOGGER.info("Batch Chunk Generator initialized"); } @@ -84,15 +84,19 @@ public class BatchGenerator implements IDhApiWorldGenerator - //===================// // generator methods // //===================// @Override public CompletableFuture generateChunks( - int chunkPosMinX, int chunkPosMinZ, int generationRequestChunkWidthCount, byte targetDataDetail, EDhApiDistantGeneratorMode generatorMode, - ExecutorService worldGeneratorThreadPool, Consumer resultConsumer) + int chunkPosMinX, + int chunkPosMinZ, + int generationRequestChunkWidthCount, + byte targetDataDetail, + EDhApiDistantGeneratorMode generatorMode, + ExecutorService worldGeneratorThreadPool, + Consumer resultConsumer) { EDhApiWorldGenerationStep targetStep = null; switch (generatorMode) @@ -105,7 +109,7 @@ public class BatchGenerator implements IDhApiWorldGenerator // targetStep = EDhApiWorldGenerationStep.NOISE; // Stone only. Requires a fake surface // break; case SURFACE: - targetStep = EDhApiWorldGenerationStep.SURFACE; + targetStep = EDhApiWorldGenerationStep.SURFACE; // TODO could we ignore adjacent chunks for a speedup? break; case FEATURES: targetStep = EDhApiWorldGenerationStep.FEATURES; @@ -128,8 +132,9 @@ public class BatchGenerator implements IDhApiWorldGenerator { if (!ExceptionUtil.isInterruptOrReject(e)) { - LOGGER.error("Error starting future for chunk generation", e); + LOGGER.error("Error starting future for chunk generation, error: ["+e.getMessage()+"].", e); } + CompletableFuture future = new CompletableFuture<>(); future.completeExceptionally(e); return future; @@ -148,9 +153,10 @@ public class BatchGenerator implements IDhApiWorldGenerator @Override public void close() { - LOGGER.info(BatchGenerator.class.getSimpleName() + " shutting down..."); - this.generationEnvironment.stop(); + LOGGER.info("["+BatchGenerator.class.getSimpleName()+"] shutting down..."); + this.generationEnvironment.close(); } + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java index 3f7f1cd52..2d31eefc6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/IWrapperFactory.java @@ -25,7 +25,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; -import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper; import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable; import java.io.IOException; @@ -39,7 +39,7 @@ import java.util.HashSet; */ public interface IWrapperFactory extends IDhApiWrapperFactory, IBindable { - AbstractBatchGenerationEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel); + IBatchGeneratorEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel); IBiomeWrapper deserializeBiomeWrapper(String str, ILevelWrapper levelWrapper) throws IOException; IBiomeWrapper getPlainsBiomeWrapper(ILevelWrapper levelWrapper); // TODO it would be nice to remove the level wrapper if possible to put this in line with getAirBlockStateWrapper() but it isn't necessary diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/AbstractBatchGenerationEnvironmentWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/IBatchGeneratorEnvironmentWrapper.java similarity index 76% rename from core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/AbstractBatchGenerationEnvironmentWrapper.java rename to core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/IBatchGeneratorEnvironmentWrapper.java index 84fbae18f..74bcbe684 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/AbstractBatchGenerationEnvironmentWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/worldGeneration/IBatchGeneratorEnvironmentWrapper.java @@ -28,18 +28,15 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.function.Consumer; -public abstract class AbstractBatchGenerationEnvironmentWrapper +public interface IBatchGeneratorEnvironmentWrapper extends AutoCloseable { - public AbstractBatchGenerationEnvironmentWrapper(IDhLevel level) { } + void updateAllFutures(); - public abstract void updateAllFutures(); - - public abstract int getEventCount(); - - public abstract void stop(); - - public abstract CompletableFuture generateChunks( - int minX, int minZ, int genSize, EDhApiDistantGeneratorMode generatorMode, EDhApiWorldGenerationStep targetStep, + CompletableFuture generateChunks( + int minX, int minZ, int genSize, + EDhApiDistantGeneratorMode generatorMode, EDhApiWorldGenerationStep targetStep, ExecutorService worldGeneratorThreadPool, Consumer resultConsumer); + void close(); + }