mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
clear top and bottom chunk light
This commit is contained in:
parent
575b60baab
commit
3404348bff
@ -155,6 +155,38 @@ class BorderSectionLight(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun decreaseCheckLevel(x: Int, z: Int, light: Int, reset: Boolean) {
|
||||||
|
decreaseCheckX(z, light, reset)
|
||||||
|
val neighbours = chunk.neighbours ?: return
|
||||||
|
|
||||||
|
if (x - light < 0) {
|
||||||
|
neighbours[ChunkNeighbours.WEST].getBorderLight().decreaseCheckX(z, light - x, reset)
|
||||||
|
}
|
||||||
|
if (x + light > ProtocolDefinition.SECTION_MAX_X) {
|
||||||
|
neighbours[ChunkNeighbours.EAST].getBorderLight().decreaseCheckX(z, light - (ProtocolDefinition.SECTION_MAX_X - x), reset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun decreaseCheckX(z: Int, light: Int, reset: Boolean) {
|
||||||
|
val neighbours = chunk.neighbours ?: return
|
||||||
|
if (reset) reset()
|
||||||
|
|
||||||
|
if (z - light < 0) {
|
||||||
|
val neighbour = neighbours[ChunkNeighbours.NORTH].getBorderLight()
|
||||||
|
if (reset) neighbour.reset()
|
||||||
|
}
|
||||||
|
if (z + light > ProtocolDefinition.SECTION_MAX_Z) {
|
||||||
|
val neighbour = neighbours[ChunkNeighbours.SOUTH].getBorderLight()
|
||||||
|
if (reset) neighbour.reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reset() {
|
||||||
|
for (i in light.indices) {
|
||||||
|
light[i] = 0x00
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun update(array: ByteArray) {
|
fun update(array: ByteArray) {
|
||||||
// ToDo: Save light from server
|
// ToDo: Save light from server
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,8 @@ class ChunkLight(private val chunk: Chunk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun recalculate(fireEvent: Boolean = true, fireSameChunkEvent: Boolean = true) {
|
fun recalculate(fireEvent: Boolean = true, fireSameChunkEvent: Boolean = true) {
|
||||||
|
bottom.reset()
|
||||||
|
top.reset()
|
||||||
val sections = chunk.sections ?: Broken("Sections is null")
|
val sections = chunk.sections ?: Broken("Sections is null")
|
||||||
for (section in sections) {
|
for (section in sections) {
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
@ -157,6 +159,8 @@ class ChunkLight(private val chunk: Chunk) {
|
|||||||
}
|
}
|
||||||
section.light.reset()
|
section.light.reset()
|
||||||
}
|
}
|
||||||
|
bottom.reset()
|
||||||
|
top.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun propagateFromNeighbours(fireEvent: Boolean = true, fireSameChunkEvent: Boolean = true) {
|
fun propagateFromNeighbours(fireEvent: Boolean = true, fireSameChunkEvent: Boolean = true) {
|
||||||
|
@ -64,13 +64,22 @@ class SectionLight(
|
|||||||
decreaseCheckLevel(x, z, light, reset)
|
decreaseCheckLevel(x, z, light, reset)
|
||||||
|
|
||||||
val neighbours = section.neighbours ?: return
|
val neighbours = section.neighbours ?: return
|
||||||
|
val chunk = section.chunk
|
||||||
if (y - light < 0) {
|
if (y - light < 0) {
|
||||||
|
if (section.sectionHeight == chunk?.lowestSection) {
|
||||||
|
chunk.light.bottom.decreaseCheckLevel(x, z, light - y, reset)
|
||||||
|
} else {
|
||||||
neighbours[Directions.O_DOWN]?.light?.decreaseCheckLevel(x, z, light - y, reset)
|
neighbours[Directions.O_DOWN]?.light?.decreaseCheckLevel(x, z, light - y, reset)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (y + light > ProtocolDefinition.SECTION_MAX_Y) {
|
if (y + light > ProtocolDefinition.SECTION_MAX_Y) {
|
||||||
|
if (section.sectionHeight == chunk?.highestSection) {
|
||||||
|
chunk.light.top.decreaseCheckLevel(x, z, light - (ProtocolDefinition.SECTION_MAX_Y - y), reset)
|
||||||
|
} else {
|
||||||
neighbours[Directions.O_UP]?.light?.decreaseCheckLevel(x, z, light - (ProtocolDefinition.SECTION_MAX_Y - y), reset)
|
neighbours[Directions.O_UP]?.light?.decreaseCheckLevel(x, z, light - (ProtocolDefinition.SECTION_MAX_Y - y), reset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun decreaseCheckLevel(x: Int, z: Int, light: Int, reset: Boolean) {
|
private fun decreaseCheckLevel(x: Int, z: Int, light: Int, reset: Boolean) {
|
||||||
decreaseCheckX(z, light, reset)
|
decreaseCheckX(z, light, reset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user