mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
skylight: don't trace above heightmap
* yep, there was a bug :)
This commit is contained in:
parent
e00a32bb41
commit
e0635f2d9e
@ -586,7 +586,7 @@ class Chunk(
|
||||
// ToDo: bare tracing
|
||||
val baseY = sectionHeight * ProtocolDefinition.SECTION_HEIGHT_Y
|
||||
for (y in ProtocolDefinition.SECTION_MAX_Y downTo 0) {
|
||||
section.light.traceSkylight(x, y, z, ProtocolDefinition.MAX_LIGHT_LEVEL.toInt(), null, baseY + y, true)
|
||||
section.light.traceSkylight(x, y, z, ProtocolDefinition.MAX_LIGHT_LEVEL.toInt(), null, baseY + y, false)
|
||||
}
|
||||
}
|
||||
val sectionHeight = maxHeight.sectionHeight
|
||||
@ -599,7 +599,7 @@ class Chunk(
|
||||
if (block != null && !block.propagatesSkylight) {
|
||||
continue
|
||||
}
|
||||
maxSection.light.traceSkylight(x, y, z, ProtocolDefinition.MAX_LIGHT_LEVEL.toInt(), null, baseY + y, true)
|
||||
maxSection.light.traceSkylight(x, y, z, ProtocolDefinition.MAX_LIGHT_LEVEL.toInt(), null, baseY + y, false)
|
||||
|
||||
}
|
||||
maxSection.light.update = true
|
||||
|
@ -247,20 +247,20 @@ class SectionLight(
|
||||
}
|
||||
|
||||
private inline fun traceSkylight(x: Int, y: Int, z: Int, nextLevel: Int, direction: Directions?, totalY: Int) {
|
||||
return traceSkylight(x, y, z, nextLevel, direction, totalY, false)
|
||||
return traceSkylight(x, y, z, nextLevel, direction, totalY, true)
|
||||
}
|
||||
|
||||
|
||||
fun traceSkylight(x: Int, y: Int, z: Int, nextLevel: Int, direction: Directions?, totalY: Int, force: Boolean) {
|
||||
fun traceSkylight(x: Int, y: Int, z: Int, nextLevel: Int, direction: Directions?, totalY: Int, noForce: Boolean) {
|
||||
val chunk = section.chunk ?: Broken("chunk == null")
|
||||
if (direction == Directions.UP && totalY >= chunk.getMaxHeight(x, z)) {
|
||||
if (noForce && totalY >= chunk.getMaxHeight(x, z)) {
|
||||
// this light level will be 15, don't care
|
||||
return
|
||||
}
|
||||
val chunkNeighbours = chunk.neighbours ?: return
|
||||
val index = getIndex(x, y, z)
|
||||
val currentLight = this[index].toInt()
|
||||
if (!force && ((currentLight and SKY_LIGHT_MASK) shr 4) >= nextLevel) {
|
||||
if (noForce && ((currentLight and SKY_LIGHT_MASK) shr 4) >= nextLevel) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user