aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/src/packets')
-rw-r--r--azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs20
-rw-r--r--azalea-protocol/src/packets/game/c_move_entity_rot.rs7
2 files changed, 21 insertions, 6 deletions
diff --git a/azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs b/azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs
index 047eb638..dffa16c7 100644
--- a/azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs
+++ b/azalea-protocol/src/packets/game/c_move_entity_pos_rot.rs
@@ -1,7 +1,7 @@
use azalea_buf::AzBuf;
-use azalea_core::delta::PositionDelta8;
+use azalea_core::{delta::PositionDelta8, entity_id::MinecraftEntityId};
+use azalea_entity::LookDirection;
use azalea_protocol_macros::ClientboundGamePacket;
-use azalea_core::entity_id::MinecraftEntityId;
/// This packet is sent by the server when an entity moves less then 8 blocks.
#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
@@ -9,7 +9,21 @@ pub struct ClientboundMoveEntityPosRot {
#[var]
pub entity_id: MinecraftEntityId,
pub delta: PositionDelta8,
+ pub look_direction: CompactLookDirection,
+ pub on_ground: bool,
+}
+
+#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Default)]
+pub struct CompactLookDirection {
pub y_rot: i8,
pub x_rot: i8,
- pub on_ground: bool,
+}
+
+impl From<CompactLookDirection> for LookDirection {
+ fn from(l: CompactLookDirection) -> Self {
+ LookDirection::new(
+ (l.y_rot as i32 * 360) as f32 / 256.,
+ (l.x_rot as i32 * 360) as f32 / 256.,
+ )
+ }
}
diff --git a/azalea-protocol/src/packets/game/c_move_entity_rot.rs b/azalea-protocol/src/packets/game/c_move_entity_rot.rs
index 4d0645b3..90ce41bc 100644
--- a/azalea-protocol/src/packets/game/c_move_entity_rot.rs
+++ b/azalea-protocol/src/packets/game/c_move_entity_rot.rs
@@ -1,12 +1,13 @@
use azalea_buf::AzBuf;
-use azalea_protocol_macros::ClientboundGamePacket;
use azalea_core::entity_id::MinecraftEntityId;
+use azalea_protocol_macros::ClientboundGamePacket;
+
+use crate::packets::game::c_move_entity_pos_rot::CompactLookDirection;
#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
pub struct ClientboundMoveEntityRot {
#[var]
pub entity_id: MinecraftEntityId,
- pub y_rot: i8,
- pub x_rot: i8,
+ pub look_direction: CompactLookDirection,
pub on_ground: bool,
}