aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-03-18 11:07:31 +0330
committermat <git@matdoes.dev>2026-03-18 11:07:31 +0330
commit9fa09259aa9daa9119d95f4b5634d017c0262596 (patch)
tree4443e0454aedd41ce2f8fb3a941ad3730626e1a4 /azalea-protocol/src/packets/game
parent8b2a9d512bad11be2ea40899e2d834f643fdc2e8 (diff)
downloadazalea-drasl-9fa09259aa9daa9119d95f4b5634d017c0262596.tar.xz
merge logic for the three move_entity packets
Diffstat (limited to 'azalea-protocol/src/packets/game')
-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,
}