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