From 50aee9dfb21689a2735f83ac76b400546ddb5845 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 31 Mar 2021 10:56:50 -0500 Subject: [PATCH] Move getCurrentWorldID into the LodUtils class --- .../com/backsun/lod/builders/LodBuilder.java | 14 ++++---- .../lod/handlers/LodDimensionFileHandler.java | 34 +------------------ .../java/com/backsun/lod/util/LodUtils.java | 32 ++++++++++++++++- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/backsun/lod/builders/LodBuilder.java b/src/main/java/com/backsun/lod/builders/LodBuilder.java index 78e084500..2968efaa4 100644 --- a/src/main/java/com/backsun/lod/builders/LodBuilder.java +++ b/src/main/java/com/backsun/lod/builders/LodBuilder.java @@ -66,12 +66,14 @@ public class LodBuilder */ public LodWorld generateLodChunkAsync(IChunk chunk, DimensionType dim) { - if (lodWorld != null) - // is this chunk from the same world as the lodWorld? - if (!lodWorld.worldName.equals(LodDimensionFileHandler.getCurrentWorldID())) - // we are not in the same world anymore - // don't add this LOD - return lodWorld; + if (lodWorld == null) + return; + + // is this chunk from the same world as the lodWorld? + if (!lodWorld.getWorldName().equals(LodUtils.getCurrentWorldID())) + // we are not in the same world anymore + // don't add this LOD + return; // don't try to create an LOD object diff --git a/src/main/java/com/backsun/lod/handlers/LodDimensionFileHandler.java b/src/main/java/com/backsun/lod/handlers/LodDimensionFileHandler.java index 139534fa0..ed8132a5d 100644 --- a/src/main/java/com/backsun/lod/handlers/LodDimensionFileHandler.java +++ b/src/main/java/com/backsun/lod/handlers/LodDimensionFileHandler.java @@ -11,11 +11,8 @@ import java.util.concurrent.Executors; import com.backsun.lod.objects.LodChunk; import com.backsun.lod.objects.LodDimension; import com.backsun.lod.objects.LodRegion; -import com.backsun.lod.util.LodUtils; import net.minecraft.client.Minecraft; -import net.minecraft.world.server.ServerChunkProvider; -import net.minecraft.world.server.ServerWorld; /** * This object handles creating LodRegions @@ -23,7 +20,7 @@ import net.minecraft.world.server.ServerWorld; * to file. * * @author James Seibel - * @version 03-30-2021 + * @version 03-31-2021 */ public class LodDimensionFileHandler { @@ -257,33 +254,4 @@ public class LodDimensionFileHandler - - /** - * If on single player this will return the name of the user's - * world, if in multiplayer it will return the server name - * and game version. - */ - public static String getCurrentWorldID() - { - Minecraft mc = Minecraft.getInstance(); - - if(mc.isIntegratedServerRunning()) - { - ServerWorld serverWorld = LodUtils.getFirstValidServerWorld(); - if (serverWorld == null) - return ""; - - ServerChunkProvider provider = serverWorld.getChunkProvider(); - if(provider != null) - return provider.getSavedData().folder.toString(); - - return ""; - } - else - { - return mc.getCurrentServerData().serverName + "_version_" + mc.getCurrentServerData().gameVersion; - } - } - - } diff --git a/src/main/java/com/backsun/lod/util/LodUtils.java b/src/main/java/com/backsun/lod/util/LodUtils.java index c3d556add..723852b94 100644 --- a/src/main/java/com/backsun/lod/util/LodUtils.java +++ b/src/main/java/com/backsun/lod/util/LodUtils.java @@ -9,13 +9,14 @@ import net.minecraft.util.math.ChunkPos; import net.minecraft.world.DimensionType; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.server.ServerChunkProvider; import net.minecraft.world.server.ServerWorld; /** * This class holds methods that may be used in multiple places. * * @author James Seibel - * @version 03-24-2021 + * @version 03-31-2021 */ public class LodUtils { @@ -107,4 +108,33 @@ public class LodUtils return false; } + + /** + * If on single player this will return the name of the user's + * world, if in multiplayer it will return the server name + * and game version. + */ + public static String getCurrentWorldID() + { + Minecraft mc = Minecraft.getInstance(); + + if(mc.isIntegratedServerRunning()) + { + ServerWorld serverWorld = LodUtils.getFirstValidServerWorld(); + if (serverWorld == null) + return ""; + + ServerChunkProvider provider = serverWorld.getChunkProvider(); + if(provider != null) + return provider.getSavedData().folder.toString(); + + return ""; + } + else + { + return mc.getCurrentServerData().serverName + "_version_" + mc.getCurrentServerData().gameVersion; + } + } + + }