Fix Init Null Exception (LodBuilder getMinHeight())

Fixed someone calling world.getMinHeight() on LodBuilder static init.
The world hasn't even been loaded... Also added it so that it updates on
world / dimension change.
This commit is contained in:
tom lee
2021-12-15 16:03:27 +08:00
parent f9914f9336
commit a295dcafd4
2 changed files with 6 additions and 1 deletions
@@ -21,6 +21,7 @@ package com.seibel.lod.core.api;
import org.lwjgl.glfw.GLFW;
import com.seibel.lod.core.builders.lodBuilding.LodBuilder;
import com.seibel.lod.core.builders.worldGeneration.LodWorldGenerator;
import com.seibel.lod.core.enums.config.DistanceGenerationMode;
import com.seibel.lod.core.objects.lod.LodDimension;
@@ -105,6 +106,8 @@ public class EventApi
public void worldLoadEvent(IWorldWrapper world)
{
DataPointUtil.WORLD_HEIGHT = world.getHeight();
LodBuilder.MIN_WORLD_HEIGHT = world.getMinHeight(); // This updates the World height
//LodNodeGenWorker.restartExecutorService();
//ThreadMapUtil.clearMaps();
@@ -60,7 +60,9 @@ public class LodBuilder
private static final IBlockColorSingletonWrapper BLOCK_COLOR = SingletonHandler.get(IBlockColorSingletonWrapper.class);
public static final short MIN_WORLD_HEIGHT = MC.getWrappedClientWorld().getMinHeight();
/** This cannot be final! Different world have different height, and in menu, this causes Null Exceptions*/
//public static final short MIN_WORLD_HEIGHT = MC.getWrappedClientWorld().getMinHeight();
public static short MIN_WORLD_HEIGHT = 0; // Currently modified in EventApi.onWorldLoaded(...)
/** Minecraft's max light value */
public static final short DEFAULT_MAX_LIGHT = 15;