From 158a614482e99d51c6d6d367d8e6a025bfd7cb0c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Aug 2023 20:51:29 -0500 Subject: [PATCH] Potentially fix custom world generator snow lighting --- .../core/generation/DhLightingEngine.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/DhLightingEngine.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/DhLightingEngine.java index af716f1de..93eae35ee 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/DhLightingEngine.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/DhLightingEngine.java @@ -103,7 +103,19 @@ public class DhLightingEngine for (int relZ = 0; relZ < LodUtil.CHUNK_WIDTH; relZ++) { // get the light - int maxY = chunk.getLightBlockingHeightMapValue(relX, relZ); + int maxY = Math.max(chunk.getLightBlockingHeightMapValue(relX, relZ), chunk.getSolidHeightMapValue(relX, relZ)); + + IBlockStateWrapper blockState = chunk.getBlockState(relX, maxY, relZ); + // go up until we reach open air or the world limit + while (!blockState.isAir() && maxY < chunk.getMaxBuildHeight()) + { + // this shouldn't normally be necessary, but in the off change the height map is wrong, + // (like with a modded world generator) + // this should prevent generating skylights inside the ground + maxY++; + blockState = chunk.getBlockState(relX, maxY, relZ); + } + DhBlockPos skyLightPos = new DhBlockPos(chunk.getMinBlockX() + relX, maxY, chunk.getMinBlockZ() + relZ); if (skyLightPos.y < chunk.getMinBuildHeight() || skyLightPos.y > chunk.getMaxBuildHeight())