Skip to main content

ghast_protocol/generated/defs/p47/play/
serverbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.8/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 play 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_8")]
29/// `keep_alive` (serverbound play).
30#[derive(Debug, Clone, PartialEq)]
31pub struct KeepAlive<const V: i32> {
32    /// `keepAliveId`
33    pub keep_alive_id: i32,
34}
35#[cfg(feature = "v1_8")]
36impl<const V: i32> Decode for KeepAlive<V> {
37    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
38        Ok({
39            let v1 = r.read_varint()?;
40            Self { keep_alive_id: v1 }
41        })
42    }
43}
44#[cfg(feature = "v1_8")]
45impl<const V: i32> Encode for KeepAlive<V> {
46    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
47        w.put_varint((*self).keep_alive_id);
48        Ok(())
49    }
50}
51#[cfg(feature = "v1_8")]
52#[cfg(feature = "testgen")]
53impl<const V: i32> Generate for KeepAlive<V> {
54    fn generate(g: &mut Gen) -> Self {
55        {
56            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
57            Self { keep_alive_id: v1 }
58        }
59    }
60}
61
62#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
63/// `chat` (serverbound play).
64#[derive(Debug, Clone, PartialEq)]
65pub struct Chat<const V: i32> {
66    /// `message`
67    pub message: ByteString,
68}
69#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
70impl<const V: i32> Decode for Chat<V> {
71    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
72        Ok({
73            let v1 = r.read_string()?;
74            Self { message: v1 }
75        })
76    }
77}
78#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
79impl<const V: i32> Encode for Chat<V> {
80    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
81        w.put_string(&(*self).message)?;
82        Ok(())
83    }
84}
85#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
86#[cfg(feature = "testgen")]
87impl<const V: i32> Generate for Chat<V> {
88    fn generate(g: &mut Gen) -> Self {
89        {
90            let v1 = g.string();
91            Self { message: v1 }
92        }
93    }
94}
95
96#[cfg(feature = "v1_8")]
97/// `use_entity` (serverbound play).
98#[derive(Debug, Clone, PartialEq)]
99pub struct UseEntity<const V: i32> {
100    /// `target`
101    pub target: i32,
102    /// `mouse`
103    pub mouse: i32,
104    /// `x`
105    pub x: Option<f32>,
106    /// `y`
107    pub y: Option<f32>,
108    /// `z`
109    pub z: Option<f32>,
110}
111#[cfg(feature = "v1_8")]
112impl<const V: i32> Decode for UseEntity<V> {
113    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
114        Ok({
115            let v1 = r.read_varint()?;
116            let v2 = r.read_varint()?;
117            let v3 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
118            let v4 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
119            let v5 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
120            Self {
121                target: v1,
122                mouse: v2,
123                x: v3,
124                y: v4,
125                z: v5,
126            }
127        })
128    }
129}
130#[cfg(feature = "v1_8")]
131impl<const V: i32> Encode for UseEntity<V> {
132    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
133        w.put_varint((*self).target);
134        w.put_varint((*self).mouse);
135        match (&(*self).x, ((*self).mouse == 2)) {
136            (Some(v1), true) => {
137                w.put_f32((*v1));
138            }
139            (None, false) => {}
140            _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
141        }
142        match (&(*self).y, ((*self).mouse == 2)) {
143            (Some(v2), true) => {
144                w.put_f32((*v2));
145            }
146            (None, false) => {}
147            _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
148        }
149        match (&(*self).z, ((*self).mouse == 2)) {
150            (Some(v3), true) => {
151                w.put_f32((*v3));
152            }
153            (None, false) => {}
154            _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
155        }
156        Ok(())
157    }
158}
159#[cfg(feature = "v1_8")]
160#[cfg(feature = "testgen")]
161impl<const V: i32> Generate for UseEntity<V> {
162    fn generate(g: &mut Gen) -> Self {
163        {
164            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
165            let v2 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2]) as i32);
166            let v3 = if (v2 == 2) { Some(g.f32()) } else { None };
167            let v4 = if (v2 == 2) { Some(g.f32()) } else { None };
168            let v5 = if (v2 == 2) { Some(g.f32()) } else { None };
169            Self {
170                target: v1,
171                mouse: v2,
172                x: v3,
173                y: v4,
174                z: v5,
175            }
176        }
177    }
178}
179
180#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
181/// `flying` (serverbound play).
182#[derive(Debug, Clone, PartialEq)]
183pub struct Flying<const V: i32> {
184    /// `onGround`
185    pub on_ground: bool,
186}
187#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
188impl<const V: i32> Decode for Flying<V> {
189    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
190        Ok({
191            let v1 = r.read_bool()?;
192            Self { on_ground: v1 }
193        })
194    }
195}
196#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
197impl<const V: i32> Encode for Flying<V> {
198    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
199        w.put_bool((*self).on_ground);
200        Ok(())
201    }
202}
203#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
204#[cfg(feature = "testgen")]
205impl<const V: i32> Generate for Flying<V> {
206    fn generate(g: &mut Gen) -> Self {
207        {
208            let v1 = g.bool();
209            Self { on_ground: v1 }
210        }
211    }
212}
213
214#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
215/// `position` (serverbound play).
216#[derive(Debug, Clone, PartialEq)]
217pub struct Position<const V: i32> {
218    /// `x`
219    pub x: f64,
220    /// `y`
221    pub y: f64,
222    /// `z`
223    pub z: f64,
224    /// `onGround`
225    pub on_ground: bool,
226}
227#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
228impl<const V: i32> Decode for Position<V> {
229    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
230        Ok({
231            let v1 = r.read_f64()?;
232            let v2 = r.read_f64()?;
233            let v3 = r.read_f64()?;
234            let v4 = r.read_bool()?;
235            Self {
236                x: v1,
237                y: v2,
238                z: v3,
239                on_ground: v4,
240            }
241        })
242    }
243}
244#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
245impl<const V: i32> Encode for Position<V> {
246    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
247        w.put_f64((*self).x);
248        w.put_f64((*self).y);
249        w.put_f64((*self).z);
250        w.put_bool((*self).on_ground);
251        Ok(())
252    }
253}
254#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
255#[cfg(feature = "testgen")]
256impl<const V: i32> Generate for Position<V> {
257    fn generate(g: &mut Gen) -> Self {
258        {
259            let v1 = g.f64();
260            let v2 = g.f64();
261            let v3 = g.f64();
262            let v4 = g.bool();
263            Self {
264                x: v1,
265                y: v2,
266                z: v3,
267                on_ground: v4,
268            }
269        }
270    }
271}
272
273#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
274/// `look` (serverbound play).
275#[derive(Debug, Clone, PartialEq)]
276pub struct Look<const V: i32> {
277    /// `yaw`
278    pub yaw: f32,
279    /// `pitch`
280    pub pitch: f32,
281    /// `onGround`
282    pub on_ground: bool,
283}
284#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
285impl<const V: i32> Decode for Look<V> {
286    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
287        Ok({
288            let v1 = r.read_f32()?;
289            let v2 = r.read_f32()?;
290            let v3 = r.read_bool()?;
291            Self {
292                yaw: v1,
293                pitch: v2,
294                on_ground: v3,
295            }
296        })
297    }
298}
299#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
300impl<const V: i32> Encode for Look<V> {
301    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
302        w.put_f32((*self).yaw);
303        w.put_f32((*self).pitch);
304        w.put_bool((*self).on_ground);
305        Ok(())
306    }
307}
308#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
309#[cfg(feature = "testgen")]
310impl<const V: i32> Generate for Look<V> {
311    fn generate(g: &mut Gen) -> Self {
312        {
313            let v1 = g.f32();
314            let v2 = g.f32();
315            let v3 = g.bool();
316            Self {
317                yaw: v1,
318                pitch: v2,
319                on_ground: v3,
320            }
321        }
322    }
323}
324
325#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
326/// `position_look` (serverbound play).
327#[derive(Debug, Clone, PartialEq)]
328pub struct PositionLook<const V: i32> {
329    /// `x`
330    pub x: f64,
331    /// `y`
332    pub y: f64,
333    /// `z`
334    pub z: f64,
335    /// `yaw`
336    pub yaw: f32,
337    /// `pitch`
338    pub pitch: f32,
339    /// `onGround`
340    pub on_ground: bool,
341}
342#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
343impl<const V: i32> Decode for PositionLook<V> {
344    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
345        Ok({
346            let v1 = r.read_f64()?;
347            let v2 = r.read_f64()?;
348            let v3 = r.read_f64()?;
349            let v4 = r.read_f32()?;
350            let v5 = r.read_f32()?;
351            let v6 = r.read_bool()?;
352            Self {
353                x: v1,
354                y: v2,
355                z: v3,
356                yaw: v4,
357                pitch: v5,
358                on_ground: v6,
359            }
360        })
361    }
362}
363#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
364impl<const V: i32> Encode for PositionLook<V> {
365    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
366        w.put_f64((*self).x);
367        w.put_f64((*self).y);
368        w.put_f64((*self).z);
369        w.put_f32((*self).yaw);
370        w.put_f32((*self).pitch);
371        w.put_bool((*self).on_ground);
372        Ok(())
373    }
374}
375#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
376#[cfg(feature = "testgen")]
377impl<const V: i32> Generate for PositionLook<V> {
378    fn generate(g: &mut Gen) -> Self {
379        {
380            let v1 = g.f64();
381            let v2 = g.f64();
382            let v3 = g.f64();
383            let v4 = g.f32();
384            let v5 = g.f32();
385            let v6 = g.bool();
386            Self {
387                x: v1,
388                y: v2,
389                z: v3,
390                yaw: v4,
391                pitch: v5,
392                on_ground: v6,
393            }
394        }
395    }
396}
397
398#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
399/// `block_dig` (serverbound play).
400#[derive(Debug, Clone, PartialEq)]
401pub struct BlockDig<const V: i32> {
402    /// `status`
403    pub status: i32,
404    /// `location`
405    pub location: BlockPos,
406    /// `face`
407    pub face: i8,
408}
409#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
410impl<const V: i32> Decode for BlockDig<V> {
411    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
412        Ok({
413            let v1 = r.read_varint()?;
414            let v2 = BlockPos::read(r, PositionLayout::Xyz)?;
415            let v3 = r.read_i8()?;
416            Self {
417                status: v1,
418                location: v2,
419                face: v3,
420            }
421        })
422    }
423}
424#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
425impl<const V: i32> Encode for BlockDig<V> {
426    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
427        w.put_varint((*self).status);
428        (*self).location.write(w, PositionLayout::Xyz)?;
429        w.put_i8((*self).face);
430        Ok(())
431    }
432}
433#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
434#[cfg(feature = "testgen")]
435impl<const V: i32> Generate for BlockDig<V> {
436    fn generate(g: &mut Gen) -> Self {
437        {
438            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
439            let v2 = g.position();
440            let v3 = (g.int_in(-128, 127, &[]) as i8);
441            Self {
442                status: v1,
443                location: v2,
444                face: v3,
445            }
446        }
447    }
448}
449
450#[cfg(feature = "v1_8")]
451/// `block_place` (serverbound play).
452#[derive(Debug, Clone, PartialEq)]
453pub struct BlockPlace<const V: i32> {
454    /// `location`
455    pub location: BlockPos,
456    /// `direction`
457    pub direction: i8,
458    /// `heldItem`
459    pub held_item: crate::types::slot::legacy::Slot,
460    /// `cursorX`
461    pub cursor_x: i8,
462    /// `cursorY`
463    pub cursor_y: i8,
464    /// `cursorZ`
465    pub cursor_z: i8,
466}
467#[cfg(feature = "v1_8")]
468impl<const V: i32> Decode for BlockPlace<V> {
469    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
470        Ok({
471            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
472            let v2 = r.read_i8()?;
473            let v3 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
474            let v4 = r.read_i8()?;
475            let v5 = r.read_i8()?;
476            let v6 = r.read_i8()?;
477            Self {
478                location: v1,
479                direction: v2,
480                held_item: v3,
481                cursor_x: v4,
482                cursor_y: v5,
483                cursor_z: v6,
484            }
485        })
486    }
487}
488#[cfg(feature = "v1_8")]
489impl<const V: i32> Encode for BlockPlace<V> {
490    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
491        (*self).location.write(w, PositionLayout::Xyz)?;
492        w.put_i8((*self).direction);
493        (*self).held_item.encode(w)?;
494        w.put_i8((*self).cursor_x);
495        w.put_i8((*self).cursor_y);
496        w.put_i8((*self).cursor_z);
497        Ok(())
498    }
499}
500#[cfg(feature = "v1_8")]
501#[cfg(feature = "testgen")]
502impl<const V: i32> Generate for BlockPlace<V> {
503    fn generate(g: &mut Gen) -> Self {
504        {
505            let v1 = g.position();
506            let v2 = (g.int_in(-128, 127, &[]) as i8);
507            let v3 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
508            let v4 = (g.int_in(-128, 127, &[]) as i8);
509            let v5 = (g.int_in(-128, 127, &[]) as i8);
510            let v6 = (g.int_in(-128, 127, &[]) as i8);
511            Self {
512                location: v1,
513                direction: v2,
514                held_item: v3,
515                cursor_x: v4,
516                cursor_y: v5,
517                cursor_z: v6,
518            }
519        }
520    }
521}
522
523#[cfg(any(
524    feature = "v1_8",
525    feature = "v1_12_2",
526    feature = "v1_16_5",
527    feature = "v26_1",
528    feature = "v26_2"
529))]
530/// `held_item_slot` (serverbound play).
531#[derive(Debug, Clone, PartialEq)]
532pub struct HeldItemSlot<const V: i32> {
533    /// `slotId`
534    pub slot_id: i16,
535}
536#[cfg(any(
537    feature = "v1_8",
538    feature = "v1_12_2",
539    feature = "v1_16_5",
540    feature = "v26_1",
541    feature = "v26_2"
542))]
543impl<const V: i32> Decode for HeldItemSlot<V> {
544    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
545        Ok({
546            let v1 = r.read_i16()?;
547            Self { slot_id: v1 }
548        })
549    }
550}
551#[cfg(any(
552    feature = "v1_8",
553    feature = "v1_12_2",
554    feature = "v1_16_5",
555    feature = "v26_1",
556    feature = "v26_2"
557))]
558impl<const V: i32> Encode for HeldItemSlot<V> {
559    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
560        w.put_i16((*self).slot_id);
561        Ok(())
562    }
563}
564#[cfg(any(
565    feature = "v1_8",
566    feature = "v1_12_2",
567    feature = "v1_16_5",
568    feature = "v26_1",
569    feature = "v26_2"
570))]
571#[cfg(feature = "testgen")]
572impl<const V: i32> Generate for HeldItemSlot<V> {
573    fn generate(g: &mut Gen) -> Self {
574        {
575            let v1 = (g.int_in(-32768, 32767, &[]) as i16);
576            Self { slot_id: v1 }
577        }
578    }
579}
580
581#[cfg(feature = "v1_8")]
582/// `arm_animation` (serverbound play).
583#[derive(Debug, Clone, PartialEq)]
584pub struct ArmAnimation<const V: i32> {}
585#[cfg(feature = "v1_8")]
586impl<const V: i32> Decode for ArmAnimation<V> {
587    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
588        Ok({ Self {} })
589    }
590}
591#[cfg(feature = "v1_8")]
592impl<const V: i32> Encode for ArmAnimation<V> {
593    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
594        Ok(())
595    }
596}
597#[cfg(feature = "v1_8")]
598#[cfg(feature = "testgen")]
599impl<const V: i32> Generate for ArmAnimation<V> {
600    fn generate(g: &mut Gen) -> Self {
601        { Self {} }
602    }
603}
604
605#[cfg(feature = "v1_8")]
606/// Mapped `i32` value; unknown values are kept as-is.
607#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
608pub struct EntityActionActionId(pub i32);
609#[cfg(feature = "v1_8")]
610impl EntityActionActionId {
611    /// `start_sneaking`
612    pub const START_SNEAKING: Self = Self(0);
613    /// `stop_sneaking`
614    pub const STOP_SNEAKING: Self = Self(1);
615    /// `stop_sleeping`
616    pub const STOP_SLEEPING: Self = Self(2);
617    /// `start_sprinting`
618    pub const START_SPRINTING: Self = Self(3);
619    /// `stop_sprinting`
620    pub const STOP_SPRINTING: Self = Self(4);
621    /// `start_riding_jump`
622    pub const START_RIDING_JUMP: Self = Self(5);
623    /// `open_inventory`
624    pub const OPEN_INVENTORY: Self = Self(6);
625    /// minecraft-data name of the value, if known.
626    pub const fn name(self) -> Option<&'static str> {
627        match self.0 {
628            0 => Some("start_sneaking"),
629            1 => Some("stop_sneaking"),
630            2 => Some("stop_sleeping"),
631            3 => Some("start_sprinting"),
632            4 => Some("stop_sprinting"),
633            5 => Some("start_riding_jump"),
634            6 => Some("open_inventory"),
635            _ => None,
636        }
637    }
638}
639#[cfg(feature = "v1_8")]
640impl std::fmt::Debug for EntityActionActionId {
641    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
642        match self.name() {
643            Some(n) => write!(f, "EntityActionActionId::{n}"),
644            None => write!(f, "EntityActionActionId({})", self.0),
645        }
646    }
647}
648
649#[cfg(feature = "v1_8")]
650/// `entity_action` (serverbound play).
651#[derive(Debug, Clone, PartialEq)]
652pub struct EntityAction<const V: i32> {
653    /// `entityId`
654    pub entity_id: i32,
655    /// `actionId`
656    pub action_id: crate::defs::p47::play::serverbound::EntityActionActionId,
657    /// `jumpBoost`
658    pub jump_boost: i32,
659}
660#[cfg(feature = "v1_8")]
661impl<const V: i32> Decode for EntityAction<V> {
662    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
663        Ok({
664            let v1 = r.read_varint()?;
665            let v2 = crate::defs::p47::play::serverbound::EntityActionActionId(r.read_varint()?);
666            let v3 = r.read_varint()?;
667            Self {
668                entity_id: v1,
669                action_id: v2,
670                jump_boost: v3,
671            }
672        })
673    }
674}
675#[cfg(feature = "v1_8")]
676impl<const V: i32> Encode for EntityAction<V> {
677    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
678        w.put_varint((*self).entity_id);
679        w.put_varint((*self).action_id.0);
680        w.put_varint((*self).jump_boost);
681        Ok(())
682    }
683}
684#[cfg(feature = "v1_8")]
685#[cfg(feature = "testgen")]
686impl<const V: i32> Generate for EntityAction<V> {
687    fn generate(g: &mut Gen) -> Self {
688        {
689            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
690            let v2 = crate::defs::p47::play::serverbound::EntityActionActionId(g.int_in(
691                -2147483648,
692                2147483647,
693                &[0, 1, 2, 3, 4, 5, 6],
694            )
695                as i32);
696            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
697            Self {
698                entity_id: v1,
699                action_id: v2,
700                jump_boost: v3,
701            }
702        }
703    }
704}
705
706#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
707/// `steer_vehicle` (serverbound play).
708#[derive(Debug, Clone, PartialEq)]
709pub struct SteerVehicle<const V: i32> {
710    /// `sideways`
711    pub sideways: f32,
712    /// `forward`
713    pub forward: f32,
714    /// `jump`
715    pub jump: u8,
716}
717#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
718impl<const V: i32> Decode for SteerVehicle<V> {
719    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
720        Ok({
721            let v1 = r.read_f32()?;
722            let v2 = r.read_f32()?;
723            let v3 = r.read_u8()?;
724            Self {
725                sideways: v1,
726                forward: v2,
727                jump: v3,
728            }
729        })
730    }
731}
732#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
733impl<const V: i32> Encode for SteerVehicle<V> {
734    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
735        w.put_f32((*self).sideways);
736        w.put_f32((*self).forward);
737        w.put_u8((*self).jump);
738        Ok(())
739    }
740}
741#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
742#[cfg(feature = "testgen")]
743impl<const V: i32> Generate for SteerVehicle<V> {
744    fn generate(g: &mut Gen) -> Self {
745        {
746            let v1 = g.f32();
747            let v2 = g.f32();
748            let v3 = (g.int_in(0, 255, &[]) as u8);
749            Self {
750                sideways: v1,
751                forward: v2,
752                jump: v3,
753            }
754        }
755    }
756}
757
758#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
759/// `close_window` (serverbound play).
760#[derive(Debug, Clone, PartialEq)]
761pub struct CloseWindow<const V: i32> {
762    /// `windowId`
763    pub window_id: u8,
764}
765#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
766impl<const V: i32> Decode for CloseWindow<V> {
767    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
768        Ok({
769            let v1 = r.read_u8()?;
770            Self { window_id: v1 }
771        })
772    }
773}
774#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
775impl<const V: i32> Encode for CloseWindow<V> {
776    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
777        w.put_u8((*self).window_id);
778        Ok(())
779    }
780}
781#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
782#[cfg(feature = "testgen")]
783impl<const V: i32> Generate for CloseWindow<V> {
784    fn generate(g: &mut Gen) -> Self {
785        {
786            let v1 = (g.int_in(0, 255, &[]) as u8);
787            Self { window_id: v1 }
788        }
789    }
790}
791
792#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
793/// `window_click` (serverbound play).
794#[derive(Debug, Clone, PartialEq)]
795pub struct WindowClick<const V: i32> {
796    /// `windowId`
797    pub window_id: u8,
798    /// `slot`
799    pub slot: i16,
800    /// `mouseButton`
801    pub mouse_button: i8,
802    /// `action`
803    pub action: i16,
804    /// `mode`
805    pub mode: i8,
806    /// `item`
807    pub item: crate::types::slot::legacy::Slot,
808}
809#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
810impl<const V: i32> Decode for WindowClick<V> {
811    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
812        Ok({
813            let v1 = r.read_u8()?;
814            let v2 = r.read_i16()?;
815            let v3 = r.read_i8()?;
816            let v4 = r.read_i16()?;
817            let v5 = r.read_i8()?;
818            let v6 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
819            Self {
820                window_id: v1,
821                slot: v2,
822                mouse_button: v3,
823                action: v4,
824                mode: v5,
825                item: v6,
826            }
827        })
828    }
829}
830#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
831impl<const V: i32> Encode for WindowClick<V> {
832    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
833        w.put_u8((*self).window_id);
834        w.put_i16((*self).slot);
835        w.put_i8((*self).mouse_button);
836        w.put_i16((*self).action);
837        w.put_i8((*self).mode);
838        (*self).item.encode(w)?;
839        Ok(())
840    }
841}
842#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
843#[cfg(feature = "testgen")]
844impl<const V: i32> Generate for WindowClick<V> {
845    fn generate(g: &mut Gen) -> Self {
846        {
847            let v1 = (g.int_in(0, 255, &[]) as u8);
848            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
849            let v3 = (g.int_in(-128, 127, &[]) as i8);
850            let v4 = (g.int_in(-32768, 32767, &[]) as i16);
851            let v5 = (g.int_in(-128, 127, &[]) as i8);
852            let v6 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
853            Self {
854                window_id: v1,
855                slot: v2,
856                mouse_button: v3,
857                action: v4,
858                mode: v5,
859                item: v6,
860            }
861        }
862    }
863}
864
865#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
866/// `transaction` (serverbound play).
867#[derive(Debug, Clone, PartialEq)]
868pub struct Transaction<const V: i32> {
869    /// `windowId`
870    pub window_id: i8,
871    /// `action`
872    pub action: i16,
873    /// `accepted`
874    pub accepted: bool,
875}
876#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
877impl<const V: i32> Decode for Transaction<V> {
878    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
879        Ok({
880            let v1 = r.read_i8()?;
881            let v2 = r.read_i16()?;
882            let v3 = r.read_bool()?;
883            Self {
884                window_id: v1,
885                action: v2,
886                accepted: v3,
887            }
888        })
889    }
890}
891#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
892impl<const V: i32> Encode for Transaction<V> {
893    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
894        w.put_i8((*self).window_id);
895        w.put_i16((*self).action);
896        w.put_bool((*self).accepted);
897        Ok(())
898    }
899}
900#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
901#[cfg(feature = "testgen")]
902impl<const V: i32> Generate for Transaction<V> {
903    fn generate(g: &mut Gen) -> Self {
904        {
905            let v1 = (g.int_in(-128, 127, &[]) as i8);
906            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
907            let v3 = g.bool();
908            Self {
909                window_id: v1,
910                action: v2,
911                accepted: v3,
912            }
913        }
914    }
915}
916
917#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
918/// `set_creative_slot` (serverbound play).
919#[derive(Debug, Clone, PartialEq)]
920pub struct SetCreativeSlot<const V: i32> {
921    /// `slot`
922    pub slot: i16,
923    /// `item`
924    pub item: crate::types::slot::legacy::Slot,
925}
926#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
927impl<const V: i32> Decode for SetCreativeSlot<V> {
928    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
929        Ok({
930            let v1 = r.read_i16()?;
931            let v2 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
932            Self { slot: v1, item: v2 }
933        })
934    }
935}
936#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
937impl<const V: i32> Encode for SetCreativeSlot<V> {
938    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
939        w.put_i16((*self).slot);
940        (*self).item.encode(w)?;
941        Ok(())
942    }
943}
944#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
945#[cfg(feature = "testgen")]
946impl<const V: i32> Generate for SetCreativeSlot<V> {
947    fn generate(g: &mut Gen) -> Self {
948        {
949            let v1 = (g.int_in(-32768, 32767, &[]) as i16);
950            let v2 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
951            Self { slot: v1, item: v2 }
952        }
953    }
954}
955
956#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
957/// `enchant_item` (serverbound play).
958#[derive(Debug, Clone, PartialEq)]
959pub struct EnchantItem<const V: i32> {
960    /// `windowId`
961    pub window_id: i8,
962    /// `enchantment`
963    pub enchantment: i8,
964}
965#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
966impl<const V: i32> Decode for EnchantItem<V> {
967    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
968        Ok({
969            let v1 = r.read_i8()?;
970            let v2 = r.read_i8()?;
971            Self {
972                window_id: v1,
973                enchantment: v2,
974            }
975        })
976    }
977}
978#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
979impl<const V: i32> Encode for EnchantItem<V> {
980    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
981        w.put_i8((*self).window_id);
982        w.put_i8((*self).enchantment);
983        Ok(())
984    }
985}
986#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
987#[cfg(feature = "testgen")]
988impl<const V: i32> Generate for EnchantItem<V> {
989    fn generate(g: &mut Gen) -> Self {
990        {
991            let v1 = (g.int_in(-128, 127, &[]) as i8);
992            let v2 = (g.int_in(-128, 127, &[]) as i8);
993            Self {
994                window_id: v1,
995                enchantment: v2,
996            }
997        }
998    }
999}
1000
1001#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1002/// `update_sign` (serverbound play).
1003#[derive(Debug, Clone, PartialEq)]
1004pub struct UpdateSign<const V: i32> {
1005    /// `location`
1006    pub location: BlockPos,
1007    /// `text1`
1008    pub text1: ByteString,
1009    /// `text2`
1010    pub text2: ByteString,
1011    /// `text3`
1012    pub text3: ByteString,
1013    /// `text4`
1014    pub text4: ByteString,
1015}
1016#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1017impl<const V: i32> Decode for UpdateSign<V> {
1018    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1019        Ok({
1020            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
1021            let v2 = r.read_string()?;
1022            let v3 = r.read_string()?;
1023            let v4 = r.read_string()?;
1024            let v5 = r.read_string()?;
1025            Self {
1026                location: v1,
1027                text1: v2,
1028                text2: v3,
1029                text3: v4,
1030                text4: v5,
1031            }
1032        })
1033    }
1034}
1035#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1036impl<const V: i32> Encode for UpdateSign<V> {
1037    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1038        (*self).location.write(w, PositionLayout::Xyz)?;
1039        w.put_string(&(*self).text1)?;
1040        w.put_string(&(*self).text2)?;
1041        w.put_string(&(*self).text3)?;
1042        w.put_string(&(*self).text4)?;
1043        Ok(())
1044    }
1045}
1046#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1047#[cfg(feature = "testgen")]
1048impl<const V: i32> Generate for UpdateSign<V> {
1049    fn generate(g: &mut Gen) -> Self {
1050        {
1051            let v1 = g.position();
1052            let v2 = g.string();
1053            let v3 = g.string();
1054            let v4 = g.string();
1055            let v5 = g.string();
1056            Self {
1057                location: v1,
1058                text1: v2,
1059                text2: v3,
1060                text3: v4,
1061                text4: v5,
1062            }
1063        }
1064    }
1065}
1066
1067#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1068/// `abilities` (serverbound play).
1069#[derive(Debug, Clone, PartialEq)]
1070pub struct Abilities<const V: i32> {
1071    /// `flags`
1072    pub flags: i8,
1073    /// `flyingSpeed`
1074    pub flying_speed: f32,
1075    /// `walkingSpeed`
1076    pub walking_speed: f32,
1077}
1078#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1079impl<const V: i32> Decode for Abilities<V> {
1080    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1081        Ok({
1082            let v1 = r.read_i8()?;
1083            let v2 = r.read_f32()?;
1084            let v3 = r.read_f32()?;
1085            Self {
1086                flags: v1,
1087                flying_speed: v2,
1088                walking_speed: v3,
1089            }
1090        })
1091    }
1092}
1093#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1094impl<const V: i32> Encode for Abilities<V> {
1095    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1096        w.put_i8((*self).flags);
1097        w.put_f32((*self).flying_speed);
1098        w.put_f32((*self).walking_speed);
1099        Ok(())
1100    }
1101}
1102#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
1103#[cfg(feature = "testgen")]
1104impl<const V: i32> Generate for Abilities<V> {
1105    fn generate(g: &mut Gen) -> Self {
1106        {
1107            let v1 = (g.int_in(-128, 127, &[]) as i8);
1108            let v2 = g.f32();
1109            let v3 = g.f32();
1110            Self {
1111                flags: v1,
1112                flying_speed: v2,
1113                walking_speed: v3,
1114            }
1115        }
1116    }
1117}
1118
1119#[cfg(feature = "v1_8")]
1120/// `tab_complete` (serverbound play).
1121#[derive(Debug, Clone, PartialEq)]
1122pub struct TabComplete<const V: i32> {
1123    /// `text`
1124    pub text: ByteString,
1125    /// `block`
1126    pub block: Option<BlockPos>,
1127}
1128#[cfg(feature = "v1_8")]
1129impl<const V: i32> Decode for TabComplete<V> {
1130    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1131        Ok({
1132            let v1 = r.read_string()?;
1133            let v2 = if r.read_bool()? {
1134                Some(BlockPos::read(r, PositionLayout::Xyz)?)
1135            } else {
1136                None
1137            };
1138            Self {
1139                text: v1,
1140                block: v2,
1141            }
1142        })
1143    }
1144}
1145#[cfg(feature = "v1_8")]
1146impl<const V: i32> Encode for TabComplete<V> {
1147    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1148        w.put_string(&(*self).text)?;
1149        match &(*self).block {
1150            Some(v1) => {
1151                w.put_u8(1);
1152                (*v1).write(w, PositionLayout::Xyz)?;
1153            }
1154            None => w.put_u8(0),
1155        }
1156        Ok(())
1157    }
1158}
1159#[cfg(feature = "v1_8")]
1160#[cfg(feature = "testgen")]
1161impl<const V: i32> Generate for TabComplete<V> {
1162    fn generate(g: &mut Gen) -> Self {
1163        {
1164            let v1 = g.string();
1165            let v2 = if g.bool() { Some(g.position()) } else { None };
1166            Self {
1167                text: v1,
1168                block: v2,
1169            }
1170        }
1171    }
1172}
1173
1174#[cfg(feature = "v1_8")]
1175/// `settings` (serverbound play).
1176#[derive(Debug, Clone, PartialEq)]
1177pub struct Settings<const V: i32> {
1178    /// `locale`
1179    pub locale: ByteString,
1180    /// `viewDistance`
1181    pub view_distance: i8,
1182    /// `chatFlags`
1183    pub chat_flags: i8,
1184    /// `chatColors`
1185    pub chat_colors: bool,
1186    /// `skinParts`
1187    pub skin_parts: u8,
1188}
1189#[cfg(feature = "v1_8")]
1190impl<const V: i32> Decode for Settings<V> {
1191    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1192        Ok({
1193            let v1 = r.read_string()?;
1194            let v2 = r.read_i8()?;
1195            let v3 = r.read_i8()?;
1196            let v4 = r.read_bool()?;
1197            let v5 = r.read_u8()?;
1198            Self {
1199                locale: v1,
1200                view_distance: v2,
1201                chat_flags: v3,
1202                chat_colors: v4,
1203                skin_parts: v5,
1204            }
1205        })
1206    }
1207}
1208#[cfg(feature = "v1_8")]
1209impl<const V: i32> Encode for Settings<V> {
1210    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1211        w.put_string(&(*self).locale)?;
1212        w.put_i8((*self).view_distance);
1213        w.put_i8((*self).chat_flags);
1214        w.put_bool((*self).chat_colors);
1215        w.put_u8((*self).skin_parts);
1216        Ok(())
1217    }
1218}
1219#[cfg(feature = "v1_8")]
1220#[cfg(feature = "testgen")]
1221impl<const V: i32> Generate for Settings<V> {
1222    fn generate(g: &mut Gen) -> Self {
1223        {
1224            let v1 = g.string();
1225            let v2 = (g.int_in(-128, 127, &[]) as i8);
1226            let v3 = (g.int_in(-128, 127, &[]) as i8);
1227            let v4 = g.bool();
1228            let v5 = (g.int_in(0, 255, &[]) as u8);
1229            Self {
1230                locale: v1,
1231                view_distance: v2,
1232                chat_flags: v3,
1233                chat_colors: v4,
1234                skin_parts: v5,
1235            }
1236        }
1237    }
1238}
1239
1240#[cfg(feature = "v1_8")]
1241/// Mapped `i32` value; unknown values are kept as-is.
1242#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
1243pub struct ClientCommandPayload(pub i32);
1244#[cfg(feature = "v1_8")]
1245impl ClientCommandPayload {
1246    /// `perform_respawn`
1247    pub const PERFORM_RESPAWN: Self = Self(0);
1248    /// `request_stats`
1249    pub const REQUEST_STATS: Self = Self(1);
1250    /// `open_inventory_achievement`
1251    pub const OPEN_INVENTORY_ACHIEVEMENT: Self = Self(2);
1252    /// minecraft-data name of the value, if known.
1253    pub const fn name(self) -> Option<&'static str> {
1254        match self.0 {
1255            0 => Some("perform_respawn"),
1256            1 => Some("request_stats"),
1257            2 => Some("open_inventory_achievement"),
1258            _ => None,
1259        }
1260    }
1261}
1262#[cfg(feature = "v1_8")]
1263impl std::fmt::Debug for ClientCommandPayload {
1264    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1265        match self.name() {
1266            Some(n) => write!(f, "ClientCommandPayload::{n}"),
1267            None => write!(f, "ClientCommandPayload({})", self.0),
1268        }
1269    }
1270}
1271
1272#[cfg(feature = "v1_8")]
1273/// `client_command` (serverbound play).
1274#[derive(Debug, Clone, PartialEq)]
1275pub struct ClientCommand<const V: i32> {
1276    /// `payload`
1277    pub payload: crate::defs::p47::play::serverbound::ClientCommandPayload,
1278}
1279#[cfg(feature = "v1_8")]
1280impl<const V: i32> Decode for ClientCommand<V> {
1281    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1282        Ok({
1283            let v1 = crate::defs::p47::play::serverbound::ClientCommandPayload(r.read_varint()?);
1284            Self { payload: v1 }
1285        })
1286    }
1287}
1288#[cfg(feature = "v1_8")]
1289impl<const V: i32> Encode for ClientCommand<V> {
1290    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1291        w.put_varint((*self).payload.0);
1292        Ok(())
1293    }
1294}
1295#[cfg(feature = "v1_8")]
1296#[cfg(feature = "testgen")]
1297impl<const V: i32> Generate for ClientCommand<V> {
1298    fn generate(g: &mut Gen) -> Self {
1299        {
1300            let v1 = crate::defs::p47::play::serverbound::ClientCommandPayload(g.int_in(
1301                -2147483648,
1302                2147483647,
1303                &[0, 1, 2],
1304            )
1305                as i32);
1306            Self { payload: v1 }
1307        }
1308    }
1309}
1310
1311#[cfg(any(
1312    feature = "v1_8",
1313    feature = "v1_12_2",
1314    feature = "v1_16_5",
1315    feature = "v26_1",
1316    feature = "v26_2"
1317))]
1318/// `custom_payload` (serverbound play).
1319#[derive(Debug, Clone, PartialEq)]
1320pub struct CustomPayload<const V: i32> {
1321    /// `channel`
1322    pub channel: ByteString,
1323    /// `data`
1324    pub data: Bytes,
1325}
1326#[cfg(any(
1327    feature = "v1_8",
1328    feature = "v1_12_2",
1329    feature = "v1_16_5",
1330    feature = "v26_1",
1331    feature = "v26_2"
1332))]
1333impl<const V: i32> Decode for CustomPayload<V> {
1334    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1335        Ok({
1336            let v1 = r.read_string()?;
1337            let v2 = r.read_rest();
1338            Self {
1339                channel: v1,
1340                data: v2,
1341            }
1342        })
1343    }
1344}
1345#[cfg(any(
1346    feature = "v1_8",
1347    feature = "v1_12_2",
1348    feature = "v1_16_5",
1349    feature = "v26_1",
1350    feature = "v26_2"
1351))]
1352impl<const V: i32> Encode for CustomPayload<V> {
1353    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1354        w.put_string(&(*self).channel)?;
1355        w.put_slice(&(*self).data);
1356        Ok(())
1357    }
1358}
1359#[cfg(any(
1360    feature = "v1_8",
1361    feature = "v1_12_2",
1362    feature = "v1_16_5",
1363    feature = "v26_1",
1364    feature = "v26_2"
1365))]
1366#[cfg(feature = "testgen")]
1367impl<const V: i32> Generate for CustomPayload<V> {
1368    fn generate(g: &mut Gen) -> Self {
1369        {
1370            let v1 = g.string();
1371            let v2 = g.bytes();
1372            Self {
1373                channel: v1,
1374                data: v2,
1375            }
1376        }
1377    }
1378}
1379
1380#[cfg(any(
1381    feature = "v1_8",
1382    feature = "v1_12_2",
1383    feature = "v1_16_5",
1384    feature = "v26_1",
1385    feature = "v26_2"
1386))]
1387/// `spectate` (serverbound play).
1388#[derive(Debug, Clone, PartialEq)]
1389pub struct Spectate<const V: i32> {
1390    /// `target`
1391    pub target: Uuid,
1392}
1393#[cfg(any(
1394    feature = "v1_8",
1395    feature = "v1_12_2",
1396    feature = "v1_16_5",
1397    feature = "v26_1",
1398    feature = "v26_2"
1399))]
1400impl<const V: i32> Decode for Spectate<V> {
1401    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1402        Ok({
1403            let v1 = r.read_uuid()?;
1404            Self { target: v1 }
1405        })
1406    }
1407}
1408#[cfg(any(
1409    feature = "v1_8",
1410    feature = "v1_12_2",
1411    feature = "v1_16_5",
1412    feature = "v26_1",
1413    feature = "v26_2"
1414))]
1415impl<const V: i32> Encode for Spectate<V> {
1416    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1417        w.put_uuid(&(*self).target);
1418        Ok(())
1419    }
1420}
1421#[cfg(any(
1422    feature = "v1_8",
1423    feature = "v1_12_2",
1424    feature = "v1_16_5",
1425    feature = "v26_1",
1426    feature = "v26_2"
1427))]
1428#[cfg(feature = "testgen")]
1429impl<const V: i32> Generate for Spectate<V> {
1430    fn generate(g: &mut Gen) -> Self {
1431        {
1432            let v1 = g.uuid();
1433            Self { target: v1 }
1434        }
1435    }
1436}
1437
1438#[cfg(feature = "v1_8")]
1439/// `resource_pack_receive` (serverbound play).
1440#[derive(Debug, Clone, PartialEq)]
1441pub struct ResourcePackReceive<const V: i32> {
1442    /// `hash`
1443    pub hash: ByteString,
1444    /// `result`
1445    pub result: i32,
1446}
1447#[cfg(feature = "v1_8")]
1448impl<const V: i32> Decode for ResourcePackReceive<V> {
1449    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1450        Ok({
1451            let v1 = r.read_string()?;
1452            let v2 = r.read_varint()?;
1453            Self {
1454                hash: v1,
1455                result: v2,
1456            }
1457        })
1458    }
1459}
1460#[cfg(feature = "v1_8")]
1461impl<const V: i32> Encode for ResourcePackReceive<V> {
1462    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1463        w.put_string(&(*self).hash)?;
1464        w.put_varint((*self).result);
1465        Ok(())
1466    }
1467}
1468#[cfg(feature = "v1_8")]
1469#[cfg(feature = "testgen")]
1470impl<const V: i32> Generate for ResourcePackReceive<V> {
1471    fn generate(g: &mut Gen) -> Self {
1472        {
1473            let v1 = g.string();
1474            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1475            Self {
1476                hash: v1,
1477                result: v2,
1478            }
1479        }
1480    }
1481}