ghast_protocol/generated/defs/p47/handshaking/
serverbound.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(any(
29 feature = "v1_8",
30 feature = "v1_12_2",
31 feature = "v1_16_5",
32 feature = "v26_1"
33))]
34#[derive(Debug, Clone, PartialEq)]
36pub struct SetProtocol<const V: i32> {
37 pub protocol_version: i32,
39 pub server_host: ByteString,
41 pub server_port: u16,
43 pub next_state: i32,
45}
46#[cfg(any(
47 feature = "v1_8",
48 feature = "v1_12_2",
49 feature = "v1_16_5",
50 feature = "v26_1"
51))]
52impl<const V: i32> Decode for SetProtocol<V> {
53 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
54 Ok({
55 let v1 = r.read_varint()?;
56 let v2 = r.read_string()?;
57 let v3 = r.read_u16()?;
58 let v4 = r.read_varint()?;
59 Self {
60 protocol_version: v1,
61 server_host: v2,
62 server_port: v3,
63 next_state: v4,
64 }
65 })
66 }
67}
68#[cfg(any(
69 feature = "v1_8",
70 feature = "v1_12_2",
71 feature = "v1_16_5",
72 feature = "v26_1"
73))]
74impl<const V: i32> Encode for SetProtocol<V> {
75 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
76 w.put_varint((*self).protocol_version);
77 w.put_string(&(*self).server_host)?;
78 w.put_u16((*self).server_port);
79 w.put_varint((*self).next_state);
80 Ok(())
81 }
82}
83#[cfg(any(
84 feature = "v1_8",
85 feature = "v1_12_2",
86 feature = "v1_16_5",
87 feature = "v26_1"
88))]
89#[cfg(feature = "testgen")]
90impl<const V: i32> Generate for SetProtocol<V> {
91 fn generate(g: &mut Gen) -> Self {
92 {
93 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
94 let v2 = g.string();
95 let v3 = (g.int_in(0, 65535, &[]) as u16);
96 let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
97 Self {
98 protocol_version: v1,
99 server_host: v2,
100 server_port: v3,
101 next_state: v4,
102 }
103 }
104 }
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#[derive(Debug, Clone, PartialEq)]
115pub struct LegacyServerListPing<const V: i32> {
116 pub payload: u8,
118}
119#[cfg(any(
120 feature = "v1_8",
121 feature = "v1_12_2",
122 feature = "v1_16_5",
123 feature = "v26_1"
124))]
125impl<const V: i32> Decode for LegacyServerListPing<V> {
126 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
127 Ok({
128 let v1 = r.read_u8()?;
129 Self { payload: v1 }
130 })
131 }
132}
133#[cfg(any(
134 feature = "v1_8",
135 feature = "v1_12_2",
136 feature = "v1_16_5",
137 feature = "v26_1"
138))]
139impl<const V: i32> Encode for LegacyServerListPing<V> {
140 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
141 w.put_u8((*self).payload);
142 Ok(())
143 }
144}
145#[cfg(any(
146 feature = "v1_8",
147 feature = "v1_12_2",
148 feature = "v1_16_5",
149 feature = "v26_1"
150))]
151#[cfg(feature = "testgen")]
152impl<const V: i32> Generate for LegacyServerListPing<V> {
153 fn generate(g: &mut Gen) -> Self {
154 {
155 let v1 = (g.int_in(0, 255, &[]) as u8);
156 Self { payload: v1 }
157 }
158 }
159}