Skip to main content

ghast_protocol/generated/defs/p754/play/
clientbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.16.2/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_16_5")]
29/// `spawn_entity` (clientbound play).
30#[derive(Debug, Clone, PartialEq)]
31pub struct SpawnEntity<const V: i32> {
32    /// `entityId`
33    pub entity_id: i32,
34    /// `objectUUID`
35    pub object_uuid: Uuid,
36    /// `type`
37    pub r#type: i32,
38    /// `x`
39    pub x: f64,
40    /// `y`
41    pub y: f64,
42    /// `z`
43    pub z: f64,
44    /// `pitch`
45    pub pitch: i8,
46    /// `yaw`
47    pub yaw: i8,
48    /// `objectData`
49    pub object_data: i32,
50    /// `velocity`
51    pub velocity: crate::defs::p47::types::Vec3i16,
52}
53#[cfg(feature = "v1_16_5")]
54impl<const V: i32> Decode for SpawnEntity<V> {
55    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
56        Ok({
57            let v1 = r.read_varint()?;
58            let v2 = r.read_uuid()?;
59            let v3 = r.read_varint()?;
60            let v4 = r.read_f64()?;
61            let v5 = r.read_f64()?;
62            let v6 = r.read_f64()?;
63            let v7 = r.read_i8()?;
64            let v8 = r.read_i8()?;
65            let v9 = r.read_i32()?;
66            let v10 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
67            Self {
68                entity_id: v1,
69                object_uuid: v2,
70                r#type: v3,
71                x: v4,
72                y: v5,
73                z: v6,
74                pitch: v7,
75                yaw: v8,
76                object_data: v9,
77                velocity: v10,
78            }
79        })
80    }
81}
82#[cfg(feature = "v1_16_5")]
83impl<const V: i32> Encode for SpawnEntity<V> {
84    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
85        w.put_varint((*self).entity_id);
86        w.put_uuid(&(*self).object_uuid);
87        w.put_varint((*self).r#type);
88        w.put_f64((*self).x);
89        w.put_f64((*self).y);
90        w.put_f64((*self).z);
91        w.put_i8((*self).pitch);
92        w.put_i8((*self).yaw);
93        w.put_i32((*self).object_data);
94        (*self).velocity.encode(w)?;
95        Ok(())
96    }
97}
98#[cfg(feature = "v1_16_5")]
99#[cfg(feature = "testgen")]
100impl<const V: i32> Generate for SpawnEntity<V> {
101    fn generate(g: &mut Gen) -> Self {
102        {
103            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
104            let v2 = g.uuid();
105            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
106            let v4 = g.f64();
107            let v5 = g.f64();
108            let v6 = g.f64();
109            let v7 = (g.int_in(-128, 127, &[]) as i8);
110            let v8 = (g.int_in(-128, 127, &[]) as i8);
111            let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
112            let v10 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
113            Self {
114                entity_id: v1,
115                object_uuid: v2,
116                r#type: v3,
117                x: v4,
118                y: v5,
119                z: v6,
120                pitch: v7,
121                yaw: v8,
122                object_data: v9,
123                velocity: v10,
124            }
125        }
126    }
127}
128
129#[cfg(feature = "v1_16_5")]
130/// `spawn_entity_living` (clientbound play).
131#[derive(Debug, Clone, PartialEq)]
132pub struct SpawnEntityLiving<const V: i32> {
133    /// `entityId`
134    pub entity_id: i32,
135    /// `entityUUID`
136    pub entity_uuid: Uuid,
137    /// `type`
138    pub r#type: i32,
139    /// `x`
140    pub x: f64,
141    /// `y`
142    pub y: f64,
143    /// `z`
144    pub z: f64,
145    /// `yaw`
146    pub yaw: i8,
147    /// `pitch`
148    pub pitch: i8,
149    /// `headPitch`
150    pub head_pitch: i8,
151    /// `velocity`
152    pub velocity: crate::defs::p47::types::Vec3i16,
153}
154#[cfg(feature = "v1_16_5")]
155impl<const V: i32> Decode for SpawnEntityLiving<V> {
156    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
157        Ok({
158            let v1 = r.read_varint()?;
159            let v2 = r.read_uuid()?;
160            let v3 = r.read_varint()?;
161            let v4 = r.read_f64()?;
162            let v5 = r.read_f64()?;
163            let v6 = r.read_f64()?;
164            let v7 = r.read_i8()?;
165            let v8 = r.read_i8()?;
166            let v9 = r.read_i8()?;
167            let v10 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
168            Self {
169                entity_id: v1,
170                entity_uuid: v2,
171                r#type: v3,
172                x: v4,
173                y: v5,
174                z: v6,
175                yaw: v7,
176                pitch: v8,
177                head_pitch: v9,
178                velocity: v10,
179            }
180        })
181    }
182}
183#[cfg(feature = "v1_16_5")]
184impl<const V: i32> Encode for SpawnEntityLiving<V> {
185    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
186        w.put_varint((*self).entity_id);
187        w.put_uuid(&(*self).entity_uuid);
188        w.put_varint((*self).r#type);
189        w.put_f64((*self).x);
190        w.put_f64((*self).y);
191        w.put_f64((*self).z);
192        w.put_i8((*self).yaw);
193        w.put_i8((*self).pitch);
194        w.put_i8((*self).head_pitch);
195        (*self).velocity.encode(w)?;
196        Ok(())
197    }
198}
199#[cfg(feature = "v1_16_5")]
200#[cfg(feature = "testgen")]
201impl<const V: i32> Generate for SpawnEntityLiving<V> {
202    fn generate(g: &mut Gen) -> Self {
203        {
204            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
205            let v2 = g.uuid();
206            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
207            let v4 = g.f64();
208            let v5 = g.f64();
209            let v6 = g.f64();
210            let v7 = (g.int_in(-128, 127, &[]) as i8);
211            let v8 = (g.int_in(-128, 127, &[]) as i8);
212            let v9 = (g.int_in(-128, 127, &[]) as i8);
213            let v10 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
214            Self {
215                entity_id: v1,
216                entity_uuid: v2,
217                r#type: v3,
218                x: v4,
219                y: v5,
220                z: v6,
221                yaw: v7,
222                pitch: v8,
223                head_pitch: v9,
224                velocity: v10,
225            }
226        }
227    }
228}
229
230#[cfg(feature = "v1_16_5")]
231/// `spawn_entity_painting` (clientbound play).
232#[derive(Debug, Clone, PartialEq)]
233pub struct SpawnEntityPainting<const V: i32> {
234    /// `entityId`
235    pub entity_id: i32,
236    /// `entityUUID`
237    pub entity_uuid: Uuid,
238    /// `title`
239    pub title: i32,
240    /// `location`
241    pub location: BlockPos,
242    /// `direction`
243    pub direction: u8,
244}
245#[cfg(feature = "v1_16_5")]
246impl<const V: i32> Decode for SpawnEntityPainting<V> {
247    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
248        Ok({
249            let v1 = r.read_varint()?;
250            let v2 = r.read_uuid()?;
251            let v3 = r.read_varint()?;
252            let v4 = BlockPos::read(r, PositionLayout::Xzy)?;
253            let v5 = r.read_u8()?;
254            Self {
255                entity_id: v1,
256                entity_uuid: v2,
257                title: v3,
258                location: v4,
259                direction: v5,
260            }
261        })
262    }
263}
264#[cfg(feature = "v1_16_5")]
265impl<const V: i32> Encode for SpawnEntityPainting<V> {
266    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
267        w.put_varint((*self).entity_id);
268        w.put_uuid(&(*self).entity_uuid);
269        w.put_varint((*self).title);
270        (*self).location.write(w, PositionLayout::Xzy)?;
271        w.put_u8((*self).direction);
272        Ok(())
273    }
274}
275#[cfg(feature = "v1_16_5")]
276#[cfg(feature = "testgen")]
277impl<const V: i32> Generate for SpawnEntityPainting<V> {
278    fn generate(g: &mut Gen) -> Self {
279        {
280            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
281            let v2 = g.uuid();
282            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
283            let v4 = g.position();
284            let v5 = (g.int_in(0, 255, &[]) as u8);
285            Self {
286                entity_id: v1,
287                entity_uuid: v2,
288                title: v3,
289                location: v4,
290                direction: v5,
291            }
292        }
293    }
294}
295
296#[cfg(feature = "v1_16_5")]
297/// `named_entity_spawn` (clientbound play).
298#[derive(Debug, Clone, PartialEq)]
299pub struct NamedEntitySpawn<const V: i32> {
300    /// `entityId`
301    pub entity_id: i32,
302    /// `playerUUID`
303    pub player_uuid: Uuid,
304    /// `x`
305    pub x: f64,
306    /// `y`
307    pub y: f64,
308    /// `z`
309    pub z: f64,
310    /// `yaw`
311    pub yaw: i8,
312    /// `pitch`
313    pub pitch: i8,
314}
315#[cfg(feature = "v1_16_5")]
316impl<const V: i32> Decode for NamedEntitySpawn<V> {
317    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
318        Ok({
319            let v1 = r.read_varint()?;
320            let v2 = r.read_uuid()?;
321            let v3 = r.read_f64()?;
322            let v4 = r.read_f64()?;
323            let v5 = r.read_f64()?;
324            let v6 = r.read_i8()?;
325            let v7 = r.read_i8()?;
326            Self {
327                entity_id: v1,
328                player_uuid: v2,
329                x: v3,
330                y: v4,
331                z: v5,
332                yaw: v6,
333                pitch: v7,
334            }
335        })
336    }
337}
338#[cfg(feature = "v1_16_5")]
339impl<const V: i32> Encode for NamedEntitySpawn<V> {
340    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
341        w.put_varint((*self).entity_id);
342        w.put_uuid(&(*self).player_uuid);
343        w.put_f64((*self).x);
344        w.put_f64((*self).y);
345        w.put_f64((*self).z);
346        w.put_i8((*self).yaw);
347        w.put_i8((*self).pitch);
348        Ok(())
349    }
350}
351#[cfg(feature = "v1_16_5")]
352#[cfg(feature = "testgen")]
353impl<const V: i32> Generate for NamedEntitySpawn<V> {
354    fn generate(g: &mut Gen) -> Self {
355        {
356            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
357            let v2 = g.uuid();
358            let v3 = g.f64();
359            let v4 = g.f64();
360            let v5 = g.f64();
361            let v6 = (g.int_in(-128, 127, &[]) as i8);
362            let v7 = (g.int_in(-128, 127, &[]) as i8);
363            Self {
364                entity_id: v1,
365                player_uuid: v2,
366                x: v3,
367                y: v4,
368                z: v5,
369                yaw: v6,
370                pitch: v7,
371            }
372        }
373    }
374}
375
376#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
377/// Nested container.
378#[derive(Debug, Clone, PartialEq)]
379pub struct StatisticsEntries {
380    /// `categoryId`
381    pub category_id: i32,
382    /// `statisticId`
383    pub statistic_id: i32,
384    /// `value`
385    pub value: i32,
386}
387
388#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
389/// `statistics` (clientbound play).
390#[derive(Debug, Clone, PartialEq)]
391pub struct Statistics<const V: i32> {
392    /// `entries`
393    pub entries: Vec<crate::defs::p754::play::clientbound::StatisticsEntries>,
394}
395#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
396impl<const V: i32> Decode for Statistics<V> {
397    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
398        Ok({
399            let v1 = {
400                let v2 = {
401                    let c = r.read_varint()?;
402                    r.check_count(i64::from(c), 3)?
403                };
404                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
405                for _ in 0..v2 {
406                    v3.push({
407                        let v4 = r.read_varint()?;
408                        let v5 = r.read_varint()?;
409                        let v6 = r.read_varint()?;
410                        crate::defs::p754::play::clientbound::StatisticsEntries {
411                            category_id: v4,
412                            statistic_id: v5,
413                            value: v6,
414                        }
415                    });
416                }
417                v3
418            };
419            Self { entries: v1 }
420        })
421    }
422}
423#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
424impl<const V: i32> Encode for Statistics<V> {
425    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
426        w.put_len_varint((*self).entries.len())?;
427        for v1 in (*self).entries.iter() {
428            w.put_varint((*v1).category_id);
429            w.put_varint((*v1).statistic_id);
430            w.put_varint((*v1).value);
431        }
432        Ok(())
433    }
434}
435#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
436#[cfg(feature = "testgen")]
437impl<const V: i32> Generate for Statistics<V> {
438    fn generate(g: &mut Gen) -> Self {
439        {
440            let v1 = {
441                let v2 = g.count();
442                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
443                for _ in 0..v2 {
444                    v3.push({
445                        let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
446                        let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
447                        let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
448                        crate::defs::p754::play::clientbound::StatisticsEntries {
449                            category_id: v4,
450                            statistic_id: v5,
451                            value: v6,
452                        }
453                    });
454                }
455                v3
456            };
457            Self { entries: v1 }
458        }
459    }
460}
461
462#[cfg(feature = "v1_16_5")]
463/// `acknowledge_player_digging` (clientbound play).
464#[derive(Debug, Clone, PartialEq)]
465pub struct AcknowledgePlayerDigging<const V: i32> {
466    /// `location`
467    pub location: BlockPos,
468    /// `block`
469    pub block: i32,
470    /// `status`
471    pub status: i32,
472    /// `successful`
473    pub successful: bool,
474}
475#[cfg(feature = "v1_16_5")]
476impl<const V: i32> Decode for AcknowledgePlayerDigging<V> {
477    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
478        Ok({
479            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
480            let v2 = r.read_varint()?;
481            let v3 = r.read_varint()?;
482            let v4 = r.read_bool()?;
483            Self {
484                location: v1,
485                block: v2,
486                status: v3,
487                successful: v4,
488            }
489        })
490    }
491}
492#[cfg(feature = "v1_16_5")]
493impl<const V: i32> Encode for AcknowledgePlayerDigging<V> {
494    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
495        (*self).location.write(w, PositionLayout::Xzy)?;
496        w.put_varint((*self).block);
497        w.put_varint((*self).status);
498        w.put_bool((*self).successful);
499        Ok(())
500    }
501}
502#[cfg(feature = "v1_16_5")]
503#[cfg(feature = "testgen")]
504impl<const V: i32> Generate for AcknowledgePlayerDigging<V> {
505    fn generate(g: &mut Gen) -> Self {
506        {
507            let v1 = g.position();
508            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
509            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
510            let v4 = g.bool();
511            Self {
512                location: v1,
513                block: v2,
514                status: v3,
515                successful: v4,
516            }
517        }
518    }
519}
520
521#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
522/// `block_break_animation` (clientbound play).
523#[derive(Debug, Clone, PartialEq)]
524pub struct BlockBreakAnimation<const V: i32> {
525    /// `entityId`
526    pub entity_id: i32,
527    /// `location`
528    pub location: BlockPos,
529    /// `destroyStage`
530    pub destroy_stage: i8,
531}
532#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
533impl<const V: i32> Decode for BlockBreakAnimation<V> {
534    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
535        Ok({
536            let v1 = r.read_varint()?;
537            let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
538            let v3 = r.read_i8()?;
539            Self {
540                entity_id: v1,
541                location: v2,
542                destroy_stage: v3,
543            }
544        })
545    }
546}
547#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
548impl<const V: i32> Encode for BlockBreakAnimation<V> {
549    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
550        w.put_varint((*self).entity_id);
551        (*self).location.write(w, PositionLayout::Xzy)?;
552        w.put_i8((*self).destroy_stage);
553        Ok(())
554    }
555}
556#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
557#[cfg(feature = "testgen")]
558impl<const V: i32> Generate for BlockBreakAnimation<V> {
559    fn generate(g: &mut Gen) -> Self {
560        {
561            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
562            let v2 = g.position();
563            let v3 = (g.int_in(-128, 127, &[]) as i8);
564            Self {
565                entity_id: v1,
566                location: v2,
567                destroy_stage: v3,
568            }
569        }
570    }
571}
572
573#[cfg(feature = "v1_16_5")]
574/// `tile_entity_data` (clientbound play).
575#[derive(Debug, Clone, PartialEq)]
576pub struct TileEntityData<const V: i32> {
577    /// `location`
578    pub location: BlockPos,
579    /// `action`
580    pub action: u8,
581    /// `nbtData`
582    pub nbt_data: Option<RawNbt>,
583}
584#[cfg(feature = "v1_16_5")]
585impl<const V: i32> Decode for TileEntityData<V> {
586    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
587        Ok({
588            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
589            let v2 = r.read_u8()?;
590            let v3 = RawNbt::read_optional(r)?;
591            Self {
592                location: v1,
593                action: v2,
594                nbt_data: v3,
595            }
596        })
597    }
598}
599#[cfg(feature = "v1_16_5")]
600impl<const V: i32> Encode for TileEntityData<V> {
601    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
602        (*self).location.write(w, PositionLayout::Xzy)?;
603        w.put_u8((*self).action);
604        RawNbt::write_optional(&(*self).nbt_data, w);
605        Ok(())
606    }
607}
608#[cfg(feature = "v1_16_5")]
609#[cfg(feature = "testgen")]
610impl<const V: i32> Generate for TileEntityData<V> {
611    fn generate(g: &mut Gen) -> Self {
612        {
613            let v1 = g.position();
614            let v2 = (g.int_in(0, 255, &[]) as u8);
615            let v3 = g.opt_nbt();
616            Self {
617                location: v1,
618                action: v2,
619                nbt_data: v3,
620            }
621        }
622    }
623}
624
625#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
626/// `block_action` (clientbound play).
627#[derive(Debug, Clone, PartialEq)]
628pub struct BlockAction<const V: i32> {
629    /// `location`
630    pub location: BlockPos,
631    /// `byte1`
632    pub byte1: u8,
633    /// `byte2`
634    pub byte2: u8,
635    /// `blockId`
636    pub block_id: i32,
637}
638#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
639impl<const V: i32> Decode for BlockAction<V> {
640    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
641        Ok({
642            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
643            let v2 = r.read_u8()?;
644            let v3 = r.read_u8()?;
645            let v4 = r.read_varint()?;
646            Self {
647                location: v1,
648                byte1: v2,
649                byte2: v3,
650                block_id: v4,
651            }
652        })
653    }
654}
655#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
656impl<const V: i32> Encode for BlockAction<V> {
657    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
658        (*self).location.write(w, PositionLayout::Xzy)?;
659        w.put_u8((*self).byte1);
660        w.put_u8((*self).byte2);
661        w.put_varint((*self).block_id);
662        Ok(())
663    }
664}
665#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
666#[cfg(feature = "testgen")]
667impl<const V: i32> Generate for BlockAction<V> {
668    fn generate(g: &mut Gen) -> Self {
669        {
670            let v1 = g.position();
671            let v2 = (g.int_in(0, 255, &[]) as u8);
672            let v3 = (g.int_in(0, 255, &[]) as u8);
673            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
674            Self {
675                location: v1,
676                byte1: v2,
677                byte2: v3,
678                block_id: v4,
679            }
680        }
681    }
682}
683
684#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
685/// `block_change` (clientbound play).
686#[derive(Debug, Clone, PartialEq)]
687pub struct BlockChange<const V: i32> {
688    /// `location`
689    pub location: BlockPos,
690    /// `type`
691    pub r#type: i32,
692}
693#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
694impl<const V: i32> Decode for BlockChange<V> {
695    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
696        Ok({
697            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
698            let v2 = r.read_varint()?;
699            Self {
700                location: v1,
701                r#type: v2,
702            }
703        })
704    }
705}
706#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
707impl<const V: i32> Encode for BlockChange<V> {
708    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
709        (*self).location.write(w, PositionLayout::Xzy)?;
710        w.put_varint((*self).r#type);
711        Ok(())
712    }
713}
714#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
715#[cfg(feature = "testgen")]
716impl<const V: i32> Generate for BlockChange<V> {
717    fn generate(g: &mut Gen) -> Self {
718        {
719            let v1 = g.position();
720            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
721            Self {
722                location: v1,
723                r#type: v2,
724            }
725        }
726    }
727}
728
729#[cfg(feature = "v1_16_5")]
730/// `difficulty` (clientbound play).
731#[derive(Debug, Clone, PartialEq)]
732pub struct Difficulty<const V: i32> {
733    /// `difficulty`
734    pub difficulty: crate::defs::p47::play::clientbound::DifficultyDifficulty,
735    /// `difficultyLocked`
736    pub difficulty_locked: bool,
737}
738#[cfg(feature = "v1_16_5")]
739impl<const V: i32> Decode for Difficulty<V> {
740    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
741        Ok({
742            let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(r.read_u8()?);
743            let v2 = r.read_bool()?;
744            Self {
745                difficulty: v1,
746                difficulty_locked: v2,
747            }
748        })
749    }
750}
751#[cfg(feature = "v1_16_5")]
752impl<const V: i32> Encode for Difficulty<V> {
753    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
754        w.put_u8((*self).difficulty.0);
755        w.put_bool((*self).difficulty_locked);
756        Ok(())
757    }
758}
759#[cfg(feature = "v1_16_5")]
760#[cfg(feature = "testgen")]
761impl<const V: i32> Generate for Difficulty<V> {
762    fn generate(g: &mut Gen) -> Self {
763        {
764            let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(g.int_in(
765                0,
766                255,
767                &[0, 1, 2, 3],
768            ) as u8);
769            let v2 = g.bool();
770            Self {
771                difficulty: v1,
772                difficulty_locked: v2,
773            }
774        }
775    }
776}
777
778#[cfg(feature = "v1_16_5")]
779/// `chat` (clientbound play).
780#[derive(Debug, Clone, PartialEq)]
781pub struct Chat<const V: i32> {
782    /// `message`
783    pub message: ByteString,
784    /// `position`
785    pub position: i8,
786    /// `sender`
787    pub sender: Uuid,
788}
789#[cfg(feature = "v1_16_5")]
790impl<const V: i32> Decode for Chat<V> {
791    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
792        Ok({
793            let v1 = r.read_string()?;
794            let v2 = r.read_i8()?;
795            let v3 = r.read_uuid()?;
796            Self {
797                message: v1,
798                position: v2,
799                sender: v3,
800            }
801        })
802    }
803}
804#[cfg(feature = "v1_16_5")]
805impl<const V: i32> Encode for Chat<V> {
806    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
807        w.put_string(&(*self).message)?;
808        w.put_i8((*self).position);
809        w.put_uuid(&(*self).sender);
810        Ok(())
811    }
812}
813#[cfg(feature = "v1_16_5")]
814#[cfg(feature = "testgen")]
815impl<const V: i32> Generate for Chat<V> {
816    fn generate(g: &mut Gen) -> Self {
817        {
818            let v1 = g.string();
819            let v2 = (g.int_in(-128, 127, &[]) as i8);
820            let v3 = g.uuid();
821            Self {
822                message: v1,
823                position: v2,
824                sender: v3,
825            }
826        }
827    }
828}
829
830#[cfg(feature = "v1_16_5")]
831/// Nested container.
832#[derive(Debug, Clone, PartialEq)]
833pub struct TabCompleteMatches {
834    /// `match`
835    pub r#match: ByteString,
836    /// `tooltip`
837    pub tooltip: Option<ByteString>,
838}
839
840#[cfg(feature = "v1_16_5")]
841/// `tab_complete` (clientbound play).
842#[derive(Debug, Clone, PartialEq)]
843pub struct TabComplete<const V: i32> {
844    /// `transactionId`
845    pub transaction_id: i32,
846    /// `start`
847    pub start: i32,
848    /// `length`
849    pub length: i32,
850    /// `matches`
851    pub matches: Vec<crate::defs::p754::play::clientbound::TabCompleteMatches>,
852}
853#[cfg(feature = "v1_16_5")]
854impl<const V: i32> Decode for TabComplete<V> {
855    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
856        Ok({
857            let v1 = r.read_varint()?;
858            let v2 = r.read_varint()?;
859            let v3 = r.read_varint()?;
860            let v4 = {
861                let v5 = {
862                    let c = r.read_varint()?;
863                    r.check_count(i64::from(c), 2)?
864                };
865                let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
866                for _ in 0..v5 {
867                    v6.push({
868                        let v7 = r.read_string()?;
869                        let v8 = if r.read_bool()? {
870                            Some(r.read_string()?)
871                        } else {
872                            None
873                        };
874                        crate::defs::p754::play::clientbound::TabCompleteMatches {
875                            r#match: v7,
876                            tooltip: v8,
877                        }
878                    });
879                }
880                v6
881            };
882            Self {
883                transaction_id: v1,
884                start: v2,
885                length: v3,
886                matches: v4,
887            }
888        })
889    }
890}
891#[cfg(feature = "v1_16_5")]
892impl<const V: i32> Encode for TabComplete<V> {
893    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
894        w.put_varint((*self).transaction_id);
895        w.put_varint((*self).start);
896        w.put_varint((*self).length);
897        w.put_len_varint((*self).matches.len())?;
898        for v1 in (*self).matches.iter() {
899            w.put_string(&(*v1).r#match)?;
900            match &(*v1).tooltip {
901                Some(v2) => {
902                    w.put_u8(1);
903                    w.put_string(&(*v2))?;
904                }
905                None => w.put_u8(0),
906            }
907        }
908        Ok(())
909    }
910}
911#[cfg(feature = "v1_16_5")]
912#[cfg(feature = "testgen")]
913impl<const V: i32> Generate for TabComplete<V> {
914    fn generate(g: &mut Gen) -> Self {
915        {
916            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
917            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
918            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
919            let v4 = {
920                let v5 = g.count();
921                let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
922                for _ in 0..v5 {
923                    v6.push({
924                        let v7 = g.string();
925                        let v8 = if g.bool() { Some(g.string()) } else { None };
926                        crate::defs::p754::play::clientbound::TabCompleteMatches {
927                            r#match: v7,
928                            tooltip: v8,
929                        }
930                    });
931                }
932                v6
933            };
934            Self {
935                transaction_id: v1,
936                start: v2,
937                length: v3,
938                matches: v4,
939            }
940        }
941    }
942}
943
944#[cfg(feature = "v1_16_5")]
945/// `declare_commands` (clientbound play).
946#[derive(Debug, Clone, PartialEq)]
947pub struct DeclareCommands<const V: i32> {
948    /// `nodes`
949    pub nodes: Vec<crate::defs::p754::types::CommandNode>,
950    /// `rootIndex`
951    pub root_index: i32,
952}
953#[cfg(feature = "v1_16_5")]
954impl<const V: i32> Decode for DeclareCommands<V> {
955    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
956        Ok({
957            let v1 = {
958                let v2 = {
959                    let c = r.read_varint()?;
960                    r.check_count(i64::from(c), 2)?
961                };
962                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
963                for _ in 0..v2 {
964                    v3.push(<crate::defs::p754::types::CommandNode as Decode>::decode(
965                        r,
966                    )?);
967                }
968                v3
969            };
970            let v4 = r.read_varint()?;
971            Self {
972                nodes: v1,
973                root_index: v4,
974            }
975        })
976    }
977}
978#[cfg(feature = "v1_16_5")]
979impl<const V: i32> Encode for DeclareCommands<V> {
980    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
981        w.put_len_varint((*self).nodes.len())?;
982        for v1 in (*self).nodes.iter() {
983            (*v1).encode(w)?;
984        }
985        w.put_varint((*self).root_index);
986        Ok(())
987    }
988}
989#[cfg(feature = "v1_16_5")]
990#[cfg(feature = "testgen")]
991impl<const V: i32> Generate for DeclareCommands<V> {
992    fn generate(g: &mut Gen) -> Self {
993        {
994            let v1 = {
995                let v2 = g.count();
996                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
997                for _ in 0..v2 {
998                    v3.push(<crate::defs::p754::types::CommandNode as Generate>::generate(g));
999                }
1000                v3
1001            };
1002            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1003            Self {
1004                nodes: v1,
1005                root_index: v4,
1006            }
1007        }
1008    }
1009}
1010
1011#[cfg(feature = "v1_16_5")]
1012/// `window_items` (clientbound play).
1013#[derive(Debug, Clone, PartialEq)]
1014pub struct WindowItems<const V: i32> {
1015    /// `windowId`
1016    pub window_id: u8,
1017    /// `items`
1018    pub items: Vec<crate::types::slot::modern::Slot>,
1019}
1020#[cfg(feature = "v1_16_5")]
1021impl<const V: i32> Decode for WindowItems<V> {
1022    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1023        Ok({
1024            let v1 = r.read_u8()?;
1025            let v2 = {
1026                let v3 = {
1027                    let c = r.read_i16()?;
1028                    r.check_count(i64::from(c), 1)?
1029                };
1030                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1031                for _ in 0..v3 {
1032                    v4.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?);
1033                }
1034                v4
1035            };
1036            Self {
1037                window_id: v1,
1038                items: v2,
1039            }
1040        })
1041    }
1042}
1043#[cfg(feature = "v1_16_5")]
1044impl<const V: i32> Encode for WindowItems<V> {
1045    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1046        w.put_u8((*self).window_id);
1047        w.put_i16(crate::codec::count_i16((*self).items.len())?);
1048        for v1 in (*self).items.iter() {
1049            (*v1).encode(w)?;
1050        }
1051        Ok(())
1052    }
1053}
1054#[cfg(feature = "v1_16_5")]
1055#[cfg(feature = "testgen")]
1056impl<const V: i32> Generate for WindowItems<V> {
1057    fn generate(g: &mut Gen) -> Self {
1058        {
1059            let v1 = (g.int_in(0, 255, &[]) as u8);
1060            let v2 = {
1061                let v3 = g.count();
1062                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1063                for _ in 0..v3 {
1064                    v4.push(<crate::types::slot::modern::Slot as Generate>::generate(g));
1065                }
1066                v4
1067            };
1068            Self {
1069                window_id: v1,
1070                items: v2,
1071            }
1072        }
1073    }
1074}
1075
1076#[cfg(feature = "v1_16_5")]
1077/// `set_slot` (clientbound play).
1078#[derive(Debug, Clone, PartialEq)]
1079pub struct SetSlot<const V: i32> {
1080    /// `windowId`
1081    pub window_id: i8,
1082    /// `slot`
1083    pub slot: i16,
1084    /// `item`
1085    pub item: crate::types::slot::modern::Slot,
1086}
1087#[cfg(feature = "v1_16_5")]
1088impl<const V: i32> Decode for SetSlot<V> {
1089    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1090        Ok({
1091            let v1 = r.read_i8()?;
1092            let v2 = r.read_i16()?;
1093            let v3 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
1094            Self {
1095                window_id: v1,
1096                slot: v2,
1097                item: v3,
1098            }
1099        })
1100    }
1101}
1102#[cfg(feature = "v1_16_5")]
1103impl<const V: i32> Encode for SetSlot<V> {
1104    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1105        w.put_i8((*self).window_id);
1106        w.put_i16((*self).slot);
1107        (*self).item.encode(w)?;
1108        Ok(())
1109    }
1110}
1111#[cfg(feature = "v1_16_5")]
1112#[cfg(feature = "testgen")]
1113impl<const V: i32> Generate for SetSlot<V> {
1114    fn generate(g: &mut Gen) -> Self {
1115        {
1116            let v1 = (g.int_in(-128, 127, &[]) as i8);
1117            let v2 = (g.int_in(-32768, 32767, &[]) as i16);
1118            let v3 = <crate::types::slot::modern::Slot as Generate>::generate(g);
1119            Self {
1120                window_id: v1,
1121                slot: v2,
1122                item: v3,
1123            }
1124        }
1125    }
1126}
1127
1128#[cfg(feature = "v1_16_5")]
1129/// Mapped `u8` value; unknown values are kept as-is.
1130#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
1131pub struct GameStateChangeReason(pub u8);
1132#[cfg(feature = "v1_16_5")]
1133impl GameStateChangeReason {
1134    /// `no_respawn_block_available`
1135    pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
1136    /// `start_raining`
1137    pub const START_RAINING: Self = Self(1);
1138    /// `stop_raining`
1139    pub const STOP_RAINING: Self = Self(2);
1140    /// `change_game_mode`
1141    pub const CHANGE_GAME_MODE: Self = Self(3);
1142    /// `win_game`
1143    pub const WIN_GAME: Self = Self(4);
1144    /// `demo_event`
1145    pub const DEMO_EVENT: Self = Self(5);
1146    /// `play_arrow_hit_sound`
1147    pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
1148    /// `rain_level_change`
1149    pub const RAIN_LEVEL_CHANGE: Self = Self(7);
1150    /// `thunder_level_change`
1151    pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
1152    /// `puffer_fish_sting`
1153    pub const PUFFER_FISH_STING: Self = Self(9);
1154    /// `guardian_elder_effect`
1155    pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
1156    /// `immediate_respawn`
1157    pub const IMMEDIATE_RESPAWN: Self = Self(11);
1158    /// minecraft-data name of the value, if known.
1159    pub const fn name(self) -> Option<&'static str> {
1160        match self.0 {
1161            0 => Some("no_respawn_block_available"),
1162            1 => Some("start_raining"),
1163            2 => Some("stop_raining"),
1164            3 => Some("change_game_mode"),
1165            4 => Some("win_game"),
1166            5 => Some("demo_event"),
1167            6 => Some("play_arrow_hit_sound"),
1168            7 => Some("rain_level_change"),
1169            8 => Some("thunder_level_change"),
1170            9 => Some("puffer_fish_sting"),
1171            10 => Some("guardian_elder_effect"),
1172            11 => Some("immediate_respawn"),
1173            _ => None,
1174        }
1175    }
1176}
1177#[cfg(feature = "v1_16_5")]
1178impl std::fmt::Debug for GameStateChangeReason {
1179    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1180        match self.name() {
1181            Some(n) => write!(f, "GameStateChangeReason::{n}"),
1182            None => write!(f, "GameStateChangeReason({})", self.0),
1183        }
1184    }
1185}
1186
1187#[cfg(feature = "v1_16_5")]
1188/// `game_state_change` (clientbound play).
1189#[derive(Debug, Clone, PartialEq)]
1190pub struct GameStateChange<const V: i32> {
1191    /// `reason`
1192    pub reason: crate::defs::p754::play::clientbound::GameStateChangeReason,
1193    /// `gameMode`
1194    pub game_mode: f32,
1195}
1196#[cfg(feature = "v1_16_5")]
1197impl<const V: i32> Decode for GameStateChange<V> {
1198    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1199        Ok({
1200            let v1 = crate::defs::p754::play::clientbound::GameStateChangeReason(r.read_u8()?);
1201            let v2 = r.read_f32()?;
1202            Self {
1203                reason: v1,
1204                game_mode: v2,
1205            }
1206        })
1207    }
1208}
1209#[cfg(feature = "v1_16_5")]
1210impl<const V: i32> Encode for GameStateChange<V> {
1211    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1212        w.put_u8((*self).reason.0);
1213        w.put_f32((*self).game_mode);
1214        Ok(())
1215    }
1216}
1217#[cfg(feature = "v1_16_5")]
1218#[cfg(feature = "testgen")]
1219impl<const V: i32> Generate for GameStateChange<V> {
1220    fn generate(g: &mut Gen) -> Self {
1221        {
1222            let v1 = crate::defs::p754::play::clientbound::GameStateChangeReason(g.int_in(
1223                0,
1224                255,
1225                &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
1226            )
1227                as u8);
1228            let v2 = g.f32();
1229            Self {
1230                reason: v1,
1231                game_mode: v2,
1232            }
1233        }
1234    }
1235}
1236
1237#[cfg(feature = "v1_16_5")]
1238/// `open_horse_window` (clientbound play).
1239#[derive(Debug, Clone, PartialEq)]
1240pub struct OpenHorseWindow<const V: i32> {
1241    /// `windowId`
1242    pub window_id: u8,
1243    /// `nbSlots`
1244    pub nb_slots: i32,
1245    /// `entityId`
1246    pub entity_id: i32,
1247}
1248#[cfg(feature = "v1_16_5")]
1249impl<const V: i32> Decode for OpenHorseWindow<V> {
1250    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1251        Ok({
1252            let v1 = r.read_u8()?;
1253            let v2 = r.read_varint()?;
1254            let v3 = r.read_i32()?;
1255            Self {
1256                window_id: v1,
1257                nb_slots: v2,
1258                entity_id: v3,
1259            }
1260        })
1261    }
1262}
1263#[cfg(feature = "v1_16_5")]
1264impl<const V: i32> Encode for OpenHorseWindow<V> {
1265    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1266        w.put_u8((*self).window_id);
1267        w.put_varint((*self).nb_slots);
1268        w.put_i32((*self).entity_id);
1269        Ok(())
1270    }
1271}
1272#[cfg(feature = "v1_16_5")]
1273#[cfg(feature = "testgen")]
1274impl<const V: i32> Generate for OpenHorseWindow<V> {
1275    fn generate(g: &mut Gen) -> Self {
1276        {
1277            let v1 = (g.int_in(0, 255, &[]) as u8);
1278            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1279            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1280            Self {
1281                window_id: v1,
1282                nb_slots: v2,
1283                entity_id: v3,
1284            }
1285        }
1286    }
1287}
1288
1289#[cfg(feature = "v1_16_5")]
1290/// `map_chunk` (clientbound play).
1291#[derive(Debug, Clone, PartialEq)]
1292pub struct MapChunk<const V: i32> {
1293    /// `x`
1294    pub x: i32,
1295    /// `z`
1296    pub z: i32,
1297    /// `groundUp`
1298    pub ground_up: bool,
1299    /// `bitMap`
1300    pub bit_map: i32,
1301    /// `heightmaps`
1302    pub heightmaps: RawNbt,
1303    /// `biomes`
1304    pub biomes: Option<Vec<i32>>,
1305    /// `chunkData`
1306    pub chunk_data: Bytes,
1307    /// `blockEntities`
1308    pub block_entities: Vec<RawNbt>,
1309}
1310#[cfg(feature = "v1_16_5")]
1311impl<const V: i32> Decode for MapChunk<V> {
1312    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1313        Ok({
1314            let v1 = r.read_i32()?;
1315            let v2 = r.read_i32()?;
1316            let v3 = r.read_bool()?;
1317            let v4 = r.read_varint()?;
1318            let v5 = RawNbt::read(r)?;
1319            let v6 = if v3 {
1320                Some({
1321                    let v7 = {
1322                        let c = r.read_varint()?;
1323                        r.check_count(i64::from(c), 1)?
1324                    };
1325                    let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
1326                    for _ in 0..v7 {
1327                        v8.push(r.read_varint()?);
1328                    }
1329                    v8
1330                })
1331            } else {
1332                None
1333            };
1334            let v9 = r.read_byte_array()?;
1335            let v10 = {
1336                let v11 = {
1337                    let c = r.read_varint()?;
1338                    r.check_count(i64::from(c), 1)?
1339                };
1340                let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
1341                for _ in 0..v11 {
1342                    v12.push(RawNbt::read(r)?);
1343                }
1344                v12
1345            };
1346            Self {
1347                x: v1,
1348                z: v2,
1349                ground_up: v3,
1350                bit_map: v4,
1351                heightmaps: v5,
1352                biomes: v6,
1353                chunk_data: v9,
1354                block_entities: v10,
1355            }
1356        })
1357    }
1358}
1359#[cfg(feature = "v1_16_5")]
1360impl<const V: i32> Encode for MapChunk<V> {
1361    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1362        w.put_i32((*self).x);
1363        w.put_i32((*self).z);
1364        w.put_bool((*self).ground_up);
1365        w.put_varint((*self).bit_map);
1366        (*self).heightmaps.write(w);
1367        match (&(*self).biomes, (*self).ground_up) {
1368            (Some(v1), true) => {
1369                w.put_len_varint((*v1).len())?;
1370                for v2 in (*v1).iter() {
1371                    w.put_varint((*v2));
1372                }
1373            }
1374            (None, false) => {}
1375            _ => {
1376                return Err(EncodeError::SwitchMismatch(
1377                    "play.clientbound.map_chunk.biomes",
1378                ));
1379            }
1380        }
1381        w.put_byte_array(&(*self).chunk_data)?;
1382        w.put_len_varint((*self).block_entities.len())?;
1383        for v3 in (*self).block_entities.iter() {
1384            (*v3).write(w);
1385        }
1386        Ok(())
1387    }
1388}
1389#[cfg(feature = "v1_16_5")]
1390#[cfg(feature = "testgen")]
1391impl<const V: i32> Generate for MapChunk<V> {
1392    fn generate(g: &mut Gen) -> Self {
1393        {
1394            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1395            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1396            let v3 = g.bool();
1397            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1398            let v5 = g.nbt();
1399            let v6 = if v3 {
1400                Some({
1401                    let v7 = g.count();
1402                    let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
1403                    for _ in 0..v7 {
1404                        v8.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
1405                    }
1406                    v8
1407                })
1408            } else {
1409                None
1410            };
1411            let v9 = g.bytes();
1412            let v10 = {
1413                let v11 = g.count();
1414                let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
1415                for _ in 0..v11 {
1416                    v12.push(g.nbt());
1417                }
1418                v12
1419            };
1420            Self {
1421                x: v1,
1422                z: v2,
1423                ground_up: v3,
1424                bit_map: v4,
1425                heightmaps: v5,
1426                biomes: v6,
1427                chunk_data: v9,
1428                block_entities: v10,
1429            }
1430        }
1431    }
1432}
1433
1434#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
1435/// `world_event` (clientbound play).
1436#[derive(Debug, Clone, PartialEq)]
1437pub struct WorldEvent<const V: i32> {
1438    /// `effectId`
1439    pub effect_id: i32,
1440    /// `location`
1441    pub location: BlockPos,
1442    /// `data`
1443    pub data: i32,
1444    /// `global`
1445    pub global: bool,
1446}
1447#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
1448impl<const V: i32> Decode for WorldEvent<V> {
1449    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1450        Ok({
1451            let v1 = r.read_i32()?;
1452            let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
1453            let v3 = r.read_i32()?;
1454            let v4 = r.read_bool()?;
1455            Self {
1456                effect_id: v1,
1457                location: v2,
1458                data: v3,
1459                global: v4,
1460            }
1461        })
1462    }
1463}
1464#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
1465impl<const V: i32> Encode for WorldEvent<V> {
1466    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1467        w.put_i32((*self).effect_id);
1468        (*self).location.write(w, PositionLayout::Xzy)?;
1469        w.put_i32((*self).data);
1470        w.put_bool((*self).global);
1471        Ok(())
1472    }
1473}
1474#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
1475#[cfg(feature = "testgen")]
1476impl<const V: i32> Generate for WorldEvent<V> {
1477    fn generate(g: &mut Gen) -> Self {
1478        {
1479            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1480            let v2 = g.position();
1481            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1482            let v4 = g.bool();
1483            Self {
1484                effect_id: v1,
1485                location: v2,
1486                data: v3,
1487                global: v4,
1488            }
1489        }
1490    }
1491}
1492
1493#[cfg(feature = "v1_16_5")]
1494/// `world_particles` (clientbound play).
1495#[derive(Debug, Clone, PartialEq)]
1496pub struct WorldParticles<const V: i32> {
1497    /// `particleId`
1498    pub particle_id: i32,
1499    /// `longDistance`
1500    pub long_distance: bool,
1501    /// `x`
1502    pub x: f64,
1503    /// `y`
1504    pub y: f64,
1505    /// `z`
1506    pub z: f64,
1507    /// `offsetX`
1508    pub offset_x: f32,
1509    /// `offsetY`
1510    pub offset_y: f32,
1511    /// `offsetZ`
1512    pub offset_z: f32,
1513    /// `particleData`
1514    pub particle_data: f32,
1515    /// `particles`
1516    pub particles: i32,
1517    /// `data`
1518    pub data: crate::defs::p754::types::ParticleData,
1519}
1520#[cfg(feature = "v1_16_5")]
1521impl<const V: i32> Decode for WorldParticles<V> {
1522    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1523        Ok({
1524            let v1 = r.read_i32()?;
1525            let v2 = r.read_bool()?;
1526            let v3 = r.read_f64()?;
1527            let v4 = r.read_f64()?;
1528            let v5 = r.read_f64()?;
1529            let v6 = r.read_f32()?;
1530            let v7 = r.read_f32()?;
1531            let v8 = r.read_f32()?;
1532            let v9 = r.read_f32()?;
1533            let v10 = r.read_i32()?;
1534            let v11 = (if (v1 == 3) {
1535                crate::defs::p754::types::ParticleData::Case3({
1536                    let v12 = r.read_varint()?;
1537                    crate::defs::p754::types::ParticleDataCase3 { block_state: v12 }
1538                })
1539            } else if (v1 == 14) {
1540                crate::defs::p754::types::ParticleData::Case14({
1541                    let v13 = r.read_f32()?;
1542                    let v14 = r.read_f32()?;
1543                    let v15 = r.read_f32()?;
1544                    let v16 = r.read_f32()?;
1545                    crate::defs::p754::types::ParticleDataCase14 {
1546                        red: v13,
1547                        green: v14,
1548                        blue: v15,
1549                        scale: v16,
1550                    }
1551                })
1552            } else if (v1 == 23) {
1553                crate::defs::p754::types::ParticleData::Case23({
1554                    let v17 = r.read_varint()?;
1555                    crate::defs::p754::types::ParticleDataCase23 { block_state: v17 }
1556                })
1557            } else if (v1 == 34) {
1558                crate::defs::p754::types::ParticleData::Case34({
1559                    let v18 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
1560                    crate::defs::p754::types::ParticleDataCase34 { item: v18 }
1561                })
1562            } else {
1563                crate::defs::p754::types::ParticleData::Other
1564            });
1565            Self {
1566                particle_id: v1,
1567                long_distance: v2,
1568                x: v3,
1569                y: v4,
1570                z: v5,
1571                offset_x: v6,
1572                offset_y: v7,
1573                offset_z: v8,
1574                particle_data: v9,
1575                particles: v10,
1576                data: v11,
1577            }
1578        })
1579    }
1580}
1581#[cfg(feature = "v1_16_5")]
1582impl<const V: i32> Encode for WorldParticles<V> {
1583    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1584        w.put_i32((*self).particle_id);
1585        w.put_bool((*self).long_distance);
1586        w.put_f64((*self).x);
1587        w.put_f64((*self).y);
1588        w.put_f64((*self).z);
1589        w.put_f32((*self).offset_x);
1590        w.put_f32((*self).offset_y);
1591        w.put_f32((*self).offset_z);
1592        w.put_f32((*self).particle_data);
1593        w.put_i32((*self).particles);
1594        match &(*self).data {
1595            crate::defs::p754::types::ParticleData::Case3(v1) => {
1596                if !((*self).particle_id == 3) {
1597                    return Err(EncodeError::SwitchMismatch(
1598                        "play.clientbound.world_particles.data",
1599                    ));
1600                }
1601                w.put_varint((*v1).block_state);
1602            }
1603            crate::defs::p754::types::ParticleData::Case14(v2) => {
1604                if !((*self).particle_id == 14) {
1605                    return Err(EncodeError::SwitchMismatch(
1606                        "play.clientbound.world_particles.data",
1607                    ));
1608                }
1609                w.put_f32((*v2).red);
1610                w.put_f32((*v2).green);
1611                w.put_f32((*v2).blue);
1612                w.put_f32((*v2).scale);
1613            }
1614            crate::defs::p754::types::ParticleData::Case23(v3) => {
1615                if !((*self).particle_id == 23) {
1616                    return Err(EncodeError::SwitchMismatch(
1617                        "play.clientbound.world_particles.data",
1618                    ));
1619                }
1620                w.put_varint((*v3).block_state);
1621            }
1622            crate::defs::p754::types::ParticleData::Case34(v4) => {
1623                if !((*self).particle_id == 34) {
1624                    return Err(EncodeError::SwitchMismatch(
1625                        "play.clientbound.world_particles.data",
1626                    ));
1627                }
1628                (*v4).item.encode(w)?;
1629            }
1630            crate::defs::p754::types::ParticleData::Other => {
1631                if !(!(((*self).particle_id == 3)
1632                    || ((*self).particle_id == 14)
1633                    || ((*self).particle_id == 23)
1634                    || ((*self).particle_id == 34)))
1635                {
1636                    return Err(EncodeError::SwitchMismatch(
1637                        "play.clientbound.world_particles.data",
1638                    ));
1639                }
1640            }
1641        }
1642        Ok(())
1643    }
1644}
1645#[cfg(feature = "v1_16_5")]
1646#[cfg(feature = "testgen")]
1647impl<const V: i32> Generate for WorldParticles<V> {
1648    fn generate(g: &mut Gen) -> Self {
1649        {
1650            let v1 = (g.int_in(-2147483648, 2147483647, &[3, 14, 23, 34]) as i32);
1651            let v2 = g.bool();
1652            let v3 = g.f64();
1653            let v4 = g.f64();
1654            let v5 = g.f64();
1655            let v6 = g.f32();
1656            let v7 = g.f32();
1657            let v8 = g.f32();
1658            let v9 = g.f32();
1659            let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1660            let v11 = (if (v1 == 3) {
1661                crate::defs::p754::types::ParticleData::Case3({
1662                    let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1663                    crate::defs::p754::types::ParticleDataCase3 { block_state: v12 }
1664                })
1665            } else if (v1 == 14) {
1666                crate::defs::p754::types::ParticleData::Case14({
1667                    let v13 = g.f32();
1668                    let v14 = g.f32();
1669                    let v15 = g.f32();
1670                    let v16 = g.f32();
1671                    crate::defs::p754::types::ParticleDataCase14 {
1672                        red: v13,
1673                        green: v14,
1674                        blue: v15,
1675                        scale: v16,
1676                    }
1677                })
1678            } else if (v1 == 23) {
1679                crate::defs::p754::types::ParticleData::Case23({
1680                    let v17 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1681                    crate::defs::p754::types::ParticleDataCase23 { block_state: v17 }
1682                })
1683            } else if (v1 == 34) {
1684                crate::defs::p754::types::ParticleData::Case34({
1685                    let v18 = <crate::types::slot::modern::Slot as Generate>::generate(g);
1686                    crate::defs::p754::types::ParticleDataCase34 { item: v18 }
1687                })
1688            } else {
1689                crate::defs::p754::types::ParticleData::Other
1690            });
1691            Self {
1692                particle_id: v1,
1693                long_distance: v2,
1694                x: v3,
1695                y: v4,
1696                z: v5,
1697                offset_x: v6,
1698                offset_y: v7,
1699                offset_z: v8,
1700                particle_data: v9,
1701                particles: v10,
1702                data: v11,
1703            }
1704        }
1705    }
1706}
1707
1708#[cfg(feature = "v1_16_5")]
1709/// `update_light` (clientbound play).
1710#[derive(Debug, Clone, PartialEq)]
1711pub struct UpdateLight<const V: i32> {
1712    /// `chunkX`
1713    pub chunk_x: i32,
1714    /// `chunkZ`
1715    pub chunk_z: i32,
1716    /// `trustEdges`
1717    pub trust_edges: bool,
1718    /// `skyLightMask`
1719    pub sky_light_mask: i32,
1720    /// `blockLightMask`
1721    pub block_light_mask: i32,
1722    /// `emptySkyLightMask`
1723    pub empty_sky_light_mask: i32,
1724    /// `emptyBlockLightMask`
1725    pub empty_block_light_mask: i32,
1726    /// `data`
1727    pub data: Bytes,
1728}
1729#[cfg(feature = "v1_16_5")]
1730impl<const V: i32> Decode for UpdateLight<V> {
1731    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1732        Ok({
1733            let v1 = r.read_varint()?;
1734            let v2 = r.read_varint()?;
1735            let v3 = r.read_bool()?;
1736            let v4 = r.read_varint()?;
1737            let v5 = r.read_varint()?;
1738            let v6 = r.read_varint()?;
1739            let v7 = r.read_varint()?;
1740            let v8 = r.read_rest();
1741            Self {
1742                chunk_x: v1,
1743                chunk_z: v2,
1744                trust_edges: v3,
1745                sky_light_mask: v4,
1746                block_light_mask: v5,
1747                empty_sky_light_mask: v6,
1748                empty_block_light_mask: v7,
1749                data: v8,
1750            }
1751        })
1752    }
1753}
1754#[cfg(feature = "v1_16_5")]
1755impl<const V: i32> Encode for UpdateLight<V> {
1756    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1757        w.put_varint((*self).chunk_x);
1758        w.put_varint((*self).chunk_z);
1759        w.put_bool((*self).trust_edges);
1760        w.put_varint((*self).sky_light_mask);
1761        w.put_varint((*self).block_light_mask);
1762        w.put_varint((*self).empty_sky_light_mask);
1763        w.put_varint((*self).empty_block_light_mask);
1764        w.put_slice(&(*self).data);
1765        Ok(())
1766    }
1767}
1768#[cfg(feature = "v1_16_5")]
1769#[cfg(feature = "testgen")]
1770impl<const V: i32> Generate for UpdateLight<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(-2147483648, 2147483647, &[]) as i32);
1775            let v3 = g.bool();
1776            let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1777            let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1778            let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1779            let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1780            let v8 = g.bytes();
1781            Self {
1782                chunk_x: v1,
1783                chunk_z: v2,
1784                trust_edges: v3,
1785                sky_light_mask: v4,
1786                block_light_mask: v5,
1787                empty_sky_light_mask: v6,
1788                empty_block_light_mask: v7,
1789                data: v8,
1790            }
1791        }
1792    }
1793}
1794
1795#[cfg(feature = "v1_16_5")]
1796/// `login` (clientbound play).
1797#[derive(Debug, Clone, PartialEq)]
1798pub struct Login<const V: i32> {
1799    /// `entityId`
1800    pub entity_id: i32,
1801    /// `isHardcore`
1802    pub is_hardcore: bool,
1803    /// `gameMode`
1804    pub game_mode: u8,
1805    /// `previousGameMode`
1806    pub previous_game_mode: u8,
1807    /// `worldNames`
1808    pub world_names: Vec<ByteString>,
1809    /// `dimensionCodec`
1810    pub dimension_codec: RawNbt,
1811    /// `dimension`
1812    pub dimension: RawNbt,
1813    /// `worldName`
1814    pub world_name: ByteString,
1815    /// `hashedSeed`
1816    pub hashed_seed: i64,
1817    /// `maxPlayers`
1818    pub max_players: i32,
1819    /// `viewDistance`
1820    pub view_distance: i32,
1821    /// `reducedDebugInfo`
1822    pub reduced_debug_info: bool,
1823    /// `enableRespawnScreen`
1824    pub enable_respawn_screen: bool,
1825    /// `isDebug`
1826    pub is_debug: bool,
1827    /// `isFlat`
1828    pub is_flat: bool,
1829}
1830#[cfg(feature = "v1_16_5")]
1831impl<const V: i32> Decode for Login<V> {
1832    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1833        Ok({
1834            let v1 = r.read_i32()?;
1835            let v2 = r.read_bool()?;
1836            let v3 = r.read_u8()?;
1837            let v4 = r.read_u8()?;
1838            let v5 = {
1839                let v6 = {
1840                    let c = r.read_varint()?;
1841                    r.check_count(i64::from(c), 1)?
1842                };
1843                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
1844                for _ in 0..v6 {
1845                    v7.push(r.read_string()?);
1846                }
1847                v7
1848            };
1849            let v8 = RawNbt::read(r)?;
1850            let v9 = RawNbt::read(r)?;
1851            let v10 = r.read_string()?;
1852            let v11 = r.read_i64()?;
1853            let v12 = r.read_varint()?;
1854            let v13 = r.read_varint()?;
1855            let v14 = r.read_bool()?;
1856            let v15 = r.read_bool()?;
1857            let v16 = r.read_bool()?;
1858            let v17 = r.read_bool()?;
1859            Self {
1860                entity_id: v1,
1861                is_hardcore: v2,
1862                game_mode: v3,
1863                previous_game_mode: v4,
1864                world_names: v5,
1865                dimension_codec: v8,
1866                dimension: v9,
1867                world_name: v10,
1868                hashed_seed: v11,
1869                max_players: v12,
1870                view_distance: v13,
1871                reduced_debug_info: v14,
1872                enable_respawn_screen: v15,
1873                is_debug: v16,
1874                is_flat: v17,
1875            }
1876        })
1877    }
1878}
1879#[cfg(feature = "v1_16_5")]
1880impl<const V: i32> Encode for Login<V> {
1881    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1882        w.put_i32((*self).entity_id);
1883        w.put_bool((*self).is_hardcore);
1884        w.put_u8((*self).game_mode);
1885        w.put_u8((*self).previous_game_mode);
1886        w.put_len_varint((*self).world_names.len())?;
1887        for v1 in (*self).world_names.iter() {
1888            w.put_string(&(*v1))?;
1889        }
1890        (*self).dimension_codec.write(w);
1891        (*self).dimension.write(w);
1892        w.put_string(&(*self).world_name)?;
1893        w.put_i64((*self).hashed_seed);
1894        w.put_varint((*self).max_players);
1895        w.put_varint((*self).view_distance);
1896        w.put_bool((*self).reduced_debug_info);
1897        w.put_bool((*self).enable_respawn_screen);
1898        w.put_bool((*self).is_debug);
1899        w.put_bool((*self).is_flat);
1900        Ok(())
1901    }
1902}
1903#[cfg(feature = "v1_16_5")]
1904#[cfg(feature = "testgen")]
1905impl<const V: i32> Generate for Login<V> {
1906    fn generate(g: &mut Gen) -> Self {
1907        {
1908            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1909            let v2 = g.bool();
1910            let v3 = (g.int_in(0, 255, &[]) as u8);
1911            let v4 = (g.int_in(0, 255, &[]) as u8);
1912            let v5 = {
1913                let v6 = g.count();
1914                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
1915                for _ in 0..v6 {
1916                    v7.push(g.string());
1917                }
1918                v7
1919            };
1920            let v8 = g.nbt();
1921            let v9 = g.nbt();
1922            let v10 = g.string();
1923            let v11 = g.i64();
1924            let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1925            let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1926            let v14 = g.bool();
1927            let v15 = g.bool();
1928            let v16 = g.bool();
1929            let v17 = g.bool();
1930            Self {
1931                entity_id: v1,
1932                is_hardcore: v2,
1933                game_mode: v3,
1934                previous_game_mode: v4,
1935                world_names: v5,
1936                dimension_codec: v8,
1937                dimension: v9,
1938                world_name: v10,
1939                hashed_seed: v11,
1940                max_players: v12,
1941                view_distance: v13,
1942                reduced_debug_info: v14,
1943                enable_respawn_screen: v15,
1944                is_debug: v16,
1945                is_flat: v17,
1946            }
1947        }
1948    }
1949}
1950
1951#[cfg(feature = "v1_16_5")]
1952/// Nested container.
1953#[derive(Debug, Clone, PartialEq)]
1954pub struct MapIcons {
1955    /// `type`
1956    pub r#type: i32,
1957    /// `x`
1958    pub x: i8,
1959    /// `z`
1960    pub z: i8,
1961    /// `direction`
1962    pub direction: u8,
1963    /// `displayName`
1964    pub display_name: Option<ByteString>,
1965}
1966
1967#[cfg(feature = "v1_16_5")]
1968/// `map` (clientbound play).
1969#[derive(Debug, Clone, PartialEq)]
1970pub struct Map<const V: i32> {
1971    /// `itemDamage`
1972    pub item_damage: i32,
1973    /// `scale`
1974    pub scale: i8,
1975    /// `trackingPosition`
1976    pub tracking_position: bool,
1977    /// `locked`
1978    pub locked: bool,
1979    /// `icons`
1980    pub icons: Vec<crate::defs::p754::play::clientbound::MapIcons>,
1981    /// `columns`
1982    pub columns: i8,
1983    /// `rows`
1984    pub rows: Option<i8>,
1985    /// `x`
1986    pub x: Option<i8>,
1987    /// `y`
1988    pub y: Option<i8>,
1989    /// `data`
1990    pub data: Option<Bytes>,
1991}
1992#[cfg(feature = "v1_16_5")]
1993impl<const V: i32> Decode for Map<V> {
1994    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1995        Ok({
1996            let v1 = r.read_varint()?;
1997            let v2 = r.read_i8()?;
1998            let v3 = r.read_bool()?;
1999            let v4 = r.read_bool()?;
2000            let v5 = {
2001                let v6 = {
2002                    let c = r.read_varint()?;
2003                    r.check_count(i64::from(c), 5)?
2004                };
2005                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
2006                for _ in 0..v6 {
2007                    v7.push({
2008                        let v8 = r.read_varint()?;
2009                        let v9 = r.read_i8()?;
2010                        let v10 = r.read_i8()?;
2011                        let v11 = r.read_u8()?;
2012                        let v12 = if r.read_bool()? {
2013                            Some(r.read_string()?)
2014                        } else {
2015                            None
2016                        };
2017                        crate::defs::p754::play::clientbound::MapIcons {
2018                            r#type: v8,
2019                            x: v9,
2020                            z: v10,
2021                            direction: v11,
2022                            display_name: v12,
2023                        }
2024                    });
2025                }
2026                v7
2027            };
2028            let v13 = r.read_i8()?;
2029            let v14 = if !(v13 == 0) {
2030                Some(r.read_i8()?)
2031            } else {
2032                None
2033            };
2034            let v15 = if !(v13 == 0) {
2035                Some(r.read_i8()?)
2036            } else {
2037                None
2038            };
2039            let v16 = if !(v13 == 0) {
2040                Some(r.read_i8()?)
2041            } else {
2042                None
2043            };
2044            let v17 = if !(v13 == 0) {
2045                Some(r.read_byte_array()?)
2046            } else {
2047                None
2048            };
2049            Self {
2050                item_damage: v1,
2051                scale: v2,
2052                tracking_position: v3,
2053                locked: v4,
2054                icons: v5,
2055                columns: v13,
2056                rows: v14,
2057                x: v15,
2058                y: v16,
2059                data: v17,
2060            }
2061        })
2062    }
2063}
2064#[cfg(feature = "v1_16_5")]
2065impl<const V: i32> Encode for Map<V> {
2066    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2067        w.put_varint((*self).item_damage);
2068        w.put_i8((*self).scale);
2069        w.put_bool((*self).tracking_position);
2070        w.put_bool((*self).locked);
2071        w.put_len_varint((*self).icons.len())?;
2072        for v1 in (*self).icons.iter() {
2073            w.put_varint((*v1).r#type);
2074            w.put_i8((*v1).x);
2075            w.put_i8((*v1).z);
2076            w.put_u8((*v1).direction);
2077            match &(*v1).display_name {
2078                Some(v2) => {
2079                    w.put_u8(1);
2080                    w.put_string(&(*v2))?;
2081                }
2082                None => w.put_u8(0),
2083            }
2084        }
2085        w.put_i8((*self).columns);
2086        match (&(*self).rows, !((*self).columns == 0)) {
2087            (Some(v3), true) => {
2088                w.put_i8((*v3));
2089            }
2090            (None, false) => {}
2091            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
2092        }
2093        match (&(*self).x, !((*self).columns == 0)) {
2094            (Some(v4), true) => {
2095                w.put_i8((*v4));
2096            }
2097            (None, false) => {}
2098            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
2099        }
2100        match (&(*self).y, !((*self).columns == 0)) {
2101            (Some(v5), true) => {
2102                w.put_i8((*v5));
2103            }
2104            (None, false) => {}
2105            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
2106        }
2107        match (&(*self).data, !((*self).columns == 0)) {
2108            (Some(v6), true) => {
2109                w.put_byte_array(&(*v6))?;
2110            }
2111            (None, false) => {}
2112            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
2113        }
2114        Ok(())
2115    }
2116}
2117#[cfg(feature = "v1_16_5")]
2118#[cfg(feature = "testgen")]
2119impl<const V: i32> Generate for Map<V> {
2120    fn generate(g: &mut Gen) -> Self {
2121        {
2122            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2123            let v2 = (g.int_in(-128, 127, &[]) as i8);
2124            let v3 = g.bool();
2125            let v4 = g.bool();
2126            let v5 = {
2127                let v6 = g.count();
2128                let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
2129                for _ in 0..v6 {
2130                    v7.push({
2131                        let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2132                        let v9 = (g.int_in(-128, 127, &[]) as i8);
2133                        let v10 = (g.int_in(-128, 127, &[]) as i8);
2134                        let v11 = (g.int_in(0, 255, &[]) as u8);
2135                        let v12 = if g.bool() { Some(g.string()) } else { None };
2136                        crate::defs::p754::play::clientbound::MapIcons {
2137                            r#type: v8,
2138                            x: v9,
2139                            z: v10,
2140                            direction: v11,
2141                            display_name: v12,
2142                        }
2143                    });
2144                }
2145                v7
2146            };
2147            let v13 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
2148            let v14 = if !(v13 == 0) {
2149                Some((g.int_in(-128, 127, &[]) as i8))
2150            } else {
2151                None
2152            };
2153            let v15 = if !(v13 == 0) {
2154                Some((g.int_in(-128, 127, &[]) as i8))
2155            } else {
2156                None
2157            };
2158            let v16 = if !(v13 == 0) {
2159                Some((g.int_in(-128, 127, &[]) as i8))
2160            } else {
2161                None
2162            };
2163            let v17 = if !(v13 == 0) { Some(g.bytes()) } else { None };
2164            Self {
2165                item_damage: v1,
2166                scale: v2,
2167                tracking_position: v3,
2168                locked: v4,
2169                icons: v5,
2170                columns: v13,
2171                rows: v14,
2172                x: v15,
2173                y: v16,
2174                data: v17,
2175            }
2176        }
2177    }
2178}
2179
2180#[cfg(feature = "v1_16_5")]
2181/// Nested container.
2182#[derive(Debug, Clone, PartialEq)]
2183pub struct TradeListTrades {
2184    /// `inputItem1`
2185    pub input_item1: crate::types::slot::modern::Slot,
2186    /// `outputItem`
2187    pub output_item: crate::types::slot::modern::Slot,
2188    /// `inputItem2`
2189    pub input_item2: Option<crate::types::slot::modern::Slot>,
2190    /// `tradeDisabled`
2191    pub trade_disabled: bool,
2192    /// `nbTradeUses`
2193    pub nb_trade_uses: i32,
2194    /// `maximumNbTradeUses`
2195    pub maximum_nb_trade_uses: i32,
2196    /// `xp`
2197    pub xp: i32,
2198    /// `specialPrice`
2199    pub special_price: i32,
2200    /// `priceMultiplier`
2201    pub price_multiplier: f32,
2202    /// `demand`
2203    pub demand: i32,
2204}
2205
2206#[cfg(feature = "v1_16_5")]
2207/// `trade_list` (clientbound play).
2208#[derive(Debug, Clone, PartialEq)]
2209pub struct TradeList<const V: i32> {
2210    /// `windowId`
2211    pub window_id: i32,
2212    /// `trades`
2213    pub trades: Vec<crate::defs::p754::play::clientbound::TradeListTrades>,
2214    /// `villagerLevel`
2215    pub villager_level: i32,
2216    /// `experience`
2217    pub experience: i32,
2218    /// `isRegularVillager`
2219    pub is_regular_villager: bool,
2220    /// `canRestock`
2221    pub can_restock: bool,
2222}
2223#[cfg(feature = "v1_16_5")]
2224impl<const V: i32> Decode for TradeList<V> {
2225    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2226        Ok({
2227            let v1 = r.read_varint()?;
2228            let v2 = {
2229                let v3 = {
2230                    let c = r.read_u8()?;
2231                    r.check_count(i64::from(c), 28)?
2232                };
2233                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2234                for _ in 0..v3 {
2235                    v4.push({
2236                        let v5 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
2237                        let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
2238                        let v7 = if r.read_bool()? {
2239                            Some(<crate::types::slot::modern::Slot as Decode>::decode(r)?)
2240                        } else {
2241                            None
2242                        };
2243                        let v8 = r.read_bool()?;
2244                        let v9 = r.read_i32()?;
2245                        let v10 = r.read_i32()?;
2246                        let v11 = r.read_i32()?;
2247                        let v12 = r.read_i32()?;
2248                        let v13 = r.read_f32()?;
2249                        let v14 = r.read_i32()?;
2250                        crate::defs::p754::play::clientbound::TradeListTrades {
2251                            input_item1: v5,
2252                            output_item: v6,
2253                            input_item2: v7,
2254                            trade_disabled: v8,
2255                            nb_trade_uses: v9,
2256                            maximum_nb_trade_uses: v10,
2257                            xp: v11,
2258                            special_price: v12,
2259                            price_multiplier: v13,
2260                            demand: v14,
2261                        }
2262                    });
2263                }
2264                v4
2265            };
2266            let v15 = r.read_varint()?;
2267            let v16 = r.read_varint()?;
2268            let v17 = r.read_bool()?;
2269            let v18 = r.read_bool()?;
2270            Self {
2271                window_id: v1,
2272                trades: v2,
2273                villager_level: v15,
2274                experience: v16,
2275                is_regular_villager: v17,
2276                can_restock: v18,
2277            }
2278        })
2279    }
2280}
2281#[cfg(feature = "v1_16_5")]
2282impl<const V: i32> Encode for TradeList<V> {
2283    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2284        w.put_varint((*self).window_id);
2285        w.put_u8(crate::codec::count_u8((*self).trades.len())?);
2286        for v1 in (*self).trades.iter() {
2287            (*v1).input_item1.encode(w)?;
2288            (*v1).output_item.encode(w)?;
2289            match &(*v1).input_item2 {
2290                Some(v2) => {
2291                    w.put_u8(1);
2292                    (*v2).encode(w)?;
2293                }
2294                None => w.put_u8(0),
2295            }
2296            w.put_bool((*v1).trade_disabled);
2297            w.put_i32((*v1).nb_trade_uses);
2298            w.put_i32((*v1).maximum_nb_trade_uses);
2299            w.put_i32((*v1).xp);
2300            w.put_i32((*v1).special_price);
2301            w.put_f32((*v1).price_multiplier);
2302            w.put_i32((*v1).demand);
2303        }
2304        w.put_varint((*self).villager_level);
2305        w.put_varint((*self).experience);
2306        w.put_bool((*self).is_regular_villager);
2307        w.put_bool((*self).can_restock);
2308        Ok(())
2309    }
2310}
2311#[cfg(feature = "v1_16_5")]
2312#[cfg(feature = "testgen")]
2313impl<const V: i32> Generate for TradeList<V> {
2314    fn generate(g: &mut Gen) -> Self {
2315        {
2316            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2317            let v2 = {
2318                let v3 = g.count();
2319                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
2320                for _ in 0..v3 {
2321                    v4.push({
2322                        let v5 = <crate::types::slot::modern::Slot as Generate>::generate(g);
2323                        let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
2324                        let v7 = if g.bool() {
2325                            Some(<crate::types::slot::modern::Slot as Generate>::generate(g))
2326                        } else {
2327                            None
2328                        };
2329                        let v8 = g.bool();
2330                        let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2331                        let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2332                        let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2333                        let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2334                        let v13 = g.f32();
2335                        let v14 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2336                        crate::defs::p754::play::clientbound::TradeListTrades {
2337                            input_item1: v5,
2338                            output_item: v6,
2339                            input_item2: v7,
2340                            trade_disabled: v8,
2341                            nb_trade_uses: v9,
2342                            maximum_nb_trade_uses: v10,
2343                            xp: v11,
2344                            special_price: v12,
2345                            price_multiplier: v13,
2346                            demand: v14,
2347                        }
2348                    });
2349                }
2350                v4
2351            };
2352            let v15 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2353            let v16 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2354            let v17 = g.bool();
2355            let v18 = g.bool();
2356            Self {
2357                window_id: v1,
2358                trades: v2,
2359                villager_level: v15,
2360                experience: v16,
2361                is_regular_villager: v17,
2362                can_restock: v18,
2363            }
2364        }
2365    }
2366}
2367
2368#[cfg(feature = "v1_16_5")]
2369/// `open_book` (clientbound play).
2370#[derive(Debug, Clone, PartialEq)]
2371pub struct OpenBook<const V: i32> {
2372    /// `hand`
2373    pub hand: i32,
2374}
2375#[cfg(feature = "v1_16_5")]
2376impl<const V: i32> Decode for OpenBook<V> {
2377    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2378        Ok({
2379            let v1 = r.read_varint()?;
2380            Self { hand: v1 }
2381        })
2382    }
2383}
2384#[cfg(feature = "v1_16_5")]
2385impl<const V: i32> Encode for OpenBook<V> {
2386    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2387        w.put_varint((*self).hand);
2388        Ok(())
2389    }
2390}
2391#[cfg(feature = "v1_16_5")]
2392#[cfg(feature = "testgen")]
2393impl<const V: i32> Generate for OpenBook<V> {
2394    fn generate(g: &mut Gen) -> Self {
2395        {
2396            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2397            Self { hand: v1 }
2398        }
2399    }
2400}
2401
2402#[cfg(feature = "v1_16_5")]
2403/// `open_window` (clientbound play).
2404#[derive(Debug, Clone, PartialEq)]
2405pub struct OpenWindow<const V: i32> {
2406    /// `windowId`
2407    pub window_id: i32,
2408    /// `inventoryType`
2409    pub inventory_type: i32,
2410    /// `windowTitle`
2411    pub window_title: ByteString,
2412}
2413#[cfg(feature = "v1_16_5")]
2414impl<const V: i32> Decode for OpenWindow<V> {
2415    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2416        Ok({
2417            let v1 = r.read_varint()?;
2418            let v2 = r.read_varint()?;
2419            let v3 = r.read_string()?;
2420            Self {
2421                window_id: v1,
2422                inventory_type: v2,
2423                window_title: v3,
2424            }
2425        })
2426    }
2427}
2428#[cfg(feature = "v1_16_5")]
2429impl<const V: i32> Encode for OpenWindow<V> {
2430    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2431        w.put_varint((*self).window_id);
2432        w.put_varint((*self).inventory_type);
2433        w.put_string(&(*self).window_title)?;
2434        Ok(())
2435    }
2436}
2437#[cfg(feature = "v1_16_5")]
2438#[cfg(feature = "testgen")]
2439impl<const V: i32> Generate for OpenWindow<V> {
2440    fn generate(g: &mut Gen) -> Self {
2441        {
2442            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2443            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2444            let v3 = g.string();
2445            Self {
2446                window_id: v1,
2447                inventory_type: v2,
2448                window_title: v3,
2449            }
2450        }
2451    }
2452}
2453
2454#[cfg(feature = "v1_16_5")]
2455/// `open_sign_entity` (clientbound play).
2456#[derive(Debug, Clone, PartialEq)]
2457pub struct OpenSignEntity<const V: i32> {
2458    /// `location`
2459    pub location: BlockPos,
2460}
2461#[cfg(feature = "v1_16_5")]
2462impl<const V: i32> Decode for OpenSignEntity<V> {
2463    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2464        Ok({
2465            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
2466            Self { location: v1 }
2467        })
2468    }
2469}
2470#[cfg(feature = "v1_16_5")]
2471impl<const V: i32> Encode for OpenSignEntity<V> {
2472    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2473        (*self).location.write(w, PositionLayout::Xzy)?;
2474        Ok(())
2475    }
2476}
2477#[cfg(feature = "v1_16_5")]
2478#[cfg(feature = "testgen")]
2479impl<const V: i32> Generate for OpenSignEntity<V> {
2480    fn generate(g: &mut Gen) -> Self {
2481        {
2482            let v1 = g.position();
2483            Self { location: v1 }
2484        }
2485    }
2486}
2487
2488#[cfg(feature = "v1_16_5")]
2489/// `craft_recipe_response` (clientbound play).
2490#[derive(Debug, Clone, PartialEq)]
2491pub struct CraftRecipeResponse<const V: i32> {
2492    /// `windowId`
2493    pub window_id: i8,
2494    /// `recipe`
2495    pub recipe: ByteString,
2496}
2497#[cfg(feature = "v1_16_5")]
2498impl<const V: i32> Decode for CraftRecipeResponse<V> {
2499    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2500        Ok({
2501            let v1 = r.read_i8()?;
2502            let v2 = r.read_string()?;
2503            Self {
2504                window_id: v1,
2505                recipe: v2,
2506            }
2507        })
2508    }
2509}
2510#[cfg(feature = "v1_16_5")]
2511impl<const V: i32> Encode for CraftRecipeResponse<V> {
2512    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2513        w.put_i8((*self).window_id);
2514        w.put_string(&(*self).recipe)?;
2515        Ok(())
2516    }
2517}
2518#[cfg(feature = "v1_16_5")]
2519#[cfg(feature = "testgen")]
2520impl<const V: i32> Generate for CraftRecipeResponse<V> {
2521    fn generate(g: &mut Gen) -> Self {
2522        {
2523            let v1 = (g.int_in(-128, 127, &[]) as i8);
2524            let v2 = g.string();
2525            Self {
2526                window_id: v1,
2527                recipe: v2,
2528            }
2529        }
2530    }
2531}
2532
2533#[cfg(feature = "v1_16_5")]
2534/// `face_player` (clientbound play).
2535#[derive(Debug, Clone, PartialEq)]
2536pub struct FacePlayer<const V: i32> {
2537    /// `feet_eyes`
2538    pub feet_eyes: i32,
2539    /// `x`
2540    pub x: f64,
2541    /// `y`
2542    pub y: f64,
2543    /// `z`
2544    pub z: f64,
2545    /// `isEntity`
2546    pub is_entity: bool,
2547    /// `entityId`
2548    pub entity_id: Option<i32>,
2549    /// `entity_feet_eyes`
2550    pub entity_feet_eyes: Option<ByteString>,
2551}
2552#[cfg(feature = "v1_16_5")]
2553impl<const V: i32> Decode for FacePlayer<V> {
2554    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2555        Ok({
2556            let v1 = r.read_varint()?;
2557            let v2 = r.read_f64()?;
2558            let v3 = r.read_f64()?;
2559            let v4 = r.read_f64()?;
2560            let v5 = r.read_bool()?;
2561            let v6 = if v5 { Some(r.read_varint()?) } else { None };
2562            let v7 = if v5 { Some(r.read_string()?) } else { None };
2563            Self {
2564                feet_eyes: v1,
2565                x: v2,
2566                y: v3,
2567                z: v4,
2568                is_entity: v5,
2569                entity_id: v6,
2570                entity_feet_eyes: v7,
2571            }
2572        })
2573    }
2574}
2575#[cfg(feature = "v1_16_5")]
2576impl<const V: i32> Encode for FacePlayer<V> {
2577    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2578        w.put_varint((*self).feet_eyes);
2579        w.put_f64((*self).x);
2580        w.put_f64((*self).y);
2581        w.put_f64((*self).z);
2582        w.put_bool((*self).is_entity);
2583        match (&(*self).entity_id, (*self).is_entity) {
2584            (Some(v1), true) => {
2585                w.put_varint((*v1));
2586            }
2587            (None, false) => {}
2588            _ => {
2589                return Err(EncodeError::SwitchMismatch(
2590                    "play.clientbound.face_player.entityId",
2591                ));
2592            }
2593        }
2594        match (&(*self).entity_feet_eyes, (*self).is_entity) {
2595            (Some(v2), true) => {
2596                w.put_string(&(*v2))?;
2597            }
2598            (None, false) => {}
2599            _ => {
2600                return Err(EncodeError::SwitchMismatch(
2601                    "play.clientbound.face_player.entity_feet_eyes",
2602                ));
2603            }
2604        }
2605        Ok(())
2606    }
2607}
2608#[cfg(feature = "v1_16_5")]
2609#[cfg(feature = "testgen")]
2610impl<const V: i32> Generate for FacePlayer<V> {
2611    fn generate(g: &mut Gen) -> Self {
2612        {
2613            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2614            let v2 = g.f64();
2615            let v3 = g.f64();
2616            let v4 = g.f64();
2617            let v5 = g.bool();
2618            let v6 = if v5 {
2619                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2620            } else {
2621                None
2622            };
2623            let v7 = if v5 { Some(g.string()) } else { None };
2624            Self {
2625                feet_eyes: v1,
2626                x: v2,
2627                y: v3,
2628                z: v4,
2629                is_entity: v5,
2630                entity_id: v6,
2631                entity_feet_eyes: v7,
2632            }
2633        }
2634    }
2635}
2636
2637#[cfg(feature = "v1_16_5")]
2638/// `unlock_recipes` (clientbound play).
2639#[derive(Debug, Clone, PartialEq)]
2640pub struct UnlockRecipes<const V: i32> {
2641    /// `action`
2642    pub action: i32,
2643    /// `craftingBookOpen`
2644    pub crafting_book_open: bool,
2645    /// `filteringCraftable`
2646    pub filtering_craftable: bool,
2647    /// `smeltingBookOpen`
2648    pub smelting_book_open: bool,
2649    /// `filteringSmeltable`
2650    pub filtering_smeltable: bool,
2651    /// `blastFurnaceOpen`
2652    pub blast_furnace_open: bool,
2653    /// `filteringBlastFurnace`
2654    pub filtering_blast_furnace: bool,
2655    /// `smokerBookOpen`
2656    pub smoker_book_open: bool,
2657    /// `filteringSmoker`
2658    pub filtering_smoker: bool,
2659    /// `recipes1`
2660    pub recipes1: Vec<ByteString>,
2661    /// `recipes2`
2662    pub recipes2: Option<Vec<ByteString>>,
2663}
2664#[cfg(feature = "v1_16_5")]
2665impl<const V: i32> Decode for UnlockRecipes<V> {
2666    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2667        Ok({
2668            let v1 = r.read_varint()?;
2669            let v2 = r.read_bool()?;
2670            let v3 = r.read_bool()?;
2671            let v4 = r.read_bool()?;
2672            let v5 = r.read_bool()?;
2673            let v6 = r.read_bool()?;
2674            let v7 = r.read_bool()?;
2675            let v8 = r.read_bool()?;
2676            let v9 = r.read_bool()?;
2677            let v10 = {
2678                let v11 = {
2679                    let c = r.read_varint()?;
2680                    r.check_count(i64::from(c), 1)?
2681                };
2682                let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
2683                for _ in 0..v11 {
2684                    v12.push(r.read_string()?);
2685                }
2686                v12
2687            };
2688            let v13 = if (v1 == 0) {
2689                Some({
2690                    let v14 = {
2691                        let c = r.read_varint()?;
2692                        r.check_count(i64::from(c), 1)?
2693                    };
2694                    let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
2695                    for _ in 0..v14 {
2696                        v15.push(r.read_string()?);
2697                    }
2698                    v15
2699                })
2700            } else {
2701                None
2702            };
2703            Self {
2704                action: v1,
2705                crafting_book_open: v2,
2706                filtering_craftable: v3,
2707                smelting_book_open: v4,
2708                filtering_smeltable: v5,
2709                blast_furnace_open: v6,
2710                filtering_blast_furnace: v7,
2711                smoker_book_open: v8,
2712                filtering_smoker: v9,
2713                recipes1: v10,
2714                recipes2: v13,
2715            }
2716        })
2717    }
2718}
2719#[cfg(feature = "v1_16_5")]
2720impl<const V: i32> Encode for UnlockRecipes<V> {
2721    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2722        w.put_varint((*self).action);
2723        w.put_bool((*self).crafting_book_open);
2724        w.put_bool((*self).filtering_craftable);
2725        w.put_bool((*self).smelting_book_open);
2726        w.put_bool((*self).filtering_smeltable);
2727        w.put_bool((*self).blast_furnace_open);
2728        w.put_bool((*self).filtering_blast_furnace);
2729        w.put_bool((*self).smoker_book_open);
2730        w.put_bool((*self).filtering_smoker);
2731        w.put_len_varint((*self).recipes1.len())?;
2732        for v1 in (*self).recipes1.iter() {
2733            w.put_string(&(*v1))?;
2734        }
2735        match (&(*self).recipes2, ((*self).action == 0)) {
2736            (Some(v2), true) => {
2737                w.put_len_varint((*v2).len())?;
2738                for v3 in (*v2).iter() {
2739                    w.put_string(&(*v3))?;
2740                }
2741            }
2742            (None, false) => {}
2743            _ => {
2744                return Err(EncodeError::SwitchMismatch(
2745                    "play.clientbound.unlock_recipes.recipes2",
2746                ));
2747            }
2748        }
2749        Ok(())
2750    }
2751}
2752#[cfg(feature = "v1_16_5")]
2753#[cfg(feature = "testgen")]
2754impl<const V: i32> Generate for UnlockRecipes<V> {
2755    fn generate(g: &mut Gen) -> Self {
2756        {
2757            let v1 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
2758            let v2 = g.bool();
2759            let v3 = g.bool();
2760            let v4 = g.bool();
2761            let v5 = g.bool();
2762            let v6 = g.bool();
2763            let v7 = g.bool();
2764            let v8 = g.bool();
2765            let v9 = g.bool();
2766            let v10 = {
2767                let v11 = g.count();
2768                let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
2769                for _ in 0..v11 {
2770                    v12.push(g.string());
2771                }
2772                v12
2773            };
2774            let v13 = if (v1 == 0) {
2775                Some({
2776                    let v14 = g.count();
2777                    let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
2778                    for _ in 0..v14 {
2779                        v15.push(g.string());
2780                    }
2781                    v15
2782                })
2783            } else {
2784                None
2785            };
2786            Self {
2787                action: v1,
2788                crafting_book_open: v2,
2789                filtering_craftable: v3,
2790                smelting_book_open: v4,
2791                filtering_smeltable: v5,
2792                blast_furnace_open: v6,
2793                filtering_blast_furnace: v7,
2794                smoker_book_open: v8,
2795                filtering_smoker: v9,
2796                recipes1: v10,
2797                recipes2: v13,
2798            }
2799        }
2800    }
2801}
2802
2803#[cfg(feature = "v1_16_5")]
2804/// `respawn` (clientbound play).
2805#[derive(Debug, Clone, PartialEq)]
2806pub struct Respawn<const V: i32> {
2807    /// `dimension`
2808    pub dimension: RawNbt,
2809    /// `worldName`
2810    pub world_name: ByteString,
2811    /// `hashedSeed`
2812    pub hashed_seed: i64,
2813    /// `gamemode`
2814    pub gamemode: u8,
2815    /// `previousGamemode`
2816    pub previous_gamemode: u8,
2817    /// `isDebug`
2818    pub is_debug: bool,
2819    /// `isFlat`
2820    pub is_flat: bool,
2821    /// `copyMetadata`
2822    pub copy_metadata: bool,
2823}
2824#[cfg(feature = "v1_16_5")]
2825impl<const V: i32> Decode for Respawn<V> {
2826    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2827        Ok({
2828            let v1 = RawNbt::read(r)?;
2829            let v2 = r.read_string()?;
2830            let v3 = r.read_i64()?;
2831            let v4 = r.read_u8()?;
2832            let v5 = r.read_u8()?;
2833            let v6 = r.read_bool()?;
2834            let v7 = r.read_bool()?;
2835            let v8 = r.read_bool()?;
2836            Self {
2837                dimension: v1,
2838                world_name: v2,
2839                hashed_seed: v3,
2840                gamemode: v4,
2841                previous_gamemode: v5,
2842                is_debug: v6,
2843                is_flat: v7,
2844                copy_metadata: v8,
2845            }
2846        })
2847    }
2848}
2849#[cfg(feature = "v1_16_5")]
2850impl<const V: i32> Encode for Respawn<V> {
2851    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2852        (*self).dimension.write(w);
2853        w.put_string(&(*self).world_name)?;
2854        w.put_i64((*self).hashed_seed);
2855        w.put_u8((*self).gamemode);
2856        w.put_u8((*self).previous_gamemode);
2857        w.put_bool((*self).is_debug);
2858        w.put_bool((*self).is_flat);
2859        w.put_bool((*self).copy_metadata);
2860        Ok(())
2861    }
2862}
2863#[cfg(feature = "v1_16_5")]
2864#[cfg(feature = "testgen")]
2865impl<const V: i32> Generate for Respawn<V> {
2866    fn generate(g: &mut Gen) -> Self {
2867        {
2868            let v1 = g.nbt();
2869            let v2 = g.string();
2870            let v3 = g.i64();
2871            let v4 = (g.int_in(0, 255, &[]) as u8);
2872            let v5 = (g.int_in(0, 255, &[]) as u8);
2873            let v6 = g.bool();
2874            let v7 = g.bool();
2875            let v8 = g.bool();
2876            Self {
2877                dimension: v1,
2878                world_name: v2,
2879                hashed_seed: v3,
2880                gamemode: v4,
2881                previous_gamemode: v5,
2882                is_debug: v6,
2883                is_flat: v7,
2884                copy_metadata: v8,
2885            }
2886        }
2887    }
2888}
2889
2890#[cfg(feature = "v1_16_5")]
2891/// Packed bit field.
2892#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
2893pub struct MultiBlockChangeChunkCoordinates {
2894    /// `x` (22 bits)
2895    pub x: i32,
2896    /// `z` (22 bits)
2897    pub z: i32,
2898    /// `y` (20 bits)
2899    pub y: u32,
2900}
2901
2902#[cfg(feature = "v1_16_5")]
2903/// `multi_block_change` (clientbound play).
2904#[derive(Debug, Clone, PartialEq)]
2905pub struct MultiBlockChange<const V: i32> {
2906    /// `chunkCoordinates`
2907    pub chunk_coordinates: crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates,
2908    /// `notTrustEdges`
2909    pub not_trust_edges: bool,
2910    /// `records`
2911    pub records: Vec<i64>,
2912}
2913#[cfg(feature = "v1_16_5")]
2914impl<const V: i32> Decode for MultiBlockChange<V> {
2915    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2916        Ok({
2917            let v1 = {
2918                let v2 = r.read_u64()?;
2919                crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates {
2920                    x: ((((((v2 >> 42) & 0x3fffff) << 42) as i64) >> 42) as i32),
2921                    z: ((((((v2 >> 20) & 0x3fffff) << 42) as i64) >> 42) as i32),
2922                    y: (((v2 >> 0) & 0xfffff) as u32),
2923                }
2924            };
2925            let v3 = r.read_bool()?;
2926            let v4 = {
2927                let v5 = {
2928                    let c = r.read_varint()?;
2929                    r.check_count(i64::from(c), 1)?
2930                };
2931                let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
2932                for _ in 0..v5 {
2933                    v6.push(r.read_varlong()?);
2934                }
2935                v6
2936            };
2937            Self {
2938                chunk_coordinates: v1,
2939                not_trust_edges: v3,
2940                records: v4,
2941            }
2942        })
2943    }
2944}
2945#[cfg(feature = "v1_16_5")]
2946impl<const V: i32> Encode for MultiBlockChange<V> {
2947    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2948        {
2949            let mut bits: u64 = 0;
2950            {
2951                let x = i128::from((*self).chunk_coordinates.x);
2952                if x < -2097152 || x > 2097151 {
2953                    return Err(EncodeError::OutOfRange("x"));
2954                }
2955                bits = (bits << 22) | ((x as u64) & 0x3fffff);
2956            }
2957            {
2958                let x = i128::from((*self).chunk_coordinates.z);
2959                if x < -2097152 || x > 2097151 {
2960                    return Err(EncodeError::OutOfRange("z"));
2961                }
2962                bits = (bits << 22) | ((x as u64) & 0x3fffff);
2963            }
2964            {
2965                let x = i128::from((*self).chunk_coordinates.y);
2966                if x < 0 || x > 1048575 {
2967                    return Err(EncodeError::OutOfRange("y"));
2968                }
2969                bits = (bits << 20) | ((x as u64) & 0xfffff);
2970            }
2971            w.put_u64(bits);
2972        }
2973        w.put_bool((*self).not_trust_edges);
2974        w.put_len_varint((*self).records.len())?;
2975        for v1 in (*self).records.iter() {
2976            w.put_varlong((*v1));
2977        }
2978        Ok(())
2979    }
2980}
2981#[cfg(feature = "v1_16_5")]
2982#[cfg(feature = "testgen")]
2983impl<const V: i32> Generate for MultiBlockChange<V> {
2984    fn generate(g: &mut Gen) -> Self {
2985        {
2986            let v1 = {
2987                crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates {
2988                    x: (g.int_in(-2097152, 2097151, &[]) as i32),
2989                    z: (g.int_in(-2097152, 2097151, &[]) as i32),
2990                    y: (g.int_in(0, 1048575, &[]) as u32),
2991                }
2992            };
2993            let v3 = g.bool();
2994            let v4 = {
2995                let v5 = g.count();
2996                let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
2997                for _ in 0..v5 {
2998                    v6.push(g.varlong());
2999                }
3000                v6
3001            };
3002            Self {
3003                chunk_coordinates: v1,
3004                not_trust_edges: v3,
3005                records: v4,
3006            }
3007        }
3008    }
3009}
3010
3011#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3012/// `update_view_position` (clientbound play).
3013#[derive(Debug, Clone, PartialEq)]
3014pub struct UpdateViewPosition<const V: i32> {
3015    /// `chunkX`
3016    pub chunk_x: i32,
3017    /// `chunkZ`
3018    pub chunk_z: i32,
3019}
3020#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3021impl<const V: i32> Decode for UpdateViewPosition<V> {
3022    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3023        Ok({
3024            let v1 = r.read_varint()?;
3025            let v2 = r.read_varint()?;
3026            Self {
3027                chunk_x: v1,
3028                chunk_z: v2,
3029            }
3030        })
3031    }
3032}
3033#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3034impl<const V: i32> Encode for UpdateViewPosition<V> {
3035    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3036        w.put_varint((*self).chunk_x);
3037        w.put_varint((*self).chunk_z);
3038        Ok(())
3039    }
3040}
3041#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3042#[cfg(feature = "testgen")]
3043impl<const V: i32> Generate for UpdateViewPosition<V> {
3044    fn generate(g: &mut Gen) -> Self {
3045        {
3046            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3047            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3048            Self {
3049                chunk_x: v1,
3050                chunk_z: v2,
3051            }
3052        }
3053    }
3054}
3055
3056#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3057/// `update_view_distance` (clientbound play).
3058#[derive(Debug, Clone, PartialEq)]
3059pub struct UpdateViewDistance<const V: i32> {
3060    /// `viewDistance`
3061    pub view_distance: i32,
3062}
3063#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3064impl<const V: i32> Decode for UpdateViewDistance<V> {
3065    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3066        Ok({
3067            let v1 = r.read_varint()?;
3068            Self { view_distance: v1 }
3069        })
3070    }
3071}
3072#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3073impl<const V: i32> Encode for UpdateViewDistance<V> {
3074    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3075        w.put_varint((*self).view_distance);
3076        Ok(())
3077    }
3078}
3079#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
3080#[cfg(feature = "testgen")]
3081impl<const V: i32> Generate for UpdateViewDistance<V> {
3082    fn generate(g: &mut Gen) -> Self {
3083        {
3084            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3085            Self { view_distance: v1 }
3086        }
3087    }
3088}
3089
3090#[cfg(feature = "v1_16_5")]
3091/// `spawn_position` (clientbound play).
3092#[derive(Debug, Clone, PartialEq)]
3093pub struct SpawnPosition<const V: i32> {
3094    /// `location`
3095    pub location: BlockPos,
3096}
3097#[cfg(feature = "v1_16_5")]
3098impl<const V: i32> Decode for SpawnPosition<V> {
3099    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3100        Ok({
3101            let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
3102            Self { location: v1 }
3103        })
3104    }
3105}
3106#[cfg(feature = "v1_16_5")]
3107impl<const V: i32> Encode for SpawnPosition<V> {
3108    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3109        (*self).location.write(w, PositionLayout::Xzy)?;
3110        Ok(())
3111    }
3112}
3113#[cfg(feature = "v1_16_5")]
3114#[cfg(feature = "testgen")]
3115impl<const V: i32> Generate for SpawnPosition<V> {
3116    fn generate(g: &mut Gen) -> Self {
3117        {
3118            let v1 = g.position();
3119            Self { location: v1 }
3120        }
3121    }
3122}
3123
3124#[cfg(feature = "v1_16_5")]
3125/// `entity_metadata` (clientbound play).
3126#[derive(Debug, Clone, PartialEq)]
3127pub struct EntityMetadata<const V: i32> {
3128    /// `entityId`
3129    pub entity_id: i32,
3130    /// `metadata`
3131    pub metadata: Vec<crate::defs::p754::types::EntityMetadataEntry>,
3132}
3133#[cfg(feature = "v1_16_5")]
3134impl<const V: i32> Decode for EntityMetadata<V> {
3135    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3136        Ok({
3137            let v1 = r.read_varint()?;
3138            let v2 = {
3139                let mut v3 = Vec::new();
3140                loop {
3141                    if r.peek_u8()? == 255 {
3142                        r.skip(1)?;
3143                        break;
3144                    }
3145                    v3.push({
3146                        let v4 = r.read_u8()?;
3147                        let v5 = r.read_varint()?;
3148                        let v6 = (if (v5 == 0) {
3149                            crate::defs::p754::types::EntityMetadataValue::Byte(r.read_i8()?)
3150                        } else if (v5 == 1) {
3151                            crate::defs::p754::types::EntityMetadataValue::VarInt(r.read_varint()?)
3152                        } else if (v5 == 2) {
3153                            crate::defs::p754::types::EntityMetadataValue::Float(r.read_f32()?)
3154                        } else if (v5 == 3) {
3155                            crate::defs::p754::types::EntityMetadataValue::String(r.read_string()?)
3156                        } else if (v5 == 4) {
3157                            crate::defs::p754::types::EntityMetadataValue::Chat(r.read_string()?)
3158                        } else if (v5 == 5) {
3159                            crate::defs::p754::types::EntityMetadataValue::OptChat(
3160                                if r.read_bool()? {
3161                                    Some(r.read_string()?)
3162                                } else {
3163                                    None
3164                                },
3165                            )
3166                        } else if (v5 == 6) {
3167                            crate::defs::p754::types::EntityMetadataValue::Slot(
3168                                <crate::types::slot::modern::Slot as Decode>::decode(r)?,
3169                            )
3170                        } else if (v5 == 7) {
3171                            crate::defs::p754::types::EntityMetadataValue::Boolean(r.read_bool()?)
3172                        } else if (v5 == 8) {
3173                            crate::defs::p754::types::EntityMetadataValue::Rotation({
3174                                let v7 = r.read_f32()?;
3175                                let v8 = r.read_f32()?;
3176                                let v9 = r.read_f32()?;
3177                                crate::defs::p47::types::EntityMetadataValueRotation {
3178                                    pitch: v7,
3179                                    yaw: v8,
3180                                    roll: v9,
3181                                }
3182                            })
3183                        } else if (v5 == 9) {
3184                            crate::defs::p754::types::EntityMetadataValue::Position(BlockPos::read(
3185                                r,
3186                                PositionLayout::Xzy,
3187                            )?)
3188                        } else if (v5 == 10) {
3189                            crate::defs::p754::types::EntityMetadataValue::OptPosition(
3190                                if r.read_bool()? {
3191                                    Some(BlockPos::read(r, PositionLayout::Xzy)?)
3192                                } else {
3193                                    None
3194                                },
3195                            )
3196                        } else if (v5 == 11) {
3197                            crate::defs::p754::types::EntityMetadataValue::Direction(
3198                                r.read_varint()?,
3199                            )
3200                        } else if (v5 == 12) {
3201                            crate::defs::p754::types::EntityMetadataValue::OptUuid(
3202                                if r.read_bool()? {
3203                                    Some(r.read_uuid()?)
3204                                } else {
3205                                    None
3206                                },
3207                            )
3208                        } else if (v5 == 13) {
3209                            crate::defs::p754::types::EntityMetadataValue::BlockState(
3210                                r.read_varint()?,
3211                            )
3212                        } else if (v5 == 14) {
3213                            crate::defs::p754::types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
3214                        } else if (v5 == 15) {
3215                            crate::defs::p754::types::EntityMetadataValue::Particle(
3216                                <crate::defs::p754::types::Particle as Decode>::decode(r)?,
3217                            )
3218                        } else if (v5 == 16) {
3219                            crate::defs::p754::types::EntityMetadataValue::VillagerData({
3220                                let v10 = r.read_varint()?;
3221                                let v11 = r.read_varint()?;
3222                                let v12 = r.read_varint()?;
3223                                crate::defs::p754::types::EntityMetadataValueVillagerData {
3224                                    villager_type: v10,
3225                                    villager_profession: v11,
3226                                    level: v12,
3227                                }
3228                            })
3229                        } else if (v5 == 17) {
3230                            crate::defs::p754::types::EntityMetadataValue::OptVarInt(
3231                                r.read_varint()?,
3232                            )
3233                        } else if (v5 == 18) {
3234                            crate::defs::p754::types::EntityMetadataValue::Pose(r.read_varint()?)
3235                        } else {
3236                            crate::defs::p754::types::EntityMetadataValue::Other
3237                        });
3238                        crate::defs::p754::types::EntityMetadataEntry {
3239                            key: v4,
3240                            r#type: v5,
3241                            value: v6,
3242                        }
3243                    });
3244                }
3245                v3
3246            };
3247            Self {
3248                entity_id: v1,
3249                metadata: v2,
3250            }
3251        })
3252    }
3253}
3254#[cfg(feature = "v1_16_5")]
3255impl<const V: i32> Encode for EntityMetadata<V> {
3256    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3257        w.put_varint((*self).entity_id);
3258        for v1 in (*self).metadata.iter() {
3259            let v2 = w.len();
3260            w.put_u8((*v1).key);
3261            w.put_varint((*v1).r#type);
3262            match &(*v1).value {
3263                crate::defs::p754::types::EntityMetadataValue::Byte(v3) => {
3264                    if !((*v1).r#type == 0) {
3265                        return Err(EncodeError::SwitchMismatch(
3266                            "play.clientbound.entity_metadata.metadata.value",
3267                        ));
3268                    }
3269                    w.put_i8((*v3));
3270                }
3271                crate::defs::p754::types::EntityMetadataValue::VarInt(v4) => {
3272                    if !((*v1).r#type == 1) {
3273                        return Err(EncodeError::SwitchMismatch(
3274                            "play.clientbound.entity_metadata.metadata.value",
3275                        ));
3276                    }
3277                    w.put_varint((*v4));
3278                }
3279                crate::defs::p754::types::EntityMetadataValue::Float(v5) => {
3280                    if !((*v1).r#type == 2) {
3281                        return Err(EncodeError::SwitchMismatch(
3282                            "play.clientbound.entity_metadata.metadata.value",
3283                        ));
3284                    }
3285                    w.put_f32((*v5));
3286                }
3287                crate::defs::p754::types::EntityMetadataValue::String(v6) => {
3288                    if !((*v1).r#type == 3) {
3289                        return Err(EncodeError::SwitchMismatch(
3290                            "play.clientbound.entity_metadata.metadata.value",
3291                        ));
3292                    }
3293                    w.put_string(&(*v6))?;
3294                }
3295                crate::defs::p754::types::EntityMetadataValue::Chat(v7) => {
3296                    if !((*v1).r#type == 4) {
3297                        return Err(EncodeError::SwitchMismatch(
3298                            "play.clientbound.entity_metadata.metadata.value",
3299                        ));
3300                    }
3301                    w.put_string(&(*v7))?;
3302                }
3303                crate::defs::p754::types::EntityMetadataValue::OptChat(v8) => {
3304                    if !((*v1).r#type == 5) {
3305                        return Err(EncodeError::SwitchMismatch(
3306                            "play.clientbound.entity_metadata.metadata.value",
3307                        ));
3308                    }
3309                    match &(*v8) {
3310                        Some(v9) => {
3311                            w.put_u8(1);
3312                            w.put_string(&(*v9))?;
3313                        }
3314                        None => w.put_u8(0),
3315                    }
3316                }
3317                crate::defs::p754::types::EntityMetadataValue::Slot(v10) => {
3318                    if !((*v1).r#type == 6) {
3319                        return Err(EncodeError::SwitchMismatch(
3320                            "play.clientbound.entity_metadata.metadata.value",
3321                        ));
3322                    }
3323                    (*v10).encode(w)?;
3324                }
3325                crate::defs::p754::types::EntityMetadataValue::Boolean(v11) => {
3326                    if !((*v1).r#type == 7) {
3327                        return Err(EncodeError::SwitchMismatch(
3328                            "play.clientbound.entity_metadata.metadata.value",
3329                        ));
3330                    }
3331                    w.put_bool((*v11));
3332                }
3333                crate::defs::p754::types::EntityMetadataValue::Rotation(v12) => {
3334                    if !((*v1).r#type == 8) {
3335                        return Err(EncodeError::SwitchMismatch(
3336                            "play.clientbound.entity_metadata.metadata.value",
3337                        ));
3338                    }
3339                    w.put_f32((*v12).pitch);
3340                    w.put_f32((*v12).yaw);
3341                    w.put_f32((*v12).roll);
3342                }
3343                crate::defs::p754::types::EntityMetadataValue::Position(v13) => {
3344                    if !((*v1).r#type == 9) {
3345                        return Err(EncodeError::SwitchMismatch(
3346                            "play.clientbound.entity_metadata.metadata.value",
3347                        ));
3348                    }
3349                    (*v13).write(w, PositionLayout::Xzy)?;
3350                }
3351                crate::defs::p754::types::EntityMetadataValue::OptPosition(v14) => {
3352                    if !((*v1).r#type == 10) {
3353                        return Err(EncodeError::SwitchMismatch(
3354                            "play.clientbound.entity_metadata.metadata.value",
3355                        ));
3356                    }
3357                    match &(*v14) {
3358                        Some(v15) => {
3359                            w.put_u8(1);
3360                            (*v15).write(w, PositionLayout::Xzy)?;
3361                        }
3362                        None => w.put_u8(0),
3363                    }
3364                }
3365                crate::defs::p754::types::EntityMetadataValue::Direction(v16) => {
3366                    if !((*v1).r#type == 11) {
3367                        return Err(EncodeError::SwitchMismatch(
3368                            "play.clientbound.entity_metadata.metadata.value",
3369                        ));
3370                    }
3371                    w.put_varint((*v16));
3372                }
3373                crate::defs::p754::types::EntityMetadataValue::OptUuid(v17) => {
3374                    if !((*v1).r#type == 12) {
3375                        return Err(EncodeError::SwitchMismatch(
3376                            "play.clientbound.entity_metadata.metadata.value",
3377                        ));
3378                    }
3379                    match &(*v17) {
3380                        Some(v18) => {
3381                            w.put_u8(1);
3382                            w.put_uuid(&(*v18));
3383                        }
3384                        None => w.put_u8(0),
3385                    }
3386                }
3387                crate::defs::p754::types::EntityMetadataValue::BlockState(v19) => {
3388                    if !((*v1).r#type == 13) {
3389                        return Err(EncodeError::SwitchMismatch(
3390                            "play.clientbound.entity_metadata.metadata.value",
3391                        ));
3392                    }
3393                    w.put_varint((*v19));
3394                }
3395                crate::defs::p754::types::EntityMetadataValue::Nbt(v20) => {
3396                    if !((*v1).r#type == 14) {
3397                        return Err(EncodeError::SwitchMismatch(
3398                            "play.clientbound.entity_metadata.metadata.value",
3399                        ));
3400                    }
3401                    (*v20).write(w);
3402                }
3403                crate::defs::p754::types::EntityMetadataValue::Particle(v21) => {
3404                    if !((*v1).r#type == 15) {
3405                        return Err(EncodeError::SwitchMismatch(
3406                            "play.clientbound.entity_metadata.metadata.value",
3407                        ));
3408                    }
3409                    (*v21).encode(w)?;
3410                }
3411                crate::defs::p754::types::EntityMetadataValue::VillagerData(v22) => {
3412                    if !((*v1).r#type == 16) {
3413                        return Err(EncodeError::SwitchMismatch(
3414                            "play.clientbound.entity_metadata.metadata.value",
3415                        ));
3416                    }
3417                    w.put_varint((*v22).villager_type);
3418                    w.put_varint((*v22).villager_profession);
3419                    w.put_varint((*v22).level);
3420                }
3421                crate::defs::p754::types::EntityMetadataValue::OptVarInt(v23) => {
3422                    if !((*v1).r#type == 17) {
3423                        return Err(EncodeError::SwitchMismatch(
3424                            "play.clientbound.entity_metadata.metadata.value",
3425                        ));
3426                    }
3427                    w.put_varint((*v23));
3428                }
3429                crate::defs::p754::types::EntityMetadataValue::Pose(v24) => {
3430                    if !((*v1).r#type == 18) {
3431                        return Err(EncodeError::SwitchMismatch(
3432                            "play.clientbound.entity_metadata.metadata.value",
3433                        ));
3434                    }
3435                    w.put_varint((*v24));
3436                }
3437                crate::defs::p754::types::EntityMetadataValue::Other => {
3438                    if !(!(((*v1).r#type == 0)
3439                        || ((*v1).r#type == 1)
3440                        || ((*v1).r#type == 2)
3441                        || ((*v1).r#type == 3)
3442                        || ((*v1).r#type == 4)
3443                        || ((*v1).r#type == 5)
3444                        || ((*v1).r#type == 6)
3445                        || ((*v1).r#type == 7)
3446                        || ((*v1).r#type == 8)
3447                        || ((*v1).r#type == 9)
3448                        || ((*v1).r#type == 10)
3449                        || ((*v1).r#type == 11)
3450                        || ((*v1).r#type == 12)
3451                        || ((*v1).r#type == 13)
3452                        || ((*v1).r#type == 14)
3453                        || ((*v1).r#type == 15)
3454                        || ((*v1).r#type == 16)
3455                        || ((*v1).r#type == 17)
3456                        || ((*v1).r#type == 18)))
3457                    {
3458                        return Err(EncodeError::SwitchMismatch(
3459                            "play.clientbound.entity_metadata.metadata.value",
3460                        ));
3461                    }
3462                }
3463            }
3464            if w.get(v2) == Some(&255) {
3465                return Err(EncodeError::OutOfRange(
3466                    "play.clientbound.entity_metadata.metadata",
3467                ));
3468            }
3469        }
3470        w.put_u8(255);
3471        Ok(())
3472    }
3473}
3474#[cfg(feature = "v1_16_5")]
3475#[cfg(feature = "testgen")]
3476impl<const V: i32> Generate for EntityMetadata<V> {
3477    fn generate(g: &mut Gen) -> Self {
3478        {
3479            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3480            let v2 = {
3481                let n = g.count();
3482                let mut v3 = Vec::with_capacity(n);
3483                for _ in 0..n {
3484                    v3.push(loop {
3485                        let v4 = {
3486                            let v5 = (g.int_in(0, 255, &[]) as u8);
3487                            let v6 = (g.int_in(
3488                                -2147483648,
3489                                2147483647,
3490                                &[
3491                                    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
3492                                    18,
3493                                ],
3494                            ) as i32);
3495                            let v7 = (if (v6 == 0) {
3496                                crate::defs::p754::types::EntityMetadataValue::Byte(
3497                                    (g.int_in(-128, 127, &[]) as i8),
3498                                )
3499                            } else if (v6 == 1) {
3500                                crate::defs::p754::types::EntityMetadataValue::VarInt(
3501                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
3502                                )
3503                            } else if (v6 == 2) {
3504                                crate::defs::p754::types::EntityMetadataValue::Float(g.f32())
3505                            } else if (v6 == 3) {
3506                                crate::defs::p754::types::EntityMetadataValue::String(g.string())
3507                            } else if (v6 == 4) {
3508                                crate::defs::p754::types::EntityMetadataValue::Chat(g.string())
3509                            } else if (v6 == 5) {
3510                                crate::defs::p754::types::EntityMetadataValue::OptChat(
3511                                    if g.bool() { Some(g.string()) } else { None },
3512                                )
3513                            } else if (v6 == 6) {
3514                                crate::defs::p754::types::EntityMetadataValue::Slot(
3515                                    <crate::types::slot::modern::Slot as Generate>::generate(g),
3516                                )
3517                            } else if (v6 == 7) {
3518                                crate::defs::p754::types::EntityMetadataValue::Boolean(g.bool())
3519                            } else if (v6 == 8) {
3520                                crate::defs::p754::types::EntityMetadataValue::Rotation({
3521                                    let v8 = g.f32();
3522                                    let v9 = g.f32();
3523                                    let v10 = g.f32();
3524                                    crate::defs::p47::types::EntityMetadataValueRotation {
3525                                        pitch: v8,
3526                                        yaw: v9,
3527                                        roll: v10,
3528                                    }
3529                                })
3530                            } else if (v6 == 9) {
3531                                crate::defs::p754::types::EntityMetadataValue::Position(
3532                                    g.position(),
3533                                )
3534                            } else if (v6 == 10) {
3535                                crate::defs::p754::types::EntityMetadataValue::OptPosition(
3536                                    if g.bool() { Some(g.position()) } else { None },
3537                                )
3538                            } else if (v6 == 11) {
3539                                crate::defs::p754::types::EntityMetadataValue::Direction(
3540                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
3541                                )
3542                            } else if (v6 == 12) {
3543                                crate::defs::p754::types::EntityMetadataValue::OptUuid(
3544                                    if g.bool() { Some(g.uuid()) } else { None },
3545                                )
3546                            } else if (v6 == 13) {
3547                                crate::defs::p754::types::EntityMetadataValue::BlockState(
3548                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
3549                                )
3550                            } else if (v6 == 14) {
3551                                crate::defs::p754::types::EntityMetadataValue::Nbt(g.nbt())
3552                            } else if (v6 == 15) {
3553                                crate::defs::p754::types::EntityMetadataValue::Particle(
3554                                    <crate::defs::p754::types::Particle as Generate>::generate(g),
3555                                )
3556                            } else if (v6 == 16) {
3557                                crate::defs::p754::types::EntityMetadataValue::VillagerData({
3558                                    let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3559                                    let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3560                                    let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3561                                    crate::defs::p754::types::EntityMetadataValueVillagerData {
3562                                        villager_type: v11,
3563                                        villager_profession: v12,
3564                                        level: v13,
3565                                    }
3566                                })
3567                            } else if (v6 == 17) {
3568                                crate::defs::p754::types::EntityMetadataValue::OptVarInt(
3569                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
3570                                )
3571                            } else if (v6 == 18) {
3572                                crate::defs::p754::types::EntityMetadataValue::Pose(
3573                                    (g.int_in(-2147483648, 2147483647, &[]) as i32),
3574                                )
3575                            } else {
3576                                crate::defs::p754::types::EntityMetadataValue::Other
3577                            });
3578                            crate::defs::p754::types::EntityMetadataEntry {
3579                                key: v5,
3580                                r#type: v6,
3581                                value: v7,
3582                            }
3583                        };
3584                        if crate::testgen::first_byte_ok(
3585                            |w: &mut BytesMut| -> EncodeResult {
3586                                w.put_u8(v4.key);
3587                                w.put_varint(v4.r#type);
3588                                match &v4.value {
3589                                    crate::defs::p754::types::EntityMetadataValue::Byte(v14) => {
3590                                        if !(v4.r#type == 0) {
3591                                            return Err(EncodeError::SwitchMismatch(
3592                                                "play.clientbound.entity_metadata.metadata.value",
3593                                            ));
3594                                        }
3595                                        w.put_i8((*v14));
3596                                    }
3597                                    crate::defs::p754::types::EntityMetadataValue::VarInt(v15) => {
3598                                        if !(v4.r#type == 1) {
3599                                            return Err(EncodeError::SwitchMismatch(
3600                                                "play.clientbound.entity_metadata.metadata.value",
3601                                            ));
3602                                        }
3603                                        w.put_varint((*v15));
3604                                    }
3605                                    crate::defs::p754::types::EntityMetadataValue::Float(v16) => {
3606                                        if !(v4.r#type == 2) {
3607                                            return Err(EncodeError::SwitchMismatch(
3608                                                "play.clientbound.entity_metadata.metadata.value",
3609                                            ));
3610                                        }
3611                                        w.put_f32((*v16));
3612                                    }
3613                                    crate::defs::p754::types::EntityMetadataValue::String(v17) => {
3614                                        if !(v4.r#type == 3) {
3615                                            return Err(EncodeError::SwitchMismatch(
3616                                                "play.clientbound.entity_metadata.metadata.value",
3617                                            ));
3618                                        }
3619                                        w.put_string(&(*v17))?;
3620                                    }
3621                                    crate::defs::p754::types::EntityMetadataValue::Chat(v18) => {
3622                                        if !(v4.r#type == 4) {
3623                                            return Err(EncodeError::SwitchMismatch(
3624                                                "play.clientbound.entity_metadata.metadata.value",
3625                                            ));
3626                                        }
3627                                        w.put_string(&(*v18))?;
3628                                    }
3629                                    crate::defs::p754::types::EntityMetadataValue::OptChat(v19) => {
3630                                        if !(v4.r#type == 5) {
3631                                            return Err(EncodeError::SwitchMismatch(
3632                                                "play.clientbound.entity_metadata.metadata.value",
3633                                            ));
3634                                        }
3635                                        match &(*v19) {
3636                                            Some(v20) => {
3637                                                w.put_u8(1);
3638                                                w.put_string(&(*v20))?;
3639                                            }
3640                                            None => w.put_u8(0),
3641                                        }
3642                                    }
3643                                    crate::defs::p754::types::EntityMetadataValue::Slot(v21) => {
3644                                        if !(v4.r#type == 6) {
3645                                            return Err(EncodeError::SwitchMismatch(
3646                                                "play.clientbound.entity_metadata.metadata.value",
3647                                            ));
3648                                        }
3649                                        (*v21).encode(w)?;
3650                                    }
3651                                    crate::defs::p754::types::EntityMetadataValue::Boolean(v22) => {
3652                                        if !(v4.r#type == 7) {
3653                                            return Err(EncodeError::SwitchMismatch(
3654                                                "play.clientbound.entity_metadata.metadata.value",
3655                                            ));
3656                                        }
3657                                        w.put_bool((*v22));
3658                                    }
3659                                    crate::defs::p754::types::EntityMetadataValue::Rotation(
3660                                        v23,
3661                                    ) => {
3662                                        if !(v4.r#type == 8) {
3663                                            return Err(EncodeError::SwitchMismatch(
3664                                                "play.clientbound.entity_metadata.metadata.value",
3665                                            ));
3666                                        }
3667                                        w.put_f32((*v23).pitch);
3668                                        w.put_f32((*v23).yaw);
3669                                        w.put_f32((*v23).roll);
3670                                    }
3671                                    crate::defs::p754::types::EntityMetadataValue::Position(
3672                                        v24,
3673                                    ) => {
3674                                        if !(v4.r#type == 9) {
3675                                            return Err(EncodeError::SwitchMismatch(
3676                                                "play.clientbound.entity_metadata.metadata.value",
3677                                            ));
3678                                        }
3679                                        (*v24).write(w, PositionLayout::Xzy)?;
3680                                    }
3681                                    crate::defs::p754::types::EntityMetadataValue::OptPosition(
3682                                        v25,
3683                                    ) => {
3684                                        if !(v4.r#type == 10) {
3685                                            return Err(EncodeError::SwitchMismatch(
3686                                                "play.clientbound.entity_metadata.metadata.value",
3687                                            ));
3688                                        }
3689                                        match &(*v25) {
3690                                            Some(v26) => {
3691                                                w.put_u8(1);
3692                                                (*v26).write(w, PositionLayout::Xzy)?;
3693                                            }
3694                                            None => w.put_u8(0),
3695                                        }
3696                                    }
3697                                    crate::defs::p754::types::EntityMetadataValue::Direction(
3698                                        v27,
3699                                    ) => {
3700                                        if !(v4.r#type == 11) {
3701                                            return Err(EncodeError::SwitchMismatch(
3702                                                "play.clientbound.entity_metadata.metadata.value",
3703                                            ));
3704                                        }
3705                                        w.put_varint((*v27));
3706                                    }
3707                                    crate::defs::p754::types::EntityMetadataValue::OptUuid(v28) => {
3708                                        if !(v4.r#type == 12) {
3709                                            return Err(EncodeError::SwitchMismatch(
3710                                                "play.clientbound.entity_metadata.metadata.value",
3711                                            ));
3712                                        }
3713                                        match &(*v28) {
3714                                            Some(v29) => {
3715                                                w.put_u8(1);
3716                                                w.put_uuid(&(*v29));
3717                                            }
3718                                            None => w.put_u8(0),
3719                                        }
3720                                    }
3721                                    crate::defs::p754::types::EntityMetadataValue::BlockState(
3722                                        v30,
3723                                    ) => {
3724                                        if !(v4.r#type == 13) {
3725                                            return Err(EncodeError::SwitchMismatch(
3726                                                "play.clientbound.entity_metadata.metadata.value",
3727                                            ));
3728                                        }
3729                                        w.put_varint((*v30));
3730                                    }
3731                                    crate::defs::p754::types::EntityMetadataValue::Nbt(v31) => {
3732                                        if !(v4.r#type == 14) {
3733                                            return Err(EncodeError::SwitchMismatch(
3734                                                "play.clientbound.entity_metadata.metadata.value",
3735                                            ));
3736                                        }
3737                                        (*v31).write(w);
3738                                    }
3739                                    crate::defs::p754::types::EntityMetadataValue::Particle(
3740                                        v32,
3741                                    ) => {
3742                                        if !(v4.r#type == 15) {
3743                                            return Err(EncodeError::SwitchMismatch(
3744                                                "play.clientbound.entity_metadata.metadata.value",
3745                                            ));
3746                                        }
3747                                        (*v32).encode(w)?;
3748                                    }
3749                                    crate::defs::p754::types::EntityMetadataValue::VillagerData(
3750                                        v33,
3751                                    ) => {
3752                                        if !(v4.r#type == 16) {
3753                                            return Err(EncodeError::SwitchMismatch(
3754                                                "play.clientbound.entity_metadata.metadata.value",
3755                                            ));
3756                                        }
3757                                        w.put_varint((*v33).villager_type);
3758                                        w.put_varint((*v33).villager_profession);
3759                                        w.put_varint((*v33).level);
3760                                    }
3761                                    crate::defs::p754::types::EntityMetadataValue::OptVarInt(
3762                                        v34,
3763                                    ) => {
3764                                        if !(v4.r#type == 17) {
3765                                            return Err(EncodeError::SwitchMismatch(
3766                                                "play.clientbound.entity_metadata.metadata.value",
3767                                            ));
3768                                        }
3769                                        w.put_varint((*v34));
3770                                    }
3771                                    crate::defs::p754::types::EntityMetadataValue::Pose(v35) => {
3772                                        if !(v4.r#type == 18) {
3773                                            return Err(EncodeError::SwitchMismatch(
3774                                                "play.clientbound.entity_metadata.metadata.value",
3775                                            ));
3776                                        }
3777                                        w.put_varint((*v35));
3778                                    }
3779                                    crate::defs::p754::types::EntityMetadataValue::Other => {
3780                                        if !(!((v4.r#type == 0)
3781                                            || (v4.r#type == 1)
3782                                            || (v4.r#type == 2)
3783                                            || (v4.r#type == 3)
3784                                            || (v4.r#type == 4)
3785                                            || (v4.r#type == 5)
3786                                            || (v4.r#type == 6)
3787                                            || (v4.r#type == 7)
3788                                            || (v4.r#type == 8)
3789                                            || (v4.r#type == 9)
3790                                            || (v4.r#type == 10)
3791                                            || (v4.r#type == 11)
3792                                            || (v4.r#type == 12)
3793                                            || (v4.r#type == 13)
3794                                            || (v4.r#type == 14)
3795                                            || (v4.r#type == 15)
3796                                            || (v4.r#type == 16)
3797                                            || (v4.r#type == 17)
3798                                            || (v4.r#type == 18)))
3799                                        {
3800                                            return Err(EncodeError::SwitchMismatch(
3801                                                "play.clientbound.entity_metadata.metadata.value",
3802                                            ));
3803                                        }
3804                                    }
3805                                }
3806                                Ok(())
3807                            },
3808                            |b| b != 255,
3809                        ) {
3810                            break v4;
3811                        }
3812                    });
3813                }
3814                v3
3815            };
3816            Self {
3817                entity_id: v1,
3818                metadata: v2,
3819            }
3820        }
3821    }
3822}
3823
3824#[cfg(feature = "v1_16_5")]
3825/// Nested container.
3826#[derive(Debug, Clone, PartialEq)]
3827pub struct EntityEquipmentEquipments {
3828    /// `slot`
3829    pub slot: i8,
3830    /// `item`
3831    pub item: crate::types::slot::modern::Slot,
3832}
3833
3834#[cfg(feature = "v1_16_5")]
3835/// `entity_equipment` (clientbound play).
3836#[derive(Debug, Clone, PartialEq)]
3837pub struct EntityEquipment<const V: i32> {
3838    /// `entityId`
3839    pub entity_id: i32,
3840    /// `equipments`
3841    pub equipments: Vec<crate::defs::p754::play::clientbound::EntityEquipmentEquipments>,
3842}
3843#[cfg(feature = "v1_16_5")]
3844impl<const V: i32> Decode for EntityEquipment<V> {
3845    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3846        Ok({
3847            let v1 = r.read_varint()?;
3848            let v2 = {
3849                let mut v3 = Vec::new();
3850                loop {
3851                    let v4 = r.read_u8()?;
3852                    v3.push({
3853                        let v5 = ((v4 & 0x7f) as i8);
3854                        let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
3855                        crate::defs::p754::play::clientbound::EntityEquipmentEquipments {
3856                            slot: v5,
3857                            item: v6,
3858                        }
3859                    });
3860                    if v4 & 0x80 == 0 {
3861                        break;
3862                    }
3863                }
3864                v3
3865            };
3866            Self {
3867                entity_id: v1,
3868                equipments: v2,
3869            }
3870        })
3871    }
3872}
3873#[cfg(feature = "v1_16_5")]
3874impl<const V: i32> Encode for EntityEquipment<V> {
3875    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3876        w.put_varint((*self).entity_id);
3877        if (*self).equipments.is_empty() {
3878            return Err(EncodeError::CountMismatch {
3879                field: "play.clientbound.entity_equipment.equipments",
3880                expected: 1,
3881                actual: 0,
3882            });
3883        }
3884        for (v2, v1) in (*self).equipments.iter().enumerate() {
3885            let v3 = w.len();
3886            w.put_i8((*v1).slot);
3887            (*v1).item.encode(w)?;
3888            match w.get_mut(v3) {
3889                Some(b) if *b & 0x80 == 0 => {
3890                    if v2 + 1 < (*self).equipments.len() {
3891                        *b |= 0x80;
3892                    }
3893                }
3894                _ => {
3895                    return Err(EncodeError::OutOfRange(
3896                        "play.clientbound.entity_equipment.equipments",
3897                    ));
3898                }
3899            }
3900        }
3901        Ok(())
3902    }
3903}
3904#[cfg(feature = "v1_16_5")]
3905#[cfg(feature = "testgen")]
3906impl<const V: i32> Generate for EntityEquipment<V> {
3907    fn generate(g: &mut Gen) -> Self {
3908        {
3909            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3910            let v2 = {
3911                let n = 1 + g.count();
3912                let mut v3 = Vec::with_capacity(n);
3913                for _ in 0..n {
3914                    v3.push(loop {
3915                        let v4 = {
3916                            let v5 = (g.int_in(-128, 127, &[]) as i8);
3917                            let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
3918                            crate::defs::p754::play::clientbound::EntityEquipmentEquipments {
3919                                slot: v5,
3920                                item: v6,
3921                            }
3922                        };
3923                        if crate::testgen::first_byte_ok(
3924                            |w: &mut BytesMut| -> EncodeResult {
3925                                w.put_i8(v4.slot);
3926                                v4.item.encode(w)?;
3927                                Ok(())
3928                            },
3929                            |b| b & 0x80 == 0,
3930                        ) {
3931                            break v4;
3932                        }
3933                    });
3934                }
3935                v3
3936            };
3937            Self {
3938                entity_id: v1,
3939                equipments: v2,
3940            }
3941        }
3942    }
3943}
3944
3945#[cfg(feature = "v1_16_5")]
3946/// `scoreboard_objective` (clientbound play).
3947#[derive(Debug, Clone, PartialEq)]
3948pub struct ScoreboardObjective<const V: i32> {
3949    /// `name`
3950    pub name: ByteString,
3951    /// `action`
3952    pub action: i8,
3953    /// `displayText`
3954    pub display_text: Option<ByteString>,
3955    /// `type`
3956    pub r#type: Option<i32>,
3957}
3958#[cfg(feature = "v1_16_5")]
3959impl<const V: i32> Decode for ScoreboardObjective<V> {
3960    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3961        Ok({
3962            let v1 = r.read_string()?;
3963            let v2 = r.read_i8()?;
3964            let v3 = if (v2 == 0) || (v2 == 2) {
3965                Some(r.read_string()?)
3966            } else {
3967                None
3968            };
3969            let v4 = if (v2 == 0) || (v2 == 2) {
3970                Some(r.read_varint()?)
3971            } else {
3972                None
3973            };
3974            Self {
3975                name: v1,
3976                action: v2,
3977                display_text: v3,
3978                r#type: v4,
3979            }
3980        })
3981    }
3982}
3983#[cfg(feature = "v1_16_5")]
3984impl<const V: i32> Encode for ScoreboardObjective<V> {
3985    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3986        w.put_string(&(*self).name)?;
3987        w.put_i8((*self).action);
3988        match (
3989            &(*self).display_text,
3990            ((*self).action == 0) || ((*self).action == 2),
3991        ) {
3992            (Some(v1), true) => {
3993                w.put_string(&(*v1))?;
3994            }
3995            (None, false) => {}
3996            _ => {
3997                return Err(EncodeError::SwitchMismatch(
3998                    "play.clientbound.scoreboard_objective.displayText",
3999                ));
4000            }
4001        }
4002        match (
4003            &(*self).r#type,
4004            ((*self).action == 0) || ((*self).action == 2),
4005        ) {
4006            (Some(v2), true) => {
4007                w.put_varint((*v2));
4008            }
4009            (None, false) => {}
4010            _ => {
4011                return Err(EncodeError::SwitchMismatch(
4012                    "play.clientbound.scoreboard_objective.type",
4013                ));
4014            }
4015        }
4016        Ok(())
4017    }
4018}
4019#[cfg(feature = "v1_16_5")]
4020#[cfg(feature = "testgen")]
4021impl<const V: i32> Generate for ScoreboardObjective<V> {
4022    fn generate(g: &mut Gen) -> Self {
4023        {
4024            let v1 = g.string();
4025            let v2 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
4026            let v3 = if (v2 == 0) || (v2 == 2) {
4027                Some(g.string())
4028            } else {
4029                None
4030            };
4031            let v4 = if (v2 == 0) || (v2 == 2) {
4032                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4033            } else {
4034                None
4035            };
4036            Self {
4037                name: v1,
4038                action: v2,
4039                display_text: v3,
4040                r#type: v4,
4041            }
4042        }
4043    }
4044}
4045
4046#[cfg(feature = "v1_16_5")]
4047/// `teams` (clientbound play).
4048#[derive(Debug, Clone, PartialEq)]
4049pub struct Teams<const V: i32> {
4050    /// `team`
4051    pub team: ByteString,
4052    /// `mode`
4053    pub mode: i8,
4054    /// `name`
4055    pub name: Option<ByteString>,
4056    /// `friendlyFire`
4057    pub friendly_fire: Option<i8>,
4058    /// `nameTagVisibility`
4059    pub name_tag_visibility: Option<ByteString>,
4060    /// `collisionRule`
4061    pub collision_rule: Option<ByteString>,
4062    /// `formatting`
4063    pub formatting: Option<i32>,
4064    /// `prefix`
4065    pub prefix: Option<ByteString>,
4066    /// `suffix`
4067    pub suffix: Option<ByteString>,
4068    /// `players`
4069    pub players: Option<Vec<ByteString>>,
4070}
4071#[cfg(feature = "v1_16_5")]
4072impl<const V: i32> Decode for Teams<V> {
4073    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4074        Ok({
4075            let v1 = r.read_string()?;
4076            let v2 = r.read_i8()?;
4077            let v3 = if (v2 == 0) || (v2 == 2) {
4078                Some(r.read_string()?)
4079            } else {
4080                None
4081            };
4082            let v4 = if (v2 == 0) || (v2 == 2) {
4083                Some(r.read_i8()?)
4084            } else {
4085                None
4086            };
4087            let v5 = if (v2 == 0) || (v2 == 2) {
4088                Some(r.read_string()?)
4089            } else {
4090                None
4091            };
4092            let v6 = if (v2 == 0) || (v2 == 2) {
4093                Some(r.read_string()?)
4094            } else {
4095                None
4096            };
4097            let v7 = if (v2 == 0) || (v2 == 2) {
4098                Some(r.read_varint()?)
4099            } else {
4100                None
4101            };
4102            let v8 = if (v2 == 0) || (v2 == 2) {
4103                Some(r.read_string()?)
4104            } else {
4105                None
4106            };
4107            let v9 = if (v2 == 0) || (v2 == 2) {
4108                Some(r.read_string()?)
4109            } else {
4110                None
4111            };
4112            let v10 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
4113                Some({
4114                    let v11 = {
4115                        let c = r.read_varint()?;
4116                        r.check_count(i64::from(c), 1)?
4117                    };
4118                    let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
4119                    for _ in 0..v11 {
4120                        v12.push(r.read_string()?);
4121                    }
4122                    v12
4123                })
4124            } else {
4125                None
4126            };
4127            Self {
4128                team: v1,
4129                mode: v2,
4130                name: v3,
4131                friendly_fire: v4,
4132                name_tag_visibility: v5,
4133                collision_rule: v6,
4134                formatting: v7,
4135                prefix: v8,
4136                suffix: v9,
4137                players: v10,
4138            }
4139        })
4140    }
4141}
4142#[cfg(feature = "v1_16_5")]
4143impl<const V: i32> Encode for Teams<V> {
4144    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4145        w.put_string(&(*self).team)?;
4146        w.put_i8((*self).mode);
4147        match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
4148            (Some(v1), true) => {
4149                w.put_string(&(*v1))?;
4150            }
4151            (None, false) => {}
4152            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
4153        }
4154        match (
4155            &(*self).friendly_fire,
4156            ((*self).mode == 0) || ((*self).mode == 2),
4157        ) {
4158            (Some(v2), true) => {
4159                w.put_i8((*v2));
4160            }
4161            (None, false) => {}
4162            _ => {
4163                return Err(EncodeError::SwitchMismatch(
4164                    "play.clientbound.teams.friendlyFire",
4165                ));
4166            }
4167        }
4168        match (
4169            &(*self).name_tag_visibility,
4170            ((*self).mode == 0) || ((*self).mode == 2),
4171        ) {
4172            (Some(v3), true) => {
4173                w.put_string(&(*v3))?;
4174            }
4175            (None, false) => {}
4176            _ => {
4177                return Err(EncodeError::SwitchMismatch(
4178                    "play.clientbound.teams.nameTagVisibility",
4179                ));
4180            }
4181        }
4182        match (
4183            &(*self).collision_rule,
4184            ((*self).mode == 0) || ((*self).mode == 2),
4185        ) {
4186            (Some(v4), true) => {
4187                w.put_string(&(*v4))?;
4188            }
4189            (None, false) => {}
4190            _ => {
4191                return Err(EncodeError::SwitchMismatch(
4192                    "play.clientbound.teams.collisionRule",
4193                ));
4194            }
4195        }
4196        match (
4197            &(*self).formatting,
4198            ((*self).mode == 0) || ((*self).mode == 2),
4199        ) {
4200            (Some(v5), true) => {
4201                w.put_varint((*v5));
4202            }
4203            (None, false) => {}
4204            _ => {
4205                return Err(EncodeError::SwitchMismatch(
4206                    "play.clientbound.teams.formatting",
4207                ));
4208            }
4209        }
4210        match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
4211            (Some(v6), true) => {
4212                w.put_string(&(*v6))?;
4213            }
4214            (None, false) => {}
4215            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
4216        }
4217        match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
4218            (Some(v7), true) => {
4219                w.put_string(&(*v7))?;
4220            }
4221            (None, false) => {}
4222            _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
4223        }
4224        match (
4225            &(*self).players,
4226            ((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
4227        ) {
4228            (Some(v8), true) => {
4229                w.put_len_varint((*v8).len())?;
4230                for v9 in (*v8).iter() {
4231                    w.put_string(&(*v9))?;
4232                }
4233            }
4234            (None, false) => {}
4235            _ => {
4236                return Err(EncodeError::SwitchMismatch(
4237                    "play.clientbound.teams.players",
4238                ));
4239            }
4240        }
4241        Ok(())
4242    }
4243}
4244#[cfg(feature = "v1_16_5")]
4245#[cfg(feature = "testgen")]
4246impl<const V: i32> Generate for Teams<V> {
4247    fn generate(g: &mut Gen) -> Self {
4248        {
4249            let v1 = g.string();
4250            let v2 = (g.int_in(
4251                -128,
4252                127,
4253                &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4],
4254            ) as i8);
4255            let v3 = if (v2 == 0) || (v2 == 2) {
4256                Some(g.string())
4257            } else {
4258                None
4259            };
4260            let v4 = if (v2 == 0) || (v2 == 2) {
4261                Some((g.int_in(-128, 127, &[]) as i8))
4262            } else {
4263                None
4264            };
4265            let v5 = if (v2 == 0) || (v2 == 2) {
4266                Some(g.string())
4267            } else {
4268                None
4269            };
4270            let v6 = if (v2 == 0) || (v2 == 2) {
4271                Some(g.string())
4272            } else {
4273                None
4274            };
4275            let v7 = if (v2 == 0) || (v2 == 2) {
4276                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4277            } else {
4278                None
4279            };
4280            let v8 = if (v2 == 0) || (v2 == 2) {
4281                Some(g.string())
4282            } else {
4283                None
4284            };
4285            let v9 = if (v2 == 0) || (v2 == 2) {
4286                Some(g.string())
4287            } else {
4288                None
4289            };
4290            let v10 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
4291                Some({
4292                    let v11 = g.count();
4293                    let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
4294                    for _ in 0..v11 {
4295                        v12.push(g.string());
4296                    }
4297                    v12
4298                })
4299            } else {
4300                None
4301            };
4302            Self {
4303                team: v1,
4304                mode: v2,
4305                name: v3,
4306                friendly_fire: v4,
4307                name_tag_visibility: v5,
4308                collision_rule: v6,
4309                formatting: v7,
4310                prefix: v8,
4311                suffix: v9,
4312                players: v10,
4313            }
4314        }
4315    }
4316}
4317
4318#[cfg(feature = "v1_16_5")]
4319/// `entity_sound_effect` (clientbound play).
4320#[derive(Debug, Clone, PartialEq)]
4321pub struct EntitySoundEffect<const V: i32> {
4322    /// `soundId`
4323    pub sound_id: i32,
4324    /// `soundCategory`
4325    pub sound_category: i32,
4326    /// `entityId`
4327    pub entity_id: i32,
4328    /// `volume`
4329    pub volume: f32,
4330    /// `pitch`
4331    pub pitch: f32,
4332}
4333#[cfg(feature = "v1_16_5")]
4334impl<const V: i32> Decode for EntitySoundEffect<V> {
4335    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4336        Ok({
4337            let v1 = r.read_varint()?;
4338            let v2 = r.read_varint()?;
4339            let v3 = r.read_varint()?;
4340            let v4 = r.read_f32()?;
4341            let v5 = r.read_f32()?;
4342            Self {
4343                sound_id: v1,
4344                sound_category: v2,
4345                entity_id: v3,
4346                volume: v4,
4347                pitch: v5,
4348            }
4349        })
4350    }
4351}
4352#[cfg(feature = "v1_16_5")]
4353impl<const V: i32> Encode for EntitySoundEffect<V> {
4354    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4355        w.put_varint((*self).sound_id);
4356        w.put_varint((*self).sound_category);
4357        w.put_varint((*self).entity_id);
4358        w.put_f32((*self).volume);
4359        w.put_f32((*self).pitch);
4360        Ok(())
4361    }
4362}
4363#[cfg(feature = "v1_16_5")]
4364#[cfg(feature = "testgen")]
4365impl<const V: i32> Generate for EntitySoundEffect<V> {
4366    fn generate(g: &mut Gen) -> Self {
4367        {
4368            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4369            let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4370            let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4371            let v4 = g.f32();
4372            let v5 = g.f32();
4373            Self {
4374                sound_id: v1,
4375                sound_category: v2,
4376                entity_id: v3,
4377                volume: v4,
4378                pitch: v5,
4379            }
4380        }
4381    }
4382}
4383
4384#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
4385/// `stop_sound` (clientbound play).
4386#[derive(Debug, Clone, PartialEq)]
4387pub struct StopSound<const V: i32> {
4388    /// `flags`
4389    pub flags: i8,
4390    /// `source`
4391    pub source: Option<i32>,
4392    /// `sound`
4393    pub sound: Option<ByteString>,
4394}
4395#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
4396impl<const V: i32> Decode for StopSound<V> {
4397    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4398        Ok({
4399            let v1 = r.read_i8()?;
4400            let v2 = if (v1 == 1) || (v1 == 3) {
4401                Some(r.read_varint()?)
4402            } else {
4403                None
4404            };
4405            let v3 = if (v1 == 2) || (v1 == 3) {
4406                Some(r.read_string()?)
4407            } else {
4408                None
4409            };
4410            Self {
4411                flags: v1,
4412                source: v2,
4413                sound: v3,
4414            }
4415        })
4416    }
4417}
4418#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
4419impl<const V: i32> Encode for StopSound<V> {
4420    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4421        w.put_i8((*self).flags);
4422        match (
4423            &(*self).source,
4424            ((*self).flags == 1) || ((*self).flags == 3),
4425        ) {
4426            (Some(v1), true) => {
4427                w.put_varint((*v1));
4428            }
4429            (None, false) => {}
4430            _ => {
4431                return Err(EncodeError::SwitchMismatch(
4432                    "play.clientbound.stop_sound.source",
4433                ));
4434            }
4435        }
4436        match (&(*self).sound, ((*self).flags == 2) || ((*self).flags == 3)) {
4437            (Some(v2), true) => {
4438                w.put_string(&(*v2))?;
4439            }
4440            (None, false) => {}
4441            _ => {
4442                return Err(EncodeError::SwitchMismatch(
4443                    "play.clientbound.stop_sound.sound",
4444                ));
4445            }
4446        }
4447        Ok(())
4448    }
4449}
4450#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
4451#[cfg(feature = "testgen")]
4452impl<const V: i32> Generate for StopSound<V> {
4453    fn generate(g: &mut Gen) -> Self {
4454        {
4455            let v1 = (g.int_in(-128, 127, &[1, 3, 2, 3]) as i8);
4456            let v2 = if (v1 == 1) || (v1 == 3) {
4457                Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4458            } else {
4459                None
4460            };
4461            let v3 = if (v1 == 2) || (v1 == 3) {
4462                Some(g.string())
4463            } else {
4464                None
4465            };
4466            Self {
4467                flags: v1,
4468                source: v2,
4469                sound: v3,
4470            }
4471        }
4472    }
4473}
4474
4475#[cfg(feature = "v1_16_5")]
4476/// `nbt_query_response` (clientbound play).
4477#[derive(Debug, Clone, PartialEq)]
4478pub struct NbtQueryResponse<const V: i32> {
4479    /// `transactionId`
4480    pub transaction_id: i32,
4481    /// `nbt`
4482    pub nbt: Option<RawNbt>,
4483}
4484#[cfg(feature = "v1_16_5")]
4485impl<const V: i32> Decode for NbtQueryResponse<V> {
4486    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4487        Ok({
4488            let v1 = r.read_varint()?;
4489            let v2 = RawNbt::read_optional(r)?;
4490            Self {
4491                transaction_id: v1,
4492                nbt: v2,
4493            }
4494        })
4495    }
4496}
4497#[cfg(feature = "v1_16_5")]
4498impl<const V: i32> Encode for NbtQueryResponse<V> {
4499    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4500        w.put_varint((*self).transaction_id);
4501        RawNbt::write_optional(&(*self).nbt, w);
4502        Ok(())
4503    }
4504}
4505#[cfg(feature = "v1_16_5")]
4506#[cfg(feature = "testgen")]
4507impl<const V: i32> Generate for NbtQueryResponse<V> {
4508    fn generate(g: &mut Gen) -> Self {
4509        {
4510            let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4511            let v2 = g.opt_nbt();
4512            Self {
4513                transaction_id: v1,
4514                nbt: v2,
4515            }
4516        }
4517    }
4518}
4519
4520#[cfg(feature = "v1_16_5")]
4521/// Nested container.
4522#[derive(Debug, Clone, PartialEq)]
4523pub struct AdvancementsAdvancementMappingValueDisplayData {
4524    /// `title`
4525    pub title: ByteString,
4526    /// `description`
4527    pub description: ByteString,
4528    /// `icon`
4529    pub icon: crate::types::slot::modern::Slot,
4530    /// `frameType`
4531    pub frame_type: i32,
4532    /// `flags`
4533    pub flags:
4534        crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags,
4535    /// `backgroundTexture`
4536    pub background_texture: Option<ByteString>,
4537    /// `xCord`
4538    pub x_cord: f32,
4539    /// `yCord`
4540    pub y_cord: f32,
4541}
4542
4543#[cfg(feature = "v1_16_5")]
4544/// Nested container.
4545#[derive(Debug, Clone, PartialEq)]
4546pub struct AdvancementsAdvancementMappingValue {
4547    /// `parentId`
4548    pub parent_id: Option<ByteString>,
4549    /// `displayData`
4550    pub display_data: Option<
4551        crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
4552    >,
4553    /// `criteria`
4554    pub criteria:
4555        Vec<crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria>,
4556    /// `requirements`
4557    pub requirements: Vec<Vec<ByteString>>,
4558}
4559
4560#[cfg(feature = "v1_16_5")]
4561/// Nested container.
4562#[derive(Debug, Clone, PartialEq)]
4563pub struct AdvancementsAdvancementMapping {
4564    /// `key`
4565    pub key: ByteString,
4566    /// `value`
4567    pub value: crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValue,
4568}
4569
4570#[cfg(feature = "v1_16_5")]
4571/// `advancements` (clientbound play).
4572#[derive(Debug, Clone, PartialEq)]
4573pub struct Advancements<const V: i32> {
4574    /// `reset`
4575    pub reset: bool,
4576    /// `advancementMapping`
4577    pub advancement_mapping:
4578        Vec<crate::defs::p754::play::clientbound::AdvancementsAdvancementMapping>,
4579    /// `identifiers`
4580    pub identifiers: Vec<ByteString>,
4581    /// `progressMapping`
4582    pub progress_mapping: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMapping>,
4583}
4584#[cfg(feature = "v1_16_5")]
4585impl<const V: i32> Decode for Advancements<V> {
4586    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4587        Ok({
4588            let v1 = r.read_bool()?;
4589            let v2 = {
4590                let v3 = {
4591                    let c = r.read_varint()?;
4592                    r.check_count(i64::from(c), 5)?
4593                };
4594                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4595                for _ in 0..v3 {
4596                    v4.push({ let v5 = r.read_string()?;let v6 = { let v7 = if r.read_bool()? { Some(r.read_string()?) } else { None };let v8 = if r.read_bool()? { Some({ let v9 = r.read_string()?;let v10 = r.read_string()?;let v11 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;let v12 = r.read_varint()?;let v13 = { let v14 = u64::from(r.read_i32()? as u32); crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { _unused: (((v14 >> 3) & 0x1fffffff) as u32), hidden: (((v14 >> 2) & 0x1) as u8), show_toast: (((v14 >> 1) & 0x1) as u8), has_background_texture: (((v14 >> 0) & 0x1) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(r.read_string()?) } else { None };let v16 = r.read_f32()?;let v17 = r.read_f32()?; crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = r.read_string()?; crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria { key: v21 } }); } v20 };let v23 = { let v24 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v24 { v25.push({ let v26 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v27 = Vec::with_capacity(v26.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v26 { v27.push(r.read_string()?); } v27 }); } v25 }; crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p754::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
4597                }
4598                v4
4599            };
4600            let v28 = {
4601                let v29 = {
4602                    let c = r.read_varint()?;
4603                    r.check_count(i64::from(c), 1)?
4604                };
4605                let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
4606                for _ in 0..v29 {
4607                    v30.push(r.read_string()?);
4608                }
4609                v30
4610            };
4611            let v31 = {
4612                let v32 = {
4613                    let c = r.read_varint()?;
4614                    r.check_count(i64::from(c), 2)?
4615                };
4616                let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT));
4617                for _ in 0..v32 {
4618                    v33.push({ let v34 = r.read_string()?;let v35 = { let v36 = { let c = r.read_varint()?; r.check_count(i64::from(c), 2)? }; let mut v37 = Vec::with_capacity(v36.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v36 { v37.push({ let v38 = r.read_string()?;let v39 = if r.read_bool()? { Some(r.read_i64()?) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v38, criterion_progress: v39 } }); } v37 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v34, value: v35 } });
4619                }
4620                v33
4621            };
4622            Self {
4623                reset: v1,
4624                advancement_mapping: v2,
4625                identifiers: v28,
4626                progress_mapping: v31,
4627            }
4628        })
4629    }
4630}
4631#[cfg(feature = "v1_16_5")]
4632impl<const V: i32> Encode for Advancements<V> {
4633    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4634        w.put_bool((*self).reset);
4635        w.put_len_varint((*self).advancement_mapping.len())?;
4636        for v1 in (*self).advancement_mapping.iter() {
4637            w.put_string(&(*v1).key)?;
4638            match &(*v1).value.parent_id {
4639                Some(v2) => {
4640                    w.put_u8(1);
4641                    w.put_string(&(*v2))?;
4642                }
4643                None => w.put_u8(0),
4644            }
4645            match &(*v1).value.display_data {
4646                Some(v3) => {
4647                    w.put_u8(1);
4648                    w.put_string(&(*v3).title)?;
4649                    w.put_string(&(*v3).description)?;
4650                    (*v3).icon.encode(w)?;
4651                    w.put_varint((*v3).frame_type);
4652                    {
4653                        let mut bits: u64 = 0;
4654                        {
4655                            let x = i128::from((*v3).flags._unused);
4656                            if x < 0 || x > 536870911 {
4657                                return Err(EncodeError::OutOfRange("_unused"));
4658                            }
4659                            bits = (bits << 29) | ((x as u64) & 0x1fffffff);
4660                        }
4661                        {
4662                            let x = i128::from((*v3).flags.hidden);
4663                            if x < 0 || x > 1 {
4664                                return Err(EncodeError::OutOfRange("hidden"));
4665                            }
4666                            bits = (bits << 1) | ((x as u64) & 0x1);
4667                        }
4668                        {
4669                            let x = i128::from((*v3).flags.show_toast);
4670                            if x < 0 || x > 1 {
4671                                return Err(EncodeError::OutOfRange("show_toast"));
4672                            }
4673                            bits = (bits << 1) | ((x as u64) & 0x1);
4674                        }
4675                        {
4676                            let x = i128::from((*v3).flags.has_background_texture);
4677                            if x < 0 || x > 1 {
4678                                return Err(EncodeError::OutOfRange("has_background_texture"));
4679                            }
4680                            bits = (bits << 1) | ((x as u64) & 0x1);
4681                        }
4682                        w.put_u32(bits as u32);
4683                    }
4684                    match (
4685                        &(*v3).background_texture,
4686                        ((*v3).flags.has_background_texture == 1),
4687                    ) {
4688                        (Some(v4), true) => {
4689                            w.put_string(&(*v4))?;
4690                        }
4691                        (None, false) => {}
4692                        _ => {
4693                            return Err(EncodeError::SwitchMismatch(
4694                                "play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
4695                            ));
4696                        }
4697                    }
4698                    w.put_f32((*v3).x_cord);
4699                    w.put_f32((*v3).y_cord);
4700                }
4701                None => w.put_u8(0),
4702            }
4703            w.put_len_varint((*v1).value.criteria.len())?;
4704            for v5 in (*v1).value.criteria.iter() {
4705                w.put_string(&(*v5).key)?;
4706            }
4707            w.put_len_varint((*v1).value.requirements.len())?;
4708            for v6 in (*v1).value.requirements.iter() {
4709                w.put_len_varint((*v6).len())?;
4710                for v7 in (*v6).iter() {
4711                    w.put_string(&(*v7))?;
4712                }
4713            }
4714        }
4715        w.put_len_varint((*self).identifiers.len())?;
4716        for v8 in (*self).identifiers.iter() {
4717            w.put_string(&(*v8))?;
4718        }
4719        w.put_len_varint((*self).progress_mapping.len())?;
4720        for v9 in (*self).progress_mapping.iter() {
4721            w.put_string(&(*v9).key)?;
4722            w.put_len_varint((*v9).value.len())?;
4723            for v10 in (*v9).value.iter() {
4724                w.put_string(&(*v10).criterion_identifier)?;
4725                match &(*v10).criterion_progress {
4726                    Some(v11) => {
4727                        w.put_u8(1);
4728                        w.put_i64((*v11));
4729                    }
4730                    None => w.put_u8(0),
4731                }
4732            }
4733        }
4734        Ok(())
4735    }
4736}
4737#[cfg(feature = "v1_16_5")]
4738#[cfg(feature = "testgen")]
4739impl<const V: i32> Generate for Advancements<V> {
4740    fn generate(g: &mut Gen) -> Self {
4741        {
4742            let v1 = g.bool();
4743            let v2 = {
4744                let v3 = g.count();
4745                let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
4746                for _ in 0..v3 {
4747                    v4.push({ let v5 = g.string();let v6 = { let v7 = if g.bool() { Some(g.string()) } else { None };let v8 = if g.bool() { Some({ let v9 = g.string();let v10 = g.string();let v11 = <crate::types::slot::modern::Slot as Generate>::generate(g);let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v13 = {  crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { _unused: (g.int_in(0, 536870911, &[]) as u32), hidden: (g.int_in(0, 1, &[]) as u8), show_toast: (g.int_in(0, 1, &[]) as u8), has_background_texture: (g.int_in(0, 1, &[1]) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(g.string()) } else { None };let v16 = g.f32();let v17 = g.f32(); crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = g.count(); let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = g.string(); crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria { key: v21 } }); } v20 };let v23 = { let v24 = g.count(); let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v24 { v25.push({ let v26 = g.count(); let mut v27 = Vec::with_capacity(v26.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v26 { v27.push(g.string()); } v27 }); } v25 }; crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p754::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
4748                }
4749                v4
4750            };
4751            let v28 = {
4752                let v29 = g.count();
4753                let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
4754                for _ in 0..v29 {
4755                    v30.push(g.string());
4756                }
4757                v30
4758            };
4759            let v31 = {
4760                let v32 = g.count();
4761                let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT));
4762                for _ in 0..v32 {
4763                    v33.push({ let v34 = g.string();let v35 = { let v36 = g.count(); let mut v37 = Vec::with_capacity(v36.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v36 { v37.push({ let v38 = g.string();let v39 = if g.bool() { Some(g.i64()) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v38, criterion_progress: v39 } }); } v37 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v34, value: v35 } });
4764                }
4765                v33
4766            };
4767            Self {
4768                reset: v1,
4769                advancement_mapping: v2,
4770                identifiers: v28,
4771                progress_mapping: v31,
4772            }
4773        }
4774    }
4775}
4776
4777#[cfg(feature = "v1_16_5")]
4778/// Nested container.
4779#[derive(Debug, Clone, PartialEq)]
4780pub struct DeclareRecipesRecipesDataCraftingShapeless {
4781    /// `group`
4782    pub group: ByteString,
4783    /// `ingredients`
4784    pub ingredients: Vec<Vec<crate::types::slot::modern::Slot>>,
4785    /// `result`
4786    pub result: crate::types::slot::modern::Slot,
4787}
4788
4789#[cfg(feature = "v1_16_5")]
4790/// Nested container.
4791#[derive(Debug, Clone, PartialEq)]
4792pub struct DeclareRecipesRecipesDataCraftingShaped {
4793    /// `width`
4794    pub width: i32,
4795    /// `height`
4796    pub height: i32,
4797    /// `group`
4798    pub group: ByteString,
4799    /// `ingredients`
4800    pub ingredients: Vec<Vec<Vec<crate::types::slot::modern::Slot>>>,
4801    /// `result`
4802    pub result: crate::types::slot::modern::Slot,
4803}
4804
4805#[cfg(feature = "v1_16_5")]
4806/// Nested container.
4807#[derive(Debug, Clone, PartialEq)]
4808pub struct DeclareRecipesRecipesDataStonecutting {
4809    /// `group`
4810    pub group: ByteString,
4811    /// `ingredient`
4812    pub ingredient: Vec<crate::types::slot::modern::Slot>,
4813    /// `result`
4814    pub result: crate::types::slot::modern::Slot,
4815}
4816
4817#[cfg(feature = "v1_16_5")]
4818/// Nested container.
4819#[derive(Debug, Clone, PartialEq)]
4820pub struct DeclareRecipesRecipesDataSmithing {
4821    /// `base`
4822    pub base: Vec<crate::types::slot::modern::Slot>,
4823    /// `addition`
4824    pub addition: Vec<crate::types::slot::modern::Slot>,
4825    /// `result`
4826    pub result: crate::types::slot::modern::Slot,
4827}
4828
4829#[cfg(feature = "v1_16_5")]
4830/// Switch on `type`.
4831#[derive(Debug, Clone, PartialEq)]
4832pub enum DeclareRecipesRecipesData {
4833    /// Case(s) `minecraft:crafting_shapeless`.
4834    CraftingShapeless(
4835        crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless,
4836    ),
4837    /// Case(s) `minecraft:crafting_shaped`.
4838    CraftingShaped(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped),
4839    /// Case(s) `minecraft:crafting_special_armordye`.
4840    CraftingSpecialArmordye,
4841    /// Case(s) `minecraft:crafting_special_bookcloning`.
4842    CraftingSpecialBookcloning,
4843    /// Case(s) `minecraft:crafting_special_mapcloning`.
4844    CraftingSpecialMapcloning,
4845    /// Case(s) `minecraft:crafting_special_mapextending`.
4846    CraftingSpecialMapextending,
4847    /// Case(s) `minecraft:crafting_special_firework_rocket`.
4848    CraftingSpecialFireworkRocket,
4849    /// Case(s) `minecraft:crafting_special_firework_star`.
4850    CraftingSpecialFireworkStar,
4851    /// Case(s) `minecraft:crafting_special_firework_star_fade`.
4852    CraftingSpecialFireworkStarFade,
4853    /// Case(s) `minecraft:crafting_special_repairitem`.
4854    CraftingSpecialRepairitem,
4855    /// Case(s) `minecraft:crafting_special_tippedarrow`.
4856    CraftingSpecialTippedarrow,
4857    /// Case(s) `minecraft:crafting_special_bannerduplicate`.
4858    CraftingSpecialBannerduplicate,
4859    /// Case(s) `minecraft:crafting_special_banneraddpattern`.
4860    CraftingSpecialBanneraddpattern,
4861    /// Case(s) `minecraft:crafting_special_shielddecoration`.
4862    CraftingSpecialShielddecoration,
4863    /// Case(s) `minecraft:crafting_special_shulkerboxcoloring`.
4864    CraftingSpecialShulkerboxcoloring,
4865    /// Case(s) `minecraft:crafting_special_suspiciousstew`.
4866    CraftingSpecialSuspiciousstew,
4867    /// Case(s) `minecraft:smelting`.
4868    Smelting(crate::defs::p754::types::MinecraftSmeltingFormat),
4869    /// Case(s) `minecraft:blasting`.
4870    Blasting(crate::defs::p754::types::MinecraftSmeltingFormat),
4871    /// Case(s) `minecraft:smoking`.
4872    Smoking(crate::defs::p754::types::MinecraftSmeltingFormat),
4873    /// Case(s) `minecraft:campfire_cooking`.
4874    CampfireCooking(crate::defs::p754::types::MinecraftSmeltingFormat),
4875    /// Case(s) `minecraft:stonecutting`.
4876    Stonecutting(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting),
4877    /// Case(s) `minecraft:smithing`.
4878    Smithing(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing),
4879    /// Any other value.
4880    Other,
4881}
4882
4883#[cfg(feature = "v1_16_5")]
4884/// Nested container.
4885#[derive(Debug, Clone, PartialEq)]
4886pub struct DeclareRecipesRecipes {
4887    /// `type`
4888    pub r#type: ByteString,
4889    /// `recipeId`
4890    pub recipe_id: ByteString,
4891    /// `data`
4892    pub data: crate::defs::p754::play::clientbound::DeclareRecipesRecipesData,
4893}
4894
4895#[cfg(feature = "v1_16_5")]
4896/// `declare_recipes` (clientbound play).
4897#[derive(Debug, Clone, PartialEq)]
4898pub struct DeclareRecipes<const V: i32> {
4899    /// `recipes`
4900    pub recipes: Vec<crate::defs::p754::play::clientbound::DeclareRecipesRecipes>,
4901}
4902#[cfg(feature = "v1_16_5")]
4903impl<const V: i32> Decode for DeclareRecipes<V> {
4904    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4905        Ok({
4906            let v1 = {
4907                let v2 = {
4908                    let c = r.read_varint()?;
4909                    r.check_count(i64::from(c), 2)?
4910                };
4911                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
4912                for _ in 0..v2 {
4913                    v3.push({ let v4 = r.read_string()?;let v5 = r.read_string()?;let v6 = (if (&*v4 == "minecraft:crafting_shapeless") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless({ let v7 = r.read_string()?;let v8 = { let v9 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push({ let v11 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v11 { v12.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v12 }); } v10 };let v13 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless { group: v7, ingredients: v8, result: v13 } }) } else if (&*v4 == "minecraft:crafting_shaped") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped({ let v14 = r.read_varint()?;let v15 = r.read_varint()?;let v16 = r.read_string()?;let v17 = { let v18 = r.check_count(i64::from(v15), 0)?; let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v18 { v19.push({ let v20 = r.check_count(i64::from(v14), 1)?; let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v20 { v21.push({ let v22 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v23 = Vec::with_capacity(v22.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v22 { v23.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v23 }); } v21 }); } v19 };let v24 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped { width: v14, height: v15, group: v16, ingredients: v17, result: v24 } }) } else if (&*v4 == "minecraft:crafting_special_armordye") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye } else if (&*v4 == "minecraft:crafting_special_bookcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning } else if (&*v4 == "minecraft:crafting_special_mapcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning } else if (&*v4 == "minecraft:crafting_special_mapextending") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending } else if (&*v4 == "minecraft:crafting_special_firework_rocket") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket } else if (&*v4 == "minecraft:crafting_special_firework_star") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar } else if (&*v4 == "minecraft:crafting_special_firework_star_fade") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade } else if (&*v4 == "minecraft:crafting_special_repairitem") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem } else if (&*v4 == "minecraft:crafting_special_tippedarrow") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow } else if (&*v4 == "minecraft:crafting_special_bannerduplicate") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate } else if (&*v4 == "minecraft:crafting_special_banneraddpattern") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern } else if (&*v4 == "minecraft:crafting_special_shielddecoration") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration } else if (&*v4 == "minecraft:crafting_special_shulkerboxcoloring") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring } else if (&*v4 == "minecraft:crafting_special_suspiciousstew") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew } else if (&*v4 == "minecraft:smelting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:blasting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:smoking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:campfire_cooking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:stonecutting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting({ let v25 = r.read_string()?;let v26 = { let v27 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v27 { v28.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v28 };let v29 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting { group: v25, ingredient: v26, result: v29 } }) } else if (&*v4 == "minecraft:smithing") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing({ let v30 = { let v31 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v32 = Vec::with_capacity(v31.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v31 { v32.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v32 };let v33 = { let v34 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v34 { v35.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v35 };let v36 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing { base: v30, addition: v33, result: v36 } }) } else { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other }); crate::defs::p754::play::clientbound::DeclareRecipesRecipes { r#type: v4, recipe_id: v5, data: v6 } });
4914                }
4915                v3
4916            };
4917            Self { recipes: v1 }
4918        })
4919    }
4920}
4921#[cfg(feature = "v1_16_5")]
4922impl<const V: i32> Encode for DeclareRecipes<V> {
4923    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4924        w.put_len_varint((*self).recipes.len())?;
4925        for v1 in (*self).recipes.iter() {
4926            w.put_string(&(*v1).r#type)?;
4927            w.put_string(&(*v1).recipe_id)?;
4928            match &(*v1).data { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless(v2) => { if !((&*(*v1).r#type == "minecraft:crafting_shapeless")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_string(&(*v2).group)?;w.put_len_varint((*v2).ingredients.len())?;for v3 in (*v2).ingredients.iter() { w.put_len_varint((*v3).len())?;for v4 in (*v3).iter() { (*v4).encode(w)?; } }(*v2).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped(v5) => { if !((&*(*v1).r#type == "minecraft:crafting_shaped")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_varint((*v5).width);w.put_varint((*v5).height);w.put_string(&(*v5).group)?;if usize::try_from((*v5).height).ok() != Some((*v5).ingredients.len()) { return Err(EncodeError::CountMismatch { field: "play.clientbound.declare_recipes.recipes.data.ingredients", expected: usize::try_from((*v5).height).unwrap_or(0), actual: (*v5).ingredients.len() }); }for v6 in (*v5).ingredients.iter() { if usize::try_from((*v5).width).ok() != Some((*v6).len()) { return Err(EncodeError::CountMismatch { field: "play.clientbound.declare_recipes.recipes.data.ingredients", expected: usize::try_from((*v5).width).unwrap_or(0), actual: (*v6).len() }); }for v7 in (*v6).iter() { w.put_len_varint((*v7).len())?;for v8 in (*v7).iter() { (*v8).encode(w)?; } } }(*v5).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye => { if !((&*(*v1).r#type == "minecraft:crafting_special_armordye")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning => { if !((&*(*v1).r#type == "minecraft:crafting_special_bookcloning")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning => { if !((&*(*v1).r#type == "minecraft:crafting_special_mapcloning")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending => { if !((&*(*v1).r#type == "minecraft:crafting_special_mapextending")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_rocket")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_star")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_star_fade")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem => { if !((&*(*v1).r#type == "minecraft:crafting_special_repairitem")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow => { if !((&*(*v1).r#type == "minecraft:crafting_special_tippedarrow")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate => { if !((&*(*v1).r#type == "minecraft:crafting_special_bannerduplicate")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern => { if !((&*(*v1).r#type == "minecraft:crafting_special_banneraddpattern")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration => { if !((&*(*v1).r#type == "minecraft:crafting_special_shielddecoration")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring => { if !((&*(*v1).r#type == "minecraft:crafting_special_shulkerboxcoloring")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew => { if !((&*(*v1).r#type == "minecraft:crafting_special_suspiciousstew")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(v9) => { if !((&*(*v1).r#type == "minecraft:smelting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v9).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(v10) => { if !((&*(*v1).r#type == "minecraft:blasting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v10).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(v11) => { if !((&*(*v1).r#type == "minecraft:smoking")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v11).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(v12) => { if !((&*(*v1).r#type == "minecraft:campfire_cooking")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v12).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting(v13) => { if !((&*(*v1).r#type == "minecraft:stonecutting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_string(&(*v13).group)?;w.put_len_varint((*v13).ingredient.len())?;for v14 in (*v13).ingredient.iter() { (*v14).encode(w)?; }(*v13).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing(v15) => { if !((&*(*v1).r#type == "minecraft:smithing")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_len_varint((*v15).base.len())?;for v16 in (*v15).base.iter() { (*v16).encode(w)?; }w.put_len_varint((*v15).addition.len())?;for v17 in (*v15).addition.iter() { (*v17).encode(w)?; }(*v15).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other => { if !(!((&*(*v1).r#type == "minecraft:crafting_shapeless") || (&*(*v1).r#type == "minecraft:crafting_shaped") || (&*(*v1).r#type == "minecraft:crafting_special_armordye") || (&*(*v1).r#type == "minecraft:crafting_special_bookcloning") || (&*(*v1).r#type == "minecraft:crafting_special_mapcloning") || (&*(*v1).r#type == "minecraft:crafting_special_mapextending") || (&*(*v1).r#type == "minecraft:crafting_special_firework_rocket") || (&*(*v1).r#type == "minecraft:crafting_special_firework_star") || (&*(*v1).r#type == "minecraft:crafting_special_firework_star_fade") || (&*(*v1).r#type == "minecraft:crafting_special_repairitem") || (&*(*v1).r#type == "minecraft:crafting_special_tippedarrow") || (&*(*v1).r#type == "minecraft:crafting_special_bannerduplicate") || (&*(*v1).r#type == "minecraft:crafting_special_banneraddpattern") || (&*(*v1).r#type == "minecraft:crafting_special_shielddecoration") || (&*(*v1).r#type == "minecraft:crafting_special_shulkerboxcoloring") || (&*(*v1).r#type == "minecraft:crafting_special_suspiciousstew") || (&*(*v1).r#type == "minecraft:smelting") || (&*(*v1).r#type == "minecraft:blasting") || (&*(*v1).r#type == "minecraft:smoking") || (&*(*v1).r#type == "minecraft:campfire_cooking") || (&*(*v1).r#type == "minecraft:stonecutting") || (&*(*v1).r#type == "minecraft:smithing"))) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } } }
4929        }
4930        Ok(())
4931    }
4932}
4933#[cfg(feature = "v1_16_5")]
4934#[cfg(feature = "testgen")]
4935impl<const V: i32> Generate for DeclareRecipes<V> {
4936    fn generate(g: &mut Gen) -> Self {
4937        {
4938            let v1 = {
4939                let v2 = g.count();
4940                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
4941                for _ in 0..v2 {
4942                    v3.push({ let v4 = g.string_in(&["minecraft:crafting_shapeless", "minecraft:crafting_shaped", "minecraft:crafting_special_armordye", "minecraft:crafting_special_bookcloning", "minecraft:crafting_special_mapcloning", "minecraft:crafting_special_mapextending", "minecraft:crafting_special_firework_rocket", "minecraft:crafting_special_firework_star", "minecraft:crafting_special_firework_star_fade", "minecraft:crafting_special_repairitem", "minecraft:crafting_special_tippedarrow", "minecraft:crafting_special_bannerduplicate", "minecraft:crafting_special_banneraddpattern", "minecraft:crafting_special_shielddecoration", "minecraft:crafting_special_shulkerboxcoloring", "minecraft:crafting_special_suspiciousstew", "minecraft:smelting", "minecraft:blasting", "minecraft:smoking", "minecraft:campfire_cooking", "minecraft:stonecutting", "minecraft:smithing"]);let v5 = g.string();let v6 = (if (&*v4 == "minecraft:crafting_shapeless") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless({ 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.count(); let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v11 { v12.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v12 }); } v10 };let v13 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless { group: v7, ingredients: v8, result: v13 } }) } else if (&*v4 == "minecraft:crafting_shaped") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped({ let v14 = (g.small_count() as i32);let v15 = (g.small_count() as i32);let v16 = g.string();let v17 = { let v18 = usize::try_from(v15).unwrap_or(0); let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v18 { v19.push({ let v20 = usize::try_from(v14).unwrap_or(0); let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v20 { v21.push({ let v22 = g.count(); let mut v23 = Vec::with_capacity(v22.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v22 { v23.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v23 }); } v21 }); } v19 };let v24 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped { width: v14, height: v15, group: v16, ingredients: v17, result: v24 } }) } else if (&*v4 == "minecraft:crafting_special_armordye") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye } else if (&*v4 == "minecraft:crafting_special_bookcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning } else if (&*v4 == "minecraft:crafting_special_mapcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning } else if (&*v4 == "minecraft:crafting_special_mapextending") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending } else if (&*v4 == "minecraft:crafting_special_firework_rocket") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket } else if (&*v4 == "minecraft:crafting_special_firework_star") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar } else if (&*v4 == "minecraft:crafting_special_firework_star_fade") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade } else if (&*v4 == "minecraft:crafting_special_repairitem") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem } else if (&*v4 == "minecraft:crafting_special_tippedarrow") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow } else if (&*v4 == "minecraft:crafting_special_bannerduplicate") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate } else if (&*v4 == "minecraft:crafting_special_banneraddpattern") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern } else if (&*v4 == "minecraft:crafting_special_shielddecoration") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration } else if (&*v4 == "minecraft:crafting_special_shulkerboxcoloring") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring } else if (&*v4 == "minecraft:crafting_special_suspiciousstew") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew } else if (&*v4 == "minecraft:smelting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:blasting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:smoking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:campfire_cooking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:stonecutting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting({ let v25 = g.string();let v26 = { let v27 = g.count(); let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v27 { v28.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v28 };let v29 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting { group: v25, ingredient: v26, result: v29 } }) } else if (&*v4 == "minecraft:smithing") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing({ let v30 = { let v31 = g.count(); let mut v32 = Vec::with_capacity(v31.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v31 { v32.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v32 };let v33 = { let v34 = g.count(); let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v34 { v35.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v35 };let v36 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing { base: v30, addition: v33, result: v36 } }) } else { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other }); crate::defs::p754::play::clientbound::DeclareRecipesRecipes { r#type: v4, recipe_id: v5, data: v6 } });
4943                }
4944                v3
4945            };
4946            Self { recipes: v1 }
4947        }
4948    }
4949}
4950
4951#[cfg(feature = "v1_16_5")]
4952/// `tags` (clientbound play).
4953#[derive(Debug, Clone, PartialEq)]
4954pub struct Tags<const V: i32> {
4955    /// `blockTags`
4956    pub block_tags: Vec<crate::defs::p754::types::Tags>,
4957    /// `itemTags`
4958    pub item_tags: Vec<crate::defs::p754::types::Tags>,
4959    /// `fluidTags`
4960    pub fluid_tags: Vec<crate::defs::p754::types::Tags>,
4961    /// `entityTags`
4962    pub entity_tags: Vec<crate::defs::p754::types::Tags>,
4963}
4964#[cfg(feature = "v1_16_5")]
4965impl<const V: i32> Decode for Tags<V> {
4966    fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4967        Ok({
4968            let v1 = {
4969                let v2 = {
4970                    let c = r.read_varint()?;
4971                    r.check_count(i64::from(c), 2)?
4972                };
4973                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
4974                for _ in 0..v2 {
4975                    v3.push({
4976                        let v4 = r.read_string()?;
4977                        let v5 = {
4978                            let v6 = {
4979                                let c = r.read_varint()?;
4980                                r.check_count(i64::from(c), 1)?
4981                            };
4982                            let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
4983                            for _ in 0..v6 {
4984                                v7.push(r.read_varint()?);
4985                            }
4986                            v7
4987                        };
4988                        crate::defs::p754::types::Tags {
4989                            tag_name: v4,
4990                            entries: v5,
4991                        }
4992                    });
4993                }
4994                v3
4995            };
4996            let v8 = {
4997                let v9 = {
4998                    let c = r.read_varint()?;
4999                    r.check_count(i64::from(c), 2)?
5000                };
5001                let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
5002                for _ in 0..v9 {
5003                    v10.push({
5004                        let v11 = r.read_string()?;
5005                        let v12 = {
5006                            let v13 = {
5007                                let c = r.read_varint()?;
5008                                r.check_count(i64::from(c), 1)?
5009                            };
5010                            let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
5011                            for _ in 0..v13 {
5012                                v14.push(r.read_varint()?);
5013                            }
5014                            v14
5015                        };
5016                        crate::defs::p754::types::Tags {
5017                            tag_name: v11,
5018                            entries: v12,
5019                        }
5020                    });
5021                }
5022                v10
5023            };
5024            let v15 = {
5025                let v16 = {
5026                    let c = r.read_varint()?;
5027                    r.check_count(i64::from(c), 2)?
5028                };
5029                let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
5030                for _ in 0..v16 {
5031                    v17.push({
5032                        let v18 = r.read_string()?;
5033                        let v19 = {
5034                            let v20 = {
5035                                let c = r.read_varint()?;
5036                                r.check_count(i64::from(c), 1)?
5037                            };
5038                            let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT));
5039                            for _ in 0..v20 {
5040                                v21.push(r.read_varint()?);
5041                            }
5042                            v21
5043                        };
5044                        crate::defs::p754::types::Tags {
5045                            tag_name: v18,
5046                            entries: v19,
5047                        }
5048                    });
5049                }
5050                v17
5051            };
5052            let v22 = {
5053                let v23 = {
5054                    let c = r.read_varint()?;
5055                    r.check_count(i64::from(c), 2)?
5056                };
5057                let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
5058                for _ in 0..v23 {
5059                    v24.push({
5060                        let v25 = r.read_string()?;
5061                        let v26 = {
5062                            let v27 = {
5063                                let c = r.read_varint()?;
5064                                r.check_count(i64::from(c), 1)?
5065                            };
5066                            let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
5067                            for _ in 0..v27 {
5068                                v28.push(r.read_varint()?);
5069                            }
5070                            v28
5071                        };
5072                        crate::defs::p754::types::Tags {
5073                            tag_name: v25,
5074                            entries: v26,
5075                        }
5076                    });
5077                }
5078                v24
5079            };
5080            Self {
5081                block_tags: v1,
5082                item_tags: v8,
5083                fluid_tags: v15,
5084                entity_tags: v22,
5085            }
5086        })
5087    }
5088}
5089#[cfg(feature = "v1_16_5")]
5090impl<const V: i32> Encode for Tags<V> {
5091    fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5092        w.put_len_varint((*self).block_tags.len())?;
5093        for v1 in (*self).block_tags.iter() {
5094            w.put_string(&(*v1).tag_name)?;
5095            w.put_len_varint((*v1).entries.len())?;
5096            for v2 in (*v1).entries.iter() {
5097                w.put_varint((*v2));
5098            }
5099        }
5100        w.put_len_varint((*self).item_tags.len())?;
5101        for v3 in (*self).item_tags.iter() {
5102            w.put_string(&(*v3).tag_name)?;
5103            w.put_len_varint((*v3).entries.len())?;
5104            for v4 in (*v3).entries.iter() {
5105                w.put_varint((*v4));
5106            }
5107        }
5108        w.put_len_varint((*self).fluid_tags.len())?;
5109        for v5 in (*self).fluid_tags.iter() {
5110            w.put_string(&(*v5).tag_name)?;
5111            w.put_len_varint((*v5).entries.len())?;
5112            for v6 in (*v5).entries.iter() {
5113                w.put_varint((*v6));
5114            }
5115        }
5116        w.put_len_varint((*self).entity_tags.len())?;
5117        for v7 in (*self).entity_tags.iter() {
5118            w.put_string(&(*v7).tag_name)?;
5119            w.put_len_varint((*v7).entries.len())?;
5120            for v8 in (*v7).entries.iter() {
5121                w.put_varint((*v8));
5122            }
5123        }
5124        Ok(())
5125    }
5126}
5127#[cfg(feature = "v1_16_5")]
5128#[cfg(feature = "testgen")]
5129impl<const V: i32> Generate for Tags<V> {
5130    fn generate(g: &mut Gen) -> Self {
5131        {
5132            let v1 = {
5133                let v2 = g.count();
5134                let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
5135                for _ in 0..v2 {
5136                    v3.push({
5137                        let v4 = g.string();
5138                        let v5 = {
5139                            let v6 = g.count();
5140                            let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
5141                            for _ in 0..v6 {
5142                                v7.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5143                            }
5144                            v7
5145                        };
5146                        crate::defs::p754::types::Tags {
5147                            tag_name: v4,
5148                            entries: v5,
5149                        }
5150                    });
5151                }
5152                v3
5153            };
5154            let v8 = {
5155                let v9 = g.count();
5156                let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
5157                for _ in 0..v9 {
5158                    v10.push({
5159                        let v11 = g.string();
5160                        let v12 = {
5161                            let v13 = g.count();
5162                            let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
5163                            for _ in 0..v13 {
5164                                v14.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5165                            }
5166                            v14
5167                        };
5168                        crate::defs::p754::types::Tags {
5169                            tag_name: v11,
5170                            entries: v12,
5171                        }
5172                    });
5173                }
5174                v10
5175            };
5176            let v15 = {
5177                let v16 = g.count();
5178                let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
5179                for _ in 0..v16 {
5180                    v17.push({
5181                        let v18 = g.string();
5182                        let v19 = {
5183                            let v20 = g.count();
5184                            let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT));
5185                            for _ in 0..v20 {
5186                                v21.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5187                            }
5188                            v21
5189                        };
5190                        crate::defs::p754::types::Tags {
5191                            tag_name: v18,
5192                            entries: v19,
5193                        }
5194                    });
5195                }
5196                v17
5197            };
5198            let v22 = {
5199                let v23 = g.count();
5200                let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
5201                for _ in 0..v23 {
5202                    v24.push({
5203                        let v25 = g.string();
5204                        let v26 = {
5205                            let v27 = g.count();
5206                            let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
5207                            for _ in 0..v27 {
5208                                v28.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5209                            }
5210                            v28
5211                        };
5212                        crate::defs::p754::types::Tags {
5213                            tag_name: v25,
5214                            entries: v26,
5215                        }
5216                    });
5217                }
5218                v24
5219            };
5220            Self {
5221                block_tags: v1,
5222                item_tags: v8,
5223                fluid_tags: v15,
5224                entity_tags: v22,
5225            }
5226        }
5227    }
5228}