Skip to main content

ghast_protocol/generated/defs/p775/login/
serverbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/26.1/protocol.json). Do not edit; run `cargo run -p ghast-codegen-protocol`.
3// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
4// in crates/ghast-protocol/src/generated/.
5
6//! Serverbound packets of the login state.
7
8#![allow(
9    unused_imports,
10    unused_variables,
11    unused_mut,
12    unused_parens,
13    unused_braces,
14    clippy::all,
15    clippy::pedantic,
16    non_camel_case_types,
17    non_snake_case
18)]
19use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
20use crate::error::{DecodeError, EncodeError};
21use crate::nbt::{AnonNbt, RawNbt};
22use crate::packet::{Direction, PacketSet, RawPacket, State};
23#[cfg(feature = "testgen")]
24use crate::testgen::{Gen, Generate};
25use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[cfg(feature = "v26_1")]
29/// `login_start` (serverbound login).
30#[derive(Debug, Clone, PartialEq)]
31pub struct LoginStart<const V: i32> {
32    /// `username`
33    pub username: ByteString,
34    /// `playerUUID`
35    pub player_uuid: Uuid,
36}
37#[cfg(feature = "v26_1")]
38impl<const V: i32> Decode for LoginStart<V> {
39    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
40        Ok({
41            let v1 = r.read_string()?;
42            let v2 = r.read_uuid()?;
43            Self {
44                username: v1,
45                player_uuid: v2,
46            }
47        })
48    }
49}
50#[cfg(feature = "v26_1")]
51impl<const V: i32> Encode for LoginStart<V> {
52    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
53        w.put_string(&(*self).username)?;
54        w.put_uuid(&(*self).player_uuid);
55        Ok(())
56    }
57}
58#[cfg(feature = "v26_1")]
59#[cfg(feature = "testgen")]
60impl<const V: i32> Generate for LoginStart<V> {
61    fn generate(g: &mut Gen) -> Self {
62        {
63            let v1 = g.string();
64            let v2 = g.uuid();
65            Self {
66                username: v1,
67                player_uuid: v2,
68            }
69        }
70    }
71}
72
73#[cfg(feature = "v26_1")]
74/// `login_acknowledged` (serverbound login).
75#[derive(Debug, Clone, PartialEq)]
76pub struct LoginAcknowledged<const V: i32> {}
77#[cfg(feature = "v26_1")]
78impl<const V: i32> Decode for LoginAcknowledged<V> {
79    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
80        Ok({ Self {} })
81    }
82}
83#[cfg(feature = "v26_1")]
84impl<const V: i32> Encode for LoginAcknowledged<V> {
85    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
86        Ok(())
87    }
88}
89#[cfg(feature = "v26_1")]
90#[cfg(feature = "testgen")]
91impl<const V: i32> Generate for LoginAcknowledged<V> {
92    fn generate(g: &mut Gen) -> Self {
93        { Self {} }
94    }
95}
96
97#[cfg(feature = "v26_1")]
98/// `cookie_response` (serverbound login).
99#[derive(Debug, Clone, PartialEq)]
100pub struct CookieResponse<const V: i32> {
101    /// `key`
102    pub key: ByteString,
103    /// `value`
104    pub value: Option<Bytes>,
105}
106#[cfg(feature = "v26_1")]
107impl<const V: i32> Decode for CookieResponse<V> {
108    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
109        Ok({
110            let v1 = r.read_string()?;
111            let v2 = if r.read_bool()? {
112                Some(r.read_byte_array()?)
113            } else {
114                None
115            };
116            Self { key: v1, value: v2 }
117        })
118    }
119}
120#[cfg(feature = "v26_1")]
121impl<const V: i32> Encode for CookieResponse<V> {
122    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
123        w.put_string(&(*self).key)?;
124        match &(*self).value {
125            Some(v1) => {
126                w.put_u8(1);
127                w.put_byte_array(&(*v1))?;
128            }
129            None => w.put_u8(0),
130        }
131        Ok(())
132    }
133}
134#[cfg(feature = "v26_1")]
135#[cfg(feature = "testgen")]
136impl<const V: i32> Generate for CookieResponse<V> {
137    fn generate(g: &mut Gen) -> Self {
138        {
139            let v1 = g.string();
140            let v2 = if g.bool() { Some(g.bytes()) } else { None };
141            Self { key: v1, value: v2 }
142        }
143    }
144}