hopefully prevent world gen structure lockup when leaving the world

This commit is contained in:
James Seibel
2023-08-18 09:11:00 -05:00
parent b1e75431ae
commit 0e017cf512
3 changed files with 8 additions and 4 deletions
@@ -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())
{
@@ -64,7 +64,7 @@ public final class StepStructureStart
public void generateGroup(
ThreadedParameters tParams, WorldGenRegion worldGenRegion,
List<ChunkWrapper> chunkWrappers)
List<ChunkWrapper> chunkWrappers) throws InterruptedException
{
ArrayList<ChunkAccess> 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);