From ec2382372e133ccff977a939db97046a3a4eac32 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 18 Aug 2023 11:19:15 -0500 Subject: [PATCH] Fix DH lighting not being baked in correctly for loaded chunks --- .../core/api/internal/ServerApi.java | 16 ++++++++-------- .../wrapperInterfaces/chunk/IChunkWrapper.java | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java index 0d9e1b2e0..4f1d3faf3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java @@ -159,7 +159,7 @@ public class ServerApi } } } - public void serverChunkSaveEvent(IChunkWrapper chunk, ILevelWrapper level) + public void serverChunkSaveEvent(IChunkWrapper chunkWrapper, ILevelWrapper level) { AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld(); if (dhWorld == null) @@ -179,13 +179,13 @@ public class ServerApi { // Save or populate the chunk wrapper's lighting // this is done so we don't have to worry about MC unloading the lighting data for this chunk - if (chunk.isLightCorrect()) + if (chunkWrapper.isLightCorrect()) { try { // If MC's lighting engine isn't thread safe this may cause the server thread to lag - chunk.bakeDhLightingUsingMcLightingEngine(); - chunk.setUseDhLighting(true); + chunkWrapper.bakeDhLightingUsingMcLightingEngine(); + chunkWrapper.setUseDhLighting(true); } catch (IllegalStateException e) { @@ -197,12 +197,12 @@ public class ServerApi // generate the chunk's lighting, ignoring neighbors. // not a perfect solution, but should prevent chunks from having completely broken lighting List nearbyChunkList = new LinkedList<>(); - nearbyChunkList.add(chunk); - DhLightingEngine.INSTANCE.lightChunks(chunk, nearbyChunkList, level.hasSkyLight() ? 15 : 0); - chunk.setUseDhLighting(true); + nearbyChunkList.add(chunkWrapper); + DhLightingEngine.INSTANCE.lightChunks(chunkWrapper, nearbyChunkList, level.hasSkyLight() ? 15 : 0); + chunkWrapper.setUseDhLighting(true); } - dhLevel.updateChunkAsync(chunk); + dhLevel.updateChunkAsync(chunkWrapper); }); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java index 1e3ed44d7..06136d7b9 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/chunk/IChunkWrapper.java @@ -91,6 +91,8 @@ public interface IChunkWrapper extends IBindable } } } + + this.setIsDhLightCorrect(true); }