Skip to main content

ghast_protocol/generated/defs/p47/login/
clientbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.8/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//! Clientbound 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(any(
29    feature = "v1_8",
30    feature = "v1_12_2",
31    feature = "v1_16_5",
32    feature = "v26_1"
33))]
34/// `disconnect` (clientbound login).
35#[derive(Debug, Clone, PartialEq)]
36pub struct Disconnect<const V: i32> {
37    /// `reason`
38    pub reason: ByteString,
39}
40#[cfg(any(
41    feature = "v1_8",
42    feature = "v1_12_2",
43    feature = "v1_16_5",
44    feature = "v26_1"
45))]
46impl<const V: i32> Decode for Disconnect<V> {
47    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
48        Ok({
49            let v1 = r.read_string()?;
50            Self { reason: v1 }
51        })
52    }
53}
54#[cfg(any(
55    feature = "v1_8",
56    feature = "v1_12_2",
57    feature = "v1_16_5",
58    feature = "v26_1"
59))]
60impl<const V: i32> Encode for Disconnect<V> {
61    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
62        w.put_string(&(*self).reason)?;
63        Ok(())
64    }
65}
66#[cfg(any(
67    feature = "v1_8",
68    feature = "v1_12_2",
69    feature = "v1_16_5",
70    feature = "v26_1"
71))]
72#[cfg(feature = "testgen")]
73impl<const V: i32> Generate for Disconnect<V> {
74    fn generate(g: &mut Gen) -> Self {
75        {
76            let v1 = g.string();
77            Self { reason: v1 }
78        }
79    }
80}
81
82#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
83/// `encryption_begin` (clientbound login).
84#[derive(Debug, Clone, PartialEq)]
85pub struct EncryptionBegin<const V: i32> {
86    /// `serverId`
87    pub server_id: ByteString,
88    /// `publicKey`
89    pub public_key: Bytes,
90    /// `verifyToken`
91    pub verify_token: Bytes,
92}
93#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
94impl<const V: i32> Decode for EncryptionBegin<V> {
95    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
96        Ok({
97            let v1 = r.read_string()?;
98            let v2 = r.read_byte_array()?;
99            let v3 = r.read_byte_array()?;
100            Self {
101                server_id: v1,
102                public_key: v2,
103                verify_token: v3,
104            }
105        })
106    }
107}
108#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
109impl<const V: i32> Encode for EncryptionBegin<V> {
110    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
111        w.put_string(&(*self).server_id)?;
112        w.put_byte_array(&(*self).public_key)?;
113        w.put_byte_array(&(*self).verify_token)?;
114        Ok(())
115    }
116}
117#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
118#[cfg(feature = "testgen")]
119impl<const V: i32> Generate for EncryptionBegin<V> {
120    fn generate(g: &mut Gen) -> Self {
121        {
122            let v1 = g.string();
123            let v2 = g.bytes();
124            let v3 = g.bytes();
125            Self {
126                server_id: v1,
127                public_key: v2,
128                verify_token: v3,
129            }
130        }
131    }
132}
133
134#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
135/// `success` (clientbound login).
136#[derive(Debug, Clone, PartialEq)]
137pub struct Success<const V: i32> {
138    /// `uuid`
139    pub uuid: ByteString,
140    /// `username`
141    pub username: ByteString,
142}
143#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
144impl<const V: i32> Decode for Success<V> {
145    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
146        Ok({
147            let v1 = r.read_string()?;
148            let v2 = r.read_string()?;
149            Self {
150                uuid: v1,
151                username: v2,
152            }
153        })
154    }
155}
156#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
157impl<const V: i32> Encode for Success<V> {
158    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
159        w.put_string(&(*self).uuid)?;
160        w.put_string(&(*self).username)?;
161        Ok(())
162    }
163}
164#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
165#[cfg(feature = "testgen")]
166impl<const V: i32> Generate for Success<V> {
167    fn generate(g: &mut Gen) -> Self {
168        {
169            let v1 = g.string();
170            let v2 = g.string();
171            Self {
172                uuid: v1,
173                username: v2,
174            }
175        }
176    }
177}
178
179#[cfg(any(
180    feature = "v1_8",
181    feature = "v1_12_2",
182    feature = "v1_16_5",
183    feature = "v26_1"
184))]
185/// `compress` (clientbound login).
186#[derive(Debug, Clone, PartialEq)]
187pub struct Compress<const V: i32> {
188    /// `threshold`
189    pub threshold: i32,
190}
191#[cfg(any(
192    feature = "v1_8",
193    feature = "v1_12_2",
194    feature = "v1_16_5",
195    feature = "v26_1"
196))]
197impl<const V: i32> Decode for Compress<V> {
198    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
199        Ok({
200            let v1 = r.read_varint()?;
201            Self { threshold: v1 }
202        })
203    }
204}
205#[cfg(any(
206    feature = "v1_8",
207    feature = "v1_12_2",
208    feature = "v1_16_5",
209    feature = "v26_1"
210))]
211impl<const V: i32> Encode for Compress<V> {
212    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
213        w.put_varint((*self).threshold);
214        Ok(())
215    }
216}
217#[cfg(any(
218    feature = "v1_8",
219    feature = "v1_12_2",
220    feature = "v1_16_5",
221    feature = "v26_1"
222))]
223#[cfg(feature = "testgen")]
224impl<const V: i32> Generate for Compress<V> {
225    fn generate(g: &mut Gen) -> Self {
226        {
227            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
228            Self { threshold: v1 }
229        }
230    }
231}