From a2624c4c4368184def3891fc5f64b6c9905be2e8 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sat, 28 Jan 2023 20:21:06 +0100 Subject: [PATCH] fix some skylight bugs --- .../minosoft/data/world/chunk/light/SectionLight.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/data/world/chunk/light/SectionLight.kt b/src/main/java/de/bixilon/minosoft/data/world/chunk/light/SectionLight.kt index 920a8873f..b2ebe05c9 100644 --- a/src/main/java/de/bixilon/minosoft/data/world/chunk/light/SectionLight.kt +++ b/src/main/java/de/bixilon/minosoft/data/world/chunk/light/SectionLight.kt @@ -364,17 +364,17 @@ class SectionLight( if (target != Directions.UP && (target == null || lightProperties.propagatesLight(Directions.DOWN))) { if (y > 0) { traceSkylightIncrease(x, y - 1, z, nextNeighbourLevel, Directions.DOWN, totalY - 1) - } else if (section.sectionHeight != chunk.maxSection) { - (neighbours[Directions.O_DOWN] ?: chunk.getOrPut(section.sectionHeight + 1, false))?.light?.traceSkylightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, nextNeighbourLevel, Directions.DOWN, totalY - 1) + } else if (section.sectionHeight == chunk.minSection) { + chunk.light.bottom.traceSkyIncrease(x, z, nextLevel) + } else { + (neighbours[Directions.O_DOWN] ?: chunk.getOrPut(section.sectionHeight - 1, false))?.light?.traceSkylightIncrease(x, ProtocolDefinition.SECTION_MAX_Y, z, nextNeighbourLevel, Directions.DOWN, totalY - 1) } } if (target != Directions.DOWN && target != null && (lightProperties.propagatesLight(Directions.UP))) { if (y < ProtocolDefinition.SECTION_MAX_Y) { traceSkylightIncrease(x, y + 1, z, nextNeighbourLevel, Directions.UP, totalY + 1) - } else if (section.sectionHeight == chunk.minSection) { - chunk.light.bottom.traceSkyIncrease(x, z, nextLevel) - } else { - (neighbours[Directions.O_UP] ?: chunk.getOrPut(section.sectionHeight - 1, false))?.light?.traceSkylightIncrease(x, 0, z, nextNeighbourLevel, Directions.UP, totalY + 1) + } else if (section.sectionHeight < chunk.maxSection) { + (neighbours[Directions.O_UP] ?: chunk.getOrPut(section.sectionHeight + 1, false))?.light?.traceSkylightIncrease(x, 0, z, nextNeighbourLevel, Directions.UP, totalY + 1) } } if (target != Directions.SOUTH && (target == null || lightProperties.propagatesLight(Directions.NORTH))) {