mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
lava fluid movement
This commit is contained in:
parent
f05ffc2742
commit
14768e89a0
@ -94,7 +94,7 @@ class LocalPlayerEntity(
|
||||
|
||||
|
||||
// fluids stuff
|
||||
private val fluidHeights: MutableMap<ResourceLocation, Float> = synchronizedMapOf()
|
||||
val fluidHeights: MutableMap<ResourceLocation, Float> = synchronizedMapOf()
|
||||
var submgergedFluid: Fluid? = null
|
||||
|
||||
var input = MovementInput()
|
||||
@ -203,6 +203,9 @@ class LocalPlayerEntity(
|
||||
override val spawnSprintingParticles: Boolean
|
||||
get() = super.spawnSprintingParticles && !baseAbilities.isFlying
|
||||
|
||||
val swimHeight: Double
|
||||
get() = (eyeHeight < 0.4).decide(0.0, 0.4)
|
||||
|
||||
private fun sendMovementPackets() {
|
||||
if (Minosoft.config.config.game.camera.disableMovementSending) {
|
||||
return
|
||||
@ -461,7 +464,7 @@ class LocalPlayerEntity(
|
||||
maxHeight = max(maxHeight, level)
|
||||
}
|
||||
// ToDo: First water, then jumping, then lava?
|
||||
if (maxHeight > 0 && (!onGround || maxHeight > ((eyeHeight < 0.4).decide(0.0, 0.4)))) {
|
||||
if (maxHeight > 0 && (!onGround || maxHeight > swimHeight)) {
|
||||
this.velocity.y += 0.03999999910593033
|
||||
} else if (onGround && jumpingCoolDown == 0) {
|
||||
jump()
|
||||
|
@ -69,7 +69,9 @@ open class Fluid(
|
||||
return (8 - ((blockState.properties[BlockProperties.FLUID_LEVEL]?.unsafeCast<Int>()) ?: 8)) / 9.0f
|
||||
}
|
||||
|
||||
open fun travel(entity: LocalPlayerEntity, sidewaysSpeed: Float, forwardSpeed: Float, gravity: Double, falling: Boolean) {}
|
||||
open fun travel(entity: LocalPlayerEntity, sidewaysSpeed: Float, forwardSpeed: Float, gravity: Double, falling: Boolean) {
|
||||
entity.accelerate(sidewaysSpeed, forwardSpeed, 0.02)
|
||||
}
|
||||
|
||||
open fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {}
|
||||
|
||||
|
@ -15,8 +15,10 @@ package de.bixilon.minosoft.data.registries.fluid.lava
|
||||
|
||||
import com.google.gson.JsonObject
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.player.LocalPlayerEntity
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
|
||||
import de.bixilon.minosoft.data.registries.fluid.FlowableFluid
|
||||
import de.bixilon.minosoft.data.registries.fluid.Fluid
|
||||
import de.bixilon.minosoft.data.registries.versions.Registries
|
||||
@ -49,6 +51,25 @@ class LavaFluid(
|
||||
return other is LavaFluid
|
||||
}
|
||||
|
||||
override fun travel(entity: LocalPlayerEntity, sidewaysSpeed: Float, forwardSpeed: Float, gravity: Double, falling: Boolean) {
|
||||
entity.accelerate(sidewaysSpeed, forwardSpeed, 0.02)
|
||||
|
||||
val fluidHeight = entity.fluidHeights[DefaultFluids.LAVA] ?: 0.0f
|
||||
|
||||
if (fluidHeight <= entity.swimHeight) {
|
||||
entity.velocity = entity.velocity * Vec3d(0.5, 0.800000011920929, 0.5)
|
||||
entity.velocity = updateMovement(entity, gravity, falling, entity.velocity)
|
||||
} else {
|
||||
entity.velocity = entity.velocity * 0.5
|
||||
}
|
||||
|
||||
if (entity.hasGravity) {
|
||||
entity.velocity.y += -gravity / 4.0
|
||||
}
|
||||
|
||||
// ToDo: Same as for water
|
||||
}
|
||||
|
||||
override fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {
|
||||
super.randomTick(connection, blockState, blockPosition, random)
|
||||
val above = connection.world[blockPosition + Directions.UP]
|
||||
|
Loading…
x
Reference in New Issue
Block a user