mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
particles: entity sprinting
This commit is contained in:
parent
26e451c454
commit
78e6b0017f
@ -26,18 +26,22 @@ import de.bixilon.minosoft.data.mappings.effects.attributes.StatusEffectAttribut
|
||||
import de.bixilon.minosoft.data.mappings.effects.attributes.StatusEffectOperations
|
||||
import de.bixilon.minosoft.data.mappings.enchantment.Enchantment
|
||||
import de.bixilon.minosoft.data.mappings.entities.EntityType
|
||||
import de.bixilon.minosoft.data.mappings.particle.data.BlockParticleData
|
||||
import de.bixilon.minosoft.data.physics.PhysicsEntity
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.rendering.chunk.models.AABB
|
||||
import de.bixilon.minosoft.gui.rendering.input.camera.EntityPositionInfo
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.advanced.block.BlockDustParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.floor
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.horizontal
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.synchronizedMapOf
|
||||
import de.bixilon.minosoft.util.KUtil.synchronizedSetOf
|
||||
import de.bixilon.minosoft.util.KUtil.toSynchronizedMap
|
||||
import glm_.func.common.floor
|
||||
import glm_.vec2.Vec2
|
||||
import glm_.vec3.Vec3
|
||||
import glm_.vec3.Vec3d
|
||||
@ -99,6 +103,9 @@ abstract class Entity(
|
||||
val realPosition: Vec3d
|
||||
get() = VecUtil.lerp((System.currentTimeMillis() - lastTickTime) / ProtocolDefinition.TICK_TIMEd, previousPosition, position)
|
||||
|
||||
open val spawnSprintingParticles: Boolean
|
||||
get() = isSprinting && !isSneaking // ToDo: Touching fluids
|
||||
|
||||
protected var lastTickTime = -1L
|
||||
|
||||
fun forceMove(deltaPosition: Vec3d) {
|
||||
@ -228,10 +235,6 @@ abstract class Entity(
|
||||
val ticksFrozen: Int
|
||||
get() = entityMetaData.sets.getInt(EntityMetaDataFields.ENTITY_TICKS_FROZEN)
|
||||
|
||||
override fun toString(): String {
|
||||
return entityType.toString()
|
||||
}
|
||||
|
||||
val entityMetaDataAsString: String
|
||||
get() = entityMetaDataFormatted.toString()
|
||||
|
||||
@ -280,6 +283,10 @@ abstract class Entity(
|
||||
return position
|
||||
}
|
||||
|
||||
override val aabb: AABB
|
||||
get() = defaultAABB + position
|
||||
|
||||
|
||||
@Synchronized
|
||||
fun tick() {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
@ -299,10 +306,33 @@ abstract class Entity(
|
||||
}
|
||||
}
|
||||
|
||||
open fun realTick() {}
|
||||
open fun realTick() {
|
||||
if (spawnSprintingParticles) {
|
||||
spawnSprintingParticles()
|
||||
}
|
||||
}
|
||||
|
||||
override val aabb: AABB
|
||||
get() = defaultAABB + position
|
||||
private fun spawnSprintingParticles() {
|
||||
val blockPosition = Vec3i(position.x.floor, (position.y - 0.20000000298023224).floor, position.z.floor)
|
||||
val blockState = connection.world[blockPosition] ?: return
|
||||
|
||||
// ToDo: Don't render particles for invisible blocks
|
||||
|
||||
val velocity = Vec3d(velocity)
|
||||
|
||||
connection.world += BlockDustParticle(
|
||||
connection = connection,
|
||||
position = position + Vec3d.horizontal(
|
||||
{ (random.nextDouble() * 0.5) * dimensions.x },
|
||||
0.1
|
||||
),
|
||||
velocity = Vec3d(velocity.x * -4.0, 1.5, velocity.z * -4.0),
|
||||
data = BlockParticleData(
|
||||
blockState = blockState,
|
||||
type = connection.registries.particleTypeRegistry[BlockDustParticle]!!,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun getEquipmentEnchant(enchantment: Enchantment?): Int {
|
||||
enchantment ?: return 0
|
||||
@ -319,6 +349,10 @@ abstract class Entity(
|
||||
|
||||
open fun setObjectData(data: Int) {}
|
||||
|
||||
override fun toString(): String {
|
||||
return entityType.toString()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val BELOW_POSITION_MINUS = Vec3(0, 0.20000000298023224f, 0)
|
||||
}
|
||||
|
@ -90,6 +90,9 @@ abstract class LivingEntity(connection: PlayConnection, entityType: EntityType,
|
||||
else -> super.pose
|
||||
}
|
||||
|
||||
override val spawnSprintingParticles: Boolean
|
||||
get() = super.spawnSprintingParticles && health > 0.0
|
||||
|
||||
private fun tickStatusEffects() {
|
||||
if (entityEffectParticle == null && ambientEntityEffectParticle == null) {
|
||||
return
|
||||
|
@ -73,6 +73,9 @@ abstract class PlayerEntity(
|
||||
val rightShoulderData: Map<String, Any>?
|
||||
get() = entityMetaData.sets.getNBT(EntityMetaDataFields.PLAYER_RIGHT_SHOULDER_DATA)
|
||||
|
||||
override val spawnSprintingParticles: Boolean
|
||||
get() = super.spawnSprintingParticles && gamemode != Gamemodes.SPECTATOR
|
||||
|
||||
override fun realTick() {
|
||||
if (gamemode == Gamemodes.SPECTATOR) {
|
||||
onGround = false
|
||||
|
@ -187,6 +187,9 @@ class LocalPlayerEntity(
|
||||
return blockModifier
|
||||
}
|
||||
|
||||
override val spawnSprintingParticles: Boolean
|
||||
get() = super.spawnSprintingParticles && !baseAbilities.isFlying
|
||||
|
||||
private fun sendMovementPackets() {
|
||||
if (Minosoft.config.config.game.camera.disableMovementSending) {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user