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