From e9136c9cbbf9010b8352127e129c1cd290f377bd Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:51:12 -0600 Subject: Implement EntityPositionSync (#196) * implement EntityPositionSync * fix EntityPositionSync setting the wrong vec_delta_codec and also move into a RelativeEntityUpdate --- azalea-protocol/src/packets/game/c_entity_position_sync.rs | 11 ++--------- azalea-protocol/src/packets/game/c_player_position.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'azalea-protocol/src') diff --git a/azalea-protocol/src/packets/game/c_entity_position_sync.rs b/azalea-protocol/src/packets/game/c_entity_position_sync.rs index c5cde322..6347ec5e 100755 --- a/azalea-protocol/src/packets/game/c_entity_position_sync.rs +++ b/azalea-protocol/src/packets/game/c_entity_position_sync.rs @@ -1,7 +1,8 @@ use azalea_buf::AzBuf; -use azalea_core::position::Vec3; use azalea_protocol_macros::ClientboundGamePacket; +use super::c_player_position::PositionMoveRotation; + #[derive(Clone, Debug, AzBuf, ClientboundGamePacket)] pub struct ClientboundEntityPositionSync { #[var] @@ -9,11 +10,3 @@ pub struct ClientboundEntityPositionSync { pub values: PositionMoveRotation, pub on_ground: bool, } - -#[derive(AzBuf, Clone, Debug)] -pub struct PositionMoveRotation { - pub position: Vec3, - pub delta_movement: Vec3, - pub y_rot: f32, - pub x_rot: f32, -} diff --git a/azalea-protocol/src/packets/game/c_player_position.rs b/azalea-protocol/src/packets/game/c_player_position.rs index c6a2e3f9..8d19ce36 100755 --- a/azalea-protocol/src/packets/game/c_player_position.rs +++ b/azalea-protocol/src/packets/game/c_player_position.rs @@ -2,6 +2,7 @@ use std::io::{Cursor, Write}; use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError}; use azalea_core::{bitset::FixedBitSet, position::Vec3}; +use azalea_entity::LookDirection; use azalea_protocol_macros::ClientboundGamePacket; #[derive(Clone, Debug, AzBuf, ClientboundGamePacket)] @@ -18,9 +19,12 @@ pub struct ClientboundPlayerPosition { pub struct PositionMoveRotation { pub pos: Vec3, /// The updated delta movement (velocity). + /// + /// This is unused when included in a [`ClientboundEntityPositionSync`]. + /// + /// [`ClientboundEntityPositionSync`]: super::c_entity_position_sync::ClientboundEntityPositionSync pub delta: Vec3, - pub y_rot: f32, - pub x_rot: f32, + pub look_direction: LookDirection, } #[derive(Debug, Clone)] -- cgit v1.2.3