ghast_protocol/generated/defs/p754/login/
clientbound.rs1#![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#[derive(Debug, Clone, PartialEq)]
31pub struct Success<const V: i32> {
32 pub uuid: Uuid,
34 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(
74 feature = "v1_16_5",
75 feature = "v26_1",
76 feature = "v26_2",
77 feature = "v26_3"
78))]
79#[derive(Debug, Clone, PartialEq)]
81pub struct LoginPluginRequest<const V: i32> {
82 pub message_id: i32,
84 pub channel: ByteString,
86 pub data: Bytes,
88}
89#[cfg(any(
90 feature = "v1_16_5",
91 feature = "v26_1",
92 feature = "v26_2",
93 feature = "v26_3"
94))]
95impl<const V: i32> Decode for LoginPluginRequest<V> {
96 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
97 Ok({
98 let v1 = r.read_varint()?;
99 let v2 = r.read_string()?;
100 let v3 = r.read_rest();
101 Self {
102 message_id: v1,
103 channel: v2,
104 data: v3,
105 }
106 })
107 }
108}
109#[cfg(any(
110 feature = "v1_16_5",
111 feature = "v26_1",
112 feature = "v26_2",
113 feature = "v26_3"
114))]
115impl<const V: i32> Encode for LoginPluginRequest<V> {
116 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
117 w.put_varint((*self).message_id);
118 w.put_string(&(*self).channel)?;
119 w.put_slice(&(*self).data);
120 Ok(())
121 }
122}
123#[cfg(any(
124 feature = "v1_16_5",
125 feature = "v26_1",
126 feature = "v26_2",
127 feature = "v26_3"
128))]
129#[cfg(feature = "testgen")]
130impl<const V: i32> Generate for LoginPluginRequest<V> {
131 fn generate(g: &mut Gen) -> Self {
132 {
133 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
134 let v2 = g.string();
135 let v3 = g.bytes();
136 Self {
137 message_id: v1,
138 channel: v2,
139 data: v3,
140 }
141 }
142 }
143}