aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
blob: 2e4500840bbc7ae86c819f82753582d159f7c197 (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
32
use azalea_buf::McBuf;
use azalea_core::EntityPos;
use azalea_entity::Entity;
use packet_macros::ClientboundGamePacket;
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 Entity {
    fn from(p: &ClientboundAddPlayerPacket) -> Self {
        Self::new(
            p.id,
            p.uuid,
            EntityPos {
                x: p.x,
                y: p.y,
                z: p.z,
            },
        )
    }
}