Have DhLightingEngine set centerChunk.setIsDhLightCorrect = true when done

This commit is contained in:
James Seibel
2023-08-18 11:49:52 -05:00
parent 3db7ffeb01
commit b229d928c1
2 changed files with 5 additions and 13 deletions
@@ -198,7 +198,7 @@ public class ServerApi
// not a perfect solution, but should prevent chunks from having completely broken lighting
List<IChunkWrapper> nearbyChunkList = new LinkedList<>();
nearbyChunkList.add(chunkWrapper);
DhLightingEngine.INSTANCE.lightChunks(chunkWrapper, nearbyChunkList, level.hasSkyLight() ? 15 : 0);
DhLightingEngine.INSTANCE.lightChunk(chunkWrapper, nearbyChunkList, level.hasSkyLight() ? 15 : 0);
chunkWrapper.setUseDhLighting(true);
}
@@ -10,7 +10,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import org.apache.logging.log4j.Logger;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* This logic was roughly based on
@@ -36,7 +35,7 @@ public class DhLightingEngine
* @param nearbyChunkList should also contain centerChunk
* @param maxSkyLight should be a value between 0 and 15
*/
public void lightChunks(IChunkWrapper centerChunk, List<IChunkWrapper> nearbyChunkList, int maxSkyLight)
public void lightChunk(IChunkWrapper centerChunk, List<IChunkWrapper> nearbyChunkList, int maxSkyLight)
{
DhChunkPos centerChunkPos = centerChunk.getChunkPos();
@@ -142,6 +141,7 @@ public class DhLightingEngine
(neighbourChunk, relBlockPos, newLightValue) -> neighbourChunk.setDhSkyLight(relBlockPos.x, relBlockPos.y, relBlockPos.z, newLightValue));
centerChunk.setIsDhLightCorrect(true);
LOGGER.trace("Finished generating lighting for chunk: [" + centerChunkPos + "]");
}
@@ -221,18 +221,10 @@ public class DhLightingEngine
//================//
@FunctionalInterface
interface IGetLightFunc
{
int getLight(IChunkWrapper chunk, DhBlockPos pos);
}
interface IGetLightFunc { int getLight(IChunkWrapper chunk, DhBlockPos pos); }
@FunctionalInterface
interface ISetLightFunc
{
void setLight(IChunkWrapper chunk, DhBlockPos pos, int lightValue);
}
interface ISetLightFunc { void setLight(IChunkWrapper chunk, DhBlockPos pos, int lightValue); }
private static class LightPos
{