Skip to main content

ghast_protocol/generated/defs/p47/login/
serverbound.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//! 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(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
29/// `login_start` (serverbound login).
30#[derive(Debug, Clone, PartialEq)]
31pub struct LoginStart<const V: i32> {
32    /// `username`
33    pub username: ByteString,
34}
35#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
36impl<const V: i32> Decode for LoginStart<V> {
37    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
38        Ok({
39            let v1 = r.read_string()?;
40            Self { username: v1 }
41        })
42    }
43}
44#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
45impl<const V: i32> Encode for LoginStart<V> {
46    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
47        w.put_string(&(*self).username)?;
48        Ok(())
49    }
50}
51#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
52#[cfg(feature = "testgen")]
53impl<const V: i32> Generate for LoginStart<V> {
54    fn generate(g: &mut Gen) -> Self {
55        {
56            let v1 = g.string();
57            Self { username: v1 }
58        }
59    }
60}
61
62#[cfg(any(
63    feature = "v1_8",
64    feature = "v1_12_2",
65    feature = "v1_16_5",
66    feature = "v26_1"
67))]
68/// `encryption_begin` (serverbound login).
69#[derive(Debug, Clone, PartialEq)]
70pub struct EncryptionBegin<const V: i32> {
71    /// `sharedSecret`
72    pub shared_secret: Bytes,
73    /// `verifyToken`
74    pub verify_token: Bytes,
75}
76#[cfg(any(
77    feature = "v1_8",
78    feature = "v1_12_2",
79    feature = "v1_16_5",
80    feature = "v26_1"
81))]
82impl<const V: i32> Decode for EncryptionBegin<V> {
83    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
84        Ok({
85            let v1 = r.read_byte_array()?;
86            let v2 = r.read_byte_array()?;
87            Self {
88                shared_secret: v1,
89                verify_token: v2,
90            }
91        })
92    }
93}
94#[cfg(any(
95    feature = "v1_8",
96    feature = "v1_12_2",
97    feature = "v1_16_5",
98    feature = "v26_1"
99))]
100impl<const V: i32> Encode for EncryptionBegin<V> {
101    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
102        w.put_byte_array(&(*self).shared_secret)?;
103        w.put_byte_array(&(*self).verify_token)?;
104        Ok(())
105    }
106}
107#[cfg(any(
108    feature = "v1_8",
109    feature = "v1_12_2",
110    feature = "v1_16_5",
111    feature = "v26_1"
112))]
113#[cfg(feature = "testgen")]
114impl<const V: i32> Generate for EncryptionBegin<V> {
115    fn generate(g: &mut Gen) -> Self {
116        {
117            let v1 = g.bytes();
118            let v2 = g.bytes();
119            Self {
120                shared_secret: v1,
121                verify_token: v2,
122            }
123        }
124    }
125}