mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
fix fluid height calculation, water fog
This commit is contained in:
parent
af5518b4b5
commit
48d9142d4c
@ -63,7 +63,11 @@ open class Fluid(
|
||||
}
|
||||
|
||||
fun getHeight(blockState: BlockState): Float {
|
||||
return (8 - ((blockState.properties[BlockProperties.FLUID_LEVEL]?.unsafeCast<Int>()) ?: 8)) / 9.0f
|
||||
val level = blockState.properties[BlockProperties.FLUID_LEVEL]?.unsafeCast<Int>() ?: 8
|
||||
if (level < 0 || level >= 8) {
|
||||
return 1.0f
|
||||
}
|
||||
return (8 - level) / 9.0f
|
||||
}
|
||||
|
||||
open fun travel(entity: LocalPlayerEntity, sidewaysSpeed: Float, forwardSpeed: Float, gravity: Double, falling: Boolean) {
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.data.entities.EntityRotation
|
||||
import de.bixilon.minosoft.data.player.LocalPlayerEntity
|
||||
import de.bixilon.minosoft.data.registries.VoxelShape
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.FluidBlock
|
||||
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
|
||||
import de.bixilon.minosoft.data.text.ChatColors
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
@ -55,7 +56,7 @@ class Camera(
|
||||
val renderWindow: RenderWindow,
|
||||
) {
|
||||
var fogColor = Previous(ChatColors.GREEN)
|
||||
private var fogStart = 100.0f
|
||||
var fogStart = 100.0f
|
||||
private var mouseSensitivity = Minosoft.getConfig().config.game.camera.moseSensitivity
|
||||
val entity: LocalPlayerEntity
|
||||
get() = connection.player
|
||||
@ -122,8 +123,13 @@ class Camera(
|
||||
fogStart = Float.MAX_VALUE
|
||||
return
|
||||
}
|
||||
val renderDistance = 10 // ToDo: Calculate correct, get real render distance
|
||||
fogStart = (renderDistance * ProtocolDefinition.SECTION_WIDTH_X).toFloat()
|
||||
|
||||
fogStart = if (connection.player.submgergedFluid?.resourceLocation == DefaultFluids.WATER) {
|
||||
10.0f
|
||||
} else {
|
||||
val renderDistance = 10 // ToDo: Calculate correct, get real render distance
|
||||
(renderDistance * ProtocolDefinition.SECTION_WIDTH_X).toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
private fun applyFog() {
|
||||
@ -142,7 +148,6 @@ class Camera(
|
||||
}
|
||||
|
||||
fun init(renderWindow: RenderWindow) {
|
||||
calculateFogDistance()
|
||||
renderWindow.inputHandler.registerCheckCallback(
|
||||
KeyBindingsNames.MOVE_SPRINT,
|
||||
KeyBindingsNames.MOVE_FORWARD,
|
||||
@ -240,6 +245,7 @@ class Camera(
|
||||
}
|
||||
|
||||
fun draw() {
|
||||
calculateFogDistance()
|
||||
if (!fogColor.equals()) {
|
||||
applyFog()
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.sky
|
||||
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
|
||||
import de.bixilon.minosoft.data.text.ChatColors
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
@ -117,7 +118,11 @@ class SkyRenderer(
|
||||
val brightness = 1.0f
|
||||
val skyColor = RGBColor((baseColor.red * brightness).toInt(), (baseColor.green * brightness).toInt(), (baseColor.blue * brightness).toInt())
|
||||
|
||||
renderWindow.inputHandler.camera.fogColor.value = skyColor
|
||||
renderWindow.inputHandler.camera.fogColor.value = if (connection.player.submgergedFluid?.resourceLocation == DefaultFluids.WATER) {
|
||||
connection.player.positionInfo.biome?.waterFogColor ?: skyColor
|
||||
} else {
|
||||
skyColor
|
||||
}
|
||||
|
||||
|
||||
for (shader in renderWindow.renderSystem.shaders) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user