From 1c9fe23633500f8400b7bfd620d27f1a53feb446 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Sun, 12 Dec 2021 12:04:08 +0100 Subject: [PATCH 1/4] fixed couple errors, but floating islands are still broken --- .../core/builders/lodBuilding/LodBuilder.java | 42 ++++++++----------- .../worldGeneration/LodWorldGenerator.java | 2 +- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java index c9fe74560..3cfb71973 100644 --- a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java @@ -22,6 +22,7 @@ package com.seibel.lod.core.builders.lodBuilding; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.config.DistanceGenerationMode; import com.seibel.lod.core.enums.config.HorizontalResolution; import com.seibel.lod.core.objects.lod.LodDimension; @@ -109,8 +110,8 @@ public class LodBuilder Thread thread = new Thread(() -> { //noinspection GrazieInspection - try - { + //try + //{ // we need a loaded client world in order to // get the textures for blocks if (MC.getWrappedClientWorld() == null) @@ -133,14 +134,14 @@ public class LodBuilder lodDim = lodWorld.getLodDimension(dim); } generateLodNodeFromChunk(lodDim, chunk, new LodBuilderConfig(generationMode)); - } - catch (IllegalArgumentException | NullPointerException e) - { - e.printStackTrace(); - // if the world changes while LODs are being generated - // they will throw errors as they try to access things that no longer - // exist. - } + //} + //catch (IllegalArgumentException | NullPointerException e) + //{ + // e.printStackTrace(); + // // if the world changes while LODs are being generated + // // they will throw errors as they try to access things that no longer + // // exist. + //} }); lodGenThreadPool.execute(thread); } @@ -469,27 +470,19 @@ public class LodBuilder int colorOfBlock; int colorInt; - IBlockShapeWrapper blockShapeWrapper; - IBlockColorWrapper blockColorWrapper; - try - { - blockShapeWrapper = chunk.getBlockShapeWrapper(x, y, z); - } - catch (Exception e) - { - //TODO fix the cause of the bug, bot it's symptoms - //ClientApi.LOGGER.error(LodBuilder.class.getSimpleName() + ": ran into an error: " + e.getMessage()); - //e.printStackTrace(); + IBlockShapeWrapper blockShapeWrapper = chunk.getBlockShapeWrapper(x, y, z); + + if (blockShapeWrapper == null || blockShapeWrapper.isToAvoid()) return 0; - } + + IBlockColorWrapper blockColorWrapper; if (chunk.isWaterLogged(x, y, z)) blockColorWrapper = BLOCK_COLOR.getWaterColor(); else blockColorWrapper = chunk.getBlockColorWrapper(x, y, z); - if (blockShapeWrapper.isToAvoid()) - return 0; + colorOfBlock = blockColorWrapper.getColor(); @@ -525,6 +518,7 @@ public class LodBuilder boolean noCollisionAvoidance = config.client().worldGenerator().getBlocksToAvoid().noCollision; IBlockShapeWrapper block = chunk.getBlockShapeWrapper(x, y, z); + if (block == null) return false; return !block.isToAvoid() && !(nonFullAvoidance && block.isNonFull()) && !(noCollisionAvoidance && block.hasNoCollision()); diff --git a/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java b/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java index 5489f43d1..a0eb1d8e1 100644 --- a/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java +++ b/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java @@ -165,7 +165,7 @@ public class LodWorldGenerator // add the far positions - if (posToGenerate.getNthDetail(farIndex, false) != 0 && farIndex < posToGenerate.getNumberOfFarPos()) + if (farIndex < posToGenerate.getNumberOfFarPos() && posToGenerate.getNthDetail(farIndex, false) != 0) { detailLevel = (byte) (posToGenerate.getNthDetail(farIndex, false) - 1); posX = posToGenerate.getNthPosX(farIndex, false); From 9e882951efccf9b2949a40badbe78d28735b2ebc Mon Sep 17 00:00:00 2001 From: tom lee Date: Sun, 12 Dec 2021 23:14:52 +0800 Subject: [PATCH 2/4] WorldGen: Quick change to respect VersionConstants Changed it so that even in FULL mode, it respects the VersionConstants setting. Who knows if one day we might get even FULL chunk gen in multithreading~ --- .../core/builders/worldGeneration/LodWorldGenerator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java b/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java index a0eb1d8e1..57b2ae7d0 100644 --- a/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java +++ b/src/main/java/com/seibel/lod/core/builders/worldGeneration/LodWorldGenerator.java @@ -232,9 +232,9 @@ public class LodWorldGenerator Runnable method = (() -> {generateChunk(newPos, newGenerationMode, newLodBuilder, newLodDimension, serverWorld);}); - if (newGenerationMode == DistanceGenerationMode.FULL - || VERSION_CONSTANTS.isWorldGeneratorSingleThreaded(newGenerationMode)) + if (VERSION_CONSTANTS.isWorldGeneratorSingleThreaded(newGenerationMode)) { + // --Note: This is now using version constants-- // if we are using FULL generation there is no reason // to queue up a bunch of generation requests, // because MC's internal server (as of 1.16.5) only @@ -268,7 +268,7 @@ public class LodWorldGenerator // be added to the current LodDimension if (lodDim.regionIsInRange(pos.getX() / LodUtil.REGION_WIDTH_IN_CHUNKS, pos.getZ() / LodUtil.REGION_WIDTH_IN_CHUNKS)) - { + { switch (generationMode) { case NONE: From a1729611126bd5358e0786452d271238f535f8ea Mon Sep 17 00:00:00 2001 From: cola98765 Date: Sun, 12 Dec 2021 21:26:40 +0100 Subject: [PATCH 3/4] probable fix to a color bug that made no sense --- .../seibel/lod/core/builders/lodBuilding/LodBuilder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java index 3cfb71973..2879d42b6 100644 --- a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java @@ -270,12 +270,14 @@ public class LodBuilder { yAbs = depth; light = getLightValue(chunk, xAbs,yAbs,zAbs, true, hasSkyLight, true); - color = generateLodColor(chunk, config, xAbs, yAbs, zAbs); + //TODO don't ask me why, but apparently it works + color = generateLodColor(chunk, config, xAbs, yAbs - DEFAULT_DEPTH, zAbs); } else { light = getLightValue(chunk, xAbs, yAbs, zAbs, hasCeiling, hasSkyLight, topBlock); - color = generateLodColor(chunk, config, xAbs, yAbs, zAbs); + //TODO don't ask me why, but apparently it works + color = generateLodColor(chunk, config, xAbs, yAbs - DEFAULT_DEPTH, zAbs); } lightBlock = light & 0b1111; lightSky = (light >> 4) & 0b1111; From 4ece2de9916ad35df24bfbdc8b90b0d931ebce59 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Sun, 12 Dec 2021 23:47:24 +0100 Subject: [PATCH 4/4] probable fix to a color bug that made no sense --- .../lod/core/builders/lodBuilding/LodBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java index 2879d42b6..805fd1015 100644 --- a/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/core/builders/lodBuilding/LodBuilder.java @@ -63,9 +63,11 @@ public class LodBuilder private static final IVersionConstants VERSION_CONSTANTS = SingletonHandler.get(IVersionConstants.class); /** If no blocks are found in the area in determineBottomPointForArea return this */ - public static final short DEFAULT_DEPTH = (short) VERSION_CONSTANTS.getMinimumWorldHeight(); + public static final short DEFAULT_DEPTH = 0;//(short) VERSION_CONSTANTS.getMinimumWorldHeight(); /** If no blocks are found in the area in determineHeightPointForArea return this */ - public static final short DEFAULT_HEIGHT = (short) VERSION_CONSTANTS.getMinimumWorldHeight(); + public static final short DEFAULT_HEIGHT = 0;//(short) VERSION_CONSTANTS.getMinimumWorldHeight(); + + public static final short MIN_WORLD_HEIGHT = (short)VERSION_CONSTANTS.getMinimumWorldHeight(); /** Minecraft's max light value */ public static final short DEFAULT_MAX_LIGHT = 15; @@ -271,13 +273,13 @@ public class LodBuilder yAbs = depth; light = getLightValue(chunk, xAbs,yAbs,zAbs, true, hasSkyLight, true); //TODO don't ask me why, but apparently it works - color = generateLodColor(chunk, config, xAbs, yAbs - DEFAULT_DEPTH, zAbs); + color = generateLodColor(chunk, config, xAbs, yAbs - MIN_WORLD_HEIGHT, zAbs); } else { light = getLightValue(chunk, xAbs, yAbs, zAbs, hasCeiling, hasSkyLight, topBlock); //TODO don't ask me why, but apparently it works - color = generateLodColor(chunk, config, xAbs, yAbs - DEFAULT_DEPTH, zAbs); + color = generateLodColor(chunk, config, xAbs, yAbs - MIN_WORLD_HEIGHT, zAbs); } lightBlock = light & 0b1111; lightSky = (light >> 4) & 0b1111;