From fd0604c7e733829a89e1dc98550cc841714cee63 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 29 Oct 2021 19:56:03 -0500 Subject: [PATCH] Fix a few potential null pointers when on a server world --- .../lod/builders/lodBuilding/LodBuilder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java index 7eb23835b..c11a7ed2a 100644 --- a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java @@ -35,18 +35,16 @@ import com.seibel.lod.util.LevelPosUtil; import com.seibel.lod.util.LodThreadFactory; import com.seibel.lod.util.LodUtil; import com.seibel.lod.util.ThreadMapUtil; -import com.seibel.lod.wrappers.Block.BlockPosWrapper; +import com.seibel.lod.wrappers.MinecraftWrapper; import com.seibel.lod.wrappers.Block.BlockColorWrapper; +import com.seibel.lod.wrappers.Block.BlockPosWrapper; import com.seibel.lod.wrappers.Block.BlockShapeWrapper; import com.seibel.lod.wrappers.Chunk.ChunkPosWrapper; import com.seibel.lod.wrappers.Chunk.ChunkWrapper; -import com.seibel.lod.wrappers.MinecraftWrapper; - import com.seibel.lod.wrappers.World.BiomeColorWrapper; import com.seibel.lod.wrappers.World.BiomeWrapper; import com.seibel.lod.wrappers.World.WorldWrapper; - import net.minecraft.world.DimensionType; import net.minecraft.world.IWorld; @@ -172,6 +170,10 @@ public class LodBuilder if (region == null) return; + // this happens if a LOD is generated after the user leaves the world. + if (MinecraftWrapper.INSTANCE.getWrappedClientWorld() == null) + return; + // determine how many LODs to generate horizontally byte minDetailLevel = region.getMinDetailLevel(); HorizontalResolution detail = DetailDistanceUtil.getLodGenDetail(minDetailLevel); @@ -396,7 +398,7 @@ public class LodBuilder - if (!world.isEmpty()) + if (world != null && !world.isEmpty()) { // server world sky light (always accurate) blockLight = world.getBlockLight(blockPos); @@ -500,7 +502,7 @@ public class LodBuilder { WorldWrapper world = MinecraftWrapper.INSTANCE.getWrappedServerWorld(); - if (world.isEmpty()) + if (world == null || world.isEmpty()) world = MinecraftWrapper.INSTANCE.getWrappedClientWorld(); int tintValue;