mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
store entity rotation as float
This commit is contained in:
parent
2aa261acae
commit
cbfa644a31
@ -23,7 +23,7 @@ class PitchRotation(
|
|||||||
override val range: FloatRange,
|
override val range: FloatRange,
|
||||||
) : RotationProperty {
|
) : RotationProperty {
|
||||||
|
|
||||||
override fun getValue(rotation: EntityRotation): Double {
|
override fun getValue(rotation: EntityRotation): Float {
|
||||||
return rotation.pitch
|
return rotation.pitch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ import de.bixilon.minosoft.data.entities.entities.Entity
|
|||||||
interface RotationProperty : EntityTargetProperty {
|
interface RotationProperty : EntityTargetProperty {
|
||||||
val range: FloatRange
|
val range: FloatRange
|
||||||
|
|
||||||
fun getValue(rotation: EntityRotation): Double
|
fun getValue(rotation: EntityRotation): Float
|
||||||
|
|
||||||
|
|
||||||
override fun passes(properties: EntitySelectorProperties, entity: Entity): Boolean {
|
override fun passes(properties: EntitySelectorProperties, entity: Entity): Boolean {
|
||||||
val rotation = getValue(entity.rotation)
|
val rotation = getValue(entity.rotation)
|
||||||
|
|
||||||
return rotation.toFloat() in range
|
return rotation in range
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class YawRotation(
|
|||||||
override val range: FloatRange,
|
override val range: FloatRange,
|
||||||
) : RotationProperty {
|
) : RotationProperty {
|
||||||
|
|
||||||
override fun getValue(rotation: EntityRotation): Double {
|
override fun getValue(rotation: EntityRotation): Float {
|
||||||
return rotation.yaw
|
return rotation.yaw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ import de.bixilon.kotlinglm.func.sin
|
|||||||
import de.bixilon.kotlinglm.vec3.Vec3
|
import de.bixilon.kotlinglm.vec3.Vec3
|
||||||
|
|
||||||
data class EntityRotation(
|
data class EntityRotation(
|
||||||
val yaw: Double,
|
val yaw: Float,
|
||||||
val pitch: Double,
|
val pitch: Float,
|
||||||
) {
|
) {
|
||||||
val front: Vec3
|
val front: Vec3
|
||||||
get() = Vec3(
|
get() = Vec3(
|
||||||
@ -28,13 +28,12 @@ data class EntityRotation(
|
|||||||
(yaw + 90).rad.sin * (-pitch).rad.cos
|
(yaw + 90).rad.sin * (-pitch).rad.cos
|
||||||
).normalize()
|
).normalize()
|
||||||
|
|
||||||
constructor(bodyYaw: Float, pitch: Float) : this(bodyYaw.toDouble(), pitch.toDouble())
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "(yaw=$yaw, pitch=$pitch)"
|
return "(yaw=$yaw, pitch=$pitch)"
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val EMPTY = EntityRotation(0.0, 0.0)
|
val EMPTY = EntityRotation(0.0f, 0.0f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,8 @@ abstract class Entity(
|
|||||||
_attachedEntity = vehicleId
|
_attachedEntity = vehicleId
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRotation(yaw: Int, pitch: Int) {
|
fun forceSetRotation(rotation: EntityRotation) {
|
||||||
rotation = EntityRotation(yaw.toDouble(), pitch.toDouble())
|
this.rotation = rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setHeadRotation(headYaw: Int) {
|
fun setHeadRotation(headYaw: Int) {
|
||||||
|
@ -127,7 +127,7 @@ abstract class LivingEntity(connection: PlayConnection, entityType: EntityType,
|
|||||||
tickStatusEffects()
|
tickStatusEffects()
|
||||||
|
|
||||||
if (isSleeping) {
|
if (isSleeping) {
|
||||||
rotation = rotation.copy(pitch = 0.0)
|
rotation = rotation.copy(pitch = 0.0f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ abstract class PlayerEntity(
|
|||||||
entityType: EntityType,
|
entityType: EntityType,
|
||||||
data: EntityData,
|
data: EntityData,
|
||||||
position: Vec3d = Vec3d.EMPTY,
|
position: Vec3d = Vec3d.EMPTY,
|
||||||
rotation: EntityRotation = EntityRotation(0.0, 0.0),
|
rotation: EntityRotation = EntityRotation.EMPTY,
|
||||||
name: String = "",
|
name: String = "",
|
||||||
properties: PlayerProperties? = null,
|
properties: PlayerProperties? = null,
|
||||||
val additional: PlayerAdditional = PlayerAdditional(name = name, properties = properties),
|
val additional: PlayerAdditional = PlayerAdditional(name = name, properties = properties),
|
||||||
|
@ -30,7 +30,7 @@ class RemotePlayerEntity(
|
|||||||
entityType: EntityType,
|
entityType: EntityType,
|
||||||
data: EntityData,
|
data: EntityData,
|
||||||
position: Vec3d = Vec3d.EMPTY,
|
position: Vec3d = Vec3d.EMPTY,
|
||||||
rotation: EntityRotation = EntityRotation(0.0, 0.0),
|
rotation: EntityRotation = EntityRotation.EMPTY,
|
||||||
name: String = "TBA",
|
name: String = "TBA",
|
||||||
properties: PlayerProperties? = null,
|
properties: PlayerProperties? = null,
|
||||||
tabListItem: PlayerAdditional = PlayerAdditional(name = name, gamemode = Gamemodes.SURVIVAL, properties = properties),
|
tabListItem: PlayerAdditional = PlayerAdditional(name = name, gamemode = Gamemodes.SURVIVAL, properties = properties),
|
||||||
|
@ -85,7 +85,7 @@ class LocalPlayerEntity(
|
|||||||
account: Account,
|
account: Account,
|
||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
val privateKey: PlayerPrivateKey?,
|
val privateKey: PlayerPrivateKey?,
|
||||||
) : PlayerEntity(connection, connection.registries.entityTypeRegistry[RemotePlayerEntity.RESOURCE_LOCATION]!!, EntityData(connection), Vec3d.EMPTY, EntityRotation(0.0, 0.0), account.username, account.properties) {
|
) : PlayerEntity(connection, connection.registries.entityTypeRegistry[RemotePlayerEntity.RESOURCE_LOCATION]!!, EntityData(connection), Vec3d.EMPTY, EntityRotation.EMPTY, account.username, account.properties) {
|
||||||
var healthCondition by observed(HealthCondition())
|
var healthCondition by observed(HealthCondition())
|
||||||
var experienceCondition by observed(ExperienceCondition())
|
var experienceCondition by observed(ExperienceCondition())
|
||||||
var compass by observed(CompassPosition())
|
var compass by observed(CompassPosition())
|
||||||
@ -117,7 +117,7 @@ class LocalPlayerEntity(
|
|||||||
// last state (for updating movement on server)
|
// last state (for updating movement on server)
|
||||||
private var lastPositionPacketSent = -1L
|
private var lastPositionPacketSent = -1L
|
||||||
private var lastSentPosition = Vec3d.EMPTY
|
private var lastSentPosition = Vec3d.EMPTY
|
||||||
private var lastRotation = EntityRotation(0.0, 0.0)
|
private var lastRotation = EntityRotation.EMPTY
|
||||||
private var lastSprinting = false
|
private var lastSprinting = false
|
||||||
private var lastSneaking = false
|
private var lastSneaking = false
|
||||||
private var lastOnGround = false
|
private var lastOnGround = false
|
||||||
@ -269,7 +269,7 @@ class LocalPlayerEntity(
|
|||||||
val rotation = rotation.copy()
|
val rotation = rotation.copy()
|
||||||
val yawDiff = rotation.yaw - lastRotation.yaw
|
val yawDiff = rotation.yaw - lastRotation.yaw
|
||||||
val pitchDiff = rotation.pitch - lastRotation.pitch
|
val pitchDiff = rotation.pitch - lastRotation.pitch
|
||||||
val rotationChanged = yawDiff != 0.0 && pitchDiff != 0.0
|
val rotationChanged = yawDiff != 0.0f && pitchDiff != 0.0f
|
||||||
|
|
||||||
val onGround = onGround
|
val onGround = onGround
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ class LocalPlayerEntity(
|
|||||||
return flyingSpeed
|
return flyingSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateVelocity(sidewaysSpeed: Float, forwardSpeed: Float, speed: Double, yaw: Double): Vec3d {
|
private fun calculateVelocity(sidewaysSpeed: Float, forwardSpeed: Float, speed: Double, yaw: Float): Vec3d {
|
||||||
if (sidewaysSpeed == 0.0f && forwardSpeed == 0.0f) {
|
if (sidewaysSpeed == 0.0f && forwardSpeed == 0.0f) {
|
||||||
return Vec3d.EMPTY
|
return Vec3d.EMPTY
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
|
|||||||
import de.bixilon.kotlinglm.vec4.Vec4i
|
import de.bixilon.kotlinglm.vec4.Vec4i
|
||||||
import de.bixilon.kutil.concurrent.Reference
|
import de.bixilon.kutil.concurrent.Reference
|
||||||
import de.bixilon.kutil.math.simple.DoubleMath.rounded10
|
import de.bixilon.kutil.math.simple.DoubleMath.rounded10
|
||||||
|
import de.bixilon.kutil.math.simple.FloatMath.rounded10
|
||||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||||
import de.bixilon.kutil.string.StringUtil.truncate
|
import de.bixilon.kutil.string.StringUtil.truncate
|
||||||
import de.bixilon.kutil.unit.UnitFormatter.formatBytes
|
import de.bixilon.kutil.unit.UnitFormatter.formatBytes
|
||||||
|
@ -107,7 +107,7 @@ class CameraInput(
|
|||||||
}
|
}
|
||||||
yaw %= 180
|
yaw %= 180
|
||||||
val pitch = GLM.clamp(delta.y + rotation.pitch, -89.9, 89.9)
|
val pitch = GLM.clamp(delta.y + rotation.pitch, -89.9, 89.9)
|
||||||
return EntityRotation(yaw, pitch)
|
return EntityRotation(yaw.toFloat(), pitch.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play.entity
|
package de.bixilon.minosoft.protocol.packets.s2c.play.entity
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
|
||||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||||
import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
|
import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
|
||||||
import de.bixilon.minosoft.data.entities.entities.player.RemotePlayerEntity
|
import de.bixilon.minosoft.data.entities.entities.player.RemotePlayerEntity
|
||||||
@ -51,8 +50,7 @@ class EntityPlayerS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
val position: Vec3d = buffer.readVec3d()
|
val position: Vec3d = buffer.readVec3d()
|
||||||
|
|
||||||
val yaw = buffer.readAngle()
|
val rotation = buffer.readEntityRotation()
|
||||||
val pitch = buffer.readAngle()
|
|
||||||
if (buffer.versionId < ProtocolVersions.V_15W31A) {
|
if (buffer.versionId < ProtocolVersions.V_15W31A) {
|
||||||
buffer.connection.registries.itemRegistry[buffer.readUnsignedShort()] // current item
|
buffer.connection.registries.itemRegistry[buffer.readUnsignedShort()] // current item
|
||||||
}
|
}
|
||||||
@ -66,7 +64,7 @@ class EntityPlayerS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
entityType = buffer.connection.registries.entityTypeRegistry[RemotePlayerEntity.RESOURCE_LOCATION]!!,
|
entityType = buffer.connection.registries.entityTypeRegistry[RemotePlayerEntity.RESOURCE_LOCATION]!!,
|
||||||
data = EntityData(buffer.connection, data),
|
data = EntityData(buffer.connection, data),
|
||||||
position = position,
|
position = position,
|
||||||
rotation = EntityRotation(yaw.toDouble(), pitch.toDouble()),
|
rotation = rotation,
|
||||||
name = name,
|
name = name,
|
||||||
properties = properties,
|
properties = properties,
|
||||||
)
|
)
|
||||||
|
@ -26,8 +26,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
class MovementRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class MovementRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
var delta: Vec3d = buffer.readPositionDelta()
|
var delta: Vec3d = buffer.readPositionDelta()
|
||||||
val yaw: Int = buffer.readAngle()
|
val rotation = buffer.readEntityRotation()
|
||||||
val pitch: Int = buffer.readAngle()
|
|
||||||
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
||||||
buffer.readBoolean()
|
buffer.readBoolean()
|
||||||
} else {
|
} else {
|
||||||
@ -37,13 +36,13 @@ class MovementRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
val entity = connection.world.entities[entityId] ?: return
|
val entity = connection.world.entities[entityId] ?: return
|
||||||
entity.forceMove(delta)
|
entity.forceMove(delta)
|
||||||
entity.setRotation(yaw, pitch)
|
entity.forceSetRotation(rotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
if (reducedLog) {
|
if (reducedLog) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity movement + rotate (entityId=$entityId, delta=$delta, yaw=$yaw, pitch=$pitch, onGround=$onGround)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity movement + rotate (entityId=$entityId, delta=$delta, rotation=$rotation, onGround=$onGround)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
|
|
||||||
@LoadPacket(threadSafe = false)
|
@LoadPacket(threadSafe = false)
|
||||||
class PositionRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class PositionRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position: Vec3d
|
val position: Vec3d = buffer.readVec3d()
|
||||||
val rotation: EntityRotation
|
val rotation: EntityRotation
|
||||||
var isOnGround = false
|
var isOnGround = false
|
||||||
private var flags: Int = 0
|
private var flags: Int = 0
|
||||||
@ -37,7 +37,6 @@ class PositionRotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
private var dismountVehicle = true
|
private var dismountVehicle = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
position = buffer.readVec3d()
|
|
||||||
rotation = EntityRotation(buffer.readFloat(), buffer.readFloat())
|
rotation = EntityRotation(buffer.readFloat(), buffer.readFloat())
|
||||||
if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
if (buffer.versionId < ProtocolVersions.V_14W03B) {
|
||||||
isOnGround = buffer.readBoolean()
|
isOnGround = buffer.readBoolean()
|
||||||
|
@ -24,8 +24,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
@LoadPacket
|
@LoadPacket
|
||||||
class RotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class RotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val entityId: Int = buffer.readEntityId()
|
val entityId: Int = buffer.readEntityId()
|
||||||
val yaw: Int = buffer.readAngle()
|
val rotation = buffer.readEntityRotation()
|
||||||
val pitch: Int = buffer.readAngle()
|
|
||||||
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
||||||
buffer.readBoolean()
|
buffer.readBoolean()
|
||||||
} else {
|
} else {
|
||||||
@ -34,13 +33,13 @@ class RotationS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
val entity = connection.world.entities[entityId] ?: return
|
val entity = connection.world.entities[entityId] ?: return
|
||||||
entity.setRotation(yaw, pitch)
|
entity.forceSetRotation(rotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
if (reducedLog) {
|
if (reducedLog) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity rotation (entityId=$entityId, yaw=$yaw, pitch=$pitch, onGround=$onGround)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity rotation (entityId=$entityId, rotation=$rotation, onGround=$onGround)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,7 @@ class TeleportS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
} else {
|
} else {
|
||||||
buffer.readVec3d()
|
buffer.readVec3d()
|
||||||
}
|
}
|
||||||
val yaw: Int = buffer.readAngle()
|
val rotation = buffer.readEntityRotation()
|
||||||
val pitch: Int = buffer.readAngle()
|
|
||||||
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
val onGround = if (buffer.versionId >= ProtocolVersions.V_14W25B) {
|
||||||
buffer.readBoolean()
|
buffer.readBoolean()
|
||||||
} else {
|
} else {
|
||||||
@ -41,13 +40,13 @@ class TeleportS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
val entity = connection.world.entities[entityId] ?: return
|
val entity = connection.world.entities[entityId] ?: return
|
||||||
entity.position = position
|
entity.position = position
|
||||||
entity.setRotation(yaw, pitch)
|
entity.forceSetRotation(rotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun log(reducedLog: Boolean) {
|
override fun log(reducedLog: Boolean) {
|
||||||
if (reducedLog) {
|
if (reducedLog) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity teleport (entityId=$entityId, position=$position, yaw=$yaw, pitch=$pitch, onGround=$onGround)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Entity teleport (entityId=$entityId, position=$position, rotation=$rotation, onGround=$onGround)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn
|
package de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
|
||||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||||
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
||||||
@ -45,7 +44,7 @@ class EntityMobSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
buffer.readVarInt()
|
buffer.readVarInt()
|
||||||
}
|
}
|
||||||
val position: Vec3d = buffer.readVec3d()
|
val position: Vec3d = buffer.readVec3d()
|
||||||
val rotation = EntityRotation(buffer.readAngle().toDouble(), buffer.readAngle().toDouble())
|
val rotation = buffer.readEntityRotation()
|
||||||
val headYaw = buffer.readAngle()
|
val headYaw = buffer.readAngle()
|
||||||
val velocity = buffer.readVelocity()
|
val velocity = buffer.readVelocity()
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn
|
package de.bixilon.minosoft.protocol.packets.s2c.play.entity.spawn
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||||
import de.bixilon.minosoft.data.entities.EntityRotation
|
|
||||||
import de.bixilon.minosoft.data.entities.entities.Entity
|
import de.bixilon.minosoft.data.entities.entities.Entity
|
||||||
import de.bixilon.minosoft.data.registries.DefaultRegistries.ENTITY_OBJECT_REGISTRY
|
import de.bixilon.minosoft.data.registries.DefaultRegistries.ENTITY_OBJECT_REGISTRY
|
||||||
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
||||||
@ -46,7 +45,7 @@ class EntityObjectSpawnS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
buffer.readVarInt()
|
buffer.readVarInt()
|
||||||
}
|
}
|
||||||
val position: Vec3d = buffer.readVec3d()
|
val position: Vec3d = buffer.readVec3d()
|
||||||
val rotation = EntityRotation(buffer.readAngle().toDouble(), buffer.readAngle().toDouble()) // ToDo: Is yaw/pitch swapped?
|
val rotation = buffer.readEntityRotation() // ToDo: Is yaw/pitch swapped?
|
||||||
if (buffer.versionId >= ProtocolVersions.V_22W14A) {
|
if (buffer.versionId >= ProtocolVersions.V_22W14A) {
|
||||||
val headYaw = buffer.readAngle()
|
val headYaw = buffer.readAngle()
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
|||||||
import de.bixilon.kutil.compression.zlib.GzipUtil.decompress
|
import de.bixilon.kutil.compression.zlib.GzipUtil.decompress
|
||||||
import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
||||||
import de.bixilon.minosoft.data.direction.Directions
|
import de.bixilon.minosoft.data.direction.Directions
|
||||||
|
import de.bixilon.minosoft.data.entities.EntityRotation
|
||||||
import de.bixilon.minosoft.data.entities.Poses
|
import de.bixilon.minosoft.data.entities.Poses
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.tags.Tag
|
import de.bixilon.minosoft.data.tags.Tag
|
||||||
@ -283,6 +284,10 @@ open class InByteBuffer {
|
|||||||
return (readByte() * ProtocolDefinition.ROTATION_ANGLE_DIVIDER).toInt()
|
return (readByte() * ProtocolDefinition.ROTATION_ANGLE_DIVIDER).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun readEntityRotation(): EntityRotation {
|
||||||
|
return EntityRotation(readAngle().toFloat(), readAngle().toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
fun readVec2f(): Vec2 {
|
fun readVec2f(): Vec2 {
|
||||||
return Vec2(readFloat(), readFloat())
|
return Vec2(readFloat(), readFloat())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user