Skip to main content

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

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.16.2/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(feature = "v1_16_5")]
29/// `success` (clientbound login).
30#[derive(Debug, Clone, PartialEq)]
31pub struct Success<const V: i32> {
32    /// `uuid`
33    pub uuid: Uuid,
34    /// `username`
35    pub username: ByteString,
36}
37#[cfg(feature = "v1_16_5")]
38impl<const V: i32> Decode for Success<V> {
39    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
40        Ok({
41            let v1 = r.read_uuid()?;
42            let v2 = r.read_string()?;
43            Self {
44                uuid: v1,
45                username: v2,
46            }
47        })
48    }
49}
50#[cfg(feature = "v1_16_5")]
51impl<const V: i32> Encode for Success<V> {
52    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
53        w.put_uuid(&(*self).uuid);
54        w.put_string(&(*self).username)?;
55        Ok(())
56    }
57}
58#[cfg(feature = "v1_16_5")]
59#[cfg(feature = "testgen")]
60impl<const V: i32> Generate for Success<V> {
61    fn generate(g: &mut Gen) -> Self {
62        {
63            let v1 = g.uuid();
64            let v2 = g.string();
65            Self {
66                uuid: v1,
67                username: v2,
68            }
69        }
70    }
71}
72
73#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
74/// `login_plugin_request` (clientbound login).
75#[derive(Debug, Clone, PartialEq)]
76pub struct LoginPluginRequest<const V: i32> {
77    /// `messageId`
78    pub message_id: i32,
79    /// `channel`
80    pub channel: ByteString,
81    /// `data`
82    pub data: Bytes,
83}
84#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
85impl<const V: i32> Decode for LoginPluginRequest<V> {
86    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
87        Ok({
88            let v1 = r.read_varint()?;
89            let v2 = r.read_string()?;
90            let v3 = r.read_rest();
91            Self {
92                message_id: v1,
93                channel: v2,
94                data: v3,
95            }
96        })
97    }
98}
99#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
100impl<const V: i32> Encode for LoginPluginRequest<V> {
101    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
102        w.put_varint((*self).message_id);
103        w.put_string(&(*self).channel)?;
104        w.put_slice(&(*self).data);
105        Ok(())
106    }
107}
108#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
109#[cfg(feature = "testgen")]
110impl<const V: i32> Generate for LoginPluginRequest<V> {
111    fn generate(g: &mut Gen) -> Self {
112        {
113            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
114            let v2 = g.string();
115            let v3 = g.bytes();
116            Self {
117                message_id: v1,
118                channel: v2,
119                data: v3,
120            }
121        }
122    }
123}