mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
properly ignore skylight in end and nether
This commit is contained in:
parent
4513bf89ce
commit
6ac207e3ef
@ -51,16 +51,16 @@ data class DimensionProperties(
|
||||
}
|
||||
val maxSection = minSection + sections
|
||||
|
||||
val lightLevels = FloatArray(16)
|
||||
val brightness = FloatArray(16)
|
||||
|
||||
init {
|
||||
check(maxSection > minSection) { "Upper section can not be lower that the lower section ($minSection > $maxSection)" }
|
||||
check(minSection in ProtocolDefinition.CHUNK_MIN_SECTION..ProtocolDefinition.CHUNK_MAX_SECTION) { "Minimum section out of bounds: $minSection" }
|
||||
check(maxSection in ProtocolDefinition.CHUNK_MIN_SECTION..ProtocolDefinition.CHUNK_MAX_SECTION) { "Maximum section out of bounds: $minSection" }
|
||||
|
||||
for (i in lightLevels.indices) {
|
||||
val fraction = i / 15.0f
|
||||
lightLevels[i] = interpolateLinear(ambientLight, fraction / (4.0f - 3.0f * fraction), 1.0f)
|
||||
for (level in brightness.indices) {
|
||||
val fraction = level / ProtocolDefinition.MAX_LIGHT_LEVEL.toFloat()
|
||||
brightness[level] = interpolateLinear(ambientLight, fraction / (4.0f - 3.0f * fraction), 1.0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ class World(
|
||||
fun getBrightness(position: BlockPosition): Float {
|
||||
val light = getLight(position)
|
||||
val level = maxOf(light and SectionLight.BLOCK_LIGHT_MASK, light and SectionLight.SKY_LIGHT_MASK shr 4)
|
||||
return dimension?.lightLevels?.get(level) ?: 0.0f
|
||||
return dimension?.brightness?.get(level) ?: 0.0f
|
||||
}
|
||||
|
||||
fun recalculateLight() {
|
||||
|
@ -18,6 +18,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||
import de.bixilon.minosoft.data.world.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours
|
||||
@ -241,7 +242,7 @@ class ChunkLight(private val chunk: Chunk) {
|
||||
section.light.calculate()
|
||||
}
|
||||
calculateSkylight()
|
||||
} else if (previous > y) {
|
||||
} else if (previous > y && connection.world.dimension.canSkylight()) {
|
||||
// block is lower
|
||||
startSkylightFloodFill(x, z)
|
||||
}
|
||||
@ -278,7 +279,7 @@ class ChunkLight(private val chunk: Chunk) {
|
||||
}
|
||||
|
||||
private fun calculateSkylight() {
|
||||
if (chunk.world.dimension?.hasSkyLight != true || !chunk.neighbours.complete) {
|
||||
if (!chunk.world.dimension.canSkylight() || !chunk.neighbours.complete) {
|
||||
// no need to calculate it
|
||||
return
|
||||
}
|
||||
@ -395,4 +396,14 @@ class ChunkLight(private val chunk: Chunk) {
|
||||
// TODO: Optimize for specific section height (i.e. not trace everything above)
|
||||
calculateSkylight()
|
||||
}
|
||||
|
||||
fun DimensionProperties?.canSkylight(): Boolean {
|
||||
if (this == null) {
|
||||
return false
|
||||
}
|
||||
if (!this.hasSkyLight || !this.skyProperties.skylight) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ object EndSkyProperties : SkyProperties {
|
||||
override val resourceLocation = minecraft("the_end")
|
||||
|
||||
override val daylightCycle: Boolean get() = false
|
||||
override val skylight: Boolean get() = false
|
||||
override val fixedTexture: ResourceLocation = minecraft("environment/end_sky").texture()
|
||||
|
||||
override val sun: Boolean get() = false
|
||||
|
@ -21,6 +21,7 @@ object NetherSkyProperties : SkyProperties {
|
||||
override val resourceLocation = minecraft("the_nether")
|
||||
|
||||
override val daylightCycle: Boolean get() = false
|
||||
override val skylight: Boolean get() = false
|
||||
|
||||
override val sun: Boolean get() = false
|
||||
override val moon: Boolean get() = false
|
||||
|
@ -21,6 +21,7 @@ object OverworldSkyProperties : SkyProperties {
|
||||
override val resourceLocation = minecraft("overworld")
|
||||
|
||||
override val daylightCycle: Boolean get() = true
|
||||
override val skylight: Boolean get() = true
|
||||
|
||||
override val sun: Boolean get() = true
|
||||
override val moon: Boolean get() = true
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
|
||||
interface SkyProperties : ResourceLocationAble {
|
||||
val daylightCycle: Boolean
|
||||
val skylight: Boolean
|
||||
val fixedTexture: ResourceLocation? get() = null
|
||||
|
||||
val sun: Boolean
|
||||
|
@ -64,8 +64,8 @@ class LegacyLightmapUpdater(private val connection: PlayConnection) : LightmapUp
|
||||
val index = ((skyLight shl 4) or blockLight) * 4
|
||||
|
||||
|
||||
val skyLightBrightness = (connection.world.dimension?.lightLevels?.get(skyLight) ?: 1.0f) * (skyGradient * 0.95f + 0.05f)
|
||||
val blockLightBrightness = (connection.world.dimension?.lightLevels?.get(blockLight) ?: 1.0f) * 1.5// ToDo: multiply with time somewhat thing?
|
||||
val skyLightBrightness = (connection.world.dimension?.brightness?.get(skyLight) ?: 1.0f) * (skyGradient * 0.95f + 0.05f)
|
||||
val blockLightBrightness = (connection.world.dimension?.brightness?.get(blockLight) ?: 1.0f) * 1.5// ToDo: multiply with time somewhat thing?
|
||||
|
||||
|
||||
var color = Vec3(blockLightBrightness, blockLightBrightness * ((blockLightBrightness * 0.6f + 0.4f) * 0.6f + 0.4f), blockLightBrightness * (blockLightBrightness * blockLightBrightness * 0.6f + 0.4f))
|
||||
|
Loading…
x
Reference in New Issue
Block a user