From 572b71d82ec798d28d675142de6831074cc1a8d3 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Fri, 2 Feb 2018 18:43:23 +0000 Subject: [PATCH] Change chunk gen command to only keep the target dimension loaded (#4705) --- .../server/command/ChunkGenWorker.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java index 715179d8c..e33cb8e86 100644 --- a/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java +++ b/src/main/java/net/minecraftforge/server/command/ChunkGenWorker.java @@ -29,7 +29,6 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.WorldWorkerManager.IWorker; public class ChunkGenWorker implements IWorker @@ -42,7 +41,7 @@ public class ChunkGenWorker implements IWorker private final int notificationFrequency; private int lastNotification = 0; private int genned = 0; - private int oldUnloadDelay = -1; + private Boolean loadSpawn; public ChunkGenWorker(ICommandSender listener, BlockPos start, int total, int dim, int interval) { @@ -116,11 +115,11 @@ public class ChunkGenWorker implements IWorker return; } } - //While we work we don't want to cause world load spam so pause unloading worlds. - if (oldUnloadDelay == -1) + // While we work we don't want to cause world load spam so pause unloading the world. + if (loadSpawn == null) { - oldUnloadDelay = ForgeModContainer.dimensionUnloadQueueDelay; - ForgeModContainer.dimensionUnloadQueueDelay = Integer.MAX_VALUE; + loadSpawn = world.provider.getDimensionType().shouldLoadSpawn(); + world.provider.getDimensionType().setLoadSpawn(true); } if (++lastNotification >= notificationFrequency) @@ -160,7 +159,7 @@ public class ChunkGenWorker implements IWorker if (queue.size() == 0) { listener.sendMessage(TextComponentHelper.createComponentTranslation(listener, "commands.forge.gen.complete", genned, total, dim)); - ForgeModContainer.dimensionUnloadQueueDelay = oldUnloadDelay; + DimensionManager.getProviderType(dim).setLoadSpawn(loadSpawn); } } }