border light: fix skylight propagation

This commit is contained in:
Bixilon 2022-10-11 14:15:02 +02:00
parent cad6fa8d2b
commit 835f62d1f4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -107,19 +107,19 @@ class BorderSectionLight(
fun traceSkyIncrease(x: Int, z: Int, nextLevel: Int) { fun traceSkyIncrease(x: Int, z: Int, nextLevel: Int) {
val index = z shl 4 or x val index = z shl 4 or x
val currentLight = light[index].toInt() and SectionLight.SKY_LIGHT_MASK shl 4 val light = light[index].toInt()
if (currentLight >= nextLevel) { if ((light and SectionLight.SKY_LIGHT_MASK shr 4) >= nextLevel) {
// light is already higher, no need to trace // light is already higher, no need to trace
return return
} }
this.light[index] = ((this.light[index].toInt() and SectionLight.BLOCK_LIGHT_MASK) or nextLevel).toByte() this.light[index] = ((light and SectionLight.BLOCK_LIGHT_MASK) or (nextLevel shl 4)).toByte()
if (!update) { if (!update) {
update = true update = true
} }
if (nextLevel == 1) { if (nextLevel <= 1) {
return updateY() return updateY()
} }
val neighbourLevel = nextLevel - 1 val neighbourLevel = nextLevel - 1