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