Skip to main content

ghast_protocol/generated/defs/p775/configuration/
serverbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/26.1/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 configuration 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 = "v26_1")]
29/// Mapped `i32` value; unknown values are kept as-is.
30#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
31pub struct SettingsParticleStatus(pub i32);
32#[cfg(feature = "v26_1")]
33impl SettingsParticleStatus {
34    /// `all`
35    pub const ALL: Self = Self(0);
36    /// `decreased`
37    pub const DECREASED: Self = Self(1);
38    /// `minimal`
39    pub const MINIMAL: Self = Self(2);
40    /// minecraft-data name of the value, if known.
41    pub const fn name(self) -> Option<&'static str> {
42        match self.0 {
43            0 => Some("all"),
44            1 => Some("decreased"),
45            2 => Some("minimal"),
46            _ => None,
47        }
48    }
49}
50#[cfg(feature = "v26_1")]
51impl std::fmt::Debug for SettingsParticleStatus {
52    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53        match self.name() {
54            Some(n) => write!(f, "SettingsParticleStatus::{n}"),
55            None => write!(f, "SettingsParticleStatus({})", self.0),
56        }
57    }
58}
59
60#[cfg(feature = "v26_1")]
61/// `settings` (serverbound configuration).
62#[derive(Debug, Clone, PartialEq)]
63pub struct Settings<const V: i32> {
64    /// `locale`
65    pub locale: ByteString,
66    /// `viewDistance`
67    pub view_distance: i8,
68    /// `chatFlags`
69    pub chat_flags: i32,
70    /// `chatColors`
71    pub chat_colors: bool,
72    /// `skinParts`
73    pub skin_parts: u8,
74    /// `mainHand`
75    pub main_hand: i32,
76    /// `enableTextFiltering`
77    pub enable_text_filtering: bool,
78    /// `enableServerListing`
79    pub enable_server_listing: bool,
80    /// `particleStatus`
81    pub particle_status: crate::defs::p775::configuration::serverbound::SettingsParticleStatus,
82}
83#[cfg(feature = "v26_1")]
84impl<const V: i32> Decode for Settings<V> {
85    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
86        Ok({
87            let v1 = r.read_string()?;
88            let v2 = r.read_i8()?;
89            let v3 = r.read_varint()?;
90            let v4 = r.read_bool()?;
91            let v5 = r.read_u8()?;
92            let v6 = r.read_varint()?;
93            let v7 = r.read_bool()?;
94            let v8 = r.read_bool()?;
95            let v9 = crate::defs::p775::configuration::serverbound::SettingsParticleStatus(
96                r.read_varint()?,
97            );
98            Self {
99                locale: v1,
100                view_distance: v2,
101                chat_flags: v3,
102                chat_colors: v4,
103                skin_parts: v5,
104                main_hand: v6,
105                enable_text_filtering: v7,
106                enable_server_listing: v8,
107                particle_status: v9,
108            }
109        })
110    }
111}
112#[cfg(feature = "v26_1")]
113impl<const V: i32> Encode for Settings<V> {
114    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
115        w.put_string(&(*self).locale)?;
116        w.put_i8((*self).view_distance);
117        w.put_varint((*self).chat_flags);
118        w.put_bool((*self).chat_colors);
119        w.put_u8((*self).skin_parts);
120        w.put_varint((*self).main_hand);
121        w.put_bool((*self).enable_text_filtering);
122        w.put_bool((*self).enable_server_listing);
123        w.put_varint((*self).particle_status.0);
124        Ok(())
125    }
126}
127#[cfg(feature = "v26_1")]
128#[cfg(feature = "testgen")]
129impl<const V: i32> Generate for Settings<V> {
130    fn generate(g: &mut Gen) -> Self {
131        {
132            let v1 = g.string();
133            let v2 = (g.int_in(-128, 127, &[]) as i8);
134            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
135            let v4 = g.bool();
136            let v5 = (g.int_in(0, 255, &[]) as u8);
137            let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
138            let v7 = g.bool();
139            let v8 = g.bool();
140            let v9 = crate::defs::p775::configuration::serverbound::SettingsParticleStatus(
141                g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32,
142            );
143            Self {
144                locale: v1,
145                view_distance: v2,
146                chat_flags: v3,
147                chat_colors: v4,
148                skin_parts: v5,
149                main_hand: v6,
150                enable_text_filtering: v7,
151                enable_server_listing: v8,
152                particle_status: v9,
153            }
154        }
155    }
156}
157
158#[cfg(feature = "v26_1")]
159/// `cookie_response` (serverbound configuration).
160#[derive(Debug, Clone, PartialEq)]
161pub struct CookieResponse<const V: i32> {
162    /// `key`
163    pub key: ByteString,
164    /// `value`
165    pub value: Option<Bytes>,
166}
167#[cfg(feature = "v26_1")]
168impl<const V: i32> Decode for CookieResponse<V> {
169    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
170        Ok({
171            let v1 = r.read_string()?;
172            let v2 = if r.read_bool()? {
173                Some(r.read_byte_array()?)
174            } else {
175                None
176            };
177            Self { key: v1, value: v2 }
178        })
179    }
180}
181#[cfg(feature = "v26_1")]
182impl<const V: i32> Encode for CookieResponse<V> {
183    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
184        w.put_string(&(*self).key)?;
185        match &(*self).value {
186            Some(v1) => {
187                w.put_u8(1);
188                w.put_byte_array(&(*v1))?;
189            }
190            None => w.put_u8(0),
191        }
192        Ok(())
193    }
194}
195#[cfg(feature = "v26_1")]
196#[cfg(feature = "testgen")]
197impl<const V: i32> Generate for CookieResponse<V> {
198    fn generate(g: &mut Gen) -> Self {
199        {
200            let v1 = g.string();
201            let v2 = if g.bool() { Some(g.bytes()) } else { None };
202            Self { key: v1, value: v2 }
203        }
204    }
205}
206
207#[cfg(feature = "v26_1")]
208/// `custom_payload` (serverbound configuration).
209#[derive(Debug, Clone, PartialEq)]
210pub struct CustomPayload<const V: i32> {
211    /// `channel`
212    pub channel: ByteString,
213    /// `data`
214    pub data: Bytes,
215}
216#[cfg(feature = "v26_1")]
217impl<const V: i32> Decode for CustomPayload<V> {
218    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
219        Ok({
220            let v1 = r.read_string()?;
221            let v2 = r.read_rest();
222            Self {
223                channel: v1,
224                data: v2,
225            }
226        })
227    }
228}
229#[cfg(feature = "v26_1")]
230impl<const V: i32> Encode for CustomPayload<V> {
231    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
232        w.put_string(&(*self).channel)?;
233        w.put_slice(&(*self).data);
234        Ok(())
235    }
236}
237#[cfg(feature = "v26_1")]
238#[cfg(feature = "testgen")]
239impl<const V: i32> Generate for CustomPayload<V> {
240    fn generate(g: &mut Gen) -> Self {
241        {
242            let v1 = g.string();
243            let v2 = g.bytes();
244            Self {
245                channel: v1,
246                data: v2,
247            }
248        }
249    }
250}
251
252#[cfg(feature = "v26_1")]
253/// `finish_configuration` (serverbound configuration).
254#[derive(Debug, Clone, PartialEq)]
255pub struct FinishConfiguration<const V: i32> {}
256#[cfg(feature = "v26_1")]
257impl<const V: i32> Decode for FinishConfiguration<V> {
258    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
259        Ok({ Self {} })
260    }
261}
262#[cfg(feature = "v26_1")]
263impl<const V: i32> Encode for FinishConfiguration<V> {
264    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
265        Ok(())
266    }
267}
268#[cfg(feature = "v26_1")]
269#[cfg(feature = "testgen")]
270impl<const V: i32> Generate for FinishConfiguration<V> {
271    fn generate(g: &mut Gen) -> Self {
272        { Self {} }
273    }
274}
275
276#[cfg(feature = "v26_1")]
277/// `keep_alive` (serverbound configuration).
278#[derive(Debug, Clone, PartialEq)]
279pub struct KeepAlive<const V: i32> {
280    /// `keepAliveId`
281    pub keep_alive_id: i64,
282}
283#[cfg(feature = "v26_1")]
284impl<const V: i32> Decode for KeepAlive<V> {
285    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
286        Ok({
287            let v1 = r.read_i64()?;
288            Self { keep_alive_id: v1 }
289        })
290    }
291}
292#[cfg(feature = "v26_1")]
293impl<const V: i32> Encode for KeepAlive<V> {
294    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
295        w.put_i64((*self).keep_alive_id);
296        Ok(())
297    }
298}
299#[cfg(feature = "v26_1")]
300#[cfg(feature = "testgen")]
301impl<const V: i32> Generate for KeepAlive<V> {
302    fn generate(g: &mut Gen) -> Self {
303        {
304            let v1 = g.i64();
305            Self { keep_alive_id: v1 }
306        }
307    }
308}
309
310#[cfg(feature = "v26_1")]
311/// `pong` (serverbound configuration).
312#[derive(Debug, Clone, PartialEq)]
313pub struct Pong<const V: i32> {
314    /// `id`
315    pub id: i32,
316}
317#[cfg(feature = "v26_1")]
318impl<const V: i32> Decode for Pong<V> {
319    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
320        Ok({
321            let v1 = r.read_i32()?;
322            Self { id: v1 }
323        })
324    }
325}
326#[cfg(feature = "v26_1")]
327impl<const V: i32> Encode for Pong<V> {
328    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
329        w.put_i32((*self).id);
330        Ok(())
331    }
332}
333#[cfg(feature = "v26_1")]
334#[cfg(feature = "testgen")]
335impl<const V: i32> Generate for Pong<V> {
336    fn generate(g: &mut Gen) -> Self {
337        {
338            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
339            Self { id: v1 }
340        }
341    }
342}
343
344#[cfg(feature = "v26_1")]
345/// `resource_pack_receive` (serverbound configuration).
346#[derive(Debug, Clone, PartialEq)]
347pub struct ResourcePackReceive<const V: i32> {
348    /// `uuid`
349    pub uuid: Uuid,
350    /// `result`
351    pub result: i32,
352}
353#[cfg(feature = "v26_1")]
354impl<const V: i32> Decode for ResourcePackReceive<V> {
355    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
356        Ok({
357            let v1 = r.read_uuid()?;
358            let v2 = r.read_varint()?;
359            Self {
360                uuid: v1,
361                result: v2,
362            }
363        })
364    }
365}
366#[cfg(feature = "v26_1")]
367impl<const V: i32> Encode for ResourcePackReceive<V> {
368    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
369        w.put_uuid(&(*self).uuid);
370        w.put_varint((*self).result);
371        Ok(())
372    }
373}
374#[cfg(feature = "v26_1")]
375#[cfg(feature = "testgen")]
376impl<const V: i32> Generate for ResourcePackReceive<V> {
377    fn generate(g: &mut Gen) -> Self {
378        {
379            let v1 = g.uuid();
380            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
381            Self {
382                uuid: v1,
383                result: v2,
384            }
385        }
386    }
387}
388
389#[cfg(feature = "v26_1")]
390/// Nested container.
391#[derive(Debug, Clone, PartialEq)]
392pub struct SelectKnownPacksPacks {
393    /// `namespace`
394    pub namespace: ByteString,
395    /// `id`
396    pub id: ByteString,
397    /// `version`
398    pub version: ByteString,
399}
400
401#[cfg(feature = "v26_1")]
402/// `select_known_packs` (serverbound configuration).
403#[derive(Debug, Clone, PartialEq)]
404pub struct SelectKnownPacks<const V: i32> {
405    /// `packs`
406    pub packs: Vec<crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks>,
407}
408#[cfg(feature = "v26_1")]
409impl<const V: i32> Decode for SelectKnownPacks<V> {
410    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
411        Ok({
412            let v1 = {
413                let v2 = {
414                    let c = r.read_varint()?;
415                    r.check_count(i64::from(c), 3)?
416                };
417                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
418                for _ in 0..v2 {
419                    v3.push({
420                        let v4 = r.read_string()?;
421                        let v5 = r.read_string()?;
422                        let v6 = r.read_string()?;
423                        crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks {
424                            namespace: v4,
425                            id: v5,
426                            version: v6,
427                        }
428                    });
429                }
430                v3
431            };
432            Self { packs: v1 }
433        })
434    }
435}
436#[cfg(feature = "v26_1")]
437impl<const V: i32> Encode for SelectKnownPacks<V> {
438    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
439        w.put_len_varint((*self).packs.len())?;
440        for v1 in (*self).packs.iter() {
441            w.put_string(&(*v1).namespace)?;
442            w.put_string(&(*v1).id)?;
443            w.put_string(&(*v1).version)?;
444        }
445        Ok(())
446    }
447}
448#[cfg(feature = "v26_1")]
449#[cfg(feature = "testgen")]
450impl<const V: i32> Generate for SelectKnownPacks<V> {
451    fn generate(g: &mut Gen) -> Self {
452        {
453            let v1 = {
454                let v2 = g.count();
455                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
456                for _ in 0..v2 {
457                    v3.push({
458                        let v4 = g.string();
459                        let v5 = g.string();
460                        let v6 = g.string();
461                        crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks {
462                            namespace: v4,
463                            id: v5,
464                            version: v6,
465                        }
466                    });
467                }
468                v3
469            };
470            Self { packs: v1 }
471        }
472    }
473}
474
475#[cfg(feature = "v26_1")]
476/// `custom_click_action` (serverbound configuration).
477#[derive(Debug, Clone, PartialEq)]
478pub struct CustomClickAction<const V: i32> {
479    /// `id`
480    pub id: ByteString,
481    /// `nbt`
482    pub nbt: Option<AnonNbt>,
483}
484#[cfg(feature = "v26_1")]
485impl<const V: i32> Decode for CustomClickAction<V> {
486    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
487        Ok({
488            let v1 = r.read_string()?;
489            let v2 = if r.read_bool()? {
490                Some(AnonNbt::read(r)?)
491            } else {
492                None
493            };
494            Self { id: v1, nbt: v2 }
495        })
496    }
497}
498#[cfg(feature = "v26_1")]
499impl<const V: i32> Encode for CustomClickAction<V> {
500    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
501        w.put_string(&(*self).id)?;
502        match &(*self).nbt {
503            Some(v1) => {
504                w.put_u8(1);
505                (*v1).write(w);
506            }
507            None => w.put_u8(0),
508        }
509        Ok(())
510    }
511}
512#[cfg(feature = "v26_1")]
513#[cfg(feature = "testgen")]
514impl<const V: i32> Generate for CustomClickAction<V> {
515    fn generate(g: &mut Gen) -> Self {
516        {
517            let v1 = g.string();
518            let v2 = if g.bool() { Some(g.anon_nbt()) } else { None };
519            Self { id: v1, nbt: v2 }
520        }
521    }
522}
523
524#[cfg(feature = "v26_1")]
525/// `accept_code_of_conduct` (serverbound configuration).
526#[derive(Debug, Clone, PartialEq)]
527pub struct AcceptCodeOfConduct<const V: i32> {}
528#[cfg(feature = "v26_1")]
529impl<const V: i32> Decode for AcceptCodeOfConduct<V> {
530    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
531        Ok({ Self {} })
532    }
533}
534#[cfg(feature = "v26_1")]
535impl<const V: i32> Encode for AcceptCodeOfConduct<V> {
536    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
537        Ok(())
538    }
539}
540#[cfg(feature = "v26_1")]
541#[cfg(feature = "testgen")]
542impl<const V: i32> Generate for AcceptCodeOfConduct<V> {
543    fn generate(g: &mut Gen) -> Self {
544        { Self {} }
545    }
546}