From 0e017cf512f77d62ff7d71e271d3e90ddf6d6a04 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Aug 2023 09:11:00 -0500 Subject: [PATCH] hopefully prevent world gen structure lockup when leaving the world --- .../worldGeneration/BatchGenerationEnvironment.java | 3 +-- .../wrappers/worldGeneration/step/StepStructureStart.java | 7 ++++++- coreSubProjects | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 18b886f71..fffb954bd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -36,7 +36,6 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos; 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.DhThreadFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvironmentWrapper; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; @@ -745,7 +744,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv * This is necessary to allow canceling world gen since waiting * for some world gen requests to finish can take a while. */ - private static void throwIfThreadInterrupted() throws InterruptedException + public static void throwIfThreadInterrupted() throws InterruptedException { if (Thread.interrupted()) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java index 68e98ce96..6dcbcbe33 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -64,7 +64,7 @@ public final class StepStructureStart public void generateGroup( ThreadedParameters tParams, WorldGenRegion worldGenRegion, - List chunkWrappers) + List chunkWrappers) throws InterruptedException { ArrayList chunksToDo = new ArrayList<>(); @@ -90,6 +90,11 @@ public final class StepStructureStart for (ChunkAccess chunk : chunksToDo) { // System.out.println("StepStructureStart: "+chunk.getPos()); + + // there are a few cases where the structure generator call may lock up (either due to teleporting or leaving the world). + // hopefully allowing interrupts here will prevent that from happening. + BatchGenerationEnvironment.throwIfThreadInterrupted(); + #if PRE_MC_1_19_2 environment.params.generator.createStructures(environment.params.registry, tParams.structFeat, chunk, environment.params.structures, environment.params.worldSeed); diff --git a/coreSubProjects b/coreSubProjects index 91f67cac9..859fcaf1b 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 91f67cac9b69f8d83f5012db55867dd5ef19e38a +Subproject commit 859fcaf1b81f69fea1f202b483452c8ff5dae649