Start world gen refactoring
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ public class DependencySetup
|
||||
SingletonInjector.INSTANCE.bind(IVersionConstants.class, VersionConstants.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IWrapperFactory.class, WrapperFactory.INSTANCE);
|
||||
SingletonInjector.INSTANCE.bind(IKeyedClientLevelManager.class, KeyedClientLevelManager.INSTANCE);
|
||||
DependencySetupDoneCheck.isDone = true;
|
||||
WorldGenThreadCheck.isSetup = true;
|
||||
}
|
||||
|
||||
public static void createServerBindings()
|
||||
|
||||
+7
-4
@@ -19,18 +19,21 @@
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DependencySetupDoneCheck
|
||||
public class WorldGenThreadCheck
|
||||
{
|
||||
// TODO move to DependencySetup
|
||||
public static boolean isDone = false;
|
||||
public static boolean isSetup = false;
|
||||
|
||||
/**
|
||||
* This is used so we can override some MC logic when running
|
||||
* in DH's world generator.
|
||||
* Specifically so we can redirect threads to run on DH threads instead
|
||||
* of MC threads.
|
||||
*/
|
||||
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> { return false; });
|
||||
//public static Supplier<Boolean> isCurrentThreadDhWorldGenThread = (() -> { return false; });
|
||||
public static Supplier<Boolean> isCurrentThreadDhWorldGenThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread; // TODO can we just do this?
|
||||
|
||||
}
|
||||
@@ -38,7 +38,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 net.minecraft.client.multiplayer.ClientLevel;
|
||||
#if MC_VER > MC_1_17_1
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -67,7 +67,7 @@ public class WrapperFactory implements IWrapperFactory
|
||||
//==============//
|
||||
|
||||
@Override
|
||||
public AbstractBatchGenerationEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel)
|
||||
public IBatchGeneratorEnvironmentWrapper createBatchGenerator(IDhLevel targetLevel)
|
||||
{
|
||||
if (targetLevel instanceof IDhServerLevel)
|
||||
{
|
||||
|
||||
+87
-86
@@ -36,11 +36,12 @@ import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.EventTimer;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import com.seibel.distanthorizons.core.util.objects.RollingAverage;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.ChunkLightStorage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.IBatchGeneratorEnvironmentWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -57,7 +58,7 @@ import java.util.stream.StreamSupport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepBiomes;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepFeatures;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.step.StepNoise;
|
||||
@@ -93,30 +94,18 @@ import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
#endif
|
||||
|
||||
/*
|
||||
Total: 3.135214124s
|
||||
=====================================
|
||||
Empty Chunks: 0.000558328s
|
||||
StructureStart Step: 0.025177207s
|
||||
StructureReference Step: 0.00189559s
|
||||
Biome Step: 0.13789155s
|
||||
Noise Step: 1.570347555s
|
||||
Surface Step: 0.741238194s
|
||||
Carver Step: 0.000009923s
|
||||
Feature Step: 0.389072425s
|
||||
Lod Generation: 0.269023348s
|
||||
*/
|
||||
public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnvironmentWrapper
|
||||
public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironmentWrapper
|
||||
{
|
||||
public static final DhLogger LOGGER = new DhLoggerBuilder()
|
||||
.name("LOD World Gen")
|
||||
.fileLevelConfig(Config.Common.Logging.logWorldGenEventToFile)
|
||||
.build();
|
||||
|
||||
public static final DhLogger PREF_LOGGER = new DhLoggerBuilder()
|
||||
.name("LOD World Gen")
|
||||
.fileLevelConfig(Config.Common.Logging.logWorldGenPerformanceToFile)
|
||||
.maxCountPerSecond(1)
|
||||
.build();
|
||||
public static final DhLogger EVENT_LOGGER = new DhLoggerBuilder()
|
||||
.name("LOD World Gen")
|
||||
.fileLevelConfig(Config.Common.Logging.logWorldGenEventToFile)
|
||||
.build();
|
||||
public static final DhLogger CHUNK_LOAD_LOGGER = new DhLoggerBuilder()
|
||||
.name("LOD World Gen")
|
||||
.fileLevelConfig(Config.Common.Logging.logWorldGenChunkLoadEventToFile)
|
||||
@@ -132,6 +121,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
private static final IModChecker MOD_CHECKER = SingletonInjector.INSTANCE.get(IModChecker.class);
|
||||
|
||||
@NotNull
|
||||
public static final ImmutableMap<EDhApiWorldGenerationStep, Integer> WORLD_GEN_CHUNK_BORDER_NEEDED_BY_GEN_STEP;
|
||||
public static final int MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
||||
|
||||
|
||||
private final IDhServerLevel serverLevel;
|
||||
|
||||
@@ -147,7 +140,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
//=================Generation Step===================
|
||||
|
||||
public final LinkedBlockingQueue<GenerationEvent> generationEventList = new LinkedBlockingQueue<>();
|
||||
public final GlobalParameters params;
|
||||
public final GlobalWorldGenParams params;
|
||||
public final StepStructureStart stepStructureStart = new StepStructureStart(this);
|
||||
public final StepStructureReference stepStructureReference = new StepStructureReference(this);
|
||||
public final StepBiomes stepBiomes = new StepBiomes(this);
|
||||
@@ -176,8 +169,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
return cache;
|
||||
}
|
||||
|
||||
public static ThreadLocal<Boolean> isDistantGeneratorThread = new ThreadLocal<>();
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() { return (isDistantGeneratorThread.get() != null); }
|
||||
public static ThreadLocal<Boolean> isDhWorldGenThreadRef = new ThreadLocal<>();
|
||||
public static boolean isCurrentThreadDistantGeneratorThread() { return (isDhWorldGenThreadRef.get() != null); }
|
||||
|
||||
|
||||
|
||||
@@ -185,31 +178,27 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// constructors //
|
||||
//==============//
|
||||
|
||||
@NotNull
|
||||
public static final ImmutableMap<EDhApiWorldGenerationStep, Integer> WORLD_GEN_CHUNK_BORDER_NEEDED_BY_GEN_STEP;
|
||||
public static final int MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
||||
|
||||
static
|
||||
{
|
||||
DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
// TODO can this be handled directly?
|
||||
WorldGenThreadCheck.isCurrentThreadDhWorldGenThread = BatchGenerationEnvironment::isCurrentThreadDistantGeneratorThread;
|
||||
|
||||
boolean isTerraFirmaCraft = false;
|
||||
boolean isTerraFirmaCraftPresent = false;
|
||||
try
|
||||
{
|
||||
Class.forName("net.dries007.tfc.world.TFCChunkGenerator");
|
||||
isTerraFirmaCraft = true;
|
||||
isTerraFirmaCraftPresent = true;
|
||||
LOGGER.info("TerraFirmaCraft detected.");
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
//Ignore
|
||||
}
|
||||
EVENT_LOGGER.info("DH TerraFirmaCraft detection: " + isTerraFirmaCraft);
|
||||
catch (ClassNotFoundException ignore) { }
|
||||
|
||||
|
||||
ImmutableMap.Builder<EDhApiWorldGenerationStep, Integer> builder = ImmutableMap.builder();
|
||||
builder.put(EDhApiWorldGenerationStep.EMPTY, 1);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_START, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_REFERENCE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.BIOMES, isTerraFirmaCraft ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.NOISE, isTerraFirmaCraft ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.BIOMES, isTerraFirmaCraftPresent ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.NOISE, isTerraFirmaCraftPresent ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.SURFACE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.CARVERS, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.LIQUID_CARVERS, 0);
|
||||
@@ -227,42 +216,43 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
public BatchGenerationEnvironment(IDhServerLevel serverLevel)
|
||||
{
|
||||
super(serverLevel);
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
EVENT_LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
LOGGER.info("================WORLD_GEN_STEP_INITING=============");
|
||||
|
||||
serverLevel.getServerLevelWrapper().getDimensionType();
|
||||
|
||||
ChunkGenerator generator = ((ServerLevelWrapper) (serverLevel.getServerLevelWrapper())).getLevel().getChunkSource().getGenerator();
|
||||
if (!(generator instanceof NoiseBasedChunkGenerator ||
|
||||
generator instanceof DebugLevelSource ||
|
||||
generator instanceof FlatLevelSource))
|
||||
boolean isMcGenerator =
|
||||
generator instanceof NoiseBasedChunkGenerator
|
||||
|| generator instanceof DebugLevelSource
|
||||
|| generator instanceof FlatLevelSource;
|
||||
if (!isMcGenerator)
|
||||
{
|
||||
if (generator.getClass().toString().equals("class com.terraforged.mod.chunk.TFChunkGenerator"))
|
||||
{
|
||||
EVENT_LOGGER.info("TerraForge Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
LOGGER.info("TerraForge Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
}
|
||||
else if (generator.getClass().toString().equals("class net.dries007.tfc.world.TFCChunkGenerator"))
|
||||
{
|
||||
EVENT_LOGGER.info("TerraFirmaCraft Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
EVENT_LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
LOGGER.info("TerraFirmaCraft Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
}
|
||||
else
|
||||
{
|
||||
EVENT_LOGGER.warn("Unknown Chunk Generator detected: [" + generator.getClass() + "], Distant Generation May Fail!");
|
||||
EVENT_LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
LOGGER.warn("Unknown Chunk Generator detected: [" + generator.getClass() + "], Distant Generation May Fail!");
|
||||
LOGGER.warn("If it does crash, disable Distant Generation or set the Generation Mode to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
}
|
||||
}
|
||||
|
||||
if (MOD_CHECKER.isModLoaded("c2me"))
|
||||
{
|
||||
EVENT_LOGGER.info("C2ME detected: DH's pre-existing chunk accessing will use methods handled by C2ME.");
|
||||
LOGGER.info("C2ME detected: DH's pre-existing chunk accessing will use methods handled by C2ME.");
|
||||
this.pullExistingChunkUsingMcAsyncMethod = true;
|
||||
}
|
||||
|
||||
this.params = new GlobalParameters(serverLevel);
|
||||
this.params = new GlobalWorldGenParams(serverLevel);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +273,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// operation to be done synchronously
|
||||
if (!this.unsafeThreadingRecorded && !future.isDone())
|
||||
{
|
||||
EVENT_LOGGER.warn(
|
||||
LOGGER.warn(
|
||||
"Unsafe MultiThreading in Distant Horizons Chunk Generator. \n" +
|
||||
"This can happen if world generation is run on one of Minecraft's thread pools " +
|
||||
"instead of the thread DH provided. \n" +
|
||||
@@ -328,7 +318,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
{
|
||||
this.unknownExceptionCount++;
|
||||
this.lastExceptionTriggerTime = System.nanoTime();
|
||||
EVENT_LOGGER.error("Batching World Generator event ["+event+"] threw an exception: "+e.getMessage(), e);
|
||||
LOGGER.error("Batching World Generator event ["+event+"] threw an exception: "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +328,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
if (this.unknownExceptionCount > EXCEPTION_COUNTER_TRIGGER)
|
||||
{
|
||||
EVENT_LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
|
||||
LOGGER.error("Too many exceptions in Batching World Generator! Disabling the generator.");
|
||||
this.unknownExceptionCount = 0;
|
||||
Config.Common.WorldGenerator.enableDistantGeneration.set(false);
|
||||
}
|
||||
@@ -355,12 +345,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
/** @throws RejectedExecutionException if the given {@link Executor} is cancelled. */
|
||||
public CompletableFuture<Void> generateLodFromListAsync(GenerationEvent genEvent, Executor executor) throws RejectedExecutionException, InterruptedException
|
||||
{
|
||||
EVENT_LOGGER.debug("Lod Generate Event: " + genEvent.minPos);
|
||||
LOGGER.debug("Lod Generate Event: " + genEvent.minPos);
|
||||
|
||||
// Minecraft's generation events expect odd chunk width areas (3x3, 7x7, or 11x11),
|
||||
// but DH submits square generation events (4x4).
|
||||
// We handle this later, although that handling would need to change if the gen size ever changes.
|
||||
LodUtil.assertTrue(genEvent.size % 2 == 0, "Generation events are expected to be an evan number of chunks wide.");
|
||||
LodUtil.assertTrue(genEvent.widthInChunks % 2 == 0, "Generation events are expected to be an evan number of chunks wide.");
|
||||
|
||||
if (genEvent.generatorMode == EDhApiDistantGeneratorMode.INTERNAL_SERVER)
|
||||
{
|
||||
@@ -369,7 +359,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
int borderSize = MAX_WORLD_GEN_CHUNK_BORDER_NEEDED;
|
||||
// genEvent.size - 1 converts the even width size to an odd number for MC compatability
|
||||
int refSize = (genEvent.size - 1) + (borderSize * 2);
|
||||
int refSize = (genEvent.widthInChunks - 1) + (borderSize * 2);
|
||||
int refPosX = genEvent.minPos.getX() - borderSize;
|
||||
int refPosZ = genEvent.minPos.getZ() - borderSize;
|
||||
|
||||
@@ -391,7 +381,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// futures to handle getting empty chunks
|
||||
CompletableFuture<?>[] readFutures =
|
||||
// the extra radius of 8 is to account for structure references which need a chunk radius of 8
|
||||
getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.size, 8)
|
||||
getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 8)
|
||||
.map((chunkPos) -> this.createEmptyOrPreExistingChunkAsync(chunkPos.x, chunkPos.z, chunkSkyLightingByDhPos, chunkBlockLightingByDhPos, generatedChunkByDhPos))
|
||||
.toArray(CompletableFuture[]::new);
|
||||
|
||||
@@ -523,7 +513,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// submit generated chunks //
|
||||
//=========================//
|
||||
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.size, 0).iterator();
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0).iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ChunkPos pos = iterator.next();
|
||||
@@ -546,12 +536,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
boolean isShutdownException = ExceptionUtil.isShutdownException(e);
|
||||
if (!isShutdownException)
|
||||
{
|
||||
EVENT_LOGGER.error("Completion error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
||||
LOGGER.error("Completion error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
EVENT_LOGGER.error("Unexpected error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
||||
LOGGER.error("Unexpected error during world gen for min chunk pos ["+genEvent.minPos+"], error: ["+e.getMessage()+"].", e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
@@ -652,7 +642,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// this shouldn't happen, if anything is null it should be
|
||||
// ioWorker.storage
|
||||
// but just in case
|
||||
EVENT_LOGGER.error("Unexpected issue pulling pre-existing chunk ["+chunkPos+"], falling back to async chunk pulling. This may cause server-tick lag.", e);
|
||||
LOGGER.error("Unexpected issue pulling pre-existing chunk ["+chunkPos+"], falling back to async chunk pulling. This may cause server-tick lag.", e);
|
||||
this.pullExistingChunkUsingMcAsyncMethod = true;
|
||||
|
||||
// try again now using the async method
|
||||
@@ -665,7 +655,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (!this.pullExistingChunkUsingMcAsyncMethod)
|
||||
{
|
||||
// this shouldn't happen, but just in case
|
||||
EVENT_LOGGER.info("Unable to pull pre-existing chunk using synchronous method. Falling back to async method. this may cause server-tick lag.");
|
||||
LOGGER.info("Unable to pull pre-existing chunk using synchronous method. Falling back to async method. this may cause server-tick lag.");
|
||||
this.pullExistingChunkUsingMcAsyncMethod = true;
|
||||
}
|
||||
|
||||
@@ -798,7 +788,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
// request each chunk pos from the server
|
||||
CompletableFuture<?>[] requestFutures =
|
||||
getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.size, 0)
|
||||
getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0)
|
||||
.map(chunkPos ->
|
||||
{
|
||||
return requestChunkFromServerAsync(this.params.level, chunkPos, true)
|
||||
@@ -859,7 +849,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
// cleanup
|
||||
// release the generated chunks
|
||||
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.size, 0).iterator();
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0).iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ChunkPos chunkPos = iterator.next();
|
||||
@@ -896,7 +886,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
// interrupted, release chunk to server
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.size, 0).iterator();
|
||||
Iterator<ChunkPos> iterator = getChunkPosToGenerateStream(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0).iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ChunkPos chunkPos = iterator.next();
|
||||
@@ -978,7 +968,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
EVENT_LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e);
|
||||
LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1124,14 +1114,11 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
|
||||
|
||||
@Override
|
||||
public int getEventCount() { return this.generationEventList.size(); }
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
public void close()
|
||||
{
|
||||
EVENT_LOGGER.info(BatchGenerationEnvironment.class.getSimpleName() + " shutting down...");
|
||||
LOGGER.info(BatchGenerationEnvironment.class.getSimpleName() + " shutting down...");
|
||||
|
||||
EVENT_LOGGER.info("Canceling in progress generation event futures...");
|
||||
LOGGER.info("Canceling in progress generation event futures...");
|
||||
Iterator<GenerationEvent> iter = this.generationEventList.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1151,11 +1138,11 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
catch (ClosedChannelException ignore) { /* world generator is being shut down */ }
|
||||
catch (IOException e)
|
||||
{
|
||||
EVENT_LOGGER.error("Failed to close region file storage cache, error: ["+e.getMessage()+"].", e);
|
||||
LOGGER.error("Failed to close region file storage cache, error: ["+e.getMessage()+"].", e);
|
||||
}
|
||||
}
|
||||
|
||||
EVENT_LOGGER.info(BatchGenerationEnvironment.class.getSimpleName() + " shutdown complete.");
|
||||
LOGGER.info(BatchGenerationEnvironment.class.getSimpleName() + " shutdown complete.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1290,14 +1277,20 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
//"lodCreation" (No longer used)
|
||||
};
|
||||
|
||||
public static final int SIZE = 50;
|
||||
ArrayList<Rolling> times = new ArrayList<>();
|
||||
public static final int ROLLING_AVG_SIZE = 50;
|
||||
ArrayList<RollingAverage> rollingAverageList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public PerfCalculator()
|
||||
{
|
||||
for (int i = 0; i < 11; i++)
|
||||
for (int i = 0; i < TIME_NAMES.length; i++)
|
||||
{
|
||||
times.add(new Rolling(SIZE));
|
||||
this.rollingAverageList.add(new RollingAverage(ROLLING_AVG_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1307,21 +1300,29 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
{
|
||||
String name = e.name;
|
||||
int index = Arrays.asList(TIME_NAMES).indexOf(name);
|
||||
if (index == -1) continue;
|
||||
times.get(index).add(e.timeNs);
|
||||
if (index == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
this.rollingAverageList.get(index).add(e.timeNs);
|
||||
}
|
||||
times.get(0).add(event.getTotalTimeNs());
|
||||
this.rollingAverageList.get(0).add(event.getTotalTimeNs());
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < times.size(); i++)
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < this.rollingAverageList.size(); i++)
|
||||
{
|
||||
if (times.get(i).getAverage() == 0) continue;
|
||||
sb.append(TIME_NAMES[i]).append(": ").append(times.get(i).getAverage()).append("\n");
|
||||
if (this.rollingAverageList.get(i).getAverage() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.append(TIME_NAMES[i]).append(": ").append(this.rollingAverageList.get(i).getAverageRoundedString()).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-13
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -34,18 +33,19 @@ import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class GenerationEvent
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();;
|
||||
private static int generationFutureDebugIDs = 0;
|
||||
|
||||
private static int generationFutureDebugIDs = 0; // TODO make atomic int?
|
||||
|
||||
|
||||
public final int id;
|
||||
public final ThreadedParameters threadedParam;
|
||||
public final ThreadWorldGenParams threadedParam;
|
||||
public final DhChunkPos minPos;
|
||||
/** the number of chunks wide this event is */
|
||||
public final int size;
|
||||
public final int widthInChunks;
|
||||
public final EDhApiWorldGenerationStep targetGenerationStep;
|
||||
public final EDhApiDistantGeneratorMode generatorMode;
|
||||
public EventTimer timer = null;
|
||||
@@ -56,17 +56,21 @@ public final class GenerationEvent
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public GenerationEvent(
|
||||
DhChunkPos minPos, int size, BatchGenerationEnvironment generationGroup,
|
||||
DhChunkPos minPos, int widthInChunks, BatchGenerationEnvironment generationGroup,
|
||||
EDhApiDistantGeneratorMode generatorMode, EDhApiWorldGenerationStep targetGenerationStep, Consumer<IChunkWrapper> resultConsumer)
|
||||
{
|
||||
this.inQueueTime = System.nanoTime();
|
||||
this.id = generationFutureDebugIDs++;
|
||||
this.minPos = minPos;
|
||||
this.size = size;
|
||||
this.widthInChunks = widthInChunks;
|
||||
this.generatorMode = generatorMode;
|
||||
this.targetGenerationStep = targetGenerationStep;
|
||||
this.threadedParam = ThreadedParameters.getOrMake(generationGroup.params);
|
||||
this.threadedParam = ThreadWorldGenParams.getOrMake(generationGroup.params);
|
||||
this.resultConsumer = resultConsumer;
|
||||
}
|
||||
|
||||
@@ -90,17 +94,18 @@ public final class GenerationEvent
|
||||
generationEvent.inQueueTime = runStartTime - generationEvent.inQueueTime;
|
||||
generationEvent.timer = new EventTimer("setup");
|
||||
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
BatchGenerationEnvironment.isDhWorldGenThreadRef.set(true);
|
||||
|
||||
|
||||
genEnvironment.generateLodFromListAsync(generationEvent, (runnable) ->
|
||||
{
|
||||
worldGeneratorThreadPool.execute(() ->
|
||||
{
|
||||
// TODO why not just always set this each time?
|
||||
boolean alreadyMarked = BatchGenerationEnvironment.isCurrentThreadDistantGeneratorThread();
|
||||
if (!alreadyMarked)
|
||||
{
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(true);
|
||||
BatchGenerationEnvironment.isDhWorldGenThreadRef.set(true);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -115,7 +120,7 @@ public final class GenerationEvent
|
||||
{
|
||||
if (!alreadyMarked)
|
||||
{
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.set(false);
|
||||
BatchGenerationEnvironment.isDhWorldGenThreadRef.set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -129,7 +134,7 @@ public final class GenerationEvent
|
||||
}
|
||||
finally
|
||||
{
|
||||
BatchGenerationEnvironment.isDistantGeneratorThread.remove();
|
||||
BatchGenerationEnvironment.isDhWorldGenThreadRef.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -194,6 +199,6 @@ public final class GenerationEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return this.id + ":" + this.size + "@" + this.minPos + "(" + this.targetGenerationStep + ")"; }
|
||||
public String toString() { return this.id + ":" + this.widthInChunks + "@" + this.minPos + "(" + this.targetGenerationStep + ")"; }
|
||||
|
||||
}
|
||||
+13
-7
@@ -27,14 +27,12 @@ import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ThreadedLevelLightEngine;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
#if MC_VER >= MC_1_18_2
|
||||
import net.minecraft.world.level.chunk.storage.ChunkScanAccess;
|
||||
#endif
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
#if MC_VER < MC_1_19_2
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
#else
|
||||
@@ -47,7 +45,7 @@ import net.minecraft.core.registries.Registries;
|
||||
#endif
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
|
||||
public final class GlobalParameters
|
||||
public final class GlobalWorldGenParams
|
||||
{
|
||||
public final ChunkGenerator generator;
|
||||
public final IDhServerLevel lodLevel;
|
||||
@@ -55,7 +53,7 @@ public final class GlobalParameters
|
||||
public final Registry<Biome> biomes;
|
||||
public final RegistryAccess registry;
|
||||
public final long worldSeed;
|
||||
public final DataFixer fixerUpper;
|
||||
public final DataFixer dataFixer;
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
public final StructureManager structures;
|
||||
@@ -72,10 +70,16 @@ public final class GlobalParameters
|
||||
|
||||
#if MC_VER >= MC_1_18_2
|
||||
public final BiomeManager biomeManager;
|
||||
public final ChunkScanAccess chunkScanner; // FIXME: Figure out if this is actually needed
|
||||
public final ChunkScanAccess chunkScanner;
|
||||
#endif
|
||||
|
||||
public GlobalParameters(IDhServerLevel lodLevel)
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public GlobalWorldGenParams(IDhServerLevel lodLevel)
|
||||
{
|
||||
this.lodLevel = lodLevel;
|
||||
|
||||
@@ -102,9 +106,11 @@ public final class GlobalParameters
|
||||
this.biomeManager = new BiomeManager(this.level, BiomeManager.obfuscateSeed(this.worldSeed));
|
||||
this.chunkScanner = this.level.getChunkSource().chunkScanner();
|
||||
#endif
|
||||
|
||||
this.structures = server.getStructureManager();
|
||||
this.generator = this.level.getChunkSource().getGenerator();
|
||||
this.fixerUpper = server.getFixerUpper();
|
||||
this.dataFixer = server.getFixerUpper();
|
||||
|
||||
#if MC_VER >= MC_1_19_2
|
||||
this.randomState = this.level.getChunkSource().randomState();
|
||||
#endif
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Distant Horizons mod
|
||||
* licensed under the GNU LGPL v3 License.
|
||||
*
|
||||
* Copyright (C) 2020 James Seibel
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration;
|
||||
|
||||
//FIXME: Move this outside the WorldGenerationStep thingy
|
||||
public class Rolling
|
||||
{
|
||||
|
||||
private final int size;
|
||||
private double total = 0d;
|
||||
private int index = 0;
|
||||
private final double[] samples;
|
||||
|
||||
public Rolling(int size)
|
||||
{
|
||||
this.size = size;
|
||||
samples = new double[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
samples[i] = 0d;
|
||||
}
|
||||
}
|
||||
|
||||
public void add(double x)
|
||||
{
|
||||
total -= samples[index];
|
||||
samples[index] = x;
|
||||
total += x;
|
||||
if (++index == size)
|
||||
index = 0; // cheaper than modulus
|
||||
}
|
||||
|
||||
public double getAverage()
|
||||
{
|
||||
return size == 0 ? 0 : total / size;
|
||||
}
|
||||
|
||||
}
|
||||
+23
-18
@@ -29,9 +29,10 @@ import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureCheck;
|
||||
#endif
|
||||
|
||||
public final class ThreadedParameters
|
||||
public final class ThreadWorldGenParams
|
||||
{
|
||||
private static final ThreadLocal<ThreadedParameters> LOCAL_PARAM = new ThreadLocal<>();
|
||||
private static final ThreadLocal<ThreadWorldGenParams> LOCAL_PARAM = new ThreadLocal<>();
|
||||
|
||||
|
||||
final ServerLevel level;
|
||||
public WorldGenStructFeatManager structFeat = null;
|
||||
@@ -41,26 +42,32 @@ public final class ThreadedParameters
|
||||
boolean isValid = true;
|
||||
public final PerfCalculator perf = new PerfCalculator();
|
||||
|
||||
private static GlobalParameters previousGlobalParameters = null;
|
||||
private static GlobalWorldGenParams previousGlobalWorldGenParams = null;
|
||||
|
||||
|
||||
|
||||
public static ThreadedParameters getOrMake(GlobalParameters param)
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public static ThreadWorldGenParams getOrMake(GlobalWorldGenParams globalParams)
|
||||
{
|
||||
ThreadedParameters tParam = LOCAL_PARAM.get();
|
||||
if (tParam != null && tParam.isValid && tParam.level == param.level)
|
||||
ThreadWorldGenParams threadParam = LOCAL_PARAM.get();
|
||||
if (threadParam != null
|
||||
&& threadParam.isValid
|
||||
&& threadParam.level == globalParams.level)
|
||||
{
|
||||
return tParam;
|
||||
return threadParam;
|
||||
}
|
||||
|
||||
tParam = new ThreadedParameters(param);
|
||||
LOCAL_PARAM.set(tParam);
|
||||
return tParam;
|
||||
threadParam = new ThreadWorldGenParams(globalParams);
|
||||
LOCAL_PARAM.set(threadParam);
|
||||
return threadParam;
|
||||
}
|
||||
|
||||
private ThreadedParameters(GlobalParameters param)
|
||||
private ThreadWorldGenParams(GlobalWorldGenParams param)
|
||||
{
|
||||
previousGlobalParameters = param;
|
||||
previousGlobalWorldGenParams = param;
|
||||
|
||||
this.level = param.level;
|
||||
#if MC_VER < MC_1_18_2
|
||||
@@ -70,20 +77,18 @@ public final class ThreadedParameters
|
||||
#else
|
||||
this.structCheck = new StructureCheck(param.chunkScanner, param.registry, param.structures,
|
||||
param.level.dimension(), param.generator, param.randomState, level, param.generator.getBiomeSource(), param.worldSeed,
|
||||
param.fixerUpper);
|
||||
param.dataFixer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void markAsInvalid() { isValid = false; }
|
||||
|
||||
public void makeStructFeat(WorldGenLevel genLevel, GlobalParameters param)
|
||||
public void makeStructFeat(WorldGenLevel genLevel, GlobalWorldGenParams param)
|
||||
{
|
||||
#if MC_VER < MC_1_19_4
|
||||
structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel #if MC_VER >= MC_1_18_2 , structCheck #endif );
|
||||
this.structFeat = new WorldGenStructFeatManager(param.worldGenSettings, genLevel #if MC_VER >= MC_1_18_2 , this.structCheck #endif );
|
||||
#else
|
||||
structFeat = new WorldGenStructFeatManager(param.worldOptions, genLevel, structCheck);
|
||||
this.structFeat = new WorldGenStructFeatManager(param.worldOptions, genLevel, this.structCheck);
|
||||
#endif
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
public abstract class AbstractWorldGenStep
|
||||
{
|
||||
public abstract void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers);
|
||||
|
||||
public abstract ChunkStatus getChunkStatus();
|
||||
|
||||
+2
-4
@@ -23,13 +23,11 @@ import java.util.ArrayList;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
|
||||
#if MC_VER >= MC_1_18_2
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
@@ -66,7 +64,7 @@ public final class StepBiomes extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = this.getChunksToGenerate(chunkWrappers);
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
@@ -67,7 +67,7 @@ public final class StepFeatures extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
|
||||
+2
-5
@@ -20,18 +20,15 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
|
||||
#if MC_VER >= MC_1_18_2
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
@@ -68,7 +65,7 @@ public final class StepNoise extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
|
||||
|
||||
+2
-4
@@ -20,15 +20,13 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
|
||||
@@ -64,7 +62,7 @@ public final class StepStructureReference extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
|
||||
+2
-7
@@ -20,21 +20,16 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
|
||||
#if MC_VER <= MC_1_20_4
|
||||
@@ -71,7 +66,7 @@ public final class StepStructureStart extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = this.getChunksToGenerate(chunkWrappers);
|
||||
|
||||
+2
-4
@@ -20,15 +20,13 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.worldGeneration.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.BatchGenerationEnvironment;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadedParameters;
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.ThreadWorldGenParams;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject.DhLitWorldGenRegion;
|
||||
import com.seibel.distanthorizons.core.util.gridList.ArrayGridList;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
|
||||
@@ -64,7 +62,7 @@ public final class StepSurface extends AbstractWorldGenStep
|
||||
|
||||
@Override
|
||||
public void generateGroup(
|
||||
ThreadedParameters tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ThreadWorldGenParams tParams, DhLitWorldGenRegion worldGenRegion,
|
||||
ArrayGridList<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 3f287388d5...2537c4a259
+2
-2
@@ -13,7 +13,7 @@ public class MixinLevelTicks<T>
|
||||
|
||||
#else
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
|
||||
import net.minecraft.world.ticks.LevelTicks;
|
||||
import net.minecraft.world.ticks.ScheduledTick;
|
||||
@@ -28,7 +28,7 @@ public class MixinLevelTicks<T>
|
||||
{
|
||||
// TODO put in a common location
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-3
@@ -35,10 +35,9 @@ public class MixinTracingExecutor
|
||||
}
|
||||
#else
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
import com.seibel.distanthorizons.core.util.objects.RunOnThisThreadExecutorService;
|
||||
import net.minecraft.TracingExecutor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@@ -57,7 +56,7 @@ public class MixinTracingExecutor
|
||||
{
|
||||
// TODO put in a common location
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
// replaced with TracingExecutor in MC 1.21.3+
|
||||
|
||||
+2
-7
@@ -19,17 +19,12 @@
|
||||
|
||||
package com.seibel.distanthorizons.fabric.mixins.server;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
import com.seibel.distanthorizons.core.util.objects.RunOnThisThreadExecutorService;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
#if MC_VER < MC_1_16_5
|
||||
#elif MC_VER < MC_1_21_3
|
||||
import java.util.function.Supplier;
|
||||
@@ -47,7 +42,7 @@ import java.util.function.Supplier;
|
||||
public class MixinUtilBackgroundThread
|
||||
{
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
#if MC_VER < MC_1_21_3
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ public class MixinLevelTicks<T>
|
||||
|
||||
#else
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
import net.minecraft.world.ticks.LevelTicks;
|
||||
import net.minecraft.world.ticks.ScheduledTick;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -26,7 +26,7 @@ public class MixinLevelTicks<T>
|
||||
{
|
||||
// TODO put in a common location
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ public class MixinTracingExecutor
|
||||
}
|
||||
#else
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
import com.seibel.distanthorizons.core.util.objects.RunOnThisThreadExecutorService;
|
||||
import net.minecraft.TracingExecutor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -57,7 +57,7 @@ public class MixinTracingExecutor
|
||||
{
|
||||
// TODO put in a common location
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
// Util.backgroundExecutor().forName("init_biomes")
|
||||
|
||||
+2
-8
@@ -19,16 +19,10 @@
|
||||
|
||||
package com.seibel.distanthorizons.neoforge.mixins.server;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.seibel.distanthorizons.core.util.objects.RunOnThisThreadExecutorService;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetupDoneCheck;
|
||||
import com.seibel.distanthorizons.common.wrappers.WorldGenThreadCheck;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
@@ -43,7 +37,7 @@ import net.minecraft.Util;
|
||||
public class MixinUtilBackgroundThread
|
||||
{
|
||||
private static boolean isWorldGenThread()
|
||||
{ return DependencySetupDoneCheck.isDone && DependencySetupDoneCheck.getIsCurrentThreadDistantGeneratorThread.get(); }
|
||||
{ return WorldGenThreadCheck.isSetup && WorldGenThreadCheck.isCurrentThreadDhWorldGenThread.get(); }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user