Skip to main content

steel_protocol/packets/login/
c_login_finished.rs

1use serde::{Deserialize, Serialize};
2use steel_macros::{ClientPacket, WriteTo};
3use steel_registry::packets::login::C_LOGIN_FINISHED;
4use uuid::Uuid;
5
6#[derive(Clone, Debug, WriteTo, Serialize, Deserialize)]
7pub struct GameProfileProperty {
8    #[write(as = Prefixed(VarInt), bound = 16)]
9    pub name: String,
10    #[write(as = Prefixed(VarInt))]
11    pub value: String,
12    #[write(as = Prefixed(VarInt))]
13    pub signature: Option<String>,
14}
15
16#[derive(Clone, Debug, WriteTo, Serialize)]
17pub struct LoginGameProfile<'a> {
18    pub id: Uuid,
19    #[write(as = Prefixed(VarInt), bound = 16)]
20    pub name: &'a str,
21    #[write(as = Prefixed(VarInt))]
22    pub properties: &'a [GameProfileProperty],
23}
24
25#[derive(ClientPacket, WriteTo, Clone, Debug)]
26#[packet_id(Login = C_LOGIN_FINISHED)]
27pub struct CLoginFinished<'a> {
28    pub game_profile: LoginGameProfile<'a>,
29    pub session_id: Uuid,
30}
31
32impl<'a> CLoginFinished<'a> {
33    #[must_use]
34    pub const fn new(game_profile: LoginGameProfile<'a>, session_id: Uuid) -> Self {
35        Self {
36            game_profile,
37            session_id,
38        }
39    }
40}