Skip to main content

ghast_protocol/generated/defs/p47/play/
clientbound.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//! Clientbound 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(any(feature = "v1_8", feature = "v1_12_2"))]
29/// `keep_alive` (clientbound play).
30#[derive(Debug, Clone, PartialEq)]
31pub struct KeepAlive<const V: i32> {
32    /// `keepAliveId`
33    pub keep_alive_id: i32,
34}
35#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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(any(feature = "v1_8", feature = "v1_12_2"))]
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(any(feature = "v1_8", feature = "v1_12_2"))]
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(feature = "v1_8")]
63/// `login` (clientbound play).
64#[derive(Debug, Clone, PartialEq)]
65pub struct Login<const V: i32> {
66    /// `entityId`
67    pub entity_id: i32,
68    /// `gameMode`
69    pub game_mode: u8,
70    /// `dimension`
71    pub dimension: i8,
72    /// `difficulty`
73    pub difficulty: u8,
74    /// `maxPlayers`
75    pub max_players: u8,
76    /// `levelType`
77    pub level_type: ByteString,
78    /// `reducedDebugInfo`
79    pub reduced_debug_info: bool,
80}
81#[cfg(feature = "v1_8")]
82impl<const V: i32> Decode for Login<V> {
83    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
84        Ok({
85            let v1 = r.read_i32()?;
86            let v2 = r.read_u8()?;
87            let v3 = r.read_i8()?;
88            let v4 = r.read_u8()?;
89            let v5 = r.read_u8()?;
90            let v6 = r.read_string()?;
91            let v7 = r.read_bool()?;
92            Self {
93                entity_id: v1,
94                game_mode: v2,
95                dimension: v3,
96                difficulty: v4,
97                max_players: v5,
98                level_type: v6,
99                reduced_debug_info: v7,
100            }
101        })
102    }
103}
104#[cfg(feature = "v1_8")]
105impl<const V: i32> Encode for Login<V> {
106    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
107        w.put_i32((*self).entity_id);
108        w.put_u8((*self).game_mode);
109        w.put_i8((*self).dimension);
110        w.put_u8((*self).difficulty);
111        w.put_u8((*self).max_players);
112        w.put_string(&(*self).level_type)?;
113        w.put_bool((*self).reduced_debug_info);
114        Ok(())
115    }
116}
117#[cfg(feature = "v1_8")]
118#[cfg(feature = "testgen")]
119impl<const V: i32> Generate for Login<V> {
120    fn generate(g: &mut Gen) -> Self {
121        {
122            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
123            let v2 = (g.int_in(0, 255, &[]) as u8);
124            let v3 = (g.int_in(-128, 127, &[]) as i8);
125            let v4 = (g.int_in(0, 255, &[]) as u8);
126            let v5 = (g.int_in(0, 255, &[]) as u8);
127            let v6 = g.string();
128            let v7 = g.bool();
129            Self {
130                entity_id: v1,
131                game_mode: v2,
132                dimension: v3,
133                difficulty: v4,
134                max_players: v5,
135                level_type: v6,
136                reduced_debug_info: v7,
137            }
138        }
139    }
140}
141
142#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
143/// `chat` (clientbound play).
144#[derive(Debug, Clone, PartialEq)]
145pub struct Chat<const V: i32> {
146    /// `message`
147    pub message: ByteString,
148    /// `position`
149    pub position: i8,
150}
151#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
152impl<const V: i32> Decode for Chat<V> {
153    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
154        Ok({
155            let v1 = r.read_string()?;
156            let v2 = r.read_i8()?;
157            Self {
158                message: v1,
159                position: v2,
160            }
161        })
162    }
163}
164#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
165impl<const V: i32> Encode for Chat<V> {
166    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
167        w.put_string(&(*self).message)?;
168        w.put_i8((*self).position);
169        Ok(())
170    }
171}
172#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
173#[cfg(feature = "testgen")]
174impl<const V: i32> Generate for Chat<V> {
175    fn generate(g: &mut Gen) -> Self {
176        {
177            let v1 = g.string();
178            let v2 = (g.int_in(-128, 127, &[]) as i8);
179            Self {
180                message: v1,
181                position: v2,
182            }
183        }
184    }
185}
186
187#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
188/// `update_time` (clientbound play).
189#[derive(Debug, Clone, PartialEq)]
190pub struct UpdateTime<const V: i32> {
191    /// `age`
192    pub age: i64,
193    /// `time`
194    pub time: i64,
195}
196#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
197impl<const V: i32> Decode for UpdateTime<V> {
198    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
199        Ok({
200            let v1 = r.read_i64()?;
201            let v2 = r.read_i64()?;
202            Self { age: v1, time: v2 }
203        })
204    }
205}
206#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
207impl<const V: i32> Encode for UpdateTime<V> {
208    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
209        w.put_i64((*self).age);
210        w.put_i64((*self).time);
211        Ok(())
212    }
213}
214#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
215#[cfg(feature = "testgen")]
216impl<const V: i32> Generate for UpdateTime<V> {
217    fn generate(g: &mut Gen) -> Self {
218        {
219            let v1 = g.i64();
220            let v2 = g.i64();
221            Self { age: v1, time: v2 }
222        }
223    }
224}
225
226#[cfg(feature = "v1_8")]
227/// `entity_equipment` (clientbound play).
228#[derive(Debug, Clone, PartialEq)]
229pub struct EntityEquipment<const V: i32> {
230    /// `entityId`
231    pub entity_id: i32,
232    /// `slot`
233    pub slot: i16,
234    /// `item`
235    pub item: crate::types::slot::legacy::Slot,
236}
237#[cfg(feature = "v1_8")]
238impl<const V: i32> Decode for EntityEquipment<V> {
239    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
240        Ok({
241            let v1 = r.read_varint()?;
242            let v2 = r.read_i16()?;
243            let v3 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
244            Self {
245                entity_id: v1,
246                slot: v2,
247                item: v3,
248            }
249        })
250    }
251}
252#[cfg(feature = "v1_8")]
253impl<const V: i32> Encode for EntityEquipment<V> {
254    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
255        w.put_varint((*self).entity_id);
256        w.put_i16((*self).slot);
257        (*self).item.encode(w)?;
258        Ok(())
259    }
260}
261#[cfg(feature = "v1_8")]
262#[cfg(feature = "testgen")]
263impl<const V: i32> Generate for EntityEquipment<V> {
264    fn generate(g: &mut Gen) -> Self {
265        {
266            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
267            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
268            let v3 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
269            Self {
270                entity_id: v1,
271                slot: v2,
272                item: v3,
273            }
274        }
275    }
276}
277
278#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
279/// `spawn_position` (clientbound play).
280#[derive(Debug, Clone, PartialEq)]
281pub struct SpawnPosition<const V: i32> {
282    /// `location`
283    pub location: BlockPos,
284}
285#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
286impl<const V: i32> Decode for SpawnPosition<V> {
287    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
288        Ok({
289            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
290            Self { location: v1 }
291        })
292    }
293}
294#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
295impl<const V: i32> Encode for SpawnPosition<V> {
296    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
297        (*self).location.write(w, PositionLayout::Xyz)?;
298        Ok(())
299    }
300}
301#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
302#[cfg(feature = "testgen")]
303impl<const V: i32> Generate for SpawnPosition<V> {
304    fn generate(g: &mut Gen) -> Self {
305        {
306            let v1 = g.position();
307            Self { location: v1 }
308        }
309    }
310}
311
312#[cfg(any(
313    feature = "v1_8",
314    feature = "v1_12_2",
315    feature = "v1_16_5",
316    feature = "v26_1",
317    feature = "v26_2"
318))]
319/// `update_health` (clientbound play).
320#[derive(Debug, Clone, PartialEq)]
321pub struct UpdateHealth<const V: i32> {
322    /// `health`
323    pub health: f32,
324    /// `food`
325    pub food: i32,
326    /// `foodSaturation`
327    pub food_saturation: f32,
328}
329#[cfg(any(
330    feature = "v1_8",
331    feature = "v1_12_2",
332    feature = "v1_16_5",
333    feature = "v26_1",
334    feature = "v26_2"
335))]
336impl<const V: i32> Decode for UpdateHealth<V> {
337    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
338        Ok({
339            let v1 = r.read_f32()?;
340            let v2 = r.read_varint()?;
341            let v3 = r.read_f32()?;
342            Self {
343                health: v1,
344                food: v2,
345                food_saturation: v3,
346            }
347        })
348    }
349}
350#[cfg(any(
351    feature = "v1_8",
352    feature = "v1_12_2",
353    feature = "v1_16_5",
354    feature = "v26_1",
355    feature = "v26_2"
356))]
357impl<const V: i32> Encode for UpdateHealth<V> {
358    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
359        w.put_f32((*self).health);
360        w.put_varint((*self).food);
361        w.put_f32((*self).food_saturation);
362        Ok(())
363    }
364}
365#[cfg(any(
366    feature = "v1_8",
367    feature = "v1_12_2",
368    feature = "v1_16_5",
369    feature = "v26_1",
370    feature = "v26_2"
371))]
372#[cfg(feature = "testgen")]
373impl<const V: i32> Generate for UpdateHealth<V> {
374    fn generate(g: &mut Gen) -> Self {
375        {
376            let v1 = g.f32();
377            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
378            let v3 = g.f32();
379            Self {
380                health: v1,
381                food: v2,
382                food_saturation: v3,
383            }
384        }
385    }
386}
387
388#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
389/// `respawn` (clientbound play).
390#[derive(Debug, Clone, PartialEq)]
391pub struct Respawn<const V: i32> {
392    /// `dimension`
393    pub dimension: i32,
394    /// `difficulty`
395    pub difficulty: u8,
396    /// `gamemode`
397    pub gamemode: u8,
398    /// `levelType`
399    pub level_type: ByteString,
400}
401#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
402impl<const V: i32> Decode for Respawn<V> {
403    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
404        Ok({
405            let v1 = r.read_i32()?;
406            let v2 = r.read_u8()?;
407            let v3 = r.read_u8()?;
408            let v4 = r.read_string()?;
409            Self {
410                dimension: v1,
411                difficulty: v2,
412                gamemode: v3,
413                level_type: v4,
414            }
415        })
416    }
417}
418#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
419impl<const V: i32> Encode for Respawn<V> {
420    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
421        w.put_i32((*self).dimension);
422        w.put_u8((*self).difficulty);
423        w.put_u8((*self).gamemode);
424        w.put_string(&(*self).level_type)?;
425        Ok(())
426    }
427}
428#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
429#[cfg(feature = "testgen")]
430impl<const V: i32> Generate for Respawn<V> {
431    fn generate(g: &mut Gen) -> Self {
432        {
433            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
434            let v2 = (g.int_in(0, 255, &[]) as u8);
435            let v3 = (g.int_in(0, 255, &[]) as u8);
436            let v4 = g.string();
437            Self {
438                dimension: v1,
439                difficulty: v2,
440                gamemode: v3,
441                level_type: v4,
442            }
443        }
444    }
445}
446
447#[cfg(feature = "v1_8")]
448/// `position` (clientbound play).
449#[derive(Debug, Clone, PartialEq)]
450pub struct Position<const V: i32> {
451    /// `x`
452    pub x: f64,
453    /// `y`
454    pub y: f64,
455    /// `z`
456    pub z: f64,
457    /// `yaw`
458    pub yaw: f32,
459    /// `pitch`
460    pub pitch: f32,
461    /// `flags`
462    pub flags: i8,
463}
464#[cfg(feature = "v1_8")]
465impl<const V: i32> Decode for Position<V> {
466    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
467        Ok({
468            let v1 = r.read_f64()?;
469            let v2 = r.read_f64()?;
470            let v3 = r.read_f64()?;
471            let v4 = r.read_f32()?;
472            let v5 = r.read_f32()?;
473            let v6 = r.read_i8()?;
474            Self {
475                x: v1,
476                y: v2,
477                z: v3,
478                yaw: v4,
479                pitch: v5,
480                flags: v6,
481            }
482        })
483    }
484}
485#[cfg(feature = "v1_8")]
486impl<const V: i32> Encode for Position<V> {
487    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
488        w.put_f64((*self).x);
489        w.put_f64((*self).y);
490        w.put_f64((*self).z);
491        w.put_f32((*self).yaw);
492        w.put_f32((*self).pitch);
493        w.put_i8((*self).flags);
494        Ok(())
495    }
496}
497#[cfg(feature = "v1_8")]
498#[cfg(feature = "testgen")]
499impl<const V: i32> Generate for Position<V> {
500    fn generate(g: &mut Gen) -> Self {
501        {
502            let v1 = g.f64();
503            let v2 = g.f64();
504            let v3 = g.f64();
505            let v4 = g.f32();
506            let v5 = g.f32();
507            let v6 = (g.int_in(-128, 127, &[]) as i8);
508            Self {
509                x: v1,
510                y: v2,
511                z: v3,
512                yaw: v4,
513                pitch: v5,
514                flags: v6,
515            }
516        }
517    }
518}
519
520#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
521/// `held_item_slot` (clientbound play).
522#[derive(Debug, Clone, PartialEq)]
523pub struct HeldItemSlot<const V: i32> {
524    /// `slot`
525    pub slot: i8,
526}
527#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
528impl<const V: i32> Decode for HeldItemSlot<V> {
529    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
530        Ok({
531            let v1 = r.read_i8()?;
532            Self { slot: v1 }
533        })
534    }
535}
536#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
537impl<const V: i32> Encode for HeldItemSlot<V> {
538    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
539        w.put_i8((*self).slot);
540        Ok(())
541    }
542}
543#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
544#[cfg(feature = "testgen")]
545impl<const V: i32> Generate for HeldItemSlot<V> {
546    fn generate(g: &mut Gen) -> Self {
547        {
548            let v1 = (g.int_in(-128, 127, &[]) as i8);
549            Self { slot: v1 }
550        }
551    }
552}
553
554#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
555/// `bed` (clientbound play).
556#[derive(Debug, Clone, PartialEq)]
557pub struct Bed<const V: i32> {
558    /// `entityId`
559    pub entity_id: i32,
560    /// `location`
561    pub location: BlockPos,
562}
563#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
564impl<const V: i32> Decode for Bed<V> {
565    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
566        Ok({
567            let v1 = r.read_varint()?;
568            let v2 = BlockPos::read(r, PositionLayout::Xyz)?;
569            Self {
570                entity_id: v1,
571                location: v2,
572            }
573        })
574    }
575}
576#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
577impl<const V: i32> Encode for Bed<V> {
578    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
579        w.put_varint((*self).entity_id);
580        (*self).location.write(w, PositionLayout::Xyz)?;
581        Ok(())
582    }
583}
584#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
585#[cfg(feature = "testgen")]
586impl<const V: i32> Generate for Bed<V> {
587    fn generate(g: &mut Gen) -> Self {
588        {
589            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
590            let v2 = g.position();
591            Self {
592                entity_id: v1,
593                location: v2,
594            }
595        }
596    }
597}
598
599#[cfg(any(
600    feature = "v1_8",
601    feature = "v1_12_2",
602    feature = "v1_16_5",
603    feature = "v26_1",
604    feature = "v26_2"
605))]
606/// `animation` (clientbound play).
607#[derive(Debug, Clone, PartialEq)]
608pub struct Animation<const V: i32> {
609    /// `entityId`
610    pub entity_id: i32,
611    /// `animation`
612    pub animation: u8,
613}
614#[cfg(any(
615    feature = "v1_8",
616    feature = "v1_12_2",
617    feature = "v1_16_5",
618    feature = "v26_1",
619    feature = "v26_2"
620))]
621impl<const V: i32> Decode for Animation<V> {
622    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
623        Ok({
624            let v1 = r.read_varint()?;
625            let v2 = r.read_u8()?;
626            Self {
627                entity_id: v1,
628                animation: v2,
629            }
630        })
631    }
632}
633#[cfg(any(
634    feature = "v1_8",
635    feature = "v1_12_2",
636    feature = "v1_16_5",
637    feature = "v26_1",
638    feature = "v26_2"
639))]
640impl<const V: i32> Encode for Animation<V> {
641    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
642        w.put_varint((*self).entity_id);
643        w.put_u8((*self).animation);
644        Ok(())
645    }
646}
647#[cfg(any(
648    feature = "v1_8",
649    feature = "v1_12_2",
650    feature = "v1_16_5",
651    feature = "v26_1",
652    feature = "v26_2"
653))]
654#[cfg(feature = "testgen")]
655impl<const V: i32> Generate for Animation<V> {
656    fn generate(g: &mut Gen) -> Self {
657        {
658            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
659            let v2 = (g.int_in(0, 255, &[]) as u8);
660            Self {
661                entity_id: v1,
662                animation: v2,
663            }
664        }
665    }
666}
667
668#[cfg(feature = "v1_8")]
669/// `named_entity_spawn` (clientbound play).
670#[derive(Debug, Clone, PartialEq)]
671pub struct NamedEntitySpawn<const V: i32> {
672    /// `entityId`
673    pub entity_id: i32,
674    /// `playerUUID`
675    pub player_uuid: Uuid,
676    /// `x`
677    pub x: i32,
678    /// `y`
679    pub y: i32,
680    /// `z`
681    pub z: i32,
682    /// `yaw`
683    pub yaw: i8,
684    /// `pitch`
685    pub pitch: i8,
686    /// `currentItem`
687    pub current_item: i16,
688    /// `metadata`
689    pub metadata: Vec<crate::defs::p47::types::EntityMetadataEntry>,
690}
691#[cfg(feature = "v1_8")]
692impl<const V: i32> Decode for NamedEntitySpawn<V> {
693    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
694        Ok({
695            let v1 = r.read_varint()?;
696            let v2 = r.read_uuid()?;
697            let v3 = r.read_i32()?;
698            let v4 = r.read_i32()?;
699            let v5 = r.read_i32()?;
700            let v6 = r.read_i8()?;
701            let v7 = r.read_i8()?;
702            let v8 = r.read_i16()?;
703            let v9 = {
704                let mut v10 = Vec::new();
705                loop {
706                    if r.peek_u8()? == 127 {
707                        r.skip(1)?;
708                        break;
709                    }
710                    v10.push({
711                        let v11 = u64::from(r.read_u8()?);
712                        let v12 = (((v11 >> 5) & 0x7) as u8);
713                        let v13 = (((v11 >> 0) & 0x1f) as u8);
714                        let v14 = (if (v12 == 0) {
715                            crate::defs::p47::types::EntityMetadataValue::Byte(r.read_i8()?)
716                        } else if (v12 == 1) {
717                            crate::defs::p47::types::EntityMetadataValue::Short(r.read_i16()?)
718                        } else if (v12 == 2) {
719                            crate::defs::p47::types::EntityMetadataValue::Int(r.read_i32()?)
720                        } else if (v12 == 3) {
721                            crate::defs::p47::types::EntityMetadataValue::Float(r.read_f32()?)
722                        } else if (v12 == 4) {
723                            crate::defs::p47::types::EntityMetadataValue::String(r.read_string()?)
724                        } else if (v12 == 5) {
725                            crate::defs::p47::types::EntityMetadataValue::Slot(
726                                <crate::types::slot::legacy::Slot as Decode>::decode(r)?,
727                            )
728                        } else if (v12 == 6) {
729                            crate::defs::p47::types::EntityMetadataValue::BlockPos({
730                                let v15 = r.read_i32()?;
731                                let v16 = r.read_i32()?;
732                                let v17 = r.read_i32()?;
733                                crate::defs::p47::types::EntityMetadataValueBlockPos {
734                                    x: v15,
735                                    y: v16,
736                                    z: v17,
737                                }
738                            })
739                        } else if (v12 == 7) {
740                            crate::defs::p47::types::EntityMetadataValue::Rotation({
741                                let v18 = r.read_f32()?;
742                                let v19 = r.read_f32()?;
743                                let v20 = r.read_f32()?;
744                                crate::defs::p47::types::EntityMetadataValueRotation {
745                                    pitch: v18,
746                                    yaw: v19,
747                                    roll: v20,
748                                }
749                            })
750                        } else {
751                            crate::defs::p47::types::EntityMetadataValue::Other
752                        });
753                        crate::defs::p47::types::EntityMetadataEntry {
754                            r#type: v12,
755                            key: v13,
756                            value: v14,
757                        }
758                    });
759                }
760                v10
761            };
762            Self {
763                entity_id: v1,
764                player_uuid: v2,
765                x: v3,
766                y: v4,
767                z: v5,
768                yaw: v6,
769                pitch: v7,
770                current_item: v8,
771                metadata: v9,
772            }
773        })
774    }
775}
776#[cfg(feature = "v1_8")]
777impl<const V: i32> Encode for NamedEntitySpawn<V> {
778    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
779        w.put_varint((*self).entity_id);
780        w.put_uuid(&(*self).player_uuid);
781        w.put_i32((*self).x);
782        w.put_i32((*self).y);
783        w.put_i32((*self).z);
784        w.put_i8((*self).yaw);
785        w.put_i8((*self).pitch);
786        w.put_i16((*self).current_item);
787        for v1 in (*self).metadata.iter() {
788            let v2 = w.len();
789            {
790                let mut bits: u64 = 0;
791                {
792                    let x = i128::from((*v1).r#type);
793                    if x < 0 || x > 7 {
794                        return Err(EncodeError::OutOfRange("type"));
795                    }
796                    bits = (bits << 3) | ((x as u64) & 0x7);
797                }
798                {
799                    let x = i128::from((*v1).key);
800                    if x < 0 || x > 31 {
801                        return Err(EncodeError::OutOfRange("key"));
802                    }
803                    bits = (bits << 5) | ((x as u64) & 0x1f);
804                }
805                w.put_u8(bits as u8);
806            }
807            match &(*v1).value {
808                crate::defs::p47::types::EntityMetadataValue::Byte(v3) => {
809                    if !((*v1).r#type == 0) {
810                        return Err(EncodeError::SwitchMismatch(
811                            "play.clientbound.named_entity_spawn.metadata.value",
812                        ));
813                    }
814                    w.put_i8((*v3));
815                }
816                crate::defs::p47::types::EntityMetadataValue::Short(v4) => {
817                    if !((*v1).r#type == 1) {
818                        return Err(EncodeError::SwitchMismatch(
819                            "play.clientbound.named_entity_spawn.metadata.value",
820                        ));
821                    }
822                    w.put_i16((*v4));
823                }
824                crate::defs::p47::types::EntityMetadataValue::Int(v5) => {
825                    if !((*v1).r#type == 2) {
826                        return Err(EncodeError::SwitchMismatch(
827                            "play.clientbound.named_entity_spawn.metadata.value",
828                        ));
829                    }
830                    w.put_i32((*v5));
831                }
832                crate::defs::p47::types::EntityMetadataValue::Float(v6) => {
833                    if !((*v1).r#type == 3) {
834                        return Err(EncodeError::SwitchMismatch(
835                            "play.clientbound.named_entity_spawn.metadata.value",
836                        ));
837                    }
838                    w.put_f32((*v6));
839                }
840                crate::defs::p47::types::EntityMetadataValue::String(v7) => {
841                    if !((*v1).r#type == 4) {
842                        return Err(EncodeError::SwitchMismatch(
843                            "play.clientbound.named_entity_spawn.metadata.value",
844                        ));
845                    }
846                    w.put_string(&(*v7))?;
847                }
848                crate::defs::p47::types::EntityMetadataValue::Slot(v8) => {
849                    if !((*v1).r#type == 5) {
850                        return Err(EncodeError::SwitchMismatch(
851                            "play.clientbound.named_entity_spawn.metadata.value",
852                        ));
853                    }
854                    (*v8).encode(w)?;
855                }
856                crate::defs::p47::types::EntityMetadataValue::BlockPos(v9) => {
857                    if !((*v1).r#type == 6) {
858                        return Err(EncodeError::SwitchMismatch(
859                            "play.clientbound.named_entity_spawn.metadata.value",
860                        ));
861                    }
862                    w.put_i32((*v9).x);
863                    w.put_i32((*v9).y);
864                    w.put_i32((*v9).z);
865                }
866                crate::defs::p47::types::EntityMetadataValue::Rotation(v10) => {
867                    if !((*v1).r#type == 7) {
868                        return Err(EncodeError::SwitchMismatch(
869                            "play.clientbound.named_entity_spawn.metadata.value",
870                        ));
871                    }
872                    w.put_f32((*v10).pitch);
873                    w.put_f32((*v10).yaw);
874                    w.put_f32((*v10).roll);
875                }
876                crate::defs::p47::types::EntityMetadataValue::Other => {
877                    if !(!(((*v1).r#type == 0)
878                        || ((*v1).r#type == 1)
879                        || ((*v1).r#type == 2)
880                        || ((*v1).r#type == 3)
881                        || ((*v1).r#type == 4)
882                        || ((*v1).r#type == 5)
883                        || ((*v1).r#type == 6)
884                        || ((*v1).r#type == 7)))
885                    {
886                        return Err(EncodeError::SwitchMismatch(
887                            "play.clientbound.named_entity_spawn.metadata.value",
888                        ));
889                    }
890                }
891            }
892            if w.get(v2) == Some(&127) {
893                return Err(EncodeError::OutOfRange(
894                    "play.clientbound.named_entity_spawn.metadata",
895                ));
896            }
897        }
898        w.put_u8(127);
899        Ok(())
900    }
901}
902#[cfg(feature = "v1_8")]
903#[cfg(feature = "testgen")]
904impl<const V: i32> Generate for NamedEntitySpawn<V> {
905    fn generate(g: &mut Gen) -> Self {
906        {
907            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
908            let v2 = g.uuid();
909            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
910            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
911            let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
912            let v6 = (g.int_in(-128, 127, &[]) as i8);
913            let v7 = (g.int_in(-128, 127, &[]) as i8);
914            let v8 = (g.int_in(-32768, 32767, &[]) as i16);
915            let v9 = {
916                let n = g.count();
917                let mut v10 = Vec::with_capacity(n);
918                for _ in 0..n {
919                    v10.push(loop { let v11 = { let v13 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v14 = (g.int_in(0, 31, &[]) as u8);let v15 = (if (v13 == 0) { crate::defs::p47::types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v13 == 1) { crate::defs::p47::types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v13 == 2) { crate::defs::p47::types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v13 == 3) { crate::defs::p47::types::EntityMetadataValue::Float(g.f32()) } else if (v13 == 4) { crate::defs::p47::types::EntityMetadataValue::String(g.string()) } else if (v13 == 5) { crate::defs::p47::types::EntityMetadataValue::Slot(<crate::types::slot::legacy::Slot as Generate>::generate(g)) } else if (v13 == 6) { crate::defs::p47::types::EntityMetadataValue::BlockPos({ let v16 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v17 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v18 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p47::types::EntityMetadataValueBlockPos { x: v16, y: v17, z: v18 } }) } else if (v13 == 7) { crate::defs::p47::types::EntityMetadataValue::Rotation({ let v19 = g.f32();let v20 = g.f32();let v21 = g.f32(); crate::defs::p47::types::EntityMetadataValueRotation { pitch: v19, yaw: v20, roll: v21 } }) } else { crate::defs::p47::types::EntityMetadataValue::Other }); crate::defs::p47::types::EntityMetadataEntry { r#type: v13, key: v14, value: v15 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v11.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v11.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v11.value { crate::defs::p47::types::EntityMetadataValue::Byte(v22) => { if !((v11.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v22)); }crate::defs::p47::types::EntityMetadataValue::Short(v23) => { if !((v11.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i16((*v23)); }crate::defs::p47::types::EntityMetadataValue::Int(v24) => { if !((v11.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v24)); }crate::defs::p47::types::EntityMetadataValue::Float(v25) => { if !((v11.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v25)); }crate::defs::p47::types::EntityMetadataValue::String(v26) => { if !((v11.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v26))?; }crate::defs::p47::types::EntityMetadataValue::Slot(v27) => { if !((v11.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v27).encode(w)?; }crate::defs::p47::types::EntityMetadataValue::BlockPos(v28) => { if !((v11.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v28).x);w.put_i32((*v28).y);w.put_i32((*v28).z); }crate::defs::p47::types::EntityMetadataValue::Rotation(v29) => { if !((v11.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v29).pitch);w.put_f32((*v29).yaw);w.put_f32((*v29).roll); }crate::defs::p47::types::EntityMetadataValue::Other => { if !(!((v11.r#type == 0) || (v11.r#type == 1) || (v11.r#type == 2) || (v11.r#type == 3) || (v11.r#type == 4) || (v11.r#type == 5) || (v11.r#type == 6) || (v11.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v11; } });
920                }
921                v10
922            };
923            Self {
924                entity_id: v1,
925                player_uuid: v2,
926                x: v3,
927                y: v4,
928                z: v5,
929                yaw: v6,
930                pitch: v7,
931                current_item: v8,
932                metadata: v9,
933            }
934        }
935    }
936}
937
938#[cfg(feature = "v1_8")]
939/// `collect` (clientbound play).
940#[derive(Debug, Clone, PartialEq)]
941pub struct Collect<const V: i32> {
942    /// `collectedEntityId`
943    pub collected_entity_id: i32,
944    /// `collectorEntityId`
945    pub collector_entity_id: i32,
946}
947#[cfg(feature = "v1_8")]
948impl<const V: i32> Decode for Collect<V> {
949    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
950        Ok({
951            let v1 = r.read_varint()?;
952            let v2 = r.read_varint()?;
953            Self {
954                collected_entity_id: v1,
955                collector_entity_id: v2,
956            }
957        })
958    }
959}
960#[cfg(feature = "v1_8")]
961impl<const V: i32> Encode for Collect<V> {
962    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
963        w.put_varint((*self).collected_entity_id);
964        w.put_varint((*self).collector_entity_id);
965        Ok(())
966    }
967}
968#[cfg(feature = "v1_8")]
969#[cfg(feature = "testgen")]
970impl<const V: i32> Generate for Collect<V> {
971    fn generate(g: &mut Gen) -> Self {
972        {
973            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
974            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
975            Self {
976                collected_entity_id: v1,
977                collector_entity_id: v2,
978            }
979        }
980    }
981}
982
983#[cfg(feature = "v1_8")]
984/// `spawn_entity` (clientbound play).
985#[derive(Debug, Clone, PartialEq)]
986pub struct SpawnEntity<const V: i32> {
987    /// `entityId`
988    pub entity_id: i32,
989    /// `type`
990    pub r#type: i8,
991    /// `x`
992    pub x: i32,
993    /// `y`
994    pub y: i32,
995    /// `z`
996    pub z: i32,
997    /// `pitch`
998    pub pitch: i8,
999    /// `yaw`
1000    pub yaw: i8,
1001    /// `objectData`
1002    pub object_data: i32,
1003    /// `velocity` — present iff `objectData > 0`, as vanilla 1.8.9 reads it (minecraft-data says `!= 0`)
1004    pub velocity: Option<crate::defs::p47::types::Vec3i16>,
1005}
1006#[cfg(feature = "v1_8")]
1007impl<const V: i32> Decode for SpawnEntity<V> {
1008    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1009        Ok({
1010            let v1 = r.read_varint()?;
1011            let v2 = r.read_i8()?;
1012            let v3 = r.read_i32()?;
1013            let v4 = r.read_i32()?;
1014            let v5 = r.read_i32()?;
1015            let v6 = r.read_i8()?;
1016            let v7 = r.read_i8()?;
1017            let v8 = r.read_i32()?;
1018            let v9 = if (v8 > 0) {
1019                Some(<crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?)
1020            } else {
1021                None
1022            };
1023            Self {
1024                entity_id: v1,
1025                r#type: v2,
1026                x: v3,
1027                y: v4,
1028                z: v5,
1029                pitch: v6,
1030                yaw: v7,
1031                object_data: v8,
1032                velocity: v9,
1033            }
1034        })
1035    }
1036}
1037#[cfg(feature = "v1_8")]
1038impl<const V: i32> Encode for SpawnEntity<V> {
1039    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1040        w.put_varint((*self).entity_id);
1041        w.put_i8((*self).r#type);
1042        w.put_i32((*self).x);
1043        w.put_i32((*self).y);
1044        w.put_i32((*self).z);
1045        w.put_i8((*self).pitch);
1046        w.put_i8((*self).yaw);
1047        w.put_i32((*self).object_data);
1048        match (&(*self).velocity, ((*self).object_data > 0)) {
1049            (Some(v1), true) => {
1050                (*v1).encode(w)?;
1051            }
1052            (None, false) => {}
1053            _ => {
1054                return Err(EncodeError::SwitchMismatch(
1055                    "play.clientbound.spawn_entity.velocity",
1056                ));
1057            }
1058        }
1059        Ok(())
1060    }
1061}
1062#[cfg(feature = "v1_8")]
1063#[cfg(feature = "testgen")]
1064impl<const V: i32> Generate for SpawnEntity<V> {
1065    fn generate(g: &mut Gen) -> Self {
1066        {
1067            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1068            let v2 = (g.int_in(-128, 127, &[]) as i8);
1069            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1070            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1071            let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1072            let v6 = (g.int_in(-128, 127, &[]) as i8);
1073            let v7 = (g.int_in(-128, 127, &[]) as i8);
1074            let v8 = (g.int_in(-2147483648, 2147483647, &[0, 1, -1, 5, -2147483648]) as i32);
1075            let v9 = if (v8 > 0) {
1076                Some(<crate::defs::p47::types::Vec3i16 as Generate>::generate(g))
1077            } else {
1078                None
1079            };
1080            Self {
1081                entity_id: v1,
1082                r#type: v2,
1083                x: v3,
1084                y: v4,
1085                z: v5,
1086                pitch: v6,
1087                yaw: v7,
1088                object_data: v8,
1089                velocity: v9,
1090            }
1091        }
1092    }
1093}
1094
1095#[cfg(feature = "v1_8")]
1096/// `spawn_entity_living` (clientbound play).
1097#[derive(Debug, Clone, PartialEq)]
1098pub struct SpawnEntityLiving<const V: i32> {
1099    /// `entityId`
1100    pub entity_id: i32,
1101    /// `type`
1102    pub r#type: u8,
1103    /// `x`
1104    pub x: i32,
1105    /// `y`
1106    pub y: i32,
1107    /// `z`
1108    pub z: i32,
1109    /// `yaw`
1110    pub yaw: i8,
1111    /// `pitch`
1112    pub pitch: i8,
1113    /// `headPitch`
1114    pub head_pitch: i8,
1115    /// `velocity`
1116    pub velocity: crate::defs::p47::types::Vec3i16,
1117    /// `metadata`
1118    pub metadata: Vec<crate::defs::p47::types::EntityMetadataEntry>,
1119}
1120#[cfg(feature = "v1_8")]
1121impl<const V: i32> Decode for SpawnEntityLiving<V> {
1122    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1123        Ok({
1124            let v1 = r.read_varint()?;
1125            let v2 = r.read_u8()?;
1126            let v3 = r.read_i32()?;
1127            let v4 = r.read_i32()?;
1128            let v5 = r.read_i32()?;
1129            let v6 = r.read_i8()?;
1130            let v7 = r.read_i8()?;
1131            let v8 = r.read_i8()?;
1132            let v9 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
1133            let v10 = {
1134                let mut v11 = Vec::new();
1135                loop {
1136                    if r.peek_u8()? == 127 {
1137                        r.skip(1)?;
1138                        break;
1139                    }
1140                    v11.push({
1141                        let v12 = u64::from(r.read_u8()?);
1142                        let v13 = (((v12 >> 5) & 0x7) as u8);
1143                        let v14 = (((v12 >> 0) & 0x1f) as u8);
1144                        let v15 = (if (v13 == 0) {
1145                            crate::defs::p47::types::EntityMetadataValue::Byte(r.read_i8()?)
1146                        } else if (v13 == 1) {
1147                            crate::defs::p47::types::EntityMetadataValue::Short(r.read_i16()?)
1148                        } else if (v13 == 2) {
1149                            crate::defs::p47::types::EntityMetadataValue::Int(r.read_i32()?)
1150                        } else if (v13 == 3) {
1151                            crate::defs::p47::types::EntityMetadataValue::Float(r.read_f32()?)
1152                        } else if (v13 == 4) {
1153                            crate::defs::p47::types::EntityMetadataValue::String(r.read_string()?)
1154                        } else if (v13 == 5) {
1155                            crate::defs::p47::types::EntityMetadataValue::Slot(
1156                                <crate::types::slot::legacy::Slot as Decode>::decode(r)?,
1157                            )
1158                        } else if (v13 == 6) {
1159                            crate::defs::p47::types::EntityMetadataValue::BlockPos({
1160                                let v16 = r.read_i32()?;
1161                                let v17 = r.read_i32()?;
1162                                let v18 = r.read_i32()?;
1163                                crate::defs::p47::types::EntityMetadataValueBlockPos {
1164                                    x: v16,
1165                                    y: v17,
1166                                    z: v18,
1167                                }
1168                            })
1169                        } else if (v13 == 7) {
1170                            crate::defs::p47::types::EntityMetadataValue::Rotation({
1171                                let v19 = r.read_f32()?;
1172                                let v20 = r.read_f32()?;
1173                                let v21 = r.read_f32()?;
1174                                crate::defs::p47::types::EntityMetadataValueRotation {
1175                                    pitch: v19,
1176                                    yaw: v20,
1177                                    roll: v21,
1178                                }
1179                            })
1180                        } else {
1181                            crate::defs::p47::types::EntityMetadataValue::Other
1182                        });
1183                        crate::defs::p47::types::EntityMetadataEntry {
1184                            r#type: v13,
1185                            key: v14,
1186                            value: v15,
1187                        }
1188                    });
1189                }
1190                v11
1191            };
1192            Self {
1193                entity_id: v1,
1194                r#type: v2,
1195                x: v3,
1196                y: v4,
1197                z: v5,
1198                yaw: v6,
1199                pitch: v7,
1200                head_pitch: v8,
1201                velocity: v9,
1202                metadata: v10,
1203            }
1204        })
1205    }
1206}
1207#[cfg(feature = "v1_8")]
1208impl<const V: i32> Encode for SpawnEntityLiving<V> {
1209    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1210        w.put_varint((*self).entity_id);
1211        w.put_u8((*self).r#type);
1212        w.put_i32((*self).x);
1213        w.put_i32((*self).y);
1214        w.put_i32((*self).z);
1215        w.put_i8((*self).yaw);
1216        w.put_i8((*self).pitch);
1217        w.put_i8((*self).head_pitch);
1218        (*self).velocity.encode(w)?;
1219        for v1 in (*self).metadata.iter() {
1220            let v2 = w.len();
1221            {
1222                let mut bits: u64 = 0;
1223                {
1224                    let x = i128::from((*v1).r#type);
1225                    if x < 0 || x > 7 {
1226                        return Err(EncodeError::OutOfRange("type"));
1227                    }
1228                    bits = (bits << 3) | ((x as u64) & 0x7);
1229                }
1230                {
1231                    let x = i128::from((*v1).key);
1232                    if x < 0 || x > 31 {
1233                        return Err(EncodeError::OutOfRange("key"));
1234                    }
1235                    bits = (bits << 5) | ((x as u64) & 0x1f);
1236                }
1237                w.put_u8(bits as u8);
1238            }
1239            match &(*v1).value {
1240                crate::defs::p47::types::EntityMetadataValue::Byte(v3) => {
1241                    if !((*v1).r#type == 0) {
1242                        return Err(EncodeError::SwitchMismatch(
1243                            "play.clientbound.spawn_entity_living.metadata.value",
1244                        ));
1245                    }
1246                    w.put_i8((*v3));
1247                }
1248                crate::defs::p47::types::EntityMetadataValue::Short(v4) => {
1249                    if !((*v1).r#type == 1) {
1250                        return Err(EncodeError::SwitchMismatch(
1251                            "play.clientbound.spawn_entity_living.metadata.value",
1252                        ));
1253                    }
1254                    w.put_i16((*v4));
1255                }
1256                crate::defs::p47::types::EntityMetadataValue::Int(v5) => {
1257                    if !((*v1).r#type == 2) {
1258                        return Err(EncodeError::SwitchMismatch(
1259                            "play.clientbound.spawn_entity_living.metadata.value",
1260                        ));
1261                    }
1262                    w.put_i32((*v5));
1263                }
1264                crate::defs::p47::types::EntityMetadataValue::Float(v6) => {
1265                    if !((*v1).r#type == 3) {
1266                        return Err(EncodeError::SwitchMismatch(
1267                            "play.clientbound.spawn_entity_living.metadata.value",
1268                        ));
1269                    }
1270                    w.put_f32((*v6));
1271                }
1272                crate::defs::p47::types::EntityMetadataValue::String(v7) => {
1273                    if !((*v1).r#type == 4) {
1274                        return Err(EncodeError::SwitchMismatch(
1275                            "play.clientbound.spawn_entity_living.metadata.value",
1276                        ));
1277                    }
1278                    w.put_string(&(*v7))?;
1279                }
1280                crate::defs::p47::types::EntityMetadataValue::Slot(v8) => {
1281                    if !((*v1).r#type == 5) {
1282                        return Err(EncodeError::SwitchMismatch(
1283                            "play.clientbound.spawn_entity_living.metadata.value",
1284                        ));
1285                    }
1286                    (*v8).encode(w)?;
1287                }
1288                crate::defs::p47::types::EntityMetadataValue::BlockPos(v9) => {
1289                    if !((*v1).r#type == 6) {
1290                        return Err(EncodeError::SwitchMismatch(
1291                            "play.clientbound.spawn_entity_living.metadata.value",
1292                        ));
1293                    }
1294                    w.put_i32((*v9).x);
1295                    w.put_i32((*v9).y);
1296                    w.put_i32((*v9).z);
1297                }
1298                crate::defs::p47::types::EntityMetadataValue::Rotation(v10) => {
1299                    if !((*v1).r#type == 7) {
1300                        return Err(EncodeError::SwitchMismatch(
1301                            "play.clientbound.spawn_entity_living.metadata.value",
1302                        ));
1303                    }
1304                    w.put_f32((*v10).pitch);
1305                    w.put_f32((*v10).yaw);
1306                    w.put_f32((*v10).roll);
1307                }
1308                crate::defs::p47::types::EntityMetadataValue::Other => {
1309                    if !(!(((*v1).r#type == 0)
1310                        || ((*v1).r#type == 1)
1311                        || ((*v1).r#type == 2)
1312                        || ((*v1).r#type == 3)
1313                        || ((*v1).r#type == 4)
1314                        || ((*v1).r#type == 5)
1315                        || ((*v1).r#type == 6)
1316                        || ((*v1).r#type == 7)))
1317                    {
1318                        return Err(EncodeError::SwitchMismatch(
1319                            "play.clientbound.spawn_entity_living.metadata.value",
1320                        ));
1321                    }
1322                }
1323            }
1324            if w.get(v2) == Some(&127) {
1325                return Err(EncodeError::OutOfRange(
1326                    "play.clientbound.spawn_entity_living.metadata",
1327                ));
1328            }
1329        }
1330        w.put_u8(127);
1331        Ok(())
1332    }
1333}
1334#[cfg(feature = "v1_8")]
1335#[cfg(feature = "testgen")]
1336impl<const V: i32> Generate for SpawnEntityLiving<V> {
1337    fn generate(g: &mut Gen) -> Self {
1338        {
1339            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1340            let v2 = (g.int_in(0, 255, &[]) as u8);
1341            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1342            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1343            let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1344            let v6 = (g.int_in(-128, 127, &[]) as i8);
1345            let v7 = (g.int_in(-128, 127, &[]) as i8);
1346            let v8 = (g.int_in(-128, 127, &[]) as i8);
1347            let v9 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
1348            let v10 = {
1349                let n = g.count();
1350                let mut v11 = Vec::with_capacity(n);
1351                for _ in 0..n {
1352                    v11.push(loop { let v12 = { let v14 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v15 = (g.int_in(0, 31, &[]) as u8);let v16 = (if (v14 == 0) { crate::defs::p47::types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v14 == 1) { crate::defs::p47::types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v14 == 2) { crate::defs::p47::types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v14 == 3) { crate::defs::p47::types::EntityMetadataValue::Float(g.f32()) } else if (v14 == 4) { crate::defs::p47::types::EntityMetadataValue::String(g.string()) } else if (v14 == 5) { crate::defs::p47::types::EntityMetadataValue::Slot(<crate::types::slot::legacy::Slot as Generate>::generate(g)) } else if (v14 == 6) { crate::defs::p47::types::EntityMetadataValue::BlockPos({ let v17 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v18 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p47::types::EntityMetadataValueBlockPos { x: v17, y: v18, z: v19 } }) } else if (v14 == 7) { crate::defs::p47::types::EntityMetadataValue::Rotation({ let v20 = g.f32();let v21 = g.f32();let v22 = g.f32(); crate::defs::p47::types::EntityMetadataValueRotation { pitch: v20, yaw: v21, roll: v22 } }) } else { crate::defs::p47::types::EntityMetadataValue::Other }); crate::defs::p47::types::EntityMetadataEntry { r#type: v14, key: v15, value: v16 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v12.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v12.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v12.value { crate::defs::p47::types::EntityMetadataValue::Byte(v23) => { if !((v12.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v23)); }crate::defs::p47::types::EntityMetadataValue::Short(v24) => { if !((v12.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i16((*v24)); }crate::defs::p47::types::EntityMetadataValue::Int(v25) => { if !((v12.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v25)); }crate::defs::p47::types::EntityMetadataValue::Float(v26) => { if !((v12.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v26)); }crate::defs::p47::types::EntityMetadataValue::String(v27) => { if !((v12.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v27))?; }crate::defs::p47::types::EntityMetadataValue::Slot(v28) => { if !((v12.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v28).encode(w)?; }crate::defs::p47::types::EntityMetadataValue::BlockPos(v29) => { if !((v12.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v29).x);w.put_i32((*v29).y);w.put_i32((*v29).z); }crate::defs::p47::types::EntityMetadataValue::Rotation(v30) => { if !((v12.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v30).pitch);w.put_f32((*v30).yaw);w.put_f32((*v30).roll); }crate::defs::p47::types::EntityMetadataValue::Other => { if !(!((v12.r#type == 0) || (v12.r#type == 1) || (v12.r#type == 2) || (v12.r#type == 3) || (v12.r#type == 4) || (v12.r#type == 5) || (v12.r#type == 6) || (v12.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v12; } });
1353                }
1354                v11
1355            };
1356            Self {
1357                entity_id: v1,
1358                r#type: v2,
1359                x: v3,
1360                y: v4,
1361                z: v5,
1362                yaw: v6,
1363                pitch: v7,
1364                head_pitch: v8,
1365                velocity: v9,
1366                metadata: v10,
1367            }
1368        }
1369    }
1370}
1371
1372#[cfg(feature = "v1_8")]
1373/// `spawn_entity_painting` (clientbound play).
1374#[derive(Debug, Clone, PartialEq)]
1375pub struct SpawnEntityPainting<const V: i32> {
1376    /// `entityId`
1377    pub entity_id: i32,
1378    /// `title`
1379    pub title: ByteString,
1380    /// `location`
1381    pub location: BlockPos,
1382    /// `direction`
1383    pub direction: u8,
1384}
1385#[cfg(feature = "v1_8")]
1386impl<const V: i32> Decode for SpawnEntityPainting<V> {
1387    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1388        Ok({
1389            let v1 = r.read_varint()?;
1390            let v2 = r.read_string()?;
1391            let v3 = BlockPos::read(r, PositionLayout::Xyz)?;
1392            let v4 = r.read_u8()?;
1393            Self {
1394                entity_id: v1,
1395                title: v2,
1396                location: v3,
1397                direction: v4,
1398            }
1399        })
1400    }
1401}
1402#[cfg(feature = "v1_8")]
1403impl<const V: i32> Encode for SpawnEntityPainting<V> {
1404    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1405        w.put_varint((*self).entity_id);
1406        w.put_string(&(*self).title)?;
1407        (*self).location.write(w, PositionLayout::Xyz)?;
1408        w.put_u8((*self).direction);
1409        Ok(())
1410    }
1411}
1412#[cfg(feature = "v1_8")]
1413#[cfg(feature = "testgen")]
1414impl<const V: i32> Generate for SpawnEntityPainting<V> {
1415    fn generate(g: &mut Gen) -> Self {
1416        {
1417            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1418            let v2 = g.string();
1419            let v3 = g.position();
1420            let v4 = (g.int_in(0, 255, &[]) as u8);
1421            Self {
1422                entity_id: v1,
1423                title: v2,
1424                location: v3,
1425                direction: v4,
1426            }
1427        }
1428    }
1429}
1430
1431#[cfg(feature = "v1_8")]
1432/// `spawn_entity_experience_orb` (clientbound play).
1433#[derive(Debug, Clone, PartialEq)]
1434pub struct SpawnEntityExperienceOrb<const V: i32> {
1435    /// `entityId`
1436    pub entity_id: i32,
1437    /// `x`
1438    pub x: i32,
1439    /// `y`
1440    pub y: i32,
1441    /// `z`
1442    pub z: i32,
1443    /// `count`
1444    pub count: i16,
1445}
1446#[cfg(feature = "v1_8")]
1447impl<const V: i32> Decode for SpawnEntityExperienceOrb<V> {
1448    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1449        Ok({
1450            let v1 = r.read_varint()?;
1451            let v2 = r.read_i32()?;
1452            let v3 = r.read_i32()?;
1453            let v4 = r.read_i32()?;
1454            let v5 = r.read_i16()?;
1455            Self {
1456                entity_id: v1,
1457                x: v2,
1458                y: v3,
1459                z: v4,
1460                count: v5,
1461            }
1462        })
1463    }
1464}
1465#[cfg(feature = "v1_8")]
1466impl<const V: i32> Encode for SpawnEntityExperienceOrb<V> {
1467    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1468        w.put_varint((*self).entity_id);
1469        w.put_i32((*self).x);
1470        w.put_i32((*self).y);
1471        w.put_i32((*self).z);
1472        w.put_i16((*self).count);
1473        Ok(())
1474    }
1475}
1476#[cfg(feature = "v1_8")]
1477#[cfg(feature = "testgen")]
1478impl<const V: i32> Generate for SpawnEntityExperienceOrb<V> {
1479    fn generate(g: &mut Gen) -> Self {
1480        {
1481            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1482            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1483            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1484            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1485            let v5 = (g.int_in(-32768, 32767, &[]) as i16);
1486            Self {
1487                entity_id: v1,
1488                x: v2,
1489                y: v3,
1490                z: v4,
1491                count: v5,
1492            }
1493        }
1494    }
1495}
1496
1497#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1498/// `entity_velocity` (clientbound play).
1499#[derive(Debug, Clone, PartialEq)]
1500pub struct EntityVelocity<const V: i32> {
1501    /// `entityId`
1502    pub entity_id: i32,
1503    /// `velocity`
1504    pub velocity: crate::defs::p47::types::Vec3i16,
1505}
1506#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1507impl<const V: i32> Decode for EntityVelocity<V> {
1508    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1509        Ok({
1510            let v1 = r.read_varint()?;
1511            let v2 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
1512            Self {
1513                entity_id: v1,
1514                velocity: v2,
1515            }
1516        })
1517    }
1518}
1519#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1520impl<const V: i32> Encode for EntityVelocity<V> {
1521    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1522        w.put_varint((*self).entity_id);
1523        (*self).velocity.encode(w)?;
1524        Ok(())
1525    }
1526}
1527#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1528#[cfg(feature = "testgen")]
1529impl<const V: i32> Generate for EntityVelocity<V> {
1530    fn generate(g: &mut Gen) -> Self {
1531        {
1532            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1533            let v2 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
1534            Self {
1535                entity_id: v1,
1536                velocity: v2,
1537            }
1538        }
1539    }
1540}
1541
1542#[cfg(any(
1543    feature = "v1_8",
1544    feature = "v1_12_2",
1545    feature = "v1_16_5",
1546    feature = "v26_1",
1547    feature = "v26_2"
1548))]
1549/// `entity_destroy` (clientbound play).
1550#[derive(Debug, Clone, PartialEq)]
1551pub struct EntityDestroy<const V: i32> {
1552    /// `entityIds`
1553    pub entity_ids: Vec<i32>,
1554}
1555#[cfg(any(
1556    feature = "v1_8",
1557    feature = "v1_12_2",
1558    feature = "v1_16_5",
1559    feature = "v26_1",
1560    feature = "v26_2"
1561))]
1562impl<const V: i32> Decode for EntityDestroy<V> {
1563    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1564        Ok({
1565            let v1 = {
1566                let v2 = {
1567                    let c = r.read_varint()?;
1568                    r.check_count(i64::from(c), 1)?
1569                };
1570                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1571                for _ in 0..v2 {
1572                    v3.push(r.read_varint()?);
1573                }
1574                v3
1575            };
1576            Self { entity_ids: v1 }
1577        })
1578    }
1579}
1580#[cfg(any(
1581    feature = "v1_8",
1582    feature = "v1_12_2",
1583    feature = "v1_16_5",
1584    feature = "v26_1",
1585    feature = "v26_2"
1586))]
1587impl<const V: i32> Encode for EntityDestroy<V> {
1588    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1589        w.put_len_varint((*self).entity_ids.len())?;
1590        for v1 in (*self).entity_ids.iter() {
1591            w.put_varint((*v1));
1592        }
1593        Ok(())
1594    }
1595}
1596#[cfg(any(
1597    feature = "v1_8",
1598    feature = "v1_12_2",
1599    feature = "v1_16_5",
1600    feature = "v26_1",
1601    feature = "v26_2"
1602))]
1603#[cfg(feature = "testgen")]
1604impl<const V: i32> Generate for EntityDestroy<V> {
1605    fn generate(g: &mut Gen) -> Self {
1606        {
1607            let v1 = {
1608                let v2 = g.count();
1609                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1610                for _ in 0..v2 {
1611                    v3.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
1612                }
1613                v3
1614            };
1615            Self { entity_ids: v1 }
1616        }
1617    }
1618}
1619
1620#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1621/// `entity` (clientbound play).
1622#[derive(Debug, Clone, PartialEq)]
1623pub struct Entity<const V: i32> {
1624    /// `entityId`
1625    pub entity_id: i32,
1626}
1627#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1628impl<const V: i32> Decode for Entity<V> {
1629    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1630        Ok({
1631            let v1 = r.read_varint()?;
1632            Self { entity_id: v1 }
1633        })
1634    }
1635}
1636#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1637impl<const V: i32> Encode for Entity<V> {
1638    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1639        w.put_varint((*self).entity_id);
1640        Ok(())
1641    }
1642}
1643#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
1644#[cfg(feature = "testgen")]
1645impl<const V: i32> Generate for Entity<V> {
1646    fn generate(g: &mut Gen) -> Self {
1647        {
1648            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1649            Self { entity_id: v1 }
1650        }
1651    }
1652}
1653
1654#[cfg(feature = "v1_8")]
1655/// `rel_entity_move` (clientbound play).
1656#[derive(Debug, Clone, PartialEq)]
1657pub struct RelEntityMove<const V: i32> {
1658    /// `entityId`
1659    pub entity_id: i32,
1660    /// `dX`
1661    pub d_x: i8,
1662    /// `dY`
1663    pub d_y: i8,
1664    /// `dZ`
1665    pub d_z: i8,
1666    /// `onGround`
1667    pub on_ground: bool,
1668}
1669#[cfg(feature = "v1_8")]
1670impl<const V: i32> Decode for RelEntityMove<V> {
1671    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1672        Ok({
1673            let v1 = r.read_varint()?;
1674            let v2 = r.read_i8()?;
1675            let v3 = r.read_i8()?;
1676            let v4 = r.read_i8()?;
1677            let v5 = r.read_bool()?;
1678            Self {
1679                entity_id: v1,
1680                d_x: v2,
1681                d_y: v3,
1682                d_z: v4,
1683                on_ground: v5,
1684            }
1685        })
1686    }
1687}
1688#[cfg(feature = "v1_8")]
1689impl<const V: i32> Encode for RelEntityMove<V> {
1690    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1691        w.put_varint((*self).entity_id);
1692        w.put_i8((*self).d_x);
1693        w.put_i8((*self).d_y);
1694        w.put_i8((*self).d_z);
1695        w.put_bool((*self).on_ground);
1696        Ok(())
1697    }
1698}
1699#[cfg(feature = "v1_8")]
1700#[cfg(feature = "testgen")]
1701impl<const V: i32> Generate for RelEntityMove<V> {
1702    fn generate(g: &mut Gen) -> Self {
1703        {
1704            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1705            let v2 = (g.int_in(-128, 127, &[]) as i8);
1706            let v3 = (g.int_in(-128, 127, &[]) as i8);
1707            let v4 = (g.int_in(-128, 127, &[]) as i8);
1708            let v5 = g.bool();
1709            Self {
1710                entity_id: v1,
1711                d_x: v2,
1712                d_y: v3,
1713                d_z: v4,
1714                on_ground: v5,
1715            }
1716        }
1717    }
1718}
1719
1720#[cfg(any(
1721    feature = "v1_8",
1722    feature = "v1_12_2",
1723    feature = "v1_16_5",
1724    feature = "v26_1",
1725    feature = "v26_2"
1726))]
1727/// `entity_look` (clientbound play).
1728#[derive(Debug, Clone, PartialEq)]
1729pub struct EntityLook<const V: i32> {
1730    /// `entityId`
1731    pub entity_id: i32,
1732    /// `yaw`
1733    pub yaw: i8,
1734    /// `pitch`
1735    pub pitch: i8,
1736    /// `onGround`
1737    pub on_ground: bool,
1738}
1739#[cfg(any(
1740    feature = "v1_8",
1741    feature = "v1_12_2",
1742    feature = "v1_16_5",
1743    feature = "v26_1",
1744    feature = "v26_2"
1745))]
1746impl<const V: i32> Decode for EntityLook<V> {
1747    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1748        Ok({
1749            let v1 = r.read_varint()?;
1750            let v2 = r.read_i8()?;
1751            let v3 = r.read_i8()?;
1752            let v4 = r.read_bool()?;
1753            Self {
1754                entity_id: v1,
1755                yaw: v2,
1756                pitch: v3,
1757                on_ground: v4,
1758            }
1759        })
1760    }
1761}
1762#[cfg(any(
1763    feature = "v1_8",
1764    feature = "v1_12_2",
1765    feature = "v1_16_5",
1766    feature = "v26_1",
1767    feature = "v26_2"
1768))]
1769impl<const V: i32> Encode for EntityLook<V> {
1770    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1771        w.put_varint((*self).entity_id);
1772        w.put_i8((*self).yaw);
1773        w.put_i8((*self).pitch);
1774        w.put_bool((*self).on_ground);
1775        Ok(())
1776    }
1777}
1778#[cfg(any(
1779    feature = "v1_8",
1780    feature = "v1_12_2",
1781    feature = "v1_16_5",
1782    feature = "v26_1",
1783    feature = "v26_2"
1784))]
1785#[cfg(feature = "testgen")]
1786impl<const V: i32> Generate for EntityLook<V> {
1787    fn generate(g: &mut Gen) -> Self {
1788        {
1789            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1790            let v2 = (g.int_in(-128, 127, &[]) as i8);
1791            let v3 = (g.int_in(-128, 127, &[]) as i8);
1792            let v4 = g.bool();
1793            Self {
1794                entity_id: v1,
1795                yaw: v2,
1796                pitch: v3,
1797                on_ground: v4,
1798            }
1799        }
1800    }
1801}
1802
1803#[cfg(feature = "v1_8")]
1804/// `entity_move_look` (clientbound play).
1805#[derive(Debug, Clone, PartialEq)]
1806pub struct EntityMoveLook<const V: i32> {
1807    /// `entityId`
1808    pub entity_id: i32,
1809    /// `dX`
1810    pub d_x: i8,
1811    /// `dY`
1812    pub d_y: i8,
1813    /// `dZ`
1814    pub d_z: i8,
1815    /// `yaw`
1816    pub yaw: i8,
1817    /// `pitch`
1818    pub pitch: i8,
1819    /// `onGround`
1820    pub on_ground: bool,
1821}
1822#[cfg(feature = "v1_8")]
1823impl<const V: i32> Decode for EntityMoveLook<V> {
1824    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1825        Ok({
1826            let v1 = r.read_varint()?;
1827            let v2 = r.read_i8()?;
1828            let v3 = r.read_i8()?;
1829            let v4 = r.read_i8()?;
1830            let v5 = r.read_i8()?;
1831            let v6 = r.read_i8()?;
1832            let v7 = r.read_bool()?;
1833            Self {
1834                entity_id: v1,
1835                d_x: v2,
1836                d_y: v3,
1837                d_z: v4,
1838                yaw: v5,
1839                pitch: v6,
1840                on_ground: v7,
1841            }
1842        })
1843    }
1844}
1845#[cfg(feature = "v1_8")]
1846impl<const V: i32> Encode for EntityMoveLook<V> {
1847    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1848        w.put_varint((*self).entity_id);
1849        w.put_i8((*self).d_x);
1850        w.put_i8((*self).d_y);
1851        w.put_i8((*self).d_z);
1852        w.put_i8((*self).yaw);
1853        w.put_i8((*self).pitch);
1854        w.put_bool((*self).on_ground);
1855        Ok(())
1856    }
1857}
1858#[cfg(feature = "v1_8")]
1859#[cfg(feature = "testgen")]
1860impl<const V: i32> Generate for EntityMoveLook<V> {
1861    fn generate(g: &mut Gen) -> Self {
1862        {
1863            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1864            let v2 = (g.int_in(-128, 127, &[]) as i8);
1865            let v3 = (g.int_in(-128, 127, &[]) as i8);
1866            let v4 = (g.int_in(-128, 127, &[]) as i8);
1867            let v5 = (g.int_in(-128, 127, &[]) as i8);
1868            let v6 = (g.int_in(-128, 127, &[]) as i8);
1869            let v7 = g.bool();
1870            Self {
1871                entity_id: v1,
1872                d_x: v2,
1873                d_y: v3,
1874                d_z: v4,
1875                yaw: v5,
1876                pitch: v6,
1877                on_ground: v7,
1878            }
1879        }
1880    }
1881}
1882
1883#[cfg(feature = "v1_8")]
1884/// `entity_teleport` (clientbound play).
1885#[derive(Debug, Clone, PartialEq)]
1886pub struct EntityTeleport<const V: i32> {
1887    /// `entityId`
1888    pub entity_id: i32,
1889    /// `x`
1890    pub x: i32,
1891    /// `y`
1892    pub y: i32,
1893    /// `z`
1894    pub z: i32,
1895    /// `yaw`
1896    pub yaw: i8,
1897    /// `pitch`
1898    pub pitch: i8,
1899    /// `onGround`
1900    pub on_ground: bool,
1901}
1902#[cfg(feature = "v1_8")]
1903impl<const V: i32> Decode for EntityTeleport<V> {
1904    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1905        Ok({
1906            let v1 = r.read_varint()?;
1907            let v2 = r.read_i32()?;
1908            let v3 = r.read_i32()?;
1909            let v4 = r.read_i32()?;
1910            let v5 = r.read_i8()?;
1911            let v6 = r.read_i8()?;
1912            let v7 = r.read_bool()?;
1913            Self {
1914                entity_id: v1,
1915                x: v2,
1916                y: v3,
1917                z: v4,
1918                yaw: v5,
1919                pitch: v6,
1920                on_ground: v7,
1921            }
1922        })
1923    }
1924}
1925#[cfg(feature = "v1_8")]
1926impl<const V: i32> Encode for EntityTeleport<V> {
1927    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1928        w.put_varint((*self).entity_id);
1929        w.put_i32((*self).x);
1930        w.put_i32((*self).y);
1931        w.put_i32((*self).z);
1932        w.put_i8((*self).yaw);
1933        w.put_i8((*self).pitch);
1934        w.put_bool((*self).on_ground);
1935        Ok(())
1936    }
1937}
1938#[cfg(feature = "v1_8")]
1939#[cfg(feature = "testgen")]
1940impl<const V: i32> Generate for EntityTeleport<V> {
1941    fn generate(g: &mut Gen) -> Self {
1942        {
1943            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1944            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1945            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1946            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1947            let v5 = (g.int_in(-128, 127, &[]) as i8);
1948            let v6 = (g.int_in(-128, 127, &[]) as i8);
1949            let v7 = g.bool();
1950            Self {
1951                entity_id: v1,
1952                x: v2,
1953                y: v3,
1954                z: v4,
1955                yaw: v5,
1956                pitch: v6,
1957                on_ground: v7,
1958            }
1959        }
1960    }
1961}
1962
1963#[cfg(any(
1964    feature = "v1_8",
1965    feature = "v1_12_2",
1966    feature = "v1_16_5",
1967    feature = "v26_1",
1968    feature = "v26_2"
1969))]
1970/// `entity_head_rotation` (clientbound play).
1971#[derive(Debug, Clone, PartialEq)]
1972pub struct EntityHeadRotation<const V: i32> {
1973    /// `entityId`
1974    pub entity_id: i32,
1975    /// `headYaw`
1976    pub head_yaw: i8,
1977}
1978#[cfg(any(
1979    feature = "v1_8",
1980    feature = "v1_12_2",
1981    feature = "v1_16_5",
1982    feature = "v26_1",
1983    feature = "v26_2"
1984))]
1985impl<const V: i32> Decode for EntityHeadRotation<V> {
1986    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1987        Ok({
1988            let v1 = r.read_varint()?;
1989            let v2 = r.read_i8()?;
1990            Self {
1991                entity_id: v1,
1992                head_yaw: v2,
1993            }
1994        })
1995    }
1996}
1997#[cfg(any(
1998    feature = "v1_8",
1999    feature = "v1_12_2",
2000    feature = "v1_16_5",
2001    feature = "v26_1",
2002    feature = "v26_2"
2003))]
2004impl<const V: i32> Encode for EntityHeadRotation<V> {
2005    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2006        w.put_varint((*self).entity_id);
2007        w.put_i8((*self).head_yaw);
2008        Ok(())
2009    }
2010}
2011#[cfg(any(
2012    feature = "v1_8",
2013    feature = "v1_12_2",
2014    feature = "v1_16_5",
2015    feature = "v26_1",
2016    feature = "v26_2"
2017))]
2018#[cfg(feature = "testgen")]
2019impl<const V: i32> Generate for EntityHeadRotation<V> {
2020    fn generate(g: &mut Gen) -> Self {
2021        {
2022            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2023            let v2 = (g.int_in(-128, 127, &[]) as i8);
2024            Self {
2025                entity_id: v1,
2026                head_yaw: v2,
2027            }
2028        }
2029    }
2030}
2031
2032#[cfg(any(
2033    feature = "v1_8",
2034    feature = "v1_12_2",
2035    feature = "v1_16_5",
2036    feature = "v26_1",
2037    feature = "v26_2"
2038))]
2039/// `entity_status` (clientbound play).
2040#[derive(Debug, Clone, PartialEq)]
2041pub struct EntityStatus<const V: i32> {
2042    /// `entityId`
2043    pub entity_id: i32,
2044    /// `entityStatus`
2045    pub entity_status: i8,
2046}
2047#[cfg(any(
2048    feature = "v1_8",
2049    feature = "v1_12_2",
2050    feature = "v1_16_5",
2051    feature = "v26_1",
2052    feature = "v26_2"
2053))]
2054impl<const V: i32> Decode for EntityStatus<V> {
2055    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2056        Ok({
2057            let v1 = r.read_i32()?;
2058            let v2 = r.read_i8()?;
2059            Self {
2060                entity_id: v1,
2061                entity_status: v2,
2062            }
2063        })
2064    }
2065}
2066#[cfg(any(
2067    feature = "v1_8",
2068    feature = "v1_12_2",
2069    feature = "v1_16_5",
2070    feature = "v26_1",
2071    feature = "v26_2"
2072))]
2073impl<const V: i32> Encode for EntityStatus<V> {
2074    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2075        w.put_i32((*self).entity_id);
2076        w.put_i8((*self).entity_status);
2077        Ok(())
2078    }
2079}
2080#[cfg(any(
2081    feature = "v1_8",
2082    feature = "v1_12_2",
2083    feature = "v1_16_5",
2084    feature = "v26_1",
2085    feature = "v26_2"
2086))]
2087#[cfg(feature = "testgen")]
2088impl<const V: i32> Generate for EntityStatus<V> {
2089    fn generate(g: &mut Gen) -> Self {
2090        {
2091            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2092            let v2 = (g.int_in(-128, 127, &[]) as i8);
2093            Self {
2094                entity_id: v1,
2095                entity_status: v2,
2096            }
2097        }
2098    }
2099}
2100
2101#[cfg(feature = "v1_8")]
2102/// `attach_entity` (clientbound play).
2103#[derive(Debug, Clone, PartialEq)]
2104pub struct AttachEntity<const V: i32> {
2105    /// `entityId`
2106    pub entity_id: i32,
2107    /// `vehicleId`
2108    pub vehicle_id: i32,
2109    /// `leash`
2110    pub leash: bool,
2111}
2112#[cfg(feature = "v1_8")]
2113impl<const V: i32> Decode for AttachEntity<V> {
2114    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2115        Ok({
2116            let v1 = r.read_i32()?;
2117            let v2 = r.read_i32()?;
2118            let v3 = r.read_bool()?;
2119            Self {
2120                entity_id: v1,
2121                vehicle_id: v2,
2122                leash: v3,
2123            }
2124        })
2125    }
2126}
2127#[cfg(feature = "v1_8")]
2128impl<const V: i32> Encode for AttachEntity<V> {
2129    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2130        w.put_i32((*self).entity_id);
2131        w.put_i32((*self).vehicle_id);
2132        w.put_bool((*self).leash);
2133        Ok(())
2134    }
2135}
2136#[cfg(feature = "v1_8")]
2137#[cfg(feature = "testgen")]
2138impl<const V: i32> Generate for AttachEntity<V> {
2139    fn generate(g: &mut Gen) -> Self {
2140        {
2141            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2142            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2143            let v3 = g.bool();
2144            Self {
2145                entity_id: v1,
2146                vehicle_id: v2,
2147                leash: v3,
2148            }
2149        }
2150    }
2151}
2152
2153#[cfg(feature = "v1_8")]
2154/// `entity_metadata` (clientbound play).
2155#[derive(Debug, Clone, PartialEq)]
2156pub struct EntityMetadata<const V: i32> {
2157    /// `entityId`
2158    pub entity_id: i32,
2159    /// `metadata`
2160    pub metadata: Vec<crate::defs::p47::types::EntityMetadataEntry>,
2161}
2162#[cfg(feature = "v1_8")]
2163impl<const V: i32> Decode for EntityMetadata<V> {
2164    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2165        Ok({
2166            let v1 = r.read_varint()?;
2167            let v2 = {
2168                let mut v3 = Vec::new();
2169                loop {
2170                    if r.peek_u8()? == 127 {
2171                        r.skip(1)?;
2172                        break;
2173                    }
2174                    v3.push({
2175                        let v4 = u64::from(r.read_u8()?);
2176                        let v5 = (((v4 >> 5) & 0x7) as u8);
2177                        let v6 = (((v4 >> 0) & 0x1f) as u8);
2178                        let v7 = (if (v5 == 0) {
2179                            crate::defs::p47::types::EntityMetadataValue::Byte(r.read_i8()?)
2180                        } else if (v5 == 1) {
2181                            crate::defs::p47::types::EntityMetadataValue::Short(r.read_i16()?)
2182                        } else if (v5 == 2) {
2183                            crate::defs::p47::types::EntityMetadataValue::Int(r.read_i32()?)
2184                        } else if (v5 == 3) {
2185                            crate::defs::p47::types::EntityMetadataValue::Float(r.read_f32()?)
2186                        } else if (v5 == 4) {
2187                            crate::defs::p47::types::EntityMetadataValue::String(r.read_string()?)
2188                        } else if (v5 == 5) {
2189                            crate::defs::p47::types::EntityMetadataValue::Slot(
2190                                <crate::types::slot::legacy::Slot as Decode>::decode(r)?,
2191                            )
2192                        } else if (v5 == 6) {
2193                            crate::defs::p47::types::EntityMetadataValue::BlockPos({
2194                                let v8 = r.read_i32()?;
2195                                let v9 = r.read_i32()?;
2196                                let v10 = r.read_i32()?;
2197                                crate::defs::p47::types::EntityMetadataValueBlockPos {
2198                                    x: v8,
2199                                    y: v9,
2200                                    z: v10,
2201                                }
2202                            })
2203                        } else if (v5 == 7) {
2204                            crate::defs::p47::types::EntityMetadataValue::Rotation({
2205                                let v11 = r.read_f32()?;
2206                                let v12 = r.read_f32()?;
2207                                let v13 = r.read_f32()?;
2208                                crate::defs::p47::types::EntityMetadataValueRotation {
2209                                    pitch: v11,
2210                                    yaw: v12,
2211                                    roll: v13,
2212                                }
2213                            })
2214                        } else {
2215                            crate::defs::p47::types::EntityMetadataValue::Other
2216                        });
2217                        crate::defs::p47::types::EntityMetadataEntry {
2218                            r#type: v5,
2219                            key: v6,
2220                            value: v7,
2221                        }
2222                    });
2223                }
2224                v3
2225            };
2226            Self {
2227                entity_id: v1,
2228                metadata: v2,
2229            }
2230        })
2231    }
2232}
2233#[cfg(feature = "v1_8")]
2234impl<const V: i32> Encode for EntityMetadata<V> {
2235    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2236        w.put_varint((*self).entity_id);
2237        for v1 in (*self).metadata.iter() {
2238            let v2 = w.len();
2239            {
2240                let mut bits: u64 = 0;
2241                {
2242                    let x = i128::from((*v1).r#type);
2243                    if x < 0 || x > 7 {
2244                        return Err(EncodeError::OutOfRange("type"));
2245                    }
2246                    bits = (bits << 3) | ((x as u64) & 0x7);
2247                }
2248                {
2249                    let x = i128::from((*v1).key);
2250                    if x < 0 || x > 31 {
2251                        return Err(EncodeError::OutOfRange("key"));
2252                    }
2253                    bits = (bits << 5) | ((x as u64) & 0x1f);
2254                }
2255                w.put_u8(bits as u8);
2256            }
2257            match &(*v1).value {
2258                crate::defs::p47::types::EntityMetadataValue::Byte(v3) => {
2259                    if !((*v1).r#type == 0) {
2260                        return Err(EncodeError::SwitchMismatch(
2261                            "play.clientbound.entity_metadata.metadata.value",
2262                        ));
2263                    }
2264                    w.put_i8((*v3));
2265                }
2266                crate::defs::p47::types::EntityMetadataValue::Short(v4) => {
2267                    if !((*v1).r#type == 1) {
2268                        return Err(EncodeError::SwitchMismatch(
2269                            "play.clientbound.entity_metadata.metadata.value",
2270                        ));
2271                    }
2272                    w.put_i16((*v4));
2273                }
2274                crate::defs::p47::types::EntityMetadataValue::Int(v5) => {
2275                    if !((*v1).r#type == 2) {
2276                        return Err(EncodeError::SwitchMismatch(
2277                            "play.clientbound.entity_metadata.metadata.value",
2278                        ));
2279                    }
2280                    w.put_i32((*v5));
2281                }
2282                crate::defs::p47::types::EntityMetadataValue::Float(v6) => {
2283                    if !((*v1).r#type == 3) {
2284                        return Err(EncodeError::SwitchMismatch(
2285                            "play.clientbound.entity_metadata.metadata.value",
2286                        ));
2287                    }
2288                    w.put_f32((*v6));
2289                }
2290                crate::defs::p47::types::EntityMetadataValue::String(v7) => {
2291                    if !((*v1).r#type == 4) {
2292                        return Err(EncodeError::SwitchMismatch(
2293                            "play.clientbound.entity_metadata.metadata.value",
2294                        ));
2295                    }
2296                    w.put_string(&(*v7))?;
2297                }
2298                crate::defs::p47::types::EntityMetadataValue::Slot(v8) => {
2299                    if !((*v1).r#type == 5) {
2300                        return Err(EncodeError::SwitchMismatch(
2301                            "play.clientbound.entity_metadata.metadata.value",
2302                        ));
2303                    }
2304                    (*v8).encode(w)?;
2305                }
2306                crate::defs::p47::types::EntityMetadataValue::BlockPos(v9) => {
2307                    if !((*v1).r#type == 6) {
2308                        return Err(EncodeError::SwitchMismatch(
2309                            "play.clientbound.entity_metadata.metadata.value",
2310                        ));
2311                    }
2312                    w.put_i32((*v9).x);
2313                    w.put_i32((*v9).y);
2314                    w.put_i32((*v9).z);
2315                }
2316                crate::defs::p47::types::EntityMetadataValue::Rotation(v10) => {
2317                    if !((*v1).r#type == 7) {
2318                        return Err(EncodeError::SwitchMismatch(
2319                            "play.clientbound.entity_metadata.metadata.value",
2320                        ));
2321                    }
2322                    w.put_f32((*v10).pitch);
2323                    w.put_f32((*v10).yaw);
2324                    w.put_f32((*v10).roll);
2325                }
2326                crate::defs::p47::types::EntityMetadataValue::Other => {
2327                    if !(!(((*v1).r#type == 0)
2328                        || ((*v1).r#type == 1)
2329                        || ((*v1).r#type == 2)
2330                        || ((*v1).r#type == 3)
2331                        || ((*v1).r#type == 4)
2332                        || ((*v1).r#type == 5)
2333                        || ((*v1).r#type == 6)
2334                        || ((*v1).r#type == 7)))
2335                    {
2336                        return Err(EncodeError::SwitchMismatch(
2337                            "play.clientbound.entity_metadata.metadata.value",
2338                        ));
2339                    }
2340                }
2341            }
2342            if w.get(v2) == Some(&127) {
2343                return Err(EncodeError::OutOfRange(
2344                    "play.clientbound.entity_metadata.metadata",
2345                ));
2346            }
2347        }
2348        w.put_u8(127);
2349        Ok(())
2350    }
2351}
2352#[cfg(feature = "v1_8")]
2353#[cfg(feature = "testgen")]
2354impl<const V: i32> Generate for EntityMetadata<V> {
2355    fn generate(g: &mut Gen) -> Self {
2356        {
2357            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2358            let v2 = {
2359                let n = g.count();
2360                let mut v3 = Vec::with_capacity(n);
2361                for _ in 0..n {
2362                    v3.push(loop {
2363                        let v4 = {
2364                            let v6 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);
2365                            let v7 = (g.int_in(0, 31, &[]) as u8);
2366                            let v8 = (if (v6 == 0) {
2367                                crate::defs::p47::types::EntityMetadataValue::Byte(
2368                                    (g.int_in(-128, 127, &[]) as i8),
2369                                )
2370                            } else if (v6 == 1) {
2371                                crate::defs::p47::types::EntityMetadataValue::Short(
2372                                    (g.int_in(-32768, 32767, &[]) as i16),
2373                                )
2374                            } else if (v6 == 2) {
2375                                crate::defs::p47::types::EntityMetadataValue::Int(
2376                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
2377                                )
2378                            } else if (v6 == 3) {
2379                                crate::defs::p47::types::EntityMetadataValue::Float(g.f32())
2380                            } else if (v6 == 4) {
2381                                crate::defs::p47::types::EntityMetadataValue::String(g.string())
2382                            } else if (v6 == 5) {
2383                                crate::defs::p47::types::EntityMetadataValue::Slot(
2384                                    <crate::types::slot::legacy::Slot as Generate>::generate(g),
2385                                )
2386                            } else if (v6 == 6) {
2387                                crate::defs::p47::types::EntityMetadataValue::BlockPos({
2388                                    let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2389                                    let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2390                                    let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2391                                    crate::defs::p47::types::EntityMetadataValueBlockPos {
2392                                        x: v9,
2393                                        y: v10,
2394                                        z: v11,
2395                                    }
2396                                })
2397                            } else if (v6 == 7) {
2398                                crate::defs::p47::types::EntityMetadataValue::Rotation({
2399                                    let v12 = g.f32();
2400                                    let v13 = g.f32();
2401                                    let v14 = g.f32();
2402                                    crate::defs::p47::types::EntityMetadataValueRotation {
2403                                        pitch: v12,
2404                                        yaw: v13,
2405                                        roll: v14,
2406                                    }
2407                                })
2408                            } else {
2409                                crate::defs::p47::types::EntityMetadataValue::Other
2410                            });
2411                            crate::defs::p47::types::EntityMetadataEntry {
2412                                r#type: v6,
2413                                key: v7,
2414                                value: v8,
2415                            }
2416                        };
2417                        if crate::testgen::first_byte_ok(
2418                            |w: &mut BytesMut| -> EncodeResult {
2419                                {
2420                                    let mut bits: u64 = 0;
2421                                    {
2422                                        let x = i128::from(v4.r#type);
2423                                        if x < 0 || x > 7 {
2424                                            return Err(EncodeError::OutOfRange("type"));
2425                                        }
2426                                        bits = (bits << 3) | ((x as u64) & 0x7);
2427                                    }
2428                                    {
2429                                        let x = i128::from(v4.key);
2430                                        if x < 0 || x > 31 {
2431                                            return Err(EncodeError::OutOfRange("key"));
2432                                        }
2433                                        bits = (bits << 5) | ((x as u64) & 0x1f);
2434                                    }
2435                                    w.put_u8(bits as u8);
2436                                }
2437                                match &v4.value {
2438                                    crate::defs::p47::types::EntityMetadataValue::Byte(v15) => {
2439                                        if !(v4.r#type == 0) {
2440                                            return Err(EncodeError::SwitchMismatch(
2441                                                "play.clientbound.entity_metadata.metadata.value",
2442                                            ));
2443                                        }
2444                                        w.put_i8((*v15));
2445                                    }
2446                                    crate::defs::p47::types::EntityMetadataValue::Short(v16) => {
2447                                        if !(v4.r#type == 1) {
2448                                            return Err(EncodeError::SwitchMismatch(
2449                                                "play.clientbound.entity_metadata.metadata.value",
2450                                            ));
2451                                        }
2452                                        w.put_i16((*v16));
2453                                    }
2454                                    crate::defs::p47::types::EntityMetadataValue::Int(v17) => {
2455                                        if !(v4.r#type == 2) {
2456                                            return Err(EncodeError::SwitchMismatch(
2457                                                "play.clientbound.entity_metadata.metadata.value",
2458                                            ));
2459                                        }
2460                                        w.put_i32((*v17));
2461                                    }
2462                                    crate::defs::p47::types::EntityMetadataValue::Float(v18) => {
2463                                        if !(v4.r#type == 3) {
2464                                            return Err(EncodeError::SwitchMismatch(
2465                                                "play.clientbound.entity_metadata.metadata.value",
2466                                            ));
2467                                        }
2468                                        w.put_f32((*v18));
2469                                    }
2470                                    crate::defs::p47::types::EntityMetadataValue::String(v19) => {
2471                                        if !(v4.r#type == 4) {
2472                                            return Err(EncodeError::SwitchMismatch(
2473                                                "play.clientbound.entity_metadata.metadata.value",
2474                                            ));
2475                                        }
2476                                        w.put_string(&(*v19))?;
2477                                    }
2478                                    crate::defs::p47::types::EntityMetadataValue::Slot(v20) => {
2479                                        if !(v4.r#type == 5) {
2480                                            return Err(EncodeError::SwitchMismatch(
2481                                                "play.clientbound.entity_metadata.metadata.value",
2482                                            ));
2483                                        }
2484                                        (*v20).encode(w)?;
2485                                    }
2486                                    crate::defs::p47::types::EntityMetadataValue::BlockPos(v21) => {
2487                                        if !(v4.r#type == 6) {
2488                                            return Err(EncodeError::SwitchMismatch(
2489                                                "play.clientbound.entity_metadata.metadata.value",
2490                                            ));
2491                                        }
2492                                        w.put_i32((*v21).x);
2493                                        w.put_i32((*v21).y);
2494                                        w.put_i32((*v21).z);
2495                                    }
2496                                    crate::defs::p47::types::EntityMetadataValue::Rotation(v22) => {
2497                                        if !(v4.r#type == 7) {
2498                                            return Err(EncodeError::SwitchMismatch(
2499                                                "play.clientbound.entity_metadata.metadata.value",
2500                                            ));
2501                                        }
2502                                        w.put_f32((*v22).pitch);
2503                                        w.put_f32((*v22).yaw);
2504                                        w.put_f32((*v22).roll);
2505                                    }
2506                                    crate::defs::p47::types::EntityMetadataValue::Other => {
2507                                        if !(!((v4.r#type == 0)
2508                                            || (v4.r#type == 1)
2509                                            || (v4.r#type == 2)
2510                                            || (v4.r#type == 3)
2511                                            || (v4.r#type == 4)
2512                                            || (v4.r#type == 5)
2513                                            || (v4.r#type == 6)
2514                                            || (v4.r#type == 7)))
2515                                        {
2516                                            return Err(EncodeError::SwitchMismatch(
2517                                                "play.clientbound.entity_metadata.metadata.value",
2518                                            ));
2519                                        }
2520                                    }
2521                                }
2522                                Ok(())
2523                            },
2524                            |b| b != 127,
2525                        ) {
2526                            break v4;
2527                        }
2528                    });
2529                }
2530                v3
2531            };
2532            Self {
2533                entity_id: v1,
2534                metadata: v2,
2535            }
2536        }
2537    }
2538}
2539
2540#[cfg(feature = "v1_8")]
2541/// `entity_effect` (clientbound play).
2542#[derive(Debug, Clone, PartialEq)]
2543pub struct EntityEffect<const V: i32> {
2544    /// `entityId`
2545    pub entity_id: i32,
2546    /// `effectId`
2547    pub effect_id: i8,
2548    /// `amplifier`
2549    pub amplifier: i8,
2550    /// `duration`
2551    pub duration: i32,
2552    /// `hideParticles`
2553    pub hide_particles: bool,
2554}
2555#[cfg(feature = "v1_8")]
2556impl<const V: i32> Decode for EntityEffect<V> {
2557    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2558        Ok({
2559            let v1 = r.read_varint()?;
2560            let v2 = r.read_i8()?;
2561            let v3 = r.read_i8()?;
2562            let v4 = r.read_varint()?;
2563            let v5 = r.read_bool()?;
2564            Self {
2565                entity_id: v1,
2566                effect_id: v2,
2567                amplifier: v3,
2568                duration: v4,
2569                hide_particles: v5,
2570            }
2571        })
2572    }
2573}
2574#[cfg(feature = "v1_8")]
2575impl<const V: i32> Encode for EntityEffect<V> {
2576    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2577        w.put_varint((*self).entity_id);
2578        w.put_i8((*self).effect_id);
2579        w.put_i8((*self).amplifier);
2580        w.put_varint((*self).duration);
2581        w.put_bool((*self).hide_particles);
2582        Ok(())
2583    }
2584}
2585#[cfg(feature = "v1_8")]
2586#[cfg(feature = "testgen")]
2587impl<const V: i32> Generate for EntityEffect<V> {
2588    fn generate(g: &mut Gen) -> Self {
2589        {
2590            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2591            let v2 = (g.int_in(-128, 127, &[]) as i8);
2592            let v3 = (g.int_in(-128, 127, &[]) as i8);
2593            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2594            let v5 = g.bool();
2595            Self {
2596                entity_id: v1,
2597                effect_id: v2,
2598                amplifier: v3,
2599                duration: v4,
2600                hide_particles: v5,
2601            }
2602        }
2603    }
2604}
2605
2606#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
2607/// `remove_entity_effect` (clientbound play).
2608#[derive(Debug, Clone, PartialEq)]
2609pub struct RemoveEntityEffect<const V: i32> {
2610    /// `entityId`
2611    pub entity_id: i32,
2612    /// `effectId`
2613    pub effect_id: i8,
2614}
2615#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
2616impl<const V: i32> Decode for RemoveEntityEffect<V> {
2617    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2618        Ok({
2619            let v1 = r.read_varint()?;
2620            let v2 = r.read_i8()?;
2621            Self {
2622                entity_id: v1,
2623                effect_id: v2,
2624            }
2625        })
2626    }
2627}
2628#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
2629impl<const V: i32> Encode for RemoveEntityEffect<V> {
2630    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2631        w.put_varint((*self).entity_id);
2632        w.put_i8((*self).effect_id);
2633        Ok(())
2634    }
2635}
2636#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
2637#[cfg(feature = "testgen")]
2638impl<const V: i32> Generate for RemoveEntityEffect<V> {
2639    fn generate(g: &mut Gen) -> Self {
2640        {
2641            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2642            let v2 = (g.int_in(-128, 127, &[]) as i8);
2643            Self {
2644                entity_id: v1,
2645                effect_id: v2,
2646            }
2647        }
2648    }
2649}
2650
2651#[cfg(any(
2652    feature = "v1_8",
2653    feature = "v1_12_2",
2654    feature = "v1_16_5",
2655    feature = "v26_1",
2656    feature = "v26_2"
2657))]
2658/// `experience` (clientbound play).
2659#[derive(Debug, Clone, PartialEq)]
2660pub struct Experience<const V: i32> {
2661    /// `experienceBar`
2662    pub experience_bar: f32,
2663    /// `level`
2664    pub level: i32,
2665    /// `totalExperience`
2666    pub total_experience: i32,
2667}
2668#[cfg(any(
2669    feature = "v1_8",
2670    feature = "v1_12_2",
2671    feature = "v1_16_5",
2672    feature = "v26_1",
2673    feature = "v26_2"
2674))]
2675impl<const V: i32> Decode for Experience<V> {
2676    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2677        Ok({
2678            let v1 = r.read_f32()?;
2679            let v2 = r.read_varint()?;
2680            let v3 = r.read_varint()?;
2681            Self {
2682                experience_bar: v1,
2683                level: v2,
2684                total_experience: v3,
2685            }
2686        })
2687    }
2688}
2689#[cfg(any(
2690    feature = "v1_8",
2691    feature = "v1_12_2",
2692    feature = "v1_16_5",
2693    feature = "v26_1",
2694    feature = "v26_2"
2695))]
2696impl<const V: i32> Encode for Experience<V> {
2697    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2698        w.put_f32((*self).experience_bar);
2699        w.put_varint((*self).level);
2700        w.put_varint((*self).total_experience);
2701        Ok(())
2702    }
2703}
2704#[cfg(any(
2705    feature = "v1_8",
2706    feature = "v1_12_2",
2707    feature = "v1_16_5",
2708    feature = "v26_1",
2709    feature = "v26_2"
2710))]
2711#[cfg(feature = "testgen")]
2712impl<const V: i32> Generate for Experience<V> {
2713    fn generate(g: &mut Gen) -> Self {
2714        {
2715            let v1 = g.f32();
2716            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2717            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2718            Self {
2719                experience_bar: v1,
2720                level: v2,
2721                total_experience: v3,
2722            }
2723        }
2724    }
2725}
2726
2727#[cfg(feature = "v1_8")]
2728/// Nested container.
2729#[derive(Debug, Clone, PartialEq)]
2730pub struct UpdateAttributesPropertiesModifiers {
2731    /// `uuid`
2732    pub uuid: Uuid,
2733    /// `amount`
2734    pub amount: f64,
2735    /// `operation`
2736    pub operation: i8,
2737}
2738
2739#[cfg(feature = "v1_8")]
2740/// Nested container.
2741#[derive(Debug, Clone, PartialEq)]
2742pub struct UpdateAttributesProperties {
2743    /// `key`
2744    pub key: ByteString,
2745    /// `value`
2746    pub value: f64,
2747    /// `modifiers`
2748    pub modifiers: Vec<crate::defs::p47::play::clientbound::UpdateAttributesPropertiesModifiers>,
2749}
2750
2751#[cfg(feature = "v1_8")]
2752/// `update_attributes` (clientbound play).
2753#[derive(Debug, Clone, PartialEq)]
2754pub struct UpdateAttributes<const V: i32> {
2755    /// `entityId`
2756    pub entity_id: i32,
2757    /// `properties`
2758    pub properties: Vec<crate::defs::p47::play::clientbound::UpdateAttributesProperties>,
2759}
2760#[cfg(feature = "v1_8")]
2761impl<const V: i32> Decode for UpdateAttributes<V> {
2762    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2763        Ok({
2764            let v1 = r.read_varint()?;
2765            let v2 = {
2766                let v3 = {
2767                    let c = r.read_i32()?;
2768                    r.check_count(i64::from(c), 10)?
2769                };
2770                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2771                for _ in 0..v3 {
2772                    v4.push({ let v5 = r.read_string()?;let v6 = r.read_f64()?;let v7 = { let v8 = { let c = r.read_varint()?; r.check_count(i64::from(c), 25)? }; let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = r.read_uuid()?;let v11 = r.read_f64()?;let v12 = r.read_i8()?; crate::defs::p47::play::clientbound::UpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p47::play::clientbound::UpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
2773                }
2774                v4
2775            };
2776            Self {
2777                entity_id: v1,
2778                properties: v2,
2779            }
2780        })
2781    }
2782}
2783#[cfg(feature = "v1_8")]
2784impl<const V: i32> Encode for UpdateAttributes<V> {
2785    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2786        w.put_varint((*self).entity_id);
2787        w.put_i32(crate::codec::count_i32((*self).properties.len())?);
2788        for v1 in (*self).properties.iter() {
2789            w.put_string(&(*v1).key)?;
2790            w.put_f64((*v1).value);
2791            w.put_len_varint((*v1).modifiers.len())?;
2792            for v2 in (*v1).modifiers.iter() {
2793                w.put_uuid(&(*v2).uuid);
2794                w.put_f64((*v2).amount);
2795                w.put_i8((*v2).operation);
2796            }
2797        }
2798        Ok(())
2799    }
2800}
2801#[cfg(feature = "v1_8")]
2802#[cfg(feature = "testgen")]
2803impl<const V: i32> Generate for UpdateAttributes<V> {
2804    fn generate(g: &mut Gen) -> Self {
2805        {
2806            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2807            let v2 = {
2808                let v3 = g.count();
2809                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2810                for _ in 0..v3 {
2811                    v4.push({ let v5 = g.string();let v6 = g.f64();let v7 = { let v8 = g.count(); let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = g.uuid();let v11 = g.f64();let v12 = (g.int_in(-128, 127, &[]) as i8); crate::defs::p47::play::clientbound::UpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p47::play::clientbound::UpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
2812                }
2813                v4
2814            };
2815            Self {
2816                entity_id: v1,
2817                properties: v2,
2818            }
2819        }
2820    }
2821}
2822
2823#[cfg(feature = "v1_8")]
2824/// `map_chunk` (clientbound play).
2825#[derive(Debug, Clone, PartialEq)]
2826pub struct MapChunk<const V: i32> {
2827    /// `x`
2828    pub x: i32,
2829    /// `z`
2830    pub z: i32,
2831    /// `groundUp`
2832    pub ground_up: bool,
2833    /// `bitMap`
2834    pub bit_map: u16,
2835    /// `chunkData`
2836    pub chunk_data: Bytes,
2837}
2838#[cfg(feature = "v1_8")]
2839impl<const V: i32> Decode for MapChunk<V> {
2840    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2841        Ok({
2842            let v1 = r.read_i32()?;
2843            let v2 = r.read_i32()?;
2844            let v3 = r.read_bool()?;
2845            let v4 = r.read_u16()?;
2846            let v5 = r.read_byte_array()?;
2847            Self {
2848                x: v1,
2849                z: v2,
2850                ground_up: v3,
2851                bit_map: v4,
2852                chunk_data: v5,
2853            }
2854        })
2855    }
2856}
2857#[cfg(feature = "v1_8")]
2858impl<const V: i32> Encode for MapChunk<V> {
2859    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2860        w.put_i32((*self).x);
2861        w.put_i32((*self).z);
2862        w.put_bool((*self).ground_up);
2863        w.put_u16((*self).bit_map);
2864        w.put_byte_array(&(*self).chunk_data)?;
2865        Ok(())
2866    }
2867}
2868#[cfg(feature = "v1_8")]
2869#[cfg(feature = "testgen")]
2870impl<const V: i32> Generate for MapChunk<V> {
2871    fn generate(g: &mut Gen) -> Self {
2872        {
2873            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2874            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2875            let v3 = g.bool();
2876            let v4 = (g.int_in(0, 65535, &[]) as u16);
2877            let v5 = g.bytes();
2878            Self {
2879                x: v1,
2880                z: v2,
2881                ground_up: v3,
2882                bit_map: v4,
2883                chunk_data: v5,
2884            }
2885        }
2886    }
2887}
2888
2889#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2890/// Nested container.
2891#[derive(Debug, Clone, PartialEq)]
2892pub struct MultiBlockChangeRecords {
2893    /// `horizontalPos`
2894    pub horizontal_pos: u8,
2895    /// `y`
2896    pub y: u8,
2897    /// `blockId`
2898    pub block_id: i32,
2899}
2900
2901#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2902/// `multi_block_change` (clientbound play).
2903#[derive(Debug, Clone, PartialEq)]
2904pub struct MultiBlockChange<const V: i32> {
2905    /// `chunkX`
2906    pub chunk_x: i32,
2907    /// `chunkZ`
2908    pub chunk_z: i32,
2909    /// `records`
2910    pub records: Vec<crate::defs::p47::play::clientbound::MultiBlockChangeRecords>,
2911}
2912#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2913impl<const V: i32> Decode for MultiBlockChange<V> {
2914    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2915        Ok({
2916            let v1 = r.read_i32()?;
2917            let v2 = r.read_i32()?;
2918            let v3 = {
2919                let v4 = {
2920                    let c = r.read_varint()?;
2921                    r.check_count(i64::from(c), 3)?
2922                };
2923                let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
2924                for _ in 0..v4 {
2925                    v5.push({
2926                        let v6 = r.read_u8()?;
2927                        let v7 = r.read_u8()?;
2928                        let v8 = r.read_varint()?;
2929                        crate::defs::p47::play::clientbound::MultiBlockChangeRecords {
2930                            horizontal_pos: v6,
2931                            y: v7,
2932                            block_id: v8,
2933                        }
2934                    });
2935                }
2936                v5
2937            };
2938            Self {
2939                chunk_x: v1,
2940                chunk_z: v2,
2941                records: v3,
2942            }
2943        })
2944    }
2945}
2946#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2947impl<const V: i32> Encode for MultiBlockChange<V> {
2948    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2949        w.put_i32((*self).chunk_x);
2950        w.put_i32((*self).chunk_z);
2951        w.put_len_varint((*self).records.len())?;
2952        for v1 in (*self).records.iter() {
2953            w.put_u8((*v1).horizontal_pos);
2954            w.put_u8((*v1).y);
2955            w.put_varint((*v1).block_id);
2956        }
2957        Ok(())
2958    }
2959}
2960#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2961#[cfg(feature = "testgen")]
2962impl<const V: i32> Generate for MultiBlockChange<V> {
2963    fn generate(g: &mut Gen) -> Self {
2964        {
2965            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2966            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2967            let v3 = {
2968                let v4 = g.count();
2969                let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
2970                for _ in 0..v4 {
2971                    v5.push({
2972                        let v6 = (g.int_in(0, 255, &[]) as u8);
2973                        let v7 = (g.int_in(0, 255, &[]) as u8);
2974                        let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2975                        crate::defs::p47::play::clientbound::MultiBlockChangeRecords {
2976                            horizontal_pos: v6,
2977                            y: v7,
2978                            block_id: v8,
2979                        }
2980                    });
2981                }
2982                v5
2983            };
2984            Self {
2985                chunk_x: v1,
2986                chunk_z: v2,
2987                records: v3,
2988            }
2989        }
2990    }
2991}
2992
2993#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
2994/// `block_change` (clientbound play).
2995#[derive(Debug, Clone, PartialEq)]
2996pub struct BlockChange<const V: i32> {
2997    /// `location`
2998    pub location: BlockPos,
2999    /// `type`
3000    pub r#type: i32,
3001}
3002#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3003impl<const V: i32> Decode for BlockChange<V> {
3004    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3005        Ok({
3006            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
3007            let v2 = r.read_varint()?;
3008            Self {
3009                location: v1,
3010                r#type: v2,
3011            }
3012        })
3013    }
3014}
3015#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3016impl<const V: i32> Encode for BlockChange<V> {
3017    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3018        (*self).location.write(w, PositionLayout::Xyz)?;
3019        w.put_varint((*self).r#type);
3020        Ok(())
3021    }
3022}
3023#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3024#[cfg(feature = "testgen")]
3025impl<const V: i32> Generate for BlockChange<V> {
3026    fn generate(g: &mut Gen) -> Self {
3027        {
3028            let v1 = g.position();
3029            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3030            Self {
3031                location: v1,
3032                r#type: v2,
3033            }
3034        }
3035    }
3036}
3037
3038#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3039/// `block_action` (clientbound play).
3040#[derive(Debug, Clone, PartialEq)]
3041pub struct BlockAction<const V: i32> {
3042    /// `location`
3043    pub location: BlockPos,
3044    /// `byte1`
3045    pub byte1: u8,
3046    /// `byte2`
3047    pub byte2: u8,
3048    /// `blockId`
3049    pub block_id: i32,
3050}
3051#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3052impl<const V: i32> Decode for BlockAction<V> {
3053    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3054        Ok({
3055            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
3056            let v2 = r.read_u8()?;
3057            let v3 = r.read_u8()?;
3058            let v4 = r.read_varint()?;
3059            Self {
3060                location: v1,
3061                byte1: v2,
3062                byte2: v3,
3063                block_id: v4,
3064            }
3065        })
3066    }
3067}
3068#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3069impl<const V: i32> Encode for BlockAction<V> {
3070    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3071        (*self).location.write(w, PositionLayout::Xyz)?;
3072        w.put_u8((*self).byte1);
3073        w.put_u8((*self).byte2);
3074        w.put_varint((*self).block_id);
3075        Ok(())
3076    }
3077}
3078#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3079#[cfg(feature = "testgen")]
3080impl<const V: i32> Generate for BlockAction<V> {
3081    fn generate(g: &mut Gen) -> Self {
3082        {
3083            let v1 = g.position();
3084            let v2 = (g.int_in(0, 255, &[]) as u8);
3085            let v3 = (g.int_in(0, 255, &[]) as u8);
3086            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3087            Self {
3088                location: v1,
3089                byte1: v2,
3090                byte2: v3,
3091                block_id: v4,
3092            }
3093        }
3094    }
3095}
3096
3097#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3098/// `block_break_animation` (clientbound play).
3099#[derive(Debug, Clone, PartialEq)]
3100pub struct BlockBreakAnimation<const V: i32> {
3101    /// `entityId`
3102    pub entity_id: i32,
3103    /// `location`
3104    pub location: BlockPos,
3105    /// `destroyStage`
3106    pub destroy_stage: i8,
3107}
3108#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3109impl<const V: i32> Decode for BlockBreakAnimation<V> {
3110    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3111        Ok({
3112            let v1 = r.read_varint()?;
3113            let v2 = BlockPos::read(r, PositionLayout::Xyz)?;
3114            let v3 = r.read_i8()?;
3115            Self {
3116                entity_id: v1,
3117                location: v2,
3118                destroy_stage: v3,
3119            }
3120        })
3121    }
3122}
3123#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3124impl<const V: i32> Encode for BlockBreakAnimation<V> {
3125    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3126        w.put_varint((*self).entity_id);
3127        (*self).location.write(w, PositionLayout::Xyz)?;
3128        w.put_i8((*self).destroy_stage);
3129        Ok(())
3130    }
3131}
3132#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3133#[cfg(feature = "testgen")]
3134impl<const V: i32> Generate for BlockBreakAnimation<V> {
3135    fn generate(g: &mut Gen) -> Self {
3136        {
3137            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3138            let v2 = g.position();
3139            let v3 = (g.int_in(-128, 127, &[]) as i8);
3140            Self {
3141                entity_id: v1,
3142                location: v2,
3143                destroy_stage: v3,
3144            }
3145        }
3146    }
3147}
3148
3149#[cfg(feature = "v1_8")]
3150/// Nested container.
3151#[derive(Debug, Clone, PartialEq)]
3152pub struct MapChunkBulkMeta {
3153    /// `x`
3154    pub x: i32,
3155    /// `z`
3156    pub z: i32,
3157    /// `bitMap`
3158    pub bit_map: u16,
3159}
3160
3161#[cfg(feature = "v1_8")]
3162/// `map_chunk_bulk` (clientbound play).
3163#[derive(Debug, Clone, PartialEq)]
3164pub struct MapChunkBulk<const V: i32> {
3165    /// `skyLightSent`
3166    pub sky_light_sent: bool,
3167    /// `meta`
3168    pub meta: Vec<crate::defs::p47::play::clientbound::MapChunkBulkMeta>,
3169    /// `data`
3170    pub data: Bytes,
3171}
3172#[cfg(feature = "v1_8")]
3173impl<const V: i32> Decode for MapChunkBulk<V> {
3174    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3175        Ok({
3176            let v1 = r.read_bool()?;
3177            let v2 = {
3178                let v3 = {
3179                    let c = r.read_varint()?;
3180                    r.check_count(i64::from(c), 10)?
3181                };
3182                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
3183                for _ in 0..v3 {
3184                    v4.push({
3185                        let v5 = r.read_i32()?;
3186                        let v6 = r.read_i32()?;
3187                        let v7 = r.read_u16()?;
3188                        crate::defs::p47::play::clientbound::MapChunkBulkMeta {
3189                            x: v5,
3190                            z: v6,
3191                            bit_map: v7,
3192                        }
3193                    });
3194                }
3195                v4
3196            };
3197            let v8 = r.read_rest();
3198            Self {
3199                sky_light_sent: v1,
3200                meta: v2,
3201                data: v8,
3202            }
3203        })
3204    }
3205}
3206#[cfg(feature = "v1_8")]
3207impl<const V: i32> Encode for MapChunkBulk<V> {
3208    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3209        w.put_bool((*self).sky_light_sent);
3210        w.put_len_varint((*self).meta.len())?;
3211        for v1 in (*self).meta.iter() {
3212            w.put_i32((*v1).x);
3213            w.put_i32((*v1).z);
3214            w.put_u16((*v1).bit_map);
3215        }
3216        w.put_slice(&(*self).data);
3217        Ok(())
3218    }
3219}
3220#[cfg(feature = "v1_8")]
3221#[cfg(feature = "testgen")]
3222impl<const V: i32> Generate for MapChunkBulk<V> {
3223    fn generate(g: &mut Gen) -> Self {
3224        {
3225            let v1 = g.bool();
3226            let v2 = {
3227                let v3 = g.count();
3228                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
3229                for _ in 0..v3 {
3230                    v4.push({
3231                        let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3232                        let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3233                        let v7 = (g.int_in(0, 65535, &[]) as u16);
3234                        crate::defs::p47::play::clientbound::MapChunkBulkMeta {
3235                            x: v5,
3236                            z: v6,
3237                            bit_map: v7,
3238                        }
3239                    });
3240                }
3241                v4
3242            };
3243            let v8 = g.bytes();
3244            Self {
3245                sky_light_sent: v1,
3246                meta: v2,
3247                data: v8,
3248            }
3249        }
3250    }
3251}
3252
3253#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
3254/// Nested container.
3255#[derive(Debug, Clone, PartialEq)]
3256pub struct ExplosionAffectedBlockOffsets {
3257    /// `x`
3258    pub x: i8,
3259    /// `y`
3260    pub y: i8,
3261    /// `z`
3262    pub z: i8,
3263}
3264
3265#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
3266/// `explosion` (clientbound play).
3267#[derive(Debug, Clone, PartialEq)]
3268pub struct Explosion<const V: i32> {
3269    /// `x`
3270    pub x: f32,
3271    /// `y`
3272    pub y: f32,
3273    /// `z`
3274    pub z: f32,
3275    /// `radius`
3276    pub radius: f32,
3277    /// `affectedBlockOffsets`
3278    pub affected_block_offsets:
3279        Vec<crate::defs::p47::play::clientbound::ExplosionAffectedBlockOffsets>,
3280    /// `playerMotionX`
3281    pub player_motion_x: f32,
3282    /// `playerMotionY`
3283    pub player_motion_y: f32,
3284    /// `playerMotionZ`
3285    pub player_motion_z: f32,
3286}
3287#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
3288impl<const V: i32> Decode for Explosion<V> {
3289    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3290        Ok({
3291            let v1 = r.read_f32()?;
3292            let v2 = r.read_f32()?;
3293            let v3 = r.read_f32()?;
3294            let v4 = r.read_f32()?;
3295            let v5 = {
3296                let v6 = {
3297                    let c = r.read_i32()?;
3298                    r.check_count(i64::from(c), 3)?
3299                };
3300                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
3301                for _ in 0..v6 {
3302                    v7.push({
3303                        let v8 = r.read_i8()?;
3304                        let v9 = r.read_i8()?;
3305                        let v10 = r.read_i8()?;
3306                        crate::defs::p47::play::clientbound::ExplosionAffectedBlockOffsets {
3307                            x: v8,
3308                            y: v9,
3309                            z: v10,
3310                        }
3311                    });
3312                }
3313                v7
3314            };
3315            let v11 = r.read_f32()?;
3316            let v12 = r.read_f32()?;
3317            let v13 = r.read_f32()?;
3318            Self {
3319                x: v1,
3320                y: v2,
3321                z: v3,
3322                radius: v4,
3323                affected_block_offsets: v5,
3324                player_motion_x: v11,
3325                player_motion_y: v12,
3326                player_motion_z: v13,
3327            }
3328        })
3329    }
3330}
3331#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
3332impl<const V: i32> Encode for Explosion<V> {
3333    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3334        w.put_f32((*self).x);
3335        w.put_f32((*self).y);
3336        w.put_f32((*self).z);
3337        w.put_f32((*self).radius);
3338        w.put_i32(crate::codec::count_i32(
3339            (*self).affected_block_offsets.len(),
3340        )?);
3341        for v1 in (*self).affected_block_offsets.iter() {
3342            w.put_i8((*v1).x);
3343            w.put_i8((*v1).y);
3344            w.put_i8((*v1).z);
3345        }
3346        w.put_f32((*self).player_motion_x);
3347        w.put_f32((*self).player_motion_y);
3348        w.put_f32((*self).player_motion_z);
3349        Ok(())
3350    }
3351}
3352#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
3353#[cfg(feature = "testgen")]
3354impl<const V: i32> Generate for Explosion<V> {
3355    fn generate(g: &mut Gen) -> Self {
3356        {
3357            let v1 = g.f32();
3358            let v2 = g.f32();
3359            let v3 = g.f32();
3360            let v4 = g.f32();
3361            let v5 = {
3362                let v6 = g.count();
3363                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
3364                for _ in 0..v6 {
3365                    v7.push({
3366                        let v8 = (g.int_in(-128, 127, &[]) as i8);
3367                        let v9 = (g.int_in(-128, 127, &[]) as i8);
3368                        let v10 = (g.int_in(-128, 127, &[]) as i8);
3369                        crate::defs::p47::play::clientbound::ExplosionAffectedBlockOffsets {
3370                            x: v8,
3371                            y: v9,
3372                            z: v10,
3373                        }
3374                    });
3375                }
3376                v7
3377            };
3378            let v11 = g.f32();
3379            let v12 = g.f32();
3380            let v13 = g.f32();
3381            Self {
3382                x: v1,
3383                y: v2,
3384                z: v3,
3385                radius: v4,
3386                affected_block_offsets: v5,
3387                player_motion_x: v11,
3388                player_motion_y: v12,
3389                player_motion_z: v13,
3390            }
3391        }
3392    }
3393}
3394
3395#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3396/// `world_event` (clientbound play).
3397#[derive(Debug, Clone, PartialEq)]
3398pub struct WorldEvent<const V: i32> {
3399    /// `effectId`
3400    pub effect_id: i32,
3401    /// `location`
3402    pub location: BlockPos,
3403    /// `data`
3404    pub data: i32,
3405    /// `global`
3406    pub global: bool,
3407}
3408#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3409impl<const V: i32> Decode for WorldEvent<V> {
3410    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3411        Ok({
3412            let v1 = r.read_i32()?;
3413            let v2 = BlockPos::read(r, PositionLayout::Xyz)?;
3414            let v3 = r.read_i32()?;
3415            let v4 = r.read_bool()?;
3416            Self {
3417                effect_id: v1,
3418                location: v2,
3419                data: v3,
3420                global: v4,
3421            }
3422        })
3423    }
3424}
3425#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3426impl<const V: i32> Encode for WorldEvent<V> {
3427    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3428        w.put_i32((*self).effect_id);
3429        (*self).location.write(w, PositionLayout::Xyz)?;
3430        w.put_i32((*self).data);
3431        w.put_bool((*self).global);
3432        Ok(())
3433    }
3434}
3435#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3436#[cfg(feature = "testgen")]
3437impl<const V: i32> Generate for WorldEvent<V> {
3438    fn generate(g: &mut Gen) -> Self {
3439        {
3440            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3441            let v2 = g.position();
3442            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3443            let v4 = g.bool();
3444            Self {
3445                effect_id: v1,
3446                location: v2,
3447                data: v3,
3448                global: v4,
3449            }
3450        }
3451    }
3452}
3453
3454#[cfg(feature = "v1_8")]
3455/// `named_sound_effect` (clientbound play).
3456#[derive(Debug, Clone, PartialEq)]
3457pub struct NamedSoundEffect<const V: i32> {
3458    /// `soundName`
3459    pub sound_name: ByteString,
3460    /// `x`
3461    pub x: i32,
3462    /// `y`
3463    pub y: i32,
3464    /// `z`
3465    pub z: i32,
3466    /// `volume`
3467    pub volume: f32,
3468    /// `pitch`
3469    pub pitch: u8,
3470}
3471#[cfg(feature = "v1_8")]
3472impl<const V: i32> Decode for NamedSoundEffect<V> {
3473    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3474        Ok({
3475            let v1 = r.read_string()?;
3476            let v2 = r.read_i32()?;
3477            let v3 = r.read_i32()?;
3478            let v4 = r.read_i32()?;
3479            let v5 = r.read_f32()?;
3480            let v6 = r.read_u8()?;
3481            Self {
3482                sound_name: v1,
3483                x: v2,
3484                y: v3,
3485                z: v4,
3486                volume: v5,
3487                pitch: v6,
3488            }
3489        })
3490    }
3491}
3492#[cfg(feature = "v1_8")]
3493impl<const V: i32> Encode for NamedSoundEffect<V> {
3494    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3495        w.put_string(&(*self).sound_name)?;
3496        w.put_i32((*self).x);
3497        w.put_i32((*self).y);
3498        w.put_i32((*self).z);
3499        w.put_f32((*self).volume);
3500        w.put_u8((*self).pitch);
3501        Ok(())
3502    }
3503}
3504#[cfg(feature = "v1_8")]
3505#[cfg(feature = "testgen")]
3506impl<const V: i32> Generate for NamedSoundEffect<V> {
3507    fn generate(g: &mut Gen) -> Self {
3508        {
3509            let v1 = g.string();
3510            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3511            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3512            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3513            let v5 = g.f32();
3514            let v6 = (g.int_in(0, 255, &[]) as u8);
3515            Self {
3516                sound_name: v1,
3517                x: v2,
3518                y: v3,
3519                z: v4,
3520                volume: v5,
3521                pitch: v6,
3522            }
3523        }
3524    }
3525}
3526
3527#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3528/// Switch on `particleId`.
3529#[derive(Debug, Clone, PartialEq)]
3530pub enum WorldParticlesData {
3531    /// Case(s) `36`.
3532    Case36(Vec<i32>),
3533    /// Case(s) `37`.
3534    Case37(Vec<i32>),
3535    /// Case(s) `38`.
3536    Case38(Vec<i32>),
3537    /// Any other value.
3538    Other,
3539}
3540
3541#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3542/// `world_particles` (clientbound play).
3543#[derive(Debug, Clone, PartialEq)]
3544pub struct WorldParticles<const V: i32> {
3545    /// `particleId`
3546    pub particle_id: i32,
3547    /// `longDistance`
3548    pub long_distance: bool,
3549    /// `x`
3550    pub x: f32,
3551    /// `y`
3552    pub y: f32,
3553    /// `z`
3554    pub z: f32,
3555    /// `offsetX`
3556    pub offset_x: f32,
3557    /// `offsetY`
3558    pub offset_y: f32,
3559    /// `offsetZ`
3560    pub offset_z: f32,
3561    /// `particleData`
3562    pub particle_data: f32,
3563    /// `particles`
3564    pub particles: i32,
3565    /// `data`
3566    pub data: crate::defs::p47::play::clientbound::WorldParticlesData,
3567}
3568#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3569impl<const V: i32> Decode for WorldParticles<V> {
3570    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3571        Ok({
3572            let v1 = r.read_i32()?;
3573            let v2 = r.read_bool()?;
3574            let v3 = r.read_f32()?;
3575            let v4 = r.read_f32()?;
3576            let v5 = r.read_f32()?;
3577            let v6 = r.read_f32()?;
3578            let v7 = r.read_f32()?;
3579            let v8 = r.read_f32()?;
3580            let v9 = r.read_f32()?;
3581            let v10 = r.read_i32()?;
3582            let v11 = (if (v1 == 36) {
3583                crate::defs::p47::play::clientbound::WorldParticlesData::Case36({
3584                    let v12 = 2;
3585                    let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
3586                    for _ in 0..v12 {
3587                        v13.push(r.read_varint()?);
3588                    }
3589                    v13
3590                })
3591            } else if (v1 == 37) {
3592                crate::defs::p47::play::clientbound::WorldParticlesData::Case37({
3593                    let v14 = 1;
3594                    let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
3595                    for _ in 0..v14 {
3596                        v15.push(r.read_varint()?);
3597                    }
3598                    v15
3599                })
3600            } else if (v1 == 38) {
3601                crate::defs::p47::play::clientbound::WorldParticlesData::Case38({
3602                    let v16 = 1;
3603                    let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
3604                    for _ in 0..v16 {
3605                        v17.push(r.read_varint()?);
3606                    }
3607                    v17
3608                })
3609            } else {
3610                crate::defs::p47::play::clientbound::WorldParticlesData::Other
3611            });
3612            Self {
3613                particle_id: v1,
3614                long_distance: v2,
3615                x: v3,
3616                y: v4,
3617                z: v5,
3618                offset_x: v6,
3619                offset_y: v7,
3620                offset_z: v8,
3621                particle_data: v9,
3622                particles: v10,
3623                data: v11,
3624            }
3625        })
3626    }
3627}
3628#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3629impl<const V: i32> Encode for WorldParticles<V> {
3630    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3631        w.put_i32((*self).particle_id);
3632        w.put_bool((*self).long_distance);
3633        w.put_f32((*self).x);
3634        w.put_f32((*self).y);
3635        w.put_f32((*self).z);
3636        w.put_f32((*self).offset_x);
3637        w.put_f32((*self).offset_y);
3638        w.put_f32((*self).offset_z);
3639        w.put_f32((*self).particle_data);
3640        w.put_i32((*self).particles);
3641        match &(*self).data {
3642            crate::defs::p47::play::clientbound::WorldParticlesData::Case36(v1) => {
3643                if !((*self).particle_id == 36) {
3644                    return Err(EncodeError::SwitchMismatch(
3645                        "play.clientbound.world_particles.data",
3646                    ));
3647                }
3648                if (*v1).len() != 2 {
3649                    return Err(EncodeError::CountMismatch {
3650                        field: "play.clientbound.world_particles.data",
3651                        expected: 2,
3652                        actual: (*v1).len(),
3653                    });
3654                }
3655                for v2 in (*v1).iter() {
3656                    w.put_varint((*v2));
3657                }
3658            }
3659            crate::defs::p47::play::clientbound::WorldParticlesData::Case37(v3) => {
3660                if !((*self).particle_id == 37) {
3661                    return Err(EncodeError::SwitchMismatch(
3662                        "play.clientbound.world_particles.data",
3663                    ));
3664                }
3665                if (*v3).len() != 1 {
3666                    return Err(EncodeError::CountMismatch {
3667                        field: "play.clientbound.world_particles.data",
3668                        expected: 1,
3669                        actual: (*v3).len(),
3670                    });
3671                }
3672                for v4 in (*v3).iter() {
3673                    w.put_varint((*v4));
3674                }
3675            }
3676            crate::defs::p47::play::clientbound::WorldParticlesData::Case38(v5) => {
3677                if !((*self).particle_id == 38) {
3678                    return Err(EncodeError::SwitchMismatch(
3679                        "play.clientbound.world_particles.data",
3680                    ));
3681                }
3682                if (*v5).len() != 1 {
3683                    return Err(EncodeError::CountMismatch {
3684                        field: "play.clientbound.world_particles.data",
3685                        expected: 1,
3686                        actual: (*v5).len(),
3687                    });
3688                }
3689                for v6 in (*v5).iter() {
3690                    w.put_varint((*v6));
3691                }
3692            }
3693            crate::defs::p47::play::clientbound::WorldParticlesData::Other => {
3694                if !(!(((*self).particle_id == 36)
3695                    || ((*self).particle_id == 37)
3696                    || ((*self).particle_id == 38)))
3697                {
3698                    return Err(EncodeError::SwitchMismatch(
3699                        "play.clientbound.world_particles.data",
3700                    ));
3701                }
3702            }
3703        }
3704        Ok(())
3705    }
3706}
3707#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3708#[cfg(feature = "testgen")]
3709impl<const V: i32> Generate for WorldParticles<V> {
3710    fn generate(g: &mut Gen) -> Self {
3711        {
3712            let v1 = (g.int_in(-2147483648, 2147483647, &[36, 37, 38]) as i32);
3713            let v2 = g.bool();
3714            let v3 = g.f32();
3715            let v4 = g.f32();
3716            let v5 = g.f32();
3717            let v6 = g.f32();
3718            let v7 = g.f32();
3719            let v8 = g.f32();
3720            let v9 = g.f32();
3721            let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3722            let v11 = (if (v1 == 36) {
3723                crate::defs::p47::play::clientbound::WorldParticlesData::Case36({
3724                    let v12 = 2;
3725                    let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
3726                    for _ in 0..v12 {
3727                        v13.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3728                    }
3729                    v13
3730                })
3731            } else if (v1 == 37) {
3732                crate::defs::p47::play::clientbound::WorldParticlesData::Case37({
3733                    let v14 = 1;
3734                    let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
3735                    for _ in 0..v14 {
3736                        v15.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3737                    }
3738                    v15
3739                })
3740            } else if (v1 == 38) {
3741                crate::defs::p47::play::clientbound::WorldParticlesData::Case38({
3742                    let v16 = 1;
3743                    let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
3744                    for _ in 0..v16 {
3745                        v17.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3746                    }
3747                    v17
3748                })
3749            } else {
3750                crate::defs::p47::play::clientbound::WorldParticlesData::Other
3751            });
3752            Self {
3753                particle_id: v1,
3754                long_distance: v2,
3755                x: v3,
3756                y: v4,
3757                z: v5,
3758                offset_x: v6,
3759                offset_y: v7,
3760                offset_z: v8,
3761                particle_data: v9,
3762                particles: v10,
3763                data: v11,
3764            }
3765        }
3766    }
3767}
3768
3769#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3770/// Mapped `u8` value; unknown values are kept as-is.
3771#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
3772pub struct GameStateChangeReason(pub u8);
3773#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3774impl GameStateChangeReason {
3775    /// `no_respawn_block_available`
3776    pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
3777    /// `start_raining`
3778    pub const START_RAINING: Self = Self(1);
3779    /// `stop_raining`
3780    pub const STOP_RAINING: Self = Self(2);
3781    /// `change_game_mode`
3782    pub const CHANGE_GAME_MODE: Self = Self(3);
3783    /// `win_game`
3784    pub const WIN_GAME: Self = Self(4);
3785    /// `demo_event`
3786    pub const DEMO_EVENT: Self = Self(5);
3787    /// `play_arrow_hit_sound`
3788    pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
3789    /// `rain_level_change`
3790    pub const RAIN_LEVEL_CHANGE: Self = Self(7);
3791    /// `thunder_level_change`
3792    pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
3793    /// `guardian_elder_effect`
3794    pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
3795    /// minecraft-data name of the value, if known.
3796    pub const fn name(self) -> Option<&'static str> {
3797        match self.0 {
3798            0 => Some("no_respawn_block_available"),
3799            1 => Some("start_raining"),
3800            2 => Some("stop_raining"),
3801            3 => Some("change_game_mode"),
3802            4 => Some("win_game"),
3803            5 => Some("demo_event"),
3804            6 => Some("play_arrow_hit_sound"),
3805            7 => Some("rain_level_change"),
3806            8 => Some("thunder_level_change"),
3807            10 => Some("guardian_elder_effect"),
3808            _ => None,
3809        }
3810    }
3811}
3812#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3813impl std::fmt::Debug for GameStateChangeReason {
3814    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3815        match self.name() {
3816            Some(n) => write!(f, "GameStateChangeReason::{n}"),
3817            None => write!(f, "GameStateChangeReason({})", self.0),
3818        }
3819    }
3820}
3821
3822#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3823/// `game_state_change` (clientbound play).
3824#[derive(Debug, Clone, PartialEq)]
3825pub struct GameStateChange<const V: i32> {
3826    /// `reason`
3827    pub reason: crate::defs::p47::play::clientbound::GameStateChangeReason,
3828    /// `gameMode`
3829    pub game_mode: f32,
3830}
3831#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3832impl<const V: i32> Decode for GameStateChange<V> {
3833    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3834        Ok({
3835            let v1 = crate::defs::p47::play::clientbound::GameStateChangeReason(r.read_u8()?);
3836            let v2 = r.read_f32()?;
3837            Self {
3838                reason: v1,
3839                game_mode: v2,
3840            }
3841        })
3842    }
3843}
3844#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3845impl<const V: i32> Encode for GameStateChange<V> {
3846    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3847        w.put_u8((*self).reason.0);
3848        w.put_f32((*self).game_mode);
3849        Ok(())
3850    }
3851}
3852#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3853#[cfg(feature = "testgen")]
3854impl<const V: i32> Generate for GameStateChange<V> {
3855    fn generate(g: &mut Gen) -> Self {
3856        {
3857            let v1 = crate::defs::p47::play::clientbound::GameStateChangeReason(g.int_in(
3858                0,
3859                255,
3860                &[0, 1, 2, 3, 4, 5, 6, 7, 8, 10],
3861            )
3862                as u8);
3863            let v2 = g.f32();
3864            Self {
3865                reason: v1,
3866                game_mode: v2,
3867            }
3868        }
3869    }
3870}
3871
3872#[cfg(feature = "v1_8")]
3873/// `spawn_entity_weather` (clientbound play).
3874#[derive(Debug, Clone, PartialEq)]
3875pub struct SpawnEntityWeather<const V: i32> {
3876    /// `entityId`
3877    pub entity_id: i32,
3878    /// `type`
3879    pub r#type: i8,
3880    /// `x`
3881    pub x: i32,
3882    /// `y`
3883    pub y: i32,
3884    /// `z`
3885    pub z: i32,
3886}
3887#[cfg(feature = "v1_8")]
3888impl<const V: i32> Decode for SpawnEntityWeather<V> {
3889    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3890        Ok({
3891            let v1 = r.read_varint()?;
3892            let v2 = r.read_i8()?;
3893            let v3 = r.read_i32()?;
3894            let v4 = r.read_i32()?;
3895            let v5 = r.read_i32()?;
3896            Self {
3897                entity_id: v1,
3898                r#type: v2,
3899                x: v3,
3900                y: v4,
3901                z: v5,
3902            }
3903        })
3904    }
3905}
3906#[cfg(feature = "v1_8")]
3907impl<const V: i32> Encode for SpawnEntityWeather<V> {
3908    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3909        w.put_varint((*self).entity_id);
3910        w.put_i8((*self).r#type);
3911        w.put_i32((*self).x);
3912        w.put_i32((*self).y);
3913        w.put_i32((*self).z);
3914        Ok(())
3915    }
3916}
3917#[cfg(feature = "v1_8")]
3918#[cfg(feature = "testgen")]
3919impl<const V: i32> Generate for SpawnEntityWeather<V> {
3920    fn generate(g: &mut Gen) -> Self {
3921        {
3922            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3923            let v2 = (g.int_in(-128, 127, &[]) as i8);
3924            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3925            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3926            let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3927            Self {
3928                entity_id: v1,
3929                r#type: v2,
3930                x: v3,
3931                y: v4,
3932                z: v5,
3933            }
3934        }
3935    }
3936}
3937
3938#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3939/// `open_window` (clientbound play).
3940#[derive(Debug, Clone, PartialEq)]
3941pub struct OpenWindow<const V: i32> {
3942    /// `windowId`
3943    pub window_id: u8,
3944    /// `inventoryType`
3945    pub inventory_type: ByteString,
3946    /// `windowTitle`
3947    pub window_title: ByteString,
3948    /// `slotCount`
3949    pub slot_count: u8,
3950    /// `entityId`
3951    pub entity_id: Option<i32>,
3952}
3953#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3954impl<const V: i32> Decode for OpenWindow<V> {
3955    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3956        Ok({
3957            let v1 = r.read_u8()?;
3958            let v2 = r.read_string()?;
3959            let v3 = r.read_string()?;
3960            let v4 = r.read_u8()?;
3961            let v5 = if (&*v2 == "EntityHorse") {
3962                Some(r.read_i32()?)
3963            } else {
3964                None
3965            };
3966            Self {
3967                window_id: v1,
3968                inventory_type: v2,
3969                window_title: v3,
3970                slot_count: v4,
3971                entity_id: v5,
3972            }
3973        })
3974    }
3975}
3976#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
3977impl<const V: i32> Encode for OpenWindow<V> {
3978    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3979        w.put_u8((*self).window_id);
3980        w.put_string(&(*self).inventory_type)?;
3981        w.put_string(&(*self).window_title)?;
3982        w.put_u8((*self).slot_count);
3983        match (
3984            &(*self).entity_id,
3985            (&*(*self).inventory_type == "EntityHorse"),
3986        ) {
3987            (Some(v1), true) => {
3988                w.put_i32((*v1));
3989            }
3990            (None, false) => {}
3991            _ => {
3992                return Err(EncodeError::SwitchMismatch(
3993                    "play.clientbound.open_window.entityId",
3994                ));
3995            }
3996        }
3997        Ok(())
3998    }
3999}
4000#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4001#[cfg(feature = "testgen")]
4002impl<const V: i32> Generate for OpenWindow<V> {
4003    fn generate(g: &mut Gen) -> Self {
4004        {
4005            let v1 = (g.int_in(0, 255, &[]) as u8);
4006            let v2 = g.string_in(&["EntityHorse"]);
4007            let v3 = g.string();
4008            let v4 = (g.int_in(0, 255, &[]) as u8);
4009            let v5 = if (&*v2 == "EntityHorse") {
4010                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4011            } else {
4012                None
4013            };
4014            Self {
4015                window_id: v1,
4016                inventory_type: v2,
4017                window_title: v3,
4018                slot_count: v4,
4019                entity_id: v5,
4020            }
4021        }
4022    }
4023}
4024
4025#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4026/// `close_window` (clientbound play).
4027#[derive(Debug, Clone, PartialEq)]
4028pub struct CloseWindow<const V: i32> {
4029    /// `windowId`
4030    pub window_id: u8,
4031}
4032#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4033impl<const V: i32> Decode for CloseWindow<V> {
4034    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4035        Ok({
4036            let v1 = r.read_u8()?;
4037            Self { window_id: v1 }
4038        })
4039    }
4040}
4041#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4042impl<const V: i32> Encode for CloseWindow<V> {
4043    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4044        w.put_u8((*self).window_id);
4045        Ok(())
4046    }
4047}
4048#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4049#[cfg(feature = "testgen")]
4050impl<const V: i32> Generate for CloseWindow<V> {
4051    fn generate(g: &mut Gen) -> Self {
4052        {
4053            let v1 = (g.int_in(0, 255, &[]) as u8);
4054            Self { window_id: v1 }
4055        }
4056    }
4057}
4058
4059#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4060/// `set_slot` (clientbound play).
4061#[derive(Debug, Clone, PartialEq)]
4062pub struct SetSlot<const V: i32> {
4063    /// `windowId`
4064    pub window_id: i8,
4065    /// `slot`
4066    pub slot: i16,
4067    /// `item`
4068    pub item: crate::types::slot::legacy::Slot,
4069}
4070#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4071impl<const V: i32> Decode for SetSlot<V> {
4072    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4073        Ok({
4074            let v1 = r.read_i8()?;
4075            let v2 = r.read_i16()?;
4076            let v3 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
4077            Self {
4078                window_id: v1,
4079                slot: v2,
4080                item: v3,
4081            }
4082        })
4083    }
4084}
4085#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4086impl<const V: i32> Encode for SetSlot<V> {
4087    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4088        w.put_i8((*self).window_id);
4089        w.put_i16((*self).slot);
4090        (*self).item.encode(w)?;
4091        Ok(())
4092    }
4093}
4094#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4095#[cfg(feature = "testgen")]
4096impl<const V: i32> Generate for SetSlot<V> {
4097    fn generate(g: &mut Gen) -> Self {
4098        {
4099            let v1 = (g.int_in(-128, 127, &[]) as i8);
4100            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
4101            let v3 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
4102            Self {
4103                window_id: v1,
4104                slot: v2,
4105                item: v3,
4106            }
4107        }
4108    }
4109}
4110
4111#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4112/// `window_items` (clientbound play).
4113#[derive(Debug, Clone, PartialEq)]
4114pub struct WindowItems<const V: i32> {
4115    /// `windowId`
4116    pub window_id: u8,
4117    /// `items`
4118    pub items: Vec<crate::types::slot::legacy::Slot>,
4119}
4120#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4121impl<const V: i32> Decode for WindowItems<V> {
4122    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4123        Ok({
4124            let v1 = r.read_u8()?;
4125            let v2 = {
4126                let v3 = {
4127                    let c = r.read_i16()?;
4128                    r.check_count(i64::from(c), 1)?
4129                };
4130                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4131                for _ in 0..v3 {
4132                    v4.push(<crate::types::slot::legacy::Slot as Decode>::decode(r)?);
4133                }
4134                v4
4135            };
4136            Self {
4137                window_id: v1,
4138                items: v2,
4139            }
4140        })
4141    }
4142}
4143#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4144impl<const V: i32> Encode for WindowItems<V> {
4145    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4146        w.put_u8((*self).window_id);
4147        w.put_i16(crate::codec::count_i16((*self).items.len())?);
4148        for v1 in (*self).items.iter() {
4149            (*v1).encode(w)?;
4150        }
4151        Ok(())
4152    }
4153}
4154#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4155#[cfg(feature = "testgen")]
4156impl<const V: i32> Generate for WindowItems<V> {
4157    fn generate(g: &mut Gen) -> Self {
4158        {
4159            let v1 = (g.int_in(0, 255, &[]) as u8);
4160            let v2 = {
4161                let v3 = g.count();
4162                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4163                for _ in 0..v3 {
4164                    v4.push(<crate::types::slot::legacy::Slot as Generate>::generate(g));
4165                }
4166                v4
4167            };
4168            Self {
4169                window_id: v1,
4170                items: v2,
4171            }
4172        }
4173    }
4174}
4175
4176#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4177/// `craft_progress_bar` (clientbound play).
4178#[derive(Debug, Clone, PartialEq)]
4179pub struct CraftProgressBar<const V: i32> {
4180    /// `windowId`
4181    pub window_id: u8,
4182    /// `property`
4183    pub property: i16,
4184    /// `value`
4185    pub value: i16,
4186}
4187#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4188impl<const V: i32> Decode for CraftProgressBar<V> {
4189    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4190        Ok({
4191            let v1 = r.read_u8()?;
4192            let v2 = r.read_i16()?;
4193            let v3 = r.read_i16()?;
4194            Self {
4195                window_id: v1,
4196                property: v2,
4197                value: v3,
4198            }
4199        })
4200    }
4201}
4202#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4203impl<const V: i32> Encode for CraftProgressBar<V> {
4204    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4205        w.put_u8((*self).window_id);
4206        w.put_i16((*self).property);
4207        w.put_i16((*self).value);
4208        Ok(())
4209    }
4210}
4211#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4212#[cfg(feature = "testgen")]
4213impl<const V: i32> Generate for CraftProgressBar<V> {
4214    fn generate(g: &mut Gen) -> Self {
4215        {
4216            let v1 = (g.int_in(0, 255, &[]) as u8);
4217            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
4218            let v3 = (g.int_in(-32768, 32767, &[]) as i16);
4219            Self {
4220                window_id: v1,
4221                property: v2,
4222                value: v3,
4223            }
4224        }
4225    }
4226}
4227
4228#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4229/// `transaction` (clientbound play).
4230#[derive(Debug, Clone, PartialEq)]
4231pub struct Transaction<const V: i32> {
4232    /// `windowId`
4233    pub window_id: i8,
4234    /// `action`
4235    pub action: i16,
4236    /// `accepted`
4237    pub accepted: bool,
4238}
4239#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4240impl<const V: i32> Decode for Transaction<V> {
4241    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4242        Ok({
4243            let v1 = r.read_i8()?;
4244            let v2 = r.read_i16()?;
4245            let v3 = r.read_bool()?;
4246            Self {
4247                window_id: v1,
4248                action: v2,
4249                accepted: v3,
4250            }
4251        })
4252    }
4253}
4254#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4255impl<const V: i32> Encode for Transaction<V> {
4256    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4257        w.put_i8((*self).window_id);
4258        w.put_i16((*self).action);
4259        w.put_bool((*self).accepted);
4260        Ok(())
4261    }
4262}
4263#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4264#[cfg(feature = "testgen")]
4265impl<const V: i32> Generate for Transaction<V> {
4266    fn generate(g: &mut Gen) -> Self {
4267        {
4268            let v1 = (g.int_in(-128, 127, &[]) as i8);
4269            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
4270            let v3 = g.bool();
4271            Self {
4272                window_id: v1,
4273                action: v2,
4274                accepted: v3,
4275            }
4276        }
4277    }
4278}
4279
4280#[cfg(feature = "v1_8")]
4281/// `update_sign` (clientbound play).
4282#[derive(Debug, Clone, PartialEq)]
4283pub struct UpdateSign<const V: i32> {
4284    /// `location`
4285    pub location: BlockPos,
4286    /// `text1`
4287    pub text1: ByteString,
4288    /// `text2`
4289    pub text2: ByteString,
4290    /// `text3`
4291    pub text3: ByteString,
4292    /// `text4`
4293    pub text4: ByteString,
4294}
4295#[cfg(feature = "v1_8")]
4296impl<const V: i32> Decode for UpdateSign<V> {
4297    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4298        Ok({
4299            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
4300            let v2 = r.read_string()?;
4301            let v3 = r.read_string()?;
4302            let v4 = r.read_string()?;
4303            let v5 = r.read_string()?;
4304            Self {
4305                location: v1,
4306                text1: v2,
4307                text2: v3,
4308                text3: v4,
4309                text4: v5,
4310            }
4311        })
4312    }
4313}
4314#[cfg(feature = "v1_8")]
4315impl<const V: i32> Encode for UpdateSign<V> {
4316    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4317        (*self).location.write(w, PositionLayout::Xyz)?;
4318        w.put_string(&(*self).text1)?;
4319        w.put_string(&(*self).text2)?;
4320        w.put_string(&(*self).text3)?;
4321        w.put_string(&(*self).text4)?;
4322        Ok(())
4323    }
4324}
4325#[cfg(feature = "v1_8")]
4326#[cfg(feature = "testgen")]
4327impl<const V: i32> Generate for UpdateSign<V> {
4328    fn generate(g: &mut Gen) -> Self {
4329        {
4330            let v1 = g.position();
4331            let v2 = g.string();
4332            let v3 = g.string();
4333            let v4 = g.string();
4334            let v5 = g.string();
4335            Self {
4336                location: v1,
4337                text1: v2,
4338                text2: v3,
4339                text3: v4,
4340                text4: v5,
4341            }
4342        }
4343    }
4344}
4345
4346#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4347/// Nested container.
4348#[derive(Debug, Clone, PartialEq)]
4349pub struct MapIcons {
4350    /// `directionAndType`
4351    pub direction_and_type: i8,
4352    /// `x`
4353    pub x: i8,
4354    /// `z`
4355    pub z: i8,
4356}
4357
4358#[cfg(feature = "v1_8")]
4359/// `map` (clientbound play).
4360#[derive(Debug, Clone, PartialEq)]
4361pub struct Map<const V: i32> {
4362    /// `itemDamage`
4363    pub item_damage: i32,
4364    /// `scale`
4365    pub scale: i8,
4366    /// `icons`
4367    pub icons: Vec<crate::defs::p47::play::clientbound::MapIcons>,
4368    /// `columns`
4369    pub columns: i8,
4370    /// `rows`
4371    pub rows: Option<i8>,
4372    /// `x`
4373    pub x: Option<i8>,
4374    /// `y`
4375    pub y: Option<i8>,
4376    /// `data`
4377    pub data: Option<Bytes>,
4378}
4379#[cfg(feature = "v1_8")]
4380impl<const V: i32> Decode for Map<V> {
4381    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4382        Ok({
4383            let v1 = r.read_varint()?;
4384            let v2 = r.read_i8()?;
4385            let v3 = {
4386                let v4 = {
4387                    let c = r.read_varint()?;
4388                    r.check_count(i64::from(c), 3)?
4389                };
4390                let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
4391                for _ in 0..v4 {
4392                    v5.push({
4393                        let v6 = r.read_i8()?;
4394                        let v7 = r.read_i8()?;
4395                        let v8 = r.read_i8()?;
4396                        crate::defs::p47::play::clientbound::MapIcons {
4397                            direction_and_type: v6,
4398                            x: v7,
4399                            z: v8,
4400                        }
4401                    });
4402                }
4403                v5
4404            };
4405            let v9 = r.read_i8()?;
4406            let v10 = if !(v9 == 0) { Some(r.read_i8()?) } else { None };
4407            let v11 = if !(v9 == 0) { Some(r.read_i8()?) } else { None };
4408            let v12 = if !(v9 == 0) { Some(r.read_i8()?) } else { None };
4409            let v13 = if !(v9 == 0) {
4410                Some(r.read_byte_array()?)
4411            } else {
4412                None
4413            };
4414            Self {
4415                item_damage: v1,
4416                scale: v2,
4417                icons: v3,
4418                columns: v9,
4419                rows: v10,
4420                x: v11,
4421                y: v12,
4422                data: v13,
4423            }
4424        })
4425    }
4426}
4427#[cfg(feature = "v1_8")]
4428impl<const V: i32> Encode for Map<V> {
4429    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4430        w.put_varint((*self).item_damage);
4431        w.put_i8((*self).scale);
4432        w.put_len_varint((*self).icons.len())?;
4433        for v1 in (*self).icons.iter() {
4434            w.put_i8((*v1).direction_and_type);
4435            w.put_i8((*v1).x);
4436            w.put_i8((*v1).z);
4437        }
4438        w.put_i8((*self).columns);
4439        match (&(*self).rows, !((*self).columns == 0)) {
4440            (Some(v2), true) => {
4441                w.put_i8((*v2));
4442            }
4443            (None, false) => {}
4444            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
4445        }
4446        match (&(*self).x, !((*self).columns == 0)) {
4447            (Some(v3), true) => {
4448                w.put_i8((*v3));
4449            }
4450            (None, false) => {}
4451            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
4452        }
4453        match (&(*self).y, !((*self).columns == 0)) {
4454            (Some(v4), true) => {
4455                w.put_i8((*v4));
4456            }
4457            (None, false) => {}
4458            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
4459        }
4460        match (&(*self).data, !((*self).columns == 0)) {
4461            (Some(v5), true) => {
4462                w.put_byte_array(&(*v5))?;
4463            }
4464            (None, false) => {}
4465            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
4466        }
4467        Ok(())
4468    }
4469}
4470#[cfg(feature = "v1_8")]
4471#[cfg(feature = "testgen")]
4472impl<const V: i32> Generate for Map<V> {
4473    fn generate(g: &mut Gen) -> Self {
4474        {
4475            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4476            let v2 = (g.int_in(-128, 127, &[]) as i8);
4477            let v3 = {
4478                let v4 = g.count();
4479                let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
4480                for _ in 0..v4 {
4481                    v5.push({
4482                        let v6 = (g.int_in(-128, 127, &[]) as i8);
4483                        let v7 = (g.int_in(-128, 127, &[]) as i8);
4484                        let v8 = (g.int_in(-128, 127, &[]) as i8);
4485                        crate::defs::p47::play::clientbound::MapIcons {
4486                            direction_and_type: v6,
4487                            x: v7,
4488                            z: v8,
4489                        }
4490                    });
4491                }
4492                v5
4493            };
4494            let v9 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
4495            let v10 = if !(v9 == 0) {
4496                Some((g.int_in(-128, 127, &[]) as i8))
4497            } else {
4498                None
4499            };
4500            let v11 = if !(v9 == 0) {
4501                Some((g.int_in(-128, 127, &[]) as i8))
4502            } else {
4503                None
4504            };
4505            let v12 = if !(v9 == 0) {
4506                Some((g.int_in(-128, 127, &[]) as i8))
4507            } else {
4508                None
4509            };
4510            let v13 = if !(v9 == 0) { Some(g.bytes()) } else { None };
4511            Self {
4512                item_damage: v1,
4513                scale: v2,
4514                icons: v3,
4515                columns: v9,
4516                rows: v10,
4517                x: v11,
4518                y: v12,
4519                data: v13,
4520            }
4521        }
4522    }
4523}
4524
4525#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4526/// `tile_entity_data` (clientbound play).
4527#[derive(Debug, Clone, PartialEq)]
4528pub struct TileEntityData<const V: i32> {
4529    /// `location`
4530    pub location: BlockPos,
4531    /// `action`
4532    pub action: u8,
4533    /// `nbtData`
4534    pub nbt_data: Option<RawNbt>,
4535}
4536#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4537impl<const V: i32> Decode for TileEntityData<V> {
4538    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4539        Ok({
4540            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
4541            let v2 = r.read_u8()?;
4542            let v3 = RawNbt::read_optional(r)?;
4543            Self {
4544                location: v1,
4545                action: v2,
4546                nbt_data: v3,
4547            }
4548        })
4549    }
4550}
4551#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4552impl<const V: i32> Encode for TileEntityData<V> {
4553    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4554        (*self).location.write(w, PositionLayout::Xyz)?;
4555        w.put_u8((*self).action);
4556        RawNbt::write_optional(&(*self).nbt_data, w);
4557        Ok(())
4558    }
4559}
4560#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4561#[cfg(feature = "testgen")]
4562impl<const V: i32> Generate for TileEntityData<V> {
4563    fn generate(g: &mut Gen) -> Self {
4564        {
4565            let v1 = g.position();
4566            let v2 = (g.int_in(0, 255, &[]) as u8);
4567            let v3 = g.opt_nbt();
4568            Self {
4569                location: v1,
4570                action: v2,
4571                nbt_data: v3,
4572            }
4573        }
4574    }
4575}
4576
4577#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4578/// `open_sign_entity` (clientbound play).
4579#[derive(Debug, Clone, PartialEq)]
4580pub struct OpenSignEntity<const V: i32> {
4581    /// `location`
4582    pub location: BlockPos,
4583}
4584#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4585impl<const V: i32> Decode for OpenSignEntity<V> {
4586    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4587        Ok({
4588            let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
4589            Self { location: v1 }
4590        })
4591    }
4592}
4593#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4594impl<const V: i32> Encode for OpenSignEntity<V> {
4595    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4596        (*self).location.write(w, PositionLayout::Xyz)?;
4597        Ok(())
4598    }
4599}
4600#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4601#[cfg(feature = "testgen")]
4602impl<const V: i32> Generate for OpenSignEntity<V> {
4603    fn generate(g: &mut Gen) -> Self {
4604        {
4605            let v1 = g.position();
4606            Self { location: v1 }
4607        }
4608    }
4609}
4610
4611#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4612/// Nested container.
4613#[derive(Debug, Clone, PartialEq)]
4614pub struct StatisticsEntries {
4615    /// `name`
4616    pub name: ByteString,
4617    /// `value`
4618    pub value: i32,
4619}
4620
4621#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4622/// `statistics` (clientbound play).
4623#[derive(Debug, Clone, PartialEq)]
4624pub struct Statistics<const V: i32> {
4625    /// `entries`
4626    pub entries: Vec<crate::defs::p47::play::clientbound::StatisticsEntries>,
4627}
4628#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4629impl<const V: i32> Decode for Statistics<V> {
4630    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4631        Ok({
4632            let v1 = {
4633                let v2 = {
4634                    let c = r.read_varint()?;
4635                    r.check_count(i64::from(c), 2)?
4636                };
4637                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
4638                for _ in 0..v2 {
4639                    v3.push({
4640                        let v4 = r.read_string()?;
4641                        let v5 = r.read_varint()?;
4642                        crate::defs::p47::play::clientbound::StatisticsEntries {
4643                            name: v4,
4644                            value: v5,
4645                        }
4646                    });
4647                }
4648                v3
4649            };
4650            Self { entries: v1 }
4651        })
4652    }
4653}
4654#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4655impl<const V: i32> Encode for Statistics<V> {
4656    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4657        w.put_len_varint((*self).entries.len())?;
4658        for v1 in (*self).entries.iter() {
4659            w.put_string(&(*v1).name)?;
4660            w.put_varint((*v1).value);
4661        }
4662        Ok(())
4663    }
4664}
4665#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
4666#[cfg(feature = "testgen")]
4667impl<const V: i32> Generate for Statistics<V> {
4668    fn generate(g: &mut Gen) -> Self {
4669        {
4670            let v1 = {
4671                let v2 = g.count();
4672                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
4673                for _ in 0..v2 {
4674                    v3.push({
4675                        let v4 = g.string();
4676                        let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4677                        crate::defs::p47::play::clientbound::StatisticsEntries {
4678                            name: v4,
4679                            value: v5,
4680                        }
4681                    });
4682                }
4683                v3
4684            };
4685            Self { entries: v1 }
4686        }
4687    }
4688}
4689
4690#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4691/// Mapped `i32` value; unknown values are kept as-is.
4692#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
4693pub struct PlayerInfoAction(pub i32);
4694#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4695impl PlayerInfoAction {
4696    /// `add_player`
4697    pub const ADD_PLAYER: Self = Self(0);
4698    /// `update_game_mode`
4699    pub const UPDATE_GAME_MODE: Self = Self(1);
4700    /// `update_latency`
4701    pub const UPDATE_LATENCY: Self = Self(2);
4702    /// `update_display_name`
4703    pub const UPDATE_DISPLAY_NAME: Self = Self(3);
4704    /// `remove_player`
4705    pub const REMOVE_PLAYER: Self = Self(4);
4706    /// minecraft-data name of the value, if known.
4707    pub const fn name(self) -> Option<&'static str> {
4708        match self.0 {
4709            0 => Some("add_player"),
4710            1 => Some("update_game_mode"),
4711            2 => Some("update_latency"),
4712            3 => Some("update_display_name"),
4713            4 => Some("remove_player"),
4714            _ => None,
4715        }
4716    }
4717}
4718#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4719impl std::fmt::Debug for PlayerInfoAction {
4720    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4721        match self.name() {
4722            Some(n) => write!(f, "PlayerInfoAction::{n}"),
4723            None => write!(f, "PlayerInfoAction({})", self.0),
4724        }
4725    }
4726}
4727
4728#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4729/// Nested container.
4730#[derive(Debug, Clone, PartialEq)]
4731pub struct PlayerInfoDataBodyAddPlayerProperties {
4732    /// `name`
4733    pub name: ByteString,
4734    /// `value`
4735    pub value: ByteString,
4736    /// `signature`
4737    pub signature: Option<ByteString>,
4738}
4739
4740#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4741/// Nested container.
4742#[derive(Debug, Clone, PartialEq)]
4743pub struct PlayerInfoDataBodyAddPlayer {
4744    /// `name`
4745    pub name: ByteString,
4746    /// `properties`
4747    pub properties: Vec<crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayerProperties>,
4748    /// `gamemode`
4749    pub gamemode: i32,
4750    /// `ping`
4751    pub ping: i32,
4752    /// `displayName`
4753    pub display_name: Option<ByteString>,
4754}
4755
4756#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4757/// Nested container.
4758#[derive(Debug, Clone, PartialEq)]
4759pub struct PlayerInfoDataBodyUpdateGameMode {
4760    /// `gamemode`
4761    pub gamemode: i32,
4762}
4763
4764#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4765/// Nested container.
4766#[derive(Debug, Clone, PartialEq)]
4767pub struct PlayerInfoDataBodyUpdateLatency {
4768    /// `ping`
4769    pub ping: i32,
4770}
4771
4772#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4773/// Nested container.
4774#[derive(Debug, Clone, PartialEq)]
4775pub struct PlayerInfoDataBodyUpdateDisplayName {
4776    /// `displayName`
4777    pub display_name: Option<ByteString>,
4778}
4779
4780#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4781/// Switch on `../action`.
4782#[derive(Debug, Clone, PartialEq)]
4783pub enum PlayerInfoDataBody {
4784    /// Case(s) `add_player`.
4785    AddPlayer(crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayer),
4786    /// Case(s) `update_game_mode`.
4787    UpdateGameMode(crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateGameMode),
4788    /// Case(s) `update_latency`.
4789    UpdateLatency(crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateLatency),
4790    /// Case(s) `update_display_name`.
4791    UpdateDisplayName(crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateDisplayName),
4792    /// Case(s) `remove_player`.
4793    RemovePlayer,
4794    /// Any other value.
4795    Other,
4796}
4797
4798#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4799/// Nested container.
4800#[derive(Debug, Clone, PartialEq)]
4801pub struct PlayerInfoData {
4802    /// `uuid`
4803    pub uuid: Uuid,
4804    /// Anonymous switch
4805    pub body: crate::defs::p47::play::clientbound::PlayerInfoDataBody,
4806}
4807
4808#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4809/// `player_info` (clientbound play).
4810#[derive(Debug, Clone, PartialEq)]
4811pub struct PlayerInfo<const V: i32> {
4812    /// `action`
4813    pub action: crate::defs::p47::play::clientbound::PlayerInfoAction,
4814    /// `data`
4815    pub data: Vec<crate::defs::p47::play::clientbound::PlayerInfoData>,
4816}
4817#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4818impl<const V: i32> Decode for PlayerInfo<V> {
4819    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4820        Ok({
4821            let v1 = crate::defs::p47::play::clientbound::PlayerInfoAction(r.read_varint()?);
4822            let v2 = {
4823                let v3 = {
4824                    let c = r.read_varint()?;
4825                    r.check_count(i64::from(c), 16)?
4826                };
4827                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4828                for _ in 0..v3 {
4829                    v4.push({ let v5 = r.read_uuid()?;let v6 = (if (v1.0 == 0) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::AddPlayer({ let v7 = r.read_string()?;let v8 = { let v9 = { let c = r.read_varint()?; r.check_count(i64::from(c), 3)? }; let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push({ let v11 = r.read_string()?;let v12 = r.read_string()?;let v13 = if r.read_bool()? { Some(r.read_string()?) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayerProperties { name: v11, value: v12, signature: v13 } }); } v10 };let v14 = r.read_varint()?;let v15 = r.read_varint()?;let v16 = if r.read_bool()? { Some(r.read_string()?) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayer { name: v7, properties: v8, gamemode: v14, ping: v15, display_name: v16 } }) } else if (v1.0 == 1) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateGameMode({ let v17 = r.read_varint()?; crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateGameMode { gamemode: v17 } }) } else if (v1.0 == 2) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateLatency({ let v18 = r.read_varint()?; crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateLatency { ping: v18 } }) } else if (v1.0 == 3) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateDisplayName({ let v19 = if r.read_bool()? { Some(r.read_string()?) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateDisplayName { display_name: v19 } }) } else if (v1.0 == 4) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::RemovePlayer } else { crate::defs::p47::play::clientbound::PlayerInfoDataBody::Other }); crate::defs::p47::play::clientbound::PlayerInfoData { uuid: v5, body: v6 } });
4830                }
4831                v4
4832            };
4833            Self {
4834                action: v1,
4835                data: v2,
4836            }
4837        })
4838    }
4839}
4840#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4841impl<const V: i32> Encode for PlayerInfo<V> {
4842    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4843        w.put_varint((*self).action.0);
4844        w.put_len_varint((*self).data.len())?;
4845        for v1 in (*self).data.iter() {
4846            w.put_uuid(&(*v1).uuid);
4847            match &(*v1).body {
4848                crate::defs::p47::play::clientbound::PlayerInfoDataBody::AddPlayer(v2) => {
4849                    if !((*self).action.0 == 0) {
4850                        return Err(EncodeError::SwitchMismatch(
4851                            "play.clientbound.player_info.data.body",
4852                        ));
4853                    }
4854                    w.put_string(&(*v2).name)?;
4855                    w.put_len_varint((*v2).properties.len())?;
4856                    for v3 in (*v2).properties.iter() {
4857                        w.put_string(&(*v3).name)?;
4858                        w.put_string(&(*v3).value)?;
4859                        match &(*v3).signature {
4860                            Some(v4) => {
4861                                w.put_u8(1);
4862                                w.put_string(&(*v4))?;
4863                            }
4864                            None => w.put_u8(0),
4865                        }
4866                    }
4867                    w.put_varint((*v2).gamemode);
4868                    w.put_varint((*v2).ping);
4869                    match &(*v2).display_name {
4870                        Some(v5) => {
4871                            w.put_u8(1);
4872                            w.put_string(&(*v5))?;
4873                        }
4874                        None => w.put_u8(0),
4875                    }
4876                }
4877                crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateGameMode(v6) => {
4878                    if !((*self).action.0 == 1) {
4879                        return Err(EncodeError::SwitchMismatch(
4880                            "play.clientbound.player_info.data.body",
4881                        ));
4882                    }
4883                    w.put_varint((*v6).gamemode);
4884                }
4885                crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateLatency(v7) => {
4886                    if !((*self).action.0 == 2) {
4887                        return Err(EncodeError::SwitchMismatch(
4888                            "play.clientbound.player_info.data.body",
4889                        ));
4890                    }
4891                    w.put_varint((*v7).ping);
4892                }
4893                crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateDisplayName(v8) => {
4894                    if !((*self).action.0 == 3) {
4895                        return Err(EncodeError::SwitchMismatch(
4896                            "play.clientbound.player_info.data.body",
4897                        ));
4898                    }
4899                    match &(*v8).display_name {
4900                        Some(v9) => {
4901                            w.put_u8(1);
4902                            w.put_string(&(*v9))?;
4903                        }
4904                        None => w.put_u8(0),
4905                    }
4906                }
4907                crate::defs::p47::play::clientbound::PlayerInfoDataBody::RemovePlayer => {
4908                    if !((*self).action.0 == 4) {
4909                        return Err(EncodeError::SwitchMismatch(
4910                            "play.clientbound.player_info.data.body",
4911                        ));
4912                    }
4913                }
4914                crate::defs::p47::play::clientbound::PlayerInfoDataBody::Other => {
4915                    if !(!(((*self).action.0 == 0)
4916                        || ((*self).action.0 == 1)
4917                        || ((*self).action.0 == 2)
4918                        || ((*self).action.0 == 3)
4919                        || ((*self).action.0 == 4)))
4920                    {
4921                        return Err(EncodeError::SwitchMismatch(
4922                            "play.clientbound.player_info.data.body",
4923                        ));
4924                    }
4925                }
4926            }
4927        }
4928        Ok(())
4929    }
4930}
4931#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
4932#[cfg(feature = "testgen")]
4933impl<const V: i32> Generate for PlayerInfo<V> {
4934    fn generate(g: &mut Gen) -> Self {
4935        {
4936            let v1 = crate::defs::p47::play::clientbound::PlayerInfoAction(g.int_in(
4937                -2147483648,
4938                2147483647,
4939                &[0, 1, 2, 3, 4],
4940            ) as i32);
4941            let v2 = {
4942                let v3 = g.count();
4943                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4944                for _ in 0..v3 {
4945                    v4.push({ let v5 = g.uuid();let v6 = (if (v1.0 == 0) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::AddPlayer({ let v7 = g.string();let v8 = { let v9 = g.count(); let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push({ let v11 = g.string();let v12 = g.string();let v13 = if g.bool() { Some(g.string()) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayerProperties { name: v11, value: v12, signature: v13 } }); } v10 };let v14 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v15 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v16 = if g.bool() { Some(g.string()) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyAddPlayer { name: v7, properties: v8, gamemode: v14, ping: v15, display_name: v16 } }) } else if (v1.0 == 1) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateGameMode({ let v17 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateGameMode { gamemode: v17 } }) } else if (v1.0 == 2) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateLatency({ let v18 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateLatency { ping: v18 } }) } else if (v1.0 == 3) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::UpdateDisplayName({ let v19 = if g.bool() { Some(g.string()) } else { None }; crate::defs::p47::play::clientbound::PlayerInfoDataBodyUpdateDisplayName { display_name: v19 } }) } else if (v1.0 == 4) { crate::defs::p47::play::clientbound::PlayerInfoDataBody::RemovePlayer } else { crate::defs::p47::play::clientbound::PlayerInfoDataBody::Other }); crate::defs::p47::play::clientbound::PlayerInfoData { uuid: v5, body: v6 } });
4946                }
4947                v4
4948            };
4949            Self {
4950                action: v1,
4951                data: v2,
4952            }
4953        }
4954    }
4955}
4956
4957#[cfg(any(
4958    feature = "v1_8",
4959    feature = "v1_12_2",
4960    feature = "v1_16_5",
4961    feature = "v26_1",
4962    feature = "v26_2"
4963))]
4964/// `abilities` (clientbound play).
4965#[derive(Debug, Clone, PartialEq)]
4966pub struct Abilities<const V: i32> {
4967    /// `flags`
4968    pub flags: i8,
4969    /// `flyingSpeed`
4970    pub flying_speed: f32,
4971    /// `walkingSpeed`
4972    pub walking_speed: f32,
4973}
4974#[cfg(any(
4975    feature = "v1_8",
4976    feature = "v1_12_2",
4977    feature = "v1_16_5",
4978    feature = "v26_1",
4979    feature = "v26_2"
4980))]
4981impl<const V: i32> Decode for Abilities<V> {
4982    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4983        Ok({
4984            let v1 = r.read_i8()?;
4985            let v2 = r.read_f32()?;
4986            let v3 = r.read_f32()?;
4987            Self {
4988                flags: v1,
4989                flying_speed: v2,
4990                walking_speed: v3,
4991            }
4992        })
4993    }
4994}
4995#[cfg(any(
4996    feature = "v1_8",
4997    feature = "v1_12_2",
4998    feature = "v1_16_5",
4999    feature = "v26_1",
5000    feature = "v26_2"
5001))]
5002impl<const V: i32> Encode for Abilities<V> {
5003    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5004        w.put_i8((*self).flags);
5005        w.put_f32((*self).flying_speed);
5006        w.put_f32((*self).walking_speed);
5007        Ok(())
5008    }
5009}
5010#[cfg(any(
5011    feature = "v1_8",
5012    feature = "v1_12_2",
5013    feature = "v1_16_5",
5014    feature = "v26_1",
5015    feature = "v26_2"
5016))]
5017#[cfg(feature = "testgen")]
5018impl<const V: i32> Generate for Abilities<V> {
5019    fn generate(g: &mut Gen) -> Self {
5020        {
5021            let v1 = (g.int_in(-128, 127, &[]) as i8);
5022            let v2 = g.f32();
5023            let v3 = g.f32();
5024            Self {
5025                flags: v1,
5026                flying_speed: v2,
5027                walking_speed: v3,
5028            }
5029        }
5030    }
5031}
5032
5033#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5034/// `tab_complete` (clientbound play).
5035#[derive(Debug, Clone, PartialEq)]
5036pub struct TabComplete<const V: i32> {
5037    /// `matches`
5038    pub matches: Vec<ByteString>,
5039}
5040#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5041impl<const V: i32> Decode for TabComplete<V> {
5042    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5043        Ok({
5044            let v1 = {
5045                let v2 = {
5046                    let c = r.read_varint()?;
5047                    r.check_count(i64::from(c), 1)?
5048                };
5049                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
5050                for _ in 0..v2 {
5051                    v3.push(r.read_string()?);
5052                }
5053                v3
5054            };
5055            Self { matches: v1 }
5056        })
5057    }
5058}
5059#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5060impl<const V: i32> Encode for TabComplete<V> {
5061    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5062        w.put_len_varint((*self).matches.len())?;
5063        for v1 in (*self).matches.iter() {
5064            w.put_string(&(*v1))?;
5065        }
5066        Ok(())
5067    }
5068}
5069#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5070#[cfg(feature = "testgen")]
5071impl<const V: i32> Generate for TabComplete<V> {
5072    fn generate(g: &mut Gen) -> Self {
5073        {
5074            let v1 = {
5075                let v2 = g.count();
5076                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
5077                for _ in 0..v2 {
5078                    v3.push(g.string());
5079                }
5080                v3
5081            };
5082            Self { matches: v1 }
5083        }
5084    }
5085}
5086
5087#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5088/// `scoreboard_objective` (clientbound play).
5089#[derive(Debug, Clone, PartialEq)]
5090pub struct ScoreboardObjective<const V: i32> {
5091    /// `name`
5092    pub name: ByteString,
5093    /// `action`
5094    pub action: i8,
5095    /// `displayText`
5096    pub display_text: Option<ByteString>,
5097    /// `type`
5098    pub r#type: Option<ByteString>,
5099}
5100#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5101impl<const V: i32> Decode for ScoreboardObjective<V> {
5102    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5103        Ok({
5104            let v1 = r.read_string()?;
5105            let v2 = r.read_i8()?;
5106            let v3 = if (v2 == 0) || (v2 == 2) {
5107                Some(r.read_string()?)
5108            } else {
5109                None
5110            };
5111            let v4 = if (v2 == 0) || (v2 == 2) {
5112                Some(r.read_string()?)
5113            } else {
5114                None
5115            };
5116            Self {
5117                name: v1,
5118                action: v2,
5119                display_text: v3,
5120                r#type: v4,
5121            }
5122        })
5123    }
5124}
5125#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5126impl<const V: i32> Encode for ScoreboardObjective<V> {
5127    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5128        w.put_string(&(*self).name)?;
5129        w.put_i8((*self).action);
5130        match (
5131            &(*self).display_text,
5132            ((*self).action == 0) || ((*self).action == 2),
5133        ) {
5134            (Some(v1), true) => {
5135                w.put_string(&(*v1))?;
5136            }
5137            (None, false) => {}
5138            _ => {
5139                return Err(EncodeError::SwitchMismatch(
5140                    "play.clientbound.scoreboard_objective.displayText",
5141                ));
5142            }
5143        }
5144        match (
5145            &(*self).r#type,
5146            ((*self).action == 0) || ((*self).action == 2),
5147        ) {
5148            (Some(v2), true) => {
5149                w.put_string(&(*v2))?;
5150            }
5151            (None, false) => {}
5152            _ => {
5153                return Err(EncodeError::SwitchMismatch(
5154                    "play.clientbound.scoreboard_objective.type",
5155                ));
5156            }
5157        }
5158        Ok(())
5159    }
5160}
5161#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5162#[cfg(feature = "testgen")]
5163impl<const V: i32> Generate for ScoreboardObjective<V> {
5164    fn generate(g: &mut Gen) -> Self {
5165        {
5166            let v1 = g.string();
5167            let v2 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
5168            let v3 = if (v2 == 0) || (v2 == 2) {
5169                Some(g.string())
5170            } else {
5171                None
5172            };
5173            let v4 = if (v2 == 0) || (v2 == 2) {
5174                Some(g.string())
5175            } else {
5176                None
5177            };
5178            Self {
5179                name: v1,
5180                action: v2,
5181                display_text: v3,
5182                r#type: v4,
5183            }
5184        }
5185    }
5186}
5187
5188#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5189/// `scoreboard_score` (clientbound play).
5190#[derive(Debug, Clone, PartialEq)]
5191pub struct ScoreboardScore<const V: i32> {
5192    /// `itemName`
5193    pub item_name: ByteString,
5194    /// `action`
5195    pub action: i32,
5196    /// `scoreName`
5197    pub score_name: ByteString,
5198    /// `value`
5199    pub value: Option<i32>,
5200}
5201#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5202impl<const V: i32> Decode for ScoreboardScore<V> {
5203    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5204        Ok({
5205            let v1 = r.read_string()?;
5206            let v2 = r.read_varint()?;
5207            let v3 = r.read_string()?;
5208            let v4 = if !(v2 == 1) {
5209                Some(r.read_varint()?)
5210            } else {
5211                None
5212            };
5213            Self {
5214                item_name: v1,
5215                action: v2,
5216                score_name: v3,
5217                value: v4,
5218            }
5219        })
5220    }
5221}
5222#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5223impl<const V: i32> Encode for ScoreboardScore<V> {
5224    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5225        w.put_string(&(*self).item_name)?;
5226        w.put_varint((*self).action);
5227        w.put_string(&(*self).score_name)?;
5228        match (&(*self).value, !((*self).action == 1)) {
5229            (Some(v1), true) => {
5230                w.put_varint((*v1));
5231            }
5232            (None, false) => {}
5233            _ => {
5234                return Err(EncodeError::SwitchMismatch(
5235                    "play.clientbound.scoreboard_score.value",
5236                ));
5237            }
5238        }
5239        Ok(())
5240    }
5241}
5242#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5243#[cfg(feature = "testgen")]
5244impl<const V: i32> Generate for ScoreboardScore<V> {
5245    fn generate(g: &mut Gen) -> Self {
5246        {
5247            let v1 = g.string();
5248            let v2 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
5249            let v3 = g.string();
5250            let v4 = if !(v2 == 1) {
5251                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5252            } else {
5253                None
5254            };
5255            Self {
5256                item_name: v1,
5257                action: v2,
5258                score_name: v3,
5259                value: v4,
5260            }
5261        }
5262    }
5263}
5264
5265#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5266/// `scoreboard_display_objective` (clientbound play).
5267#[derive(Debug, Clone, PartialEq)]
5268pub struct ScoreboardDisplayObjective<const V: i32> {
5269    /// `position`
5270    pub position: i8,
5271    /// `name`
5272    pub name: ByteString,
5273}
5274#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5275impl<const V: i32> Decode for ScoreboardDisplayObjective<V> {
5276    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5277        Ok({
5278            let v1 = r.read_i8()?;
5279            let v2 = r.read_string()?;
5280            Self {
5281                position: v1,
5282                name: v2,
5283            }
5284        })
5285    }
5286}
5287#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5288impl<const V: i32> Encode for ScoreboardDisplayObjective<V> {
5289    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5290        w.put_i8((*self).position);
5291        w.put_string(&(*self).name)?;
5292        Ok(())
5293    }
5294}
5295#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5296#[cfg(feature = "testgen")]
5297impl<const V: i32> Generate for ScoreboardDisplayObjective<V> {
5298    fn generate(g: &mut Gen) -> Self {
5299        {
5300            let v1 = (g.int_in(-128, 127, &[]) as i8);
5301            let v2 = g.string();
5302            Self {
5303                position: v1,
5304                name: v2,
5305            }
5306        }
5307    }
5308}
5309
5310#[cfg(feature = "v1_8")]
5311/// `scoreboard_team` (clientbound play).
5312#[derive(Debug, Clone, PartialEq)]
5313pub struct ScoreboardTeam<const V: i32> {
5314    /// `team`
5315    pub team: ByteString,
5316    /// `mode`
5317    pub mode: i8,
5318    /// `name`
5319    pub name: Option<ByteString>,
5320    /// `prefix`
5321    pub prefix: Option<ByteString>,
5322    /// `suffix`
5323    pub suffix: Option<ByteString>,
5324    /// `friendlyFire`
5325    pub friendly_fire: Option<i8>,
5326    /// `nameTagVisibility`
5327    pub name_tag_visibility: Option<ByteString>,
5328    /// `color`
5329    pub color: Option<i8>,
5330    /// `players`
5331    pub players: Option<Vec<ByteString>>,
5332}
5333#[cfg(feature = "v1_8")]
5334impl<const V: i32> Decode for ScoreboardTeam<V> {
5335    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5336        Ok({
5337            let v1 = r.read_string()?;
5338            let v2 = r.read_i8()?;
5339            let v3 = if (v2 == 0) || (v2 == 2) {
5340                Some(r.read_string()?)
5341            } else {
5342                None
5343            };
5344            let v4 = if (v2 == 0) || (v2 == 2) {
5345                Some(r.read_string()?)
5346            } else {
5347                None
5348            };
5349            let v5 = if (v2 == 0) || (v2 == 2) {
5350                Some(r.read_string()?)
5351            } else {
5352                None
5353            };
5354            let v6 = if (v2 == 0) || (v2 == 2) {
5355                Some(r.read_i8()?)
5356            } else {
5357                None
5358            };
5359            let v7 = if (v2 == 0) || (v2 == 2) {
5360                Some(r.read_string()?)
5361            } else {
5362                None
5363            };
5364            let v8 = if (v2 == 0) || (v2 == 2) {
5365                Some(r.read_i8()?)
5366            } else {
5367                None
5368            };
5369            let v9 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
5370                Some({
5371                    let v10 = {
5372                        let c = r.read_varint()?;
5373                        r.check_count(i64::from(c), 1)?
5374                    };
5375                    let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT));
5376                    for _ in 0..v10 {
5377                        v11.push(r.read_string()?);
5378                    }
5379                    v11
5380                })
5381            } else {
5382                None
5383            };
5384            Self {
5385                team: v1,
5386                mode: v2,
5387                name: v3,
5388                prefix: v4,
5389                suffix: v5,
5390                friendly_fire: v6,
5391                name_tag_visibility: v7,
5392                color: v8,
5393                players: v9,
5394            }
5395        })
5396    }
5397}
5398#[cfg(feature = "v1_8")]
5399impl<const V: i32> Encode for ScoreboardTeam<V> {
5400    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5401        w.put_string(&(*self).team)?;
5402        w.put_i8((*self).mode);
5403        match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
5404            (Some(v1), true) => {
5405                w.put_string(&(*v1))?;
5406            }
5407            (None, false) => {}
5408            _ => {
5409                return Err(EncodeError::SwitchMismatch(
5410                    "play.clientbound.scoreboard_team.name",
5411                ));
5412            }
5413        }
5414        match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
5415            (Some(v2), true) => {
5416                w.put_string(&(*v2))?;
5417            }
5418            (None, false) => {}
5419            _ => {
5420                return Err(EncodeError::SwitchMismatch(
5421                    "play.clientbound.scoreboard_team.prefix",
5422                ));
5423            }
5424        }
5425        match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
5426            (Some(v3), true) => {
5427                w.put_string(&(*v3))?;
5428            }
5429            (None, false) => {}
5430            _ => {
5431                return Err(EncodeError::SwitchMismatch(
5432                    "play.clientbound.scoreboard_team.suffix",
5433                ));
5434            }
5435        }
5436        match (
5437            &(*self).friendly_fire,
5438            ((*self).mode == 0) || ((*self).mode == 2),
5439        ) {
5440            (Some(v4), true) => {
5441                w.put_i8((*v4));
5442            }
5443            (None, false) => {}
5444            _ => {
5445                return Err(EncodeError::SwitchMismatch(
5446                    "play.clientbound.scoreboard_team.friendlyFire",
5447                ));
5448            }
5449        }
5450        match (
5451            &(*self).name_tag_visibility,
5452            ((*self).mode == 0) || ((*self).mode == 2),
5453        ) {
5454            (Some(v5), true) => {
5455                w.put_string(&(*v5))?;
5456            }
5457            (None, false) => {}
5458            _ => {
5459                return Err(EncodeError::SwitchMismatch(
5460                    "play.clientbound.scoreboard_team.nameTagVisibility",
5461                ));
5462            }
5463        }
5464        match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
5465            (Some(v6), true) => {
5466                w.put_i8((*v6));
5467            }
5468            (None, false) => {}
5469            _ => {
5470                return Err(EncodeError::SwitchMismatch(
5471                    "play.clientbound.scoreboard_team.color",
5472                ));
5473            }
5474        }
5475        match (
5476            &(*self).players,
5477            ((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
5478        ) {
5479            (Some(v7), true) => {
5480                w.put_len_varint((*v7).len())?;
5481                for v8 in (*v7).iter() {
5482                    w.put_string(&(*v8))?;
5483                }
5484            }
5485            (None, false) => {}
5486            _ => {
5487                return Err(EncodeError::SwitchMismatch(
5488                    "play.clientbound.scoreboard_team.players",
5489                ));
5490            }
5491        }
5492        Ok(())
5493    }
5494}
5495#[cfg(feature = "v1_8")]
5496#[cfg(feature = "testgen")]
5497impl<const V: i32> Generate for ScoreboardTeam<V> {
5498    fn generate(g: &mut Gen) -> Self {
5499        {
5500            let v1 = g.string();
5501            let v2 = (g.int_in(-128, 127, &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4]) as i8);
5502            let v3 = if (v2 == 0) || (v2 == 2) {
5503                Some(g.string())
5504            } else {
5505                None
5506            };
5507            let v4 = if (v2 == 0) || (v2 == 2) {
5508                Some(g.string())
5509            } else {
5510                None
5511            };
5512            let v5 = if (v2 == 0) || (v2 == 2) {
5513                Some(g.string())
5514            } else {
5515                None
5516            };
5517            let v6 = if (v2 == 0) || (v2 == 2) {
5518                Some((g.int_in(-128, 127, &[]) as i8))
5519            } else {
5520                None
5521            };
5522            let v7 = if (v2 == 0) || (v2 == 2) {
5523                Some(g.string())
5524            } else {
5525                None
5526            };
5527            let v8 = if (v2 == 0) || (v2 == 2) {
5528                Some((g.int_in(-128, 127, &[]) as i8))
5529            } else {
5530                None
5531            };
5532            let v9 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
5533                Some({
5534                    let v10 = g.count();
5535                    let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT));
5536                    for _ in 0..v10 {
5537                        v11.push(g.string());
5538                    }
5539                    v11
5540                })
5541            } else {
5542                None
5543            };
5544            Self {
5545                team: v1,
5546                mode: v2,
5547                name: v3,
5548                prefix: v4,
5549                suffix: v5,
5550                friendly_fire: v6,
5551                name_tag_visibility: v7,
5552                color: v8,
5553                players: v9,
5554            }
5555        }
5556    }
5557}
5558
5559#[cfg(any(
5560    feature = "v1_8",
5561    feature = "v1_12_2",
5562    feature = "v1_16_5",
5563    feature = "v26_1",
5564    feature = "v26_2"
5565))]
5566/// `custom_payload` (clientbound play).
5567#[derive(Debug, Clone, PartialEq)]
5568pub struct CustomPayload<const V: i32> {
5569    /// `channel`
5570    pub channel: ByteString,
5571    /// `data`
5572    pub data: Bytes,
5573}
5574#[cfg(any(
5575    feature = "v1_8",
5576    feature = "v1_12_2",
5577    feature = "v1_16_5",
5578    feature = "v26_1",
5579    feature = "v26_2"
5580))]
5581impl<const V: i32> Decode for CustomPayload<V> {
5582    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5583        Ok({
5584            let v1 = r.read_string()?;
5585            let v2 = r.read_rest();
5586            Self {
5587                channel: v1,
5588                data: v2,
5589            }
5590        })
5591    }
5592}
5593#[cfg(any(
5594    feature = "v1_8",
5595    feature = "v1_12_2",
5596    feature = "v1_16_5",
5597    feature = "v26_1",
5598    feature = "v26_2"
5599))]
5600impl<const V: i32> Encode for CustomPayload<V> {
5601    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5602        w.put_string(&(*self).channel)?;
5603        w.put_slice(&(*self).data);
5604        Ok(())
5605    }
5606}
5607#[cfg(any(
5608    feature = "v1_8",
5609    feature = "v1_12_2",
5610    feature = "v1_16_5",
5611    feature = "v26_1",
5612    feature = "v26_2"
5613))]
5614#[cfg(feature = "testgen")]
5615impl<const V: i32> Generate for CustomPayload<V> {
5616    fn generate(g: &mut Gen) -> Self {
5617        {
5618            let v1 = g.string();
5619            let v2 = g.bytes();
5620            Self {
5621                channel: v1,
5622                data: v2,
5623            }
5624        }
5625    }
5626}
5627
5628#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5629/// `kick_disconnect` (clientbound play).
5630#[derive(Debug, Clone, PartialEq)]
5631pub struct KickDisconnect<const V: i32> {
5632    /// `reason`
5633    pub reason: ByteString,
5634}
5635#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5636impl<const V: i32> Decode for KickDisconnect<V> {
5637    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5638        Ok({
5639            let v1 = r.read_string()?;
5640            Self { reason: v1 }
5641        })
5642    }
5643}
5644#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5645impl<const V: i32> Encode for KickDisconnect<V> {
5646    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5647        w.put_string(&(*self).reason)?;
5648        Ok(())
5649    }
5650}
5651#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5652#[cfg(feature = "testgen")]
5653impl<const V: i32> Generate for KickDisconnect<V> {
5654    fn generate(g: &mut Gen) -> Self {
5655        {
5656            let v1 = g.string();
5657            Self { reason: v1 }
5658        }
5659    }
5660}
5661
5662#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5663/// Mapped `u8` value; unknown values are kept as-is.
5664#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
5665pub struct DifficultyDifficulty(pub u8);
5666#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5667impl DifficultyDifficulty {
5668    /// `peaceful`
5669    pub const PEACEFUL: Self = Self(0);
5670    /// `easy`
5671    pub const EASY: Self = Self(1);
5672    /// `normal`
5673    pub const NORMAL: Self = Self(2);
5674    /// `hard`
5675    pub const HARD: Self = Self(3);
5676    /// minecraft-data name of the value, if known.
5677    pub const fn name(self) -> Option<&'static str> {
5678        match self.0 {
5679            0 => Some("peaceful"),
5680            1 => Some("easy"),
5681            2 => Some("normal"),
5682            3 => Some("hard"),
5683            _ => None,
5684        }
5685    }
5686}
5687#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5688impl std::fmt::Debug for DifficultyDifficulty {
5689    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5690        match self.name() {
5691            Some(n) => write!(f, "DifficultyDifficulty::{n}"),
5692            None => write!(f, "DifficultyDifficulty({})", self.0),
5693        }
5694    }
5695}
5696
5697#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5698/// `difficulty` (clientbound play).
5699#[derive(Debug, Clone, PartialEq)]
5700pub struct Difficulty<const V: i32> {
5701    /// `difficulty`
5702    pub difficulty: crate::defs::p47::play::clientbound::DifficultyDifficulty,
5703}
5704#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5705impl<const V: i32> Decode for Difficulty<V> {
5706    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5707        Ok({
5708            let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(r.read_u8()?);
5709            Self { difficulty: v1 }
5710        })
5711    }
5712}
5713#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5714impl<const V: i32> Encode for Difficulty<V> {
5715    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5716        w.put_u8((*self).difficulty.0);
5717        Ok(())
5718    }
5719}
5720#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
5721#[cfg(feature = "testgen")]
5722impl<const V: i32> Generate for Difficulty<V> {
5723    fn generate(g: &mut Gen) -> Self {
5724        {
5725            let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(g.int_in(
5726                0,
5727                255,
5728                &[0, 1, 2, 3],
5729            ) as u8);
5730            Self { difficulty: v1 }
5731        }
5732    }
5733}
5734
5735#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5736/// `combat_event` (clientbound play).
5737#[derive(Debug, Clone, PartialEq)]
5738pub struct CombatEvent<const V: i32> {
5739    /// `event`
5740    pub event: i32,
5741    /// `duration`
5742    pub duration: Option<i32>,
5743    /// `playerId`
5744    pub player_id: Option<i32>,
5745    /// `entityId`
5746    pub entity_id: Option<i32>,
5747    /// `message`
5748    pub message: Option<ByteString>,
5749}
5750#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5751impl<const V: i32> Decode for CombatEvent<V> {
5752    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5753        Ok({
5754            let v1 = r.read_varint()?;
5755            let v2 = if (v1 == 1) {
5756                Some(r.read_varint()?)
5757            } else {
5758                None
5759            };
5760            let v3 = if (v1 == 2) {
5761                Some(r.read_varint()?)
5762            } else {
5763                None
5764            };
5765            let v4 = if (v1 == 1) || (v1 == 2) {
5766                Some(r.read_i32()?)
5767            } else {
5768                None
5769            };
5770            let v5 = if (v1 == 2) {
5771                Some(r.read_string()?)
5772            } else {
5773                None
5774            };
5775            Self {
5776                event: v1,
5777                duration: v2,
5778                player_id: v3,
5779                entity_id: v4,
5780                message: v5,
5781            }
5782        })
5783    }
5784}
5785#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5786impl<const V: i32> Encode for CombatEvent<V> {
5787    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5788        w.put_varint((*self).event);
5789        match (&(*self).duration, ((*self).event == 1)) {
5790            (Some(v1), true) => {
5791                w.put_varint((*v1));
5792            }
5793            (None, false) => {}
5794            _ => {
5795                return Err(EncodeError::SwitchMismatch(
5796                    "play.clientbound.combat_event.duration",
5797                ));
5798            }
5799        }
5800        match (&(*self).player_id, ((*self).event == 2)) {
5801            (Some(v2), true) => {
5802                w.put_varint((*v2));
5803            }
5804            (None, false) => {}
5805            _ => {
5806                return Err(EncodeError::SwitchMismatch(
5807                    "play.clientbound.combat_event.playerId",
5808                ));
5809            }
5810        }
5811        match (
5812            &(*self).entity_id,
5813            ((*self).event == 1) || ((*self).event == 2),
5814        ) {
5815            (Some(v3), true) => {
5816                w.put_i32((*v3));
5817            }
5818            (None, false) => {}
5819            _ => {
5820                return Err(EncodeError::SwitchMismatch(
5821                    "play.clientbound.combat_event.entityId",
5822                ));
5823            }
5824        }
5825        match (&(*self).message, ((*self).event == 2)) {
5826            (Some(v4), true) => {
5827                w.put_string(&(*v4))?;
5828            }
5829            (None, false) => {}
5830            _ => {
5831                return Err(EncodeError::SwitchMismatch(
5832                    "play.clientbound.combat_event.message",
5833                ));
5834            }
5835        }
5836        Ok(())
5837    }
5838}
5839#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5840#[cfg(feature = "testgen")]
5841impl<const V: i32> Generate for CombatEvent<V> {
5842    fn generate(g: &mut Gen) -> Self {
5843        {
5844            let v1 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
5845            let v2 = if (v1 == 1) {
5846                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5847            } else {
5848                None
5849            };
5850            let v3 = if (v1 == 2) {
5851                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5852            } else {
5853                None
5854            };
5855            let v4 = if (v1 == 1) || (v1 == 2) {
5856                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5857            } else {
5858                None
5859            };
5860            let v5 = if (v1 == 2) { Some(g.string()) } else { None };
5861            Self {
5862                event: v1,
5863                duration: v2,
5864                player_id: v3,
5865                entity_id: v4,
5866                message: v5,
5867            }
5868        }
5869    }
5870}
5871
5872#[cfg(any(
5873    feature = "v1_8",
5874    feature = "v1_12_2",
5875    feature = "v1_16_5",
5876    feature = "v26_1",
5877    feature = "v26_2"
5878))]
5879/// `camera` (clientbound play).
5880#[derive(Debug, Clone, PartialEq)]
5881pub struct Camera<const V: i32> {
5882    /// `cameraId`
5883    pub camera_id: i32,
5884}
5885#[cfg(any(
5886    feature = "v1_8",
5887    feature = "v1_12_2",
5888    feature = "v1_16_5",
5889    feature = "v26_1",
5890    feature = "v26_2"
5891))]
5892impl<const V: i32> Decode for Camera<V> {
5893    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5894        Ok({
5895            let v1 = r.read_varint()?;
5896            Self { camera_id: v1 }
5897        })
5898    }
5899}
5900#[cfg(any(
5901    feature = "v1_8",
5902    feature = "v1_12_2",
5903    feature = "v1_16_5",
5904    feature = "v26_1",
5905    feature = "v26_2"
5906))]
5907impl<const V: i32> Encode for Camera<V> {
5908    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5909        w.put_varint((*self).camera_id);
5910        Ok(())
5911    }
5912}
5913#[cfg(any(
5914    feature = "v1_8",
5915    feature = "v1_12_2",
5916    feature = "v1_16_5",
5917    feature = "v26_1",
5918    feature = "v26_2"
5919))]
5920#[cfg(feature = "testgen")]
5921impl<const V: i32> Generate for Camera<V> {
5922    fn generate(g: &mut Gen) -> Self {
5923        {
5924            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5925            Self { camera_id: v1 }
5926        }
5927    }
5928}
5929
5930#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5931/// `world_border` (clientbound play).
5932#[derive(Debug, Clone, PartialEq)]
5933pub struct WorldBorder<const V: i32> {
5934    /// `action`
5935    pub action: i32,
5936    /// `radius`
5937    pub radius: Option<f64>,
5938    /// `x`
5939    pub x: Option<f64>,
5940    /// `z`
5941    pub z: Option<f64>,
5942    /// `old_radius`
5943    pub old_radius: Option<f64>,
5944    /// `new_radius`
5945    pub new_radius: Option<f64>,
5946    /// `speed`
5947    pub speed: Option<i64>,
5948    /// `portalBoundary`
5949    pub portal_boundary: Option<i32>,
5950    /// `warning_time`
5951    pub warning_time: Option<i32>,
5952    /// `warning_blocks`
5953    pub warning_blocks: Option<i32>,
5954}
5955#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
5956impl<const V: i32> Decode for WorldBorder<V> {
5957    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5958        Ok({
5959            let v1 = r.read_varint()?;
5960            let v2 = if (v1 == 0) { Some(r.read_f64()?) } else { None };
5961            let v3 = if (v1 == 2) || (v1 == 3) {
5962                Some(r.read_f64()?)
5963            } else {
5964                None
5965            };
5966            let v4 = if (v1 == 2) || (v1 == 3) {
5967                Some(r.read_f64()?)
5968            } else {
5969                None
5970            };
5971            let v5 = if (v1 == 1) || (v1 == 3) {
5972                Some(r.read_f64()?)
5973            } else {
5974                None
5975            };
5976            let v6 = if (v1 == 1) || (v1 == 3) {
5977                Some(r.read_f64()?)
5978            } else {
5979                None
5980            };
5981            let v7 = if (v1 == 1) || (v1 == 3) {
5982                Some(r.read_varlong()?)
5983            } else {
5984                None
5985            };
5986            let v8 = if (v1 == 3) {
5987                Some(r.read_varint()?)
5988            } else {
5989                None
5990            };
5991            let v9 = if (v1 == 3) || (v1 == 4) {
5992                Some(r.read_varint()?)
5993            } else {
5994                None
5995            };
5996            let v10 = if (v1 == 3) || (v1 == 5) {
5997                Some(r.read_varint()?)
5998            } else {
5999                None
6000            };
6001            Self {
6002                action: v1,
6003                radius: v2,
6004                x: v3,
6005                z: v4,
6006                old_radius: v5,
6007                new_radius: v6,
6008                speed: v7,
6009                portal_boundary: v8,
6010                warning_time: v9,
6011                warning_blocks: v10,
6012            }
6013        })
6014    }
6015}
6016#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6017impl<const V: i32> Encode for WorldBorder<V> {
6018    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6019        w.put_varint((*self).action);
6020        match (&(*self).radius, ((*self).action == 0)) {
6021            (Some(v1), true) => {
6022                w.put_f64((*v1));
6023            }
6024            (None, false) => {}
6025            _ => {
6026                return Err(EncodeError::SwitchMismatch(
6027                    "play.clientbound.world_border.radius",
6028                ));
6029            }
6030        }
6031        match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
6032            (Some(v2), true) => {
6033                w.put_f64((*v2));
6034            }
6035            (None, false) => {}
6036            _ => {
6037                return Err(EncodeError::SwitchMismatch(
6038                    "play.clientbound.world_border.x",
6039                ));
6040            }
6041        }
6042        match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
6043            (Some(v3), true) => {
6044                w.put_f64((*v3));
6045            }
6046            (None, false) => {}
6047            _ => {
6048                return Err(EncodeError::SwitchMismatch(
6049                    "play.clientbound.world_border.z",
6050                ));
6051            }
6052        }
6053        match (
6054            &(*self).old_radius,
6055            ((*self).action == 1) || ((*self).action == 3),
6056        ) {
6057            (Some(v4), true) => {
6058                w.put_f64((*v4));
6059            }
6060            (None, false) => {}
6061            _ => {
6062                return Err(EncodeError::SwitchMismatch(
6063                    "play.clientbound.world_border.old_radius",
6064                ));
6065            }
6066        }
6067        match (
6068            &(*self).new_radius,
6069            ((*self).action == 1) || ((*self).action == 3),
6070        ) {
6071            (Some(v5), true) => {
6072                w.put_f64((*v5));
6073            }
6074            (None, false) => {}
6075            _ => {
6076                return Err(EncodeError::SwitchMismatch(
6077                    "play.clientbound.world_border.new_radius",
6078                ));
6079            }
6080        }
6081        match (
6082            &(*self).speed,
6083            ((*self).action == 1) || ((*self).action == 3),
6084        ) {
6085            (Some(v6), true) => {
6086                w.put_varlong((*v6));
6087            }
6088            (None, false) => {}
6089            _ => {
6090                return Err(EncodeError::SwitchMismatch(
6091                    "play.clientbound.world_border.speed",
6092                ));
6093            }
6094        }
6095        match (&(*self).portal_boundary, ((*self).action == 3)) {
6096            (Some(v7), true) => {
6097                w.put_varint((*v7));
6098            }
6099            (None, false) => {}
6100            _ => {
6101                return Err(EncodeError::SwitchMismatch(
6102                    "play.clientbound.world_border.portalBoundary",
6103                ));
6104            }
6105        }
6106        match (
6107            &(*self).warning_time,
6108            ((*self).action == 3) || ((*self).action == 4),
6109        ) {
6110            (Some(v8), true) => {
6111                w.put_varint((*v8));
6112            }
6113            (None, false) => {}
6114            _ => {
6115                return Err(EncodeError::SwitchMismatch(
6116                    "play.clientbound.world_border.warning_time",
6117                ));
6118            }
6119        }
6120        match (
6121            &(*self).warning_blocks,
6122            ((*self).action == 3) || ((*self).action == 5),
6123        ) {
6124            (Some(v9), true) => {
6125                w.put_varint((*v9));
6126            }
6127            (None, false) => {}
6128            _ => {
6129                return Err(EncodeError::SwitchMismatch(
6130                    "play.clientbound.world_border.warning_blocks",
6131                ));
6132            }
6133        }
6134        Ok(())
6135    }
6136}
6137#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6138#[cfg(feature = "testgen")]
6139impl<const V: i32> Generate for WorldBorder<V> {
6140    fn generate(g: &mut Gen) -> Self {
6141        {
6142            let v1 = (g.int_in(
6143                -2147483648,
6144                2147483647,
6145                &[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
6146            ) as i32);
6147            let v2 = if (v1 == 0) { Some(g.f64()) } else { None };
6148            let v3 = if (v1 == 2) || (v1 == 3) {
6149                Some(g.f64())
6150            } else {
6151                None
6152            };
6153            let v4 = if (v1 == 2) || (v1 == 3) {
6154                Some(g.f64())
6155            } else {
6156                None
6157            };
6158            let v5 = if (v1 == 1) || (v1 == 3) {
6159                Some(g.f64())
6160            } else {
6161                None
6162            };
6163            let v6 = if (v1 == 1) || (v1 == 3) {
6164                Some(g.f64())
6165            } else {
6166                None
6167            };
6168            let v7 = if (v1 == 1) || (v1 == 3) {
6169                Some(g.varlong())
6170            } else {
6171                None
6172            };
6173            let v8 = if (v1 == 3) {
6174                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6175            } else {
6176                None
6177            };
6178            let v9 = if (v1 == 3) || (v1 == 4) {
6179                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6180            } else {
6181                None
6182            };
6183            let v10 = if (v1 == 3) || (v1 == 5) {
6184                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6185            } else {
6186                None
6187            };
6188            Self {
6189                action: v1,
6190                radius: v2,
6191                x: v3,
6192                z: v4,
6193                old_radius: v5,
6194                new_radius: v6,
6195                speed: v7,
6196                portal_boundary: v8,
6197                warning_time: v9,
6198                warning_blocks: v10,
6199            }
6200        }
6201    }
6202}
6203
6204#[cfg(feature = "v1_8")]
6205/// `title` (clientbound play).
6206#[derive(Debug, Clone, PartialEq)]
6207pub struct Title<const V: i32> {
6208    /// `action`
6209    pub action: i32,
6210    /// `text`
6211    pub text: Option<ByteString>,
6212    /// `fadeIn`
6213    pub fade_in: Option<i32>,
6214    /// `stay`
6215    pub stay: Option<i32>,
6216    /// `fadeOut`
6217    pub fade_out: Option<i32>,
6218}
6219#[cfg(feature = "v1_8")]
6220impl<const V: i32> Decode for Title<V> {
6221    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6222        Ok({
6223            let v1 = r.read_varint()?;
6224            let v2 = if (v1 == 0) || (v1 == 1) {
6225                Some(r.read_string()?)
6226            } else {
6227                None
6228            };
6229            let v3 = if (v1 == 2) { Some(r.read_i32()?) } else { None };
6230            let v4 = if (v1 == 2) { Some(r.read_i32()?) } else { None };
6231            let v5 = if (v1 == 2) { Some(r.read_i32()?) } else { None };
6232            Self {
6233                action: v1,
6234                text: v2,
6235                fade_in: v3,
6236                stay: v4,
6237                fade_out: v5,
6238            }
6239        })
6240    }
6241}
6242#[cfg(feature = "v1_8")]
6243impl<const V: i32> Encode for Title<V> {
6244    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6245        w.put_varint((*self).action);
6246        match (
6247            &(*self).text,
6248            ((*self).action == 0) || ((*self).action == 1),
6249        ) {
6250            (Some(v1), true) => {
6251                w.put_string(&(*v1))?;
6252            }
6253            (None, false) => {}
6254            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
6255        }
6256        match (&(*self).fade_in, ((*self).action == 2)) {
6257            (Some(v2), true) => {
6258                w.put_i32((*v2));
6259            }
6260            (None, false) => {}
6261            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
6262        }
6263        match (&(*self).stay, ((*self).action == 2)) {
6264            (Some(v3), true) => {
6265                w.put_i32((*v3));
6266            }
6267            (None, false) => {}
6268            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
6269        }
6270        match (&(*self).fade_out, ((*self).action == 2)) {
6271            (Some(v4), true) => {
6272                w.put_i32((*v4));
6273            }
6274            (None, false) => {}
6275            _ => {
6276                return Err(EncodeError::SwitchMismatch(
6277                    "play.clientbound.title.fadeOut",
6278                ));
6279            }
6280        }
6281        Ok(())
6282    }
6283}
6284#[cfg(feature = "v1_8")]
6285#[cfg(feature = "testgen")]
6286impl<const V: i32> Generate for Title<V> {
6287    fn generate(g: &mut Gen) -> Self {
6288        {
6289            let v1 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 2, 2]) as i32);
6290            let v2 = if (v1 == 0) || (v1 == 1) {
6291                Some(g.string())
6292            } else {
6293                None
6294            };
6295            let v3 = if (v1 == 2) {
6296                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6297            } else {
6298                None
6299            };
6300            let v4 = if (v1 == 2) {
6301                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6302            } else {
6303                None
6304            };
6305            let v5 = if (v1 == 2) {
6306                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6307            } else {
6308                None
6309            };
6310            Self {
6311                action: v1,
6312                text: v2,
6313                fade_in: v3,
6314                stay: v4,
6315                fade_out: v5,
6316            }
6317        }
6318    }
6319}
6320
6321#[cfg(feature = "v1_8")]
6322/// `set_compression` (clientbound play).
6323#[derive(Debug, Clone, PartialEq)]
6324pub struct SetCompression<const V: i32> {
6325    /// `threshold`
6326    pub threshold: i32,
6327}
6328#[cfg(feature = "v1_8")]
6329impl<const V: i32> Decode for SetCompression<V> {
6330    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6331        Ok({
6332            let v1 = r.read_varint()?;
6333            Self { threshold: v1 }
6334        })
6335    }
6336}
6337#[cfg(feature = "v1_8")]
6338impl<const V: i32> Encode for SetCompression<V> {
6339    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6340        w.put_varint((*self).threshold);
6341        Ok(())
6342    }
6343}
6344#[cfg(feature = "v1_8")]
6345#[cfg(feature = "testgen")]
6346impl<const V: i32> Generate for SetCompression<V> {
6347    fn generate(g: &mut Gen) -> Self {
6348        {
6349            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6350            Self { threshold: v1 }
6351        }
6352    }
6353}
6354
6355#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6356/// `playerlist_header` (clientbound play).
6357#[derive(Debug, Clone, PartialEq)]
6358pub struct PlayerlistHeader<const V: i32> {
6359    /// `header`
6360    pub header: ByteString,
6361    /// `footer`
6362    pub footer: ByteString,
6363}
6364#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6365impl<const V: i32> Decode for PlayerlistHeader<V> {
6366    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6367        Ok({
6368            let v1 = r.read_string()?;
6369            let v2 = r.read_string()?;
6370            Self {
6371                header: v1,
6372                footer: v2,
6373            }
6374        })
6375    }
6376}
6377#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6378impl<const V: i32> Encode for PlayerlistHeader<V> {
6379    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6380        w.put_string(&(*self).header)?;
6381        w.put_string(&(*self).footer)?;
6382        Ok(())
6383    }
6384}
6385#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6386#[cfg(feature = "testgen")]
6387impl<const V: i32> Generate for PlayerlistHeader<V> {
6388    fn generate(g: &mut Gen) -> Self {
6389        {
6390            let v1 = g.string();
6391            let v2 = g.string();
6392            Self {
6393                header: v1,
6394                footer: v2,
6395            }
6396        }
6397    }
6398}
6399
6400#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6401/// `resource_pack_send` (clientbound play).
6402#[derive(Debug, Clone, PartialEq)]
6403pub struct ResourcePackSend<const V: i32> {
6404    /// `url`
6405    pub url: ByteString,
6406    /// `hash`
6407    pub hash: ByteString,
6408}
6409#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6410impl<const V: i32> Decode for ResourcePackSend<V> {
6411    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6412        Ok({
6413            let v1 = r.read_string()?;
6414            let v2 = r.read_string()?;
6415            Self { url: v1, hash: v2 }
6416        })
6417    }
6418}
6419#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6420impl<const V: i32> Encode for ResourcePackSend<V> {
6421    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6422        w.put_string(&(*self).url)?;
6423        w.put_string(&(*self).hash)?;
6424        Ok(())
6425    }
6426}
6427#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
6428#[cfg(feature = "testgen")]
6429impl<const V: i32> Generate for ResourcePackSend<V> {
6430    fn generate(g: &mut Gen) -> Self {
6431        {
6432            let v1 = g.string();
6433            let v2 = g.string();
6434            Self { url: v1, hash: v2 }
6435        }
6436    }
6437}
6438
6439#[cfg(feature = "v1_8")]
6440/// `update_entity_nbt` (clientbound play).
6441#[derive(Debug, Clone, PartialEq)]
6442pub struct UpdateEntityNbt<const V: i32> {
6443    /// `entityId`
6444    pub entity_id: i32,
6445    /// `tag`
6446    pub tag: RawNbt,
6447}
6448#[cfg(feature = "v1_8")]
6449impl<const V: i32> Decode for UpdateEntityNbt<V> {
6450    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6451        Ok({
6452            let v1 = r.read_varint()?;
6453            let v2 = RawNbt::read(r)?;
6454            Self {
6455                entity_id: v1,
6456                tag: v2,
6457            }
6458        })
6459    }
6460}
6461#[cfg(feature = "v1_8")]
6462impl<const V: i32> Encode for UpdateEntityNbt<V> {
6463    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6464        w.put_varint((*self).entity_id);
6465        (*self).tag.write(w);
6466        Ok(())
6467    }
6468}
6469#[cfg(feature = "v1_8")]
6470#[cfg(feature = "testgen")]
6471impl<const V: i32> Generate for UpdateEntityNbt<V> {
6472    fn generate(g: &mut Gen) -> Self {
6473        {
6474            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6475            let v2 = g.nbt();
6476            Self {
6477                entity_id: v1,
6478                tag: v2,
6479            }
6480        }
6481    }
6482}