aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
blob: 4a763c64db8efde0e5073b77c223022bf754202e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use azalea_buf::McBuf;
use azalea_core::Vec3;
use azalea_protocol_macros::ClientboundGamePacket;
use azalea_world::entity::EntityData;
use uuid::Uuid;

/// This packet is sent by the server when a player comes into visible range, not when a player joins.
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundAddPlayerPacket {
    #[var]
    pub id: u32,
    pub uuid: Uuid,
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub x_rot: i8,
    pub y_rot: i8,
}

impl From<&ClientboundAddPlayerPacket> for EntityData {
    fn from(p: &ClientboundAddPlayerPacket) -> Self {
        Self::new(
            p.uuid,
            Vec3 {
                x: p.x,
                y: p.y,
                z: p.z,
            },
        )
    }
}