Skip to main content

azalea_protocol/packets/game/
c_move_entity_pos_rot.rs

1use azalea_buf::AzBuf;
2use azalea_core::{delta::PositionDelta8, entity_id::MinecraftEntityId};
3use azalea_entity::LookDirection;
4use azalea_protocol_macros::ClientboundGamePacket;
5
6/// This packet is sent by the server when an entity moves less then 8 blocks.
7#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
8pub struct ClientboundMoveEntityPosRot {
9    #[var]
10    pub entity_id: MinecraftEntityId,
11    pub delta: PositionDelta8,
12    pub look_direction: CompactLookDirection,
13    pub on_ground: bool,
14}
15
16#[derive(AzBuf, Clone, Copy, Debug, PartialEq, Default)]
17pub struct CompactLookDirection {
18    pub y_rot: i8,
19    pub x_rot: i8,
20}
21
22impl From<CompactLookDirection> for LookDirection {
23    fn from(l: CompactLookDirection) -> Self {
24        LookDirection::new(
25            (l.y_rot as i32 * 360) as f32 / 256.,
26            (l.x_rot as i32 * 360) as f32 / 256.,
27        )
28    }
29}