ghast_protocol/generated/v26_1/configuration/
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
28pub mod id {
30 pub const SETTINGS: i32 = 0x00;
32 pub const COOKIE_RESPONSE: i32 = 0x01;
34 pub const CUSTOM_PAYLOAD: i32 = 0x02;
36 pub const FINISH_CONFIGURATION: i32 = 0x03;
38 pub const KEEP_ALIVE: i32 = 0x04;
40 pub const PONG: i32 = 0x05;
42 pub const RESOURCE_PACK_RECEIVE: i32 = 0x06;
44 pub const SELECT_KNOWN_PACKS: i32 = 0x07;
46 pub const CUSTOM_CLICK_ACTION: i32 = 0x08;
48 pub const ACCEPT_CODE_OF_CONDUCT: i32 = 0x09;
50}
51
52pub use crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks;
53pub use crate::defs::p775::configuration::serverbound::SettingsParticleStatus;
54
55pub type Settings = crate::defs::p775::configuration::serverbound::Settings<775>;
57impl crate::packet::Packet for Settings {
58 const ID: i32 = id::SETTINGS;
59 const NAME: &'static str = "settings";
60 const STATE: State = State::Configuration;
61 const DIRECTION: Direction = Direction::Serverbound;
62}
63impl From<Settings> for ServerboundConfigurationPacket {
64 fn from(p: Settings) -> Self {
65 Self::Settings(p)
66 }
67}
68
69pub type CookieResponse = crate::defs::p775::configuration::serverbound::CookieResponse<775>;
71impl crate::packet::Packet for CookieResponse {
72 const ID: i32 = id::COOKIE_RESPONSE;
73 const NAME: &'static str = "cookie_response";
74 const STATE: State = State::Configuration;
75 const DIRECTION: Direction = Direction::Serverbound;
76}
77impl From<CookieResponse> for ServerboundConfigurationPacket {
78 fn from(p: CookieResponse) -> Self {
79 Self::CookieResponse(p)
80 }
81}
82
83pub type CustomPayload = crate::defs::p775::configuration::serverbound::CustomPayload<775>;
85impl crate::packet::Packet for CustomPayload {
86 const ID: i32 = id::CUSTOM_PAYLOAD;
87 const NAME: &'static str = "custom_payload";
88 const STATE: State = State::Configuration;
89 const DIRECTION: Direction = Direction::Serverbound;
90}
91impl From<CustomPayload> for ServerboundConfigurationPacket {
92 fn from(p: CustomPayload) -> Self {
93 Self::CustomPayload(p)
94 }
95}
96
97pub type FinishConfiguration =
99 crate::defs::p775::configuration::serverbound::FinishConfiguration<775>;
100impl crate::packet::Packet for FinishConfiguration {
101 const ID: i32 = id::FINISH_CONFIGURATION;
102 const NAME: &'static str = "finish_configuration";
103 const STATE: State = State::Configuration;
104 const DIRECTION: Direction = Direction::Serverbound;
105}
106impl From<FinishConfiguration> for ServerboundConfigurationPacket {
107 fn from(p: FinishConfiguration) -> Self {
108 Self::FinishConfiguration(p)
109 }
110}
111
112pub type KeepAlive = crate::defs::p775::configuration::serverbound::KeepAlive<775>;
114impl crate::packet::Packet for KeepAlive {
115 const ID: i32 = id::KEEP_ALIVE;
116 const NAME: &'static str = "keep_alive";
117 const STATE: State = State::Configuration;
118 const DIRECTION: Direction = Direction::Serverbound;
119}
120impl From<KeepAlive> for ServerboundConfigurationPacket {
121 fn from(p: KeepAlive) -> Self {
122 Self::KeepAlive(p)
123 }
124}
125
126pub type Pong = crate::defs::p775::configuration::serverbound::Pong<775>;
128impl crate::packet::Packet for Pong {
129 const ID: i32 = id::PONG;
130 const NAME: &'static str = "pong";
131 const STATE: State = State::Configuration;
132 const DIRECTION: Direction = Direction::Serverbound;
133}
134impl From<Pong> for ServerboundConfigurationPacket {
135 fn from(p: Pong) -> Self {
136 Self::Pong(p)
137 }
138}
139
140pub type ResourcePackReceive =
142 crate::defs::p775::configuration::serverbound::ResourcePackReceive<775>;
143impl crate::packet::Packet for ResourcePackReceive {
144 const ID: i32 = id::RESOURCE_PACK_RECEIVE;
145 const NAME: &'static str = "resource_pack_receive";
146 const STATE: State = State::Configuration;
147 const DIRECTION: Direction = Direction::Serverbound;
148}
149impl From<ResourcePackReceive> for ServerboundConfigurationPacket {
150 fn from(p: ResourcePackReceive) -> Self {
151 Self::ResourcePackReceive(p)
152 }
153}
154
155pub type SelectKnownPacks = crate::defs::p775::configuration::serverbound::SelectKnownPacks<775>;
157impl crate::packet::Packet for SelectKnownPacks {
158 const ID: i32 = id::SELECT_KNOWN_PACKS;
159 const NAME: &'static str = "select_known_packs";
160 const STATE: State = State::Configuration;
161 const DIRECTION: Direction = Direction::Serverbound;
162}
163impl From<SelectKnownPacks> for ServerboundConfigurationPacket {
164 fn from(p: SelectKnownPacks) -> Self {
165 Self::SelectKnownPacks(p)
166 }
167}
168
169pub type CustomClickAction = crate::defs::p775::configuration::serverbound::CustomClickAction<775>;
171impl crate::packet::Packet for CustomClickAction {
172 const ID: i32 = id::CUSTOM_CLICK_ACTION;
173 const NAME: &'static str = "custom_click_action";
174 const STATE: State = State::Configuration;
175 const DIRECTION: Direction = Direction::Serverbound;
176}
177impl From<CustomClickAction> for ServerboundConfigurationPacket {
178 fn from(p: CustomClickAction) -> Self {
179 Self::CustomClickAction(p)
180 }
181}
182
183pub type AcceptCodeOfConduct =
185 crate::defs::p775::configuration::serverbound::AcceptCodeOfConduct<775>;
186impl crate::packet::Packet for AcceptCodeOfConduct {
187 const ID: i32 = id::ACCEPT_CODE_OF_CONDUCT;
188 const NAME: &'static str = "accept_code_of_conduct";
189 const STATE: State = State::Configuration;
190 const DIRECTION: Direction = Direction::Serverbound;
191}
192impl From<AcceptCodeOfConduct> for ServerboundConfigurationPacket {
193 fn from(p: AcceptCodeOfConduct) -> Self {
194 Self::AcceptCodeOfConduct(p)
195 }
196}
197
198#[derive(Debug, Clone, PartialEq)]
200pub enum ServerboundConfigurationPacket {
201 Settings(Settings),
203 CookieResponse(CookieResponse),
205 CustomPayload(CustomPayload),
207 FinishConfiguration(FinishConfiguration),
209 KeepAlive(KeepAlive),
211 Pong(Pong),
213 ResourcePackReceive(ResourcePackReceive),
215 SelectKnownPacks(SelectKnownPacks),
217 CustomClickAction(CustomClickAction),
219 AcceptCodeOfConduct(AcceptCodeOfConduct),
221}
222
223impl PacketSet for ServerboundConfigurationPacket {
224 const STATE: State = State::Configuration;
225 const DIRECTION: Direction = Direction::Serverbound;
226 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
227 match raw.id {
228 id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
229 id::COOKIE_RESPONSE => decode_exact(&raw.body).map(Self::CookieResponse),
230 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
231 id::FINISH_CONFIGURATION => decode_exact(&raw.body).map(Self::FinishConfiguration),
232 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
233 id::PONG => decode_exact(&raw.body).map(Self::Pong),
234 id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
235 id::SELECT_KNOWN_PACKS => decode_exact(&raw.body).map(Self::SelectKnownPacks),
236 id::CUSTOM_CLICK_ACTION => decode_exact(&raw.body).map(Self::CustomClickAction),
237 id::ACCEPT_CODE_OF_CONDUCT => decode_exact(&raw.body).map(Self::AcceptCodeOfConduct),
238 other => Err(DecodeError::UnknownPacketId(other)),
239 }
240 }
241 fn id(&self) -> i32 {
242 match *self {
243 Self::Settings(_) => id::SETTINGS,
244 Self::CookieResponse(_) => id::COOKIE_RESPONSE,
245 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
246 Self::FinishConfiguration(_) => id::FINISH_CONFIGURATION,
247 Self::KeepAlive(_) => id::KEEP_ALIVE,
248 Self::Pong(_) => id::PONG,
249 Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
250 Self::SelectKnownPacks(_) => id::SELECT_KNOWN_PACKS,
251 Self::CustomClickAction(_) => id::CUSTOM_CLICK_ACTION,
252 Self::AcceptCodeOfConduct(_) => id::ACCEPT_CODE_OF_CONDUCT,
253 }
254 }
255 fn name(&self) -> &'static str {
256 match *self {
257 Self::Settings(_) => "settings",
258 Self::CookieResponse(_) => "cookie_response",
259 Self::CustomPayload(_) => "custom_payload",
260 Self::FinishConfiguration(_) => "finish_configuration",
261 Self::KeepAlive(_) => "keep_alive",
262 Self::Pong(_) => "pong",
263 Self::ResourcePackReceive(_) => "resource_pack_receive",
264 Self::SelectKnownPacks(_) => "select_known_packs",
265 Self::CustomClickAction(_) => "custom_click_action",
266 Self::AcceptCodeOfConduct(_) => "accept_code_of_conduct",
267 }
268 }
269 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
270 match *self {
271 Self::Settings(ref p) => p.encode(w),
272 Self::CookieResponse(ref p) => p.encode(w),
273 Self::CustomPayload(ref p) => p.encode(w),
274 Self::FinishConfiguration(ref p) => p.encode(w),
275 Self::KeepAlive(ref p) => p.encode(w),
276 Self::Pong(ref p) => p.encode(w),
277 Self::ResourcePackReceive(ref p) => p.encode(w),
278 Self::SelectKnownPacks(ref p) => p.encode(w),
279 Self::CustomClickAction(ref p) => p.encode(w),
280 Self::AcceptCodeOfConduct(ref p) => p.encode(w),
281 }
282 }
283 fn name_of(id: i32) -> Option<&'static str> {
284 match id {
285 id::SETTINGS => Some("settings"),
286 id::COOKIE_RESPONSE => Some("cookie_response"),
287 id::CUSTOM_PAYLOAD => Some("custom_payload"),
288 id::FINISH_CONFIGURATION => Some("finish_configuration"),
289 id::KEEP_ALIVE => Some("keep_alive"),
290 id::PONG => Some("pong"),
291 id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
292 id::SELECT_KNOWN_PACKS => Some("select_known_packs"),
293 id::CUSTOM_CLICK_ACTION => Some("custom_click_action"),
294 id::ACCEPT_CODE_OF_CONDUCT => Some("accept_code_of_conduct"),
295 _ => None,
296 }
297 }
298}
299
300impl ServerboundConfigurationPacket {
301 pub const IDS: &'static [i32] = &[
303 id::SETTINGS,
304 id::COOKIE_RESPONSE,
305 id::CUSTOM_PAYLOAD,
306 id::FINISH_CONFIGURATION,
307 id::KEEP_ALIVE,
308 id::PONG,
309 id::RESOURCE_PACK_RECEIVE,
310 id::SELECT_KNOWN_PACKS,
311 id::CUSTOM_CLICK_ACTION,
312 id::ACCEPT_CODE_OF_CONDUCT,
313 ];
314 #[cfg(feature = "testgen")]
316 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
317 match id {
318 id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
319 id::COOKIE_RESPONSE => Some(Self::CookieResponse(
320 <CookieResponse as Generate>::generate(g),
321 )),
322 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
323 g,
324 ))),
325 id::FINISH_CONFIGURATION => Some(Self::FinishConfiguration(
326 <FinishConfiguration as Generate>::generate(g),
327 )),
328 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
329 id::PONG => Some(Self::Pong(<Pong as Generate>::generate(g))),
330 id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
331 <ResourcePackReceive as Generate>::generate(g),
332 )),
333 id::SELECT_KNOWN_PACKS => Some(Self::SelectKnownPacks(
334 <SelectKnownPacks as Generate>::generate(g),
335 )),
336 id::CUSTOM_CLICK_ACTION => Some(Self::CustomClickAction(
337 <CustomClickAction as Generate>::generate(g),
338 )),
339 id::ACCEPT_CODE_OF_CONDUCT => Some(Self::AcceptCodeOfConduct(
340 <AcceptCodeOfConduct as Generate>::generate(g),
341 )),
342 _ => None,
343 }
344 }
345}