mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
constants improvements
This commit is contained in:
parent
a85ec4c68e
commit
e38f1f1594
@ -357,7 +357,7 @@ abstract class Entity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun spawnSprintingParticles() {
|
private fun spawnSprintingParticles() {
|
||||||
val blockPosition = Vec3i(position.x.floor, (position.y - 0.20000000298023224).floor, position.z.floor)
|
val blockPosition = Vec3i(position.x.floor, (position.y - 0.2).floor, position.z.floor)
|
||||||
val blockState = connection.world[blockPosition] ?: return
|
val blockState = connection.world[blockPosition] ?: return
|
||||||
|
|
||||||
// ToDo: Don't render particles for invisible blocks
|
// ToDo: Don't render particles for invisible blocks
|
||||||
@ -544,9 +544,9 @@ abstract class Entity(
|
|||||||
velocity /= checks
|
velocity /= checks
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abs(this.velocity.x) < 0.003 && abs(this.velocity.z) < 0.003 && velocity.length() < 0.0045000000000000005) {
|
if (abs(this.velocity.x) < 0.003 && abs(this.velocity.z) < 0.003 && velocity.length() < 0.0045) {
|
||||||
velocity.normalizeAssign()
|
velocity.normalizeAssign()
|
||||||
velocity *= 0.0045000000000000005
|
velocity *= 0.0045
|
||||||
}
|
}
|
||||||
|
|
||||||
this.velocity = (this.velocity + velocity)
|
this.velocity = (this.velocity + velocity)
|
||||||
@ -603,6 +603,6 @@ abstract class Entity(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val BELOW_POSITION_MINUS = Vec3(0, 0.20000000298023224f, 0)
|
private val BELOW_POSITION_MINUS = Vec3(0, 0.2f, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ class LocalPlayerEntity(
|
|||||||
velocity.y += (0.05 * (it.amplifier + 1.0f) - velocity.y) * 0.2 // ToDo: This should be correct, but somehow are we to fast...
|
velocity.y += (0.05 * (it.amplifier + 1.0f) - velocity.y) * 0.2 // ToDo: This should be correct, but somehow are we to fast...
|
||||||
} ?: let {
|
} ?: let {
|
||||||
if (connection.world[positionInfo.chunkPosition] == null) {
|
if (connection.world[positionInfo.chunkPosition] == null) {
|
||||||
velocity.y = if (position.y > connection.world.dimension?.minY ?: 0) {
|
velocity.y = if (position.y > (connection.world.dimension?.minY ?: 0)) {
|
||||||
-0.1
|
-0.1
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
@ -393,7 +393,7 @@ class LocalPlayerEntity(
|
|||||||
velocity.y -= gravity
|
velocity.y -= gravity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.velocity = velocity * Vec3d(speedMultiplier, 0.9800000190734863, speedMultiplier)
|
this.velocity = velocity * Vec3d(speedMultiplier, 0.98, speedMultiplier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class LavaFluid(
|
|||||||
val fluidHeight = entity.fluidHeights[DefaultFluids.LAVA] ?: 0.0f
|
val fluidHeight = entity.fluidHeights[DefaultFluids.LAVA] ?: 0.0f
|
||||||
|
|
||||||
if (fluidHeight <= entity.swimHeight) {
|
if (fluidHeight <= entity.swimHeight) {
|
||||||
entity.velocity = entity.velocity * Vec3d(0.5, 0.800000011920929, 0.5)
|
entity.velocity = entity.velocity * Vec3d(0.5, 0.8, 0.5)
|
||||||
entity.velocity = updateMovement(entity, gravity, falling, entity.velocity)
|
entity.velocity = updateMovement(entity, gravity, falling, entity.velocity)
|
||||||
} else {
|
} else {
|
||||||
entity.velocity = entity.velocity * 0.5
|
entity.velocity = entity.velocity * 0.5
|
||||||
|
@ -103,7 +103,7 @@ class WaterFluid(
|
|||||||
if (entity.horizontalCollision && entity.isClimbing) {
|
if (entity.horizontalCollision && entity.isClimbing) {
|
||||||
velocity.y = 0.2
|
velocity.y = 0.2
|
||||||
}
|
}
|
||||||
entity.velocity = velocity * Vec3d(speedMultiplier, 0.800000011920929, speedMultiplier)
|
entity.velocity = velocity * Vec3d(speedMultiplier, 0.8, speedMultiplier)
|
||||||
|
|
||||||
entity.velocity = updateMovement(entity, gravity, falling, entity.velocity)
|
entity.velocity = updateMovement(entity, gravity, falling, entity.velocity)
|
||||||
|
|
||||||
|
@ -38,19 +38,25 @@ class PlayerInventory(connection: PlayConnection) : Container(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getHotbarSlot(hotbarSlot: Int = connection.player.selectedHotbarSlot): ItemStack? {
|
fun getHotbarSlot(hotbarSlot: Int = connection.player.selectedHotbarSlot): ItemStack? {
|
||||||
check(hotbarSlot in 0..9) { "Hotbar slot out of bounds!" }
|
check(hotbarSlot in 0..HOTBAR_SLOTS) { "Hotbar slot out of bounds!" }
|
||||||
return slots[hotbarSlot + 36] // ToDo
|
return slots[hotbarSlot + HOTBAR_OFFSET] // ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(slot: InventorySlots.EquipmentSlots): ItemStack? {
|
operator fun get(slot: InventorySlots.EquipmentSlots): ItemStack? {
|
||||||
return this[when (slot) {
|
return this[when (slot) {
|
||||||
InventorySlots.EquipmentSlots.HEAD -> 5
|
InventorySlots.EquipmentSlots.HEAD -> ARMOR_OFFSET + 0
|
||||||
InventorySlots.EquipmentSlots.CHEST -> 6
|
InventorySlots.EquipmentSlots.CHEST -> ARMOR_OFFSET + 1
|
||||||
InventorySlots.EquipmentSlots.LEGS -> 7
|
InventorySlots.EquipmentSlots.LEGS -> ARMOR_OFFSET + 2
|
||||||
InventorySlots.EquipmentSlots.FEET -> 8
|
InventorySlots.EquipmentSlots.FEET -> ARMOR_OFFSET + 3
|
||||||
|
|
||||||
InventorySlots.EquipmentSlots.MAIN_HAND -> connection.player.selectedHotbarSlot + 36
|
InventorySlots.EquipmentSlots.MAIN_HAND -> connection.player.selectedHotbarSlot + HOTBAR_OFFSET
|
||||||
InventorySlots.EquipmentSlots.OFF_HAND -> 45
|
InventorySlots.EquipmentSlots.OFF_HAND -> 45
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val HOTBAR_OFFSET = 36
|
||||||
|
private const val ARMOR_OFFSET = 5
|
||||||
|
const val HOTBAR_SLOTS = 9
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,11 @@ abstract class Particle(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
this.velocity += { (random.nextDouble() * 2.0 - 1.0) * MAGIC_VELOCITY_CONSTANT }
|
this.velocity += { (random.nextDouble() * 2.0 - 1.0) * MAGIC_VELOCITY_CONSTANT }
|
||||||
val modifier = (random.nextFloat() + random.nextFloat() + 1.0f) * 0.15000000596046448
|
val modifier = (random.nextFloat() + random.nextFloat() + 1.0f) * 0.15
|
||||||
val divider = this.velocity.length()
|
val divider = this.velocity.length()
|
||||||
|
|
||||||
this.velocity assign this.velocity / divider * modifier * MAGIC_VELOCITY_CONSTANTf
|
this.velocity assign this.velocity / divider * modifier * MAGIC_VELOCITY_CONSTANTf
|
||||||
this.velocity.y += 0.10000000149011612
|
this.velocity.y += 0.1
|
||||||
|
|
||||||
spacing = Vec3(0.2)
|
spacing = Vec3(0.2)
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ abstract class Particle(
|
|||||||
abstract fun addVertex(transparentMesh: ParticleMesh, particleMesh: ParticleMesh)
|
abstract fun addVertex(transparentMesh: ParticleMesh, particleMesh: ParticleMesh)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MAGIC_VELOCITY_CONSTANT = 0.4000000059604645
|
private const val MAGIC_VELOCITY_CONSTANT = 0.4
|
||||||
private const val MAGIC_VELOCITY_CONSTANTf = MAGIC_VELOCITY_CONSTANT.toFloat()
|
private const val MAGIC_VELOCITY_CONSTANTf = MAGIC_VELOCITY_CONSTANT.toFloat()
|
||||||
private const val Y_VELOCITY_TO_CHECK = 9.999999747378752E-6f
|
private const val Y_VELOCITY_TO_CHECK = 9.999999747378752E-6f
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@ open class CloudParticle(connection: PlayConnection, position: Vec3d, velocity:
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
friction = 0.96f
|
friction = 0.96f
|
||||||
this.velocity *= 0.10000000149011612
|
this.velocity *= 0.1
|
||||||
this.velocity += velocity
|
this.velocity += velocity
|
||||||
|
|
||||||
this.color = (1.0f - random.nextFloat() * 0.30000001192092896f).asGray()
|
this.color = (1.0f - random.nextFloat() * 0.3).asGray()
|
||||||
|
|
||||||
super.scale *= 1.875f
|
super.scale *= 1.875f
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ abstract class DamageParticle(connection: PlayConnection, position: Vec3d, veloc
|
|||||||
init {
|
init {
|
||||||
friction = 0.7f
|
friction = 0.7f
|
||||||
gravityStrength = 0.5f
|
gravityStrength = 0.5f
|
||||||
this.velocity *= 0.10000000149011612
|
this.velocity *= 0.1
|
||||||
this.velocity += velocity * 0.4f
|
this.velocity += velocity * 0.4f
|
||||||
color = (random.nextFloat() * 0.30000001192092896f + 0.6000000238418579f).asGray()
|
color = (random.nextFloat() * 0.3 + 0.6).asGray()
|
||||||
super.scale *= 0.75f
|
super.scale *= 0.75f
|
||||||
maxAge = (6.0f / (random.nextFloat() * 0.8f + 0.6f)).toInt().coerceAtLeast(1)
|
maxAge = (6.0f / (random.nextFloat() * 0.8f + 0.6f)).toInt().coerceAtLeast(1)
|
||||||
physics = false
|
physics = false
|
||||||
|
@ -30,7 +30,7 @@ abstract class AbstractDustParticle(connection: PlayConnection, position: Vec3d,
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
this.friction = 0.96f
|
this.friction = 0.96f
|
||||||
this.velocity *= 0.10000000149011612f
|
this.velocity *= 0.1f
|
||||||
|
|
||||||
val brightness = random.nextFloat() * 0.4f + 0.6f
|
val brightness = random.nextFloat() * 0.4f + 0.6f
|
||||||
this.color = RGBColor(
|
this.color = RGBColor(
|
||||||
|
@ -35,9 +35,9 @@ class LavaParticle(connection: PlayConnection, position: Vec3d, data: ParticleDa
|
|||||||
init {
|
init {
|
||||||
gravityStrength = 0.75f
|
gravityStrength = 0.75f
|
||||||
friction = 0.999f
|
friction = 0.999f
|
||||||
velocity.x *= 0.800000011920929
|
velocity.x *= 0.8
|
||||||
velocity.y = random.nextDouble() * 0.4f + 0.05f
|
velocity.y = random.nextDouble() * 0.4f + 0.05f
|
||||||
velocity.z *= 0.800000011920929
|
velocity.z *= 0.8
|
||||||
scale *= random.nextFloat() * 2.0f + 0.2f
|
scale *= random.nextFloat() * 2.0f + 0.2f
|
||||||
maxAge = (16.0f / (random.nextFloat() * 0.8f + 0.2f)).toInt()
|
maxAge = (16.0f / (random.nextFloat() * 0.8f + 0.2f)).toInt()
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ abstract class SpellParticle(connection: PlayConnection, position: Vec3d, veloci
|
|||||||
friction = 0.96f
|
friction = 0.96f
|
||||||
gravityStrength = -0.1f
|
gravityStrength = -0.1f
|
||||||
accelerateIfYBlocked = true
|
accelerateIfYBlocked = true
|
||||||
this.velocity.y *= 0.20000000298023224
|
this.velocity.y *= 0.2
|
||||||
if (velocity.x == 0.0 && velocity.z == 0.0) {
|
if (velocity.x == 0.0 && velocity.z == 0.0) {
|
||||||
this.velocity.x *= 0.10000000149011612
|
this.velocity.x *= 0.1
|
||||||
this.velocity.z *= 0.10000000149011612
|
this.velocity.z *= 0.1
|
||||||
}
|
}
|
||||||
super.scale *= 0.75f
|
super.scale *= 0.75f
|
||||||
maxAge = (8.0f / (random.nextFloat() * 0.8f + 0.2f)).toInt()
|
maxAge = (8.0f / (random.nextFloat() * 0.8f + 0.2f)).toInt()
|
||||||
|
@ -32,7 +32,7 @@ class BubbleParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3
|
|||||||
|
|
||||||
this.scale *= random.nextFloat() * 0.6f + 0.2f
|
this.scale *= random.nextFloat() * 0.6f + 0.2f
|
||||||
|
|
||||||
this.velocity assign (velocity * 0.20000000298023224) + (Vec3d.of { random.nextDouble() * 2.0 - 1.0 } * 0.019999999552965164)
|
this.velocity assign (velocity * 0.2) + (Vec3d.of { random.nextDouble() * 2.0 - 1.0 } * 0.02)
|
||||||
this.maxAge = (8.0f / random.nextFloat() * 0.8f + 0.2f).toInt()
|
this.maxAge = (8.0f / random.nextFloat() * 0.8f + 0.2f).toInt()
|
||||||
|
|
||||||
movement = false
|
movement = false
|
||||||
@ -45,7 +45,7 @@ class BubbleParticle(connection: PlayConnection, position: Vec3d, velocity: Vec3
|
|||||||
}
|
}
|
||||||
this.velocity.y += 0.002
|
this.velocity.y += 0.002
|
||||||
forceMove(velocity)
|
forceMove(velocity)
|
||||||
velocity *= 0.8500000238418579
|
velocity *= 0.85
|
||||||
|
|
||||||
// ToDo: Check if in water: Kill particle
|
// ToDo: Check if in water: Kill particle
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.bixilon.minosoft.protocol.packets.s2c.play
|
package de.bixilon.minosoft.protocol.packets.s2c.play
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.other.containers.PlayerInventory
|
||||||
import de.bixilon.minosoft.modding.event.events.SelectHotbarSlotEvent
|
import de.bixilon.minosoft.modding.event.events.SelectHotbarSlotEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||||
@ -23,12 +24,18 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
class HotbarSlotSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||||
val slot: Int = buffer.readUnsignedByte()
|
val slot: Int = buffer.readUnsignedByte()
|
||||||
|
|
||||||
|
|
||||||
|
override fun check(connection: PlayConnection) {
|
||||||
|
check(slot in 0..PlayerInventory.HOTBAR_SLOTS)
|
||||||
|
}
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
connection.fireEvent(SelectHotbarSlotEvent(connection, this))
|
connection.fireEvent(SelectHotbarSlotEvent(connection, this))
|
||||||
|
|
||||||
connection.player.selectedHotbarSlot = slot
|
connection.player.selectedHotbarSlot = slot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun log() {
|
override fun log() {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Hotbar slot set (slot=$slot)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Hotbar slot set (slot=$slot)" }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user