azalea_protocol/packets/game/
c_entity_position_sync.rs1use azalea_buf::AzBuf;
2use azalea_core::{entity_id::MinecraftEntityId, position::Vec3};
3use azalea_entity::LookDirection;
4use azalea_protocol_macros::ClientboundGamePacket;
5use tracing::warn;
6
7#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
8pub struct ClientboundEntityPositionSync {
9 #[var]
10 pub id: MinecraftEntityId,
11 pub position: PositionPath,
12 pub look_direction: LookDirection,
13 pub on_ground: bool,
14}
15
16#[derive(AzBuf, Clone, Debug, PartialEq)]
17pub enum PositionPath {
18 Linear(Vec3),
19 Stepped(Vec<PositionStep>),
22}
23#[derive(AzBuf, Clone, Debug, PartialEq)]
24pub struct PositionStep {
25 pub pos: Vec3,
26 #[var]
27 pub tick_offset: i32,
28}
29impl PositionPath {
30 pub fn end_position(&self) -> Vec3 {
31 match self {
32 PositionPath::Linear(v) => *v,
33 PositionPath::Stepped(v) => match v.last() {
34 Some(v) => v.pos,
35 None => {
36 warn!("called end_position on a stepped PositionPath with no steps");
37 Vec3::default()
38 }
39 },
40 }
41 }
42}