mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
invalidate neighbour skylight when level==1
This fixes some potential black spots in the world when the block is using cullface option to get the neighbours light level
This commit is contained in:
parent
a37d6d69a7
commit
eaeb59132c
@ -107,6 +107,17 @@ class SectionLight(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Array<ChunkSection?>.invalidateLight(x: Int, y: Int, z: Int) {
|
||||
// we can not further increase the light
|
||||
// set neighbour update, cullface might change lighting properties
|
||||
if (y == 0) this[Directions.O_DOWN]?.light?.update = true
|
||||
if (y == ProtocolDefinition.SECTION_MAX_Y) this[Directions.O_UP]?.light?.update = true
|
||||
if (z == 0) this[Directions.O_NORTH]?.light?.update = true
|
||||
if (z == ProtocolDefinition.SECTION_MAX_Z) this[Directions.O_SOUTH]?.light?.update = true
|
||||
if (x == 0) this[Directions.O_WEST]?.light?.update = true
|
||||
if (x == ProtocolDefinition.SECTION_MAX_X) this[Directions.O_EAST]?.light?.update = true
|
||||
}
|
||||
|
||||
fun traceBlockIncrease(x: Int, y: Int, z: Int, nextLuminance: Int, target: Directions?) {
|
||||
val index = getIndex(x, y, z)
|
||||
val block = section.blocks.unsafeGet(index)
|
||||
@ -137,14 +148,7 @@ class SectionLight(
|
||||
val neighbours = section.neighbours ?: return
|
||||
|
||||
if (nextLuminance == 1) {
|
||||
// we can not further increase the light
|
||||
// set neighbour update, cullface might change lighting properties
|
||||
if (y == 0) neighbours[Directions.O_DOWN]?.light?.update = true
|
||||
if (y == ProtocolDefinition.SECTION_MAX_Y) neighbours[Directions.O_UP]?.light?.update = true
|
||||
if (z == 0) neighbours[Directions.O_NORTH]?.light?.update = true
|
||||
if (z == ProtocolDefinition.SECTION_MAX_Z) neighbours[Directions.O_SOUTH]?.light?.update = true
|
||||
if (x == 0) neighbours[Directions.O_WEST]?.light?.update = true
|
||||
if (x == ProtocolDefinition.SECTION_MAX_X) neighbours[Directions.O_EAST]?.light?.update = true
|
||||
neighbours.invalidateLight(x, y, z)
|
||||
return
|
||||
}
|
||||
|
||||
@ -335,17 +339,24 @@ class SectionLight(
|
||||
return
|
||||
}
|
||||
|
||||
val neighbours = this.section.neighbours ?: return
|
||||
|
||||
this.light[index] = ((currentLight and BLOCK_LIGHT_MASK) or (nextLevel shl 4)).toByte()
|
||||
|
||||
if (!update) {
|
||||
update = true
|
||||
}
|
||||
|
||||
|
||||
if (nextLevel == 1) {
|
||||
neighbours.invalidateLight(x, y, z)
|
||||
return
|
||||
}
|
||||
|
||||
if (nextLevel <= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
val neighbours = this.section.neighbours ?: return
|
||||
val nextNeighbourLevel = nextLevel - 1
|
||||
|
||||
if (target != Directions.UP && (target == null || lightProperties.propagatesLight(Directions.DOWN))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user