mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 19:35:00 -04:00
particles: enchant
, nautilus
, witch
, wip stepping
This reduces the warnings in lobbies on hypixel
This commit is contained in:
parent
136702ad8c
commit
df3e645ea9
@ -83,7 +83,8 @@ class CollisionDetector(val connection: PlayConnection) {
|
|||||||
return movement
|
return movement
|
||||||
}
|
}
|
||||||
|
|
||||||
fun collide(physicsEntity: PhysicsEntity?, deltaPosition: Vec3, aabb: AABB, collisionsToCheck: VoxelShape = connection.collisionDetector.getCollisionsToCheck(deltaPosition, aabb)): Vec3 {
|
fun collide(physicsEntity: PhysicsEntity?, deltaPosition: Vec3, aabb: AABB, stepping: Boolean = false, collisionsToCheck: VoxelShape = connection.collisionDetector.getCollisionsToCheck(deltaPosition, aabb)): Vec3 {
|
||||||
|
// ToDo: Check world border collision
|
||||||
val delta = Vec3(deltaPosition)
|
val delta = Vec3(deltaPosition)
|
||||||
if (delta.y != 0.0f) {
|
if (delta.y != 0.0f) {
|
||||||
delta.y = collisionsToCheck.computeOffset(aabb, deltaPosition.y, Axes.Y)
|
delta.y = collisionsToCheck.computeOffset(aabb, deltaPosition.y, Axes.Y)
|
||||||
@ -95,22 +96,33 @@ class CollisionDetector(val connection: PlayConnection) {
|
|||||||
it.onGround = true
|
it.onGround = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aabb += Vec3(0f, delta.y, 0f)
|
aabb += Vec3(0.0f, delta.y, 0.0f)
|
||||||
} else if (delta.y < 0) {
|
} else if (delta.y < 0) {
|
||||||
physicsEntity?.let { it.onGround = false }
|
physicsEntity?.let { it.onGround = false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (false && stepping && (deltaPosition.x != 0.0f || deltaPosition.z != 0.0f)) {
|
||||||
|
val testDelta = Vec3(delta)
|
||||||
|
testDelta.y = PhysicsConstants.STEP_HEIGHT
|
||||||
|
val stepMovementY = collisionsToCheck.computeOffset(aabb + testDelta, -PhysicsConstants.STEP_HEIGHT, Axes.Y)
|
||||||
|
if (stepMovementY < 0.0f && stepMovementY >= -PhysicsConstants.STEP_HEIGHT) {
|
||||||
|
testDelta.y = PhysicsConstants.STEP_HEIGHT + stepMovementY
|
||||||
|
aabb += Vec3(0.0f, testDelta.y, 0.0f)
|
||||||
|
delta.y += testDelta.y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val xPriority = delta.x > delta.z
|
val xPriority = delta.x > delta.z
|
||||||
if (delta.x != 0.0f && xPriority) {
|
if (delta.x != 0.0f && xPriority) {
|
||||||
delta.x = collisionsToCheck.computeOffset(aabb, deltaPosition.x, Axes.X)
|
delta.x = collisionsToCheck.computeOffset(aabb, deltaPosition.x, Axes.X)
|
||||||
aabb += Vec3(delta.x, 0f, 0f)
|
aabb += Vec3(delta.x, 0.0f, 0.0f)
|
||||||
if (delta.x != deltaPosition.x) {
|
if (delta.x != deltaPosition.x) {
|
||||||
physicsEntity?.let { it.velocity.x = 0.0f }
|
physicsEntity?.let { it.velocity.x = 0.0f }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delta.z != 0.0f) {
|
if (delta.z != 0.0f) {
|
||||||
delta.z = collisionsToCheck.computeOffset(aabb, deltaPosition.z, Axes.Z)
|
delta.z = collisionsToCheck.computeOffset(aabb, deltaPosition.z, Axes.Z)
|
||||||
aabb += Vec3(0f, 0f, delta.z)
|
aabb += Vec3(0.0f, 0.0f, delta.z)
|
||||||
if (delta.z != deltaPosition.z) {
|
if (delta.z != deltaPosition.z) {
|
||||||
physicsEntity?.let { it.velocity.z = 0.0f }
|
physicsEntity?.let { it.velocity.z = 0.0f }
|
||||||
}
|
}
|
||||||
@ -122,7 +134,11 @@ class CollisionDetector(val connection: PlayConnection) {
|
|||||||
physicsEntity?.let { it.velocity.x = 0.0f }
|
physicsEntity?.let { it.velocity.x = 0.0f }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delta.length() > deltaPosition.length()) {
|
var length = deltaPosition.length()
|
||||||
|
if (stepping) {
|
||||||
|
length += PhysicsConstants.STEP_HEIGHT
|
||||||
|
}
|
||||||
|
if (delta.length() > length) {
|
||||||
return Vec3.EMPTY // abort all movement if the collision system would move the entity further than wanted
|
return Vec3.EMPTY // abort all movement if the collision system would move the entity further than wanted
|
||||||
}
|
}
|
||||||
return delta
|
return delta
|
||||||
|
@ -21,10 +21,13 @@ import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.Ca
|
|||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.ExplosionParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.ExplosionParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.EnchantedHitParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.damage.EnchantedHitParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant.EnchantParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant.NautilusParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.fire.SmokeParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.fire.SmokeParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.lava.LavaParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.lava.LavaParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell.AmbientEntityEffectParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell.AmbientEntityEffectParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell.EntityEffectParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell.EntityEffectParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell.WitchParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle
|
||||||
|
|
||||||
object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
||||||
@ -40,4 +43,7 @@ object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
|||||||
AmbientEntityEffectParticle,
|
AmbientEntityEffectParticle,
|
||||||
BlockDustParticle,
|
BlockDustParticle,
|
||||||
EnchantedHitParticle,
|
EnchantedHitParticle,
|
||||||
|
WitchParticle,
|
||||||
|
EnchantParticle,
|
||||||
|
NautilusParticle,
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2021 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class EnchantParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : EnchantedGlyphParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
companion object : ParticleFactory<EnchantParticle> {
|
||||||
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:enchant".asResourceLocation()
|
||||||
|
|
||||||
|
override fun build(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData): EnchantParticle {
|
||||||
|
return EnchantParticle(connection, position, velocity, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2021 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.data.text.RGBColor
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.SimpleTextureParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||||
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.assign
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import glm_.pow
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
abstract class EnchantedGlyphParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : SimpleTextureParticle(connection, position, Vec3.EMPTY, data) {
|
||||||
|
private val startPosition = Vec3(position)
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.velocity assign velocity
|
||||||
|
|
||||||
|
super.scale = 0.1f * (random.nextFloat() * 0.5f + 0.2f)
|
||||||
|
|
||||||
|
val colorMultiplier = random.nextFloat() * 0.6f + 0.4f
|
||||||
|
this.color = RGBColor(colorMultiplier * 0.9f, colorMultiplier * 0.9f, colorMultiplier)
|
||||||
|
|
||||||
|
this.physics = false
|
||||||
|
|
||||||
|
this.maxAge = (random.nextFloat() * 10.0f).toInt() + 30
|
||||||
|
movement = false
|
||||||
|
spriteDisabled = true
|
||||||
|
setRandomSprite()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun postTick(deltaTime: Int) {
|
||||||
|
super.postTick(deltaTime)
|
||||||
|
if (dead) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val ageDivisor = 1.0f - floatAge / maxAge
|
||||||
|
val ageDivisor2 = (1.0f - ageDivisor).pow(3)
|
||||||
|
this.position assign (startPosition + velocity * ageDivisor)
|
||||||
|
this.position.y -= ageDivisor2 * 1.2f
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2021 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.enchant
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class NautilusParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : EnchantedGlyphParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
companion object : ParticleFactory<NautilusParticle> {
|
||||||
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:nautilus".asResourceLocation()
|
||||||
|
|
||||||
|
override fun build(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData): NautilusParticle {
|
||||||
|
return NautilusParticle(connection, position, velocity, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2021 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.spell
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.data.text.RGBColor
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class WitchParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : SpellParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
val randomColor = random.nextFloat() * 0.5f + 0.35f
|
||||||
|
color = RGBColor(red = randomColor, green = 0.0f, blue = randomColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : ParticleFactory<WitchParticle> {
|
||||||
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:witch".asResourceLocation()
|
||||||
|
|
||||||
|
override fun build(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData): WitchParticle {
|
||||||
|
return WitchParticle(connection, position, velocity, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -77,9 +77,8 @@ class PositionAndRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
|
|
||||||
if (connection.version.versionId >= ProtocolVersions.V_15W42A) {
|
if (connection.version.versionId >= ProtocolVersions.V_15W42A) {
|
||||||
connection.sendPacket(TeleportConfirmC2SP(teleportId))
|
connection.sendPacket(TeleportConfirmC2SP(teleportId))
|
||||||
} else {
|
|
||||||
connection.sendPacket(PositionAndRotationC2SP(position, rotation, isOnGround))
|
|
||||||
}
|
}
|
||||||
|
connection.sendPacket(PositionAndRotationC2SP(position, rotation, isOnGround))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log() {
|
override fun log() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user