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