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(any(
29 feature = "v1_16_5",
30 feature = "v26_1",
31 feature = "v26_2",
32 feature = "v26_3"
33))]
34#[derive(Debug, Clone, PartialEq)]
36pub struct QueryBlockNbt<const V: i32> {
37 pub transaction_id: i32,
39 pub location: BlockPos,
41}
42#[cfg(any(
43 feature = "v1_16_5",
44 feature = "v26_1",
45 feature = "v26_2",
46 feature = "v26_3"
47))]
48impl<const V: i32> Decode for QueryBlockNbt<V> {
49 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
50 Ok({
51 let v1 = r.read_varint()?;
52 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
53 Self {
54 transaction_id: v1,
55 location: v2,
56 }
57 })
58 }
59}
60#[cfg(any(
61 feature = "v1_16_5",
62 feature = "v26_1",
63 feature = "v26_2",
64 feature = "v26_3"
65))]
66impl<const V: i32> Encode for QueryBlockNbt<V> {
67 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
68 w.put_varint((*self).transaction_id);
69 (*self).location.write(w, PositionLayout::Xzy)?;
70 Ok(())
71 }
72}
73#[cfg(any(
74 feature = "v1_16_5",
75 feature = "v26_1",
76 feature = "v26_2",
77 feature = "v26_3"
78))]
79#[cfg(feature = "testgen")]
80impl<const V: i32> Generate for QueryBlockNbt<V> {
81 fn generate(g: &mut Gen) -> Self {
82 {
83 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
84 let v2 = g.position();
85 Self {
86 transaction_id: v1,
87 location: v2,
88 }
89 }
90 }
91}
92
93#[cfg(feature = "v1_16_5")]
94#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
96pub struct SetDifficultyNewDifficulty(pub u8);
97#[cfg(feature = "v1_16_5")]
98impl SetDifficultyNewDifficulty {
99 pub const PEACEFUL: Self = Self(0);
101 pub const EASY: Self = Self(1);
103 pub const NORMAL: Self = Self(2);
105 pub const HARD: Self = Self(3);
107 pub const fn name(self) -> Option<&'static str> {
109 match self.0 {
110 0 => Some("peaceful"),
111 1 => Some("easy"),
112 2 => Some("normal"),
113 3 => Some("hard"),
114 _ => None,
115 }
116 }
117}
118#[cfg(feature = "v1_16_5")]
119impl std::fmt::Debug for SetDifficultyNewDifficulty {
120 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
121 match self.name() {
122 Some(n) => write!(f, "SetDifficultyNewDifficulty::{n}"),
123 None => write!(f, "SetDifficultyNewDifficulty({})", self.0),
124 }
125 }
126}
127
128#[cfg(feature = "v1_16_5")]
129#[derive(Debug, Clone, PartialEq)]
131pub struct SetDifficulty<const V: i32> {
132 pub new_difficulty: crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty,
134}
135#[cfg(feature = "v1_16_5")]
136impl<const V: i32> Decode for SetDifficulty<V> {
137 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
138 Ok({
139 let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(r.read_u8()?);
140 Self { new_difficulty: v1 }
141 })
142 }
143}
144#[cfg(feature = "v1_16_5")]
145impl<const V: i32> Encode for SetDifficulty<V> {
146 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
147 w.put_u8((*self).new_difficulty.0);
148 Ok(())
149 }
150}
151#[cfg(feature = "v1_16_5")]
152#[cfg(feature = "testgen")]
153impl<const V: i32> Generate for SetDifficulty<V> {
154 fn generate(g: &mut Gen) -> Self {
155 {
156 let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(g.int_in(
157 0,
158 255,
159 &[0, 1, 2, 3],
160 )
161 as u8);
162 Self { new_difficulty: v1 }
163 }
164 }
165}
166
167#[cfg(any(
168 feature = "v1_16_5",
169 feature = "v26_1",
170 feature = "v26_2",
171 feature = "v26_3"
172))]
173#[derive(Debug, Clone, PartialEq)]
175pub struct TabComplete<const V: i32> {
176 pub transaction_id: i32,
178 pub text: ByteString,
180}
181#[cfg(any(
182 feature = "v1_16_5",
183 feature = "v26_1",
184 feature = "v26_2",
185 feature = "v26_3"
186))]
187impl<const V: i32> Decode for TabComplete<V> {
188 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
189 Ok({
190 let v1 = r.read_varint()?;
191 let v2 = r.read_string()?;
192 Self {
193 transaction_id: v1,
194 text: v2,
195 }
196 })
197 }
198}
199#[cfg(any(
200 feature = "v1_16_5",
201 feature = "v26_1",
202 feature = "v26_2",
203 feature = "v26_3"
204))]
205impl<const V: i32> Encode for TabComplete<V> {
206 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
207 w.put_varint((*self).transaction_id);
208 w.put_string(&(*self).text)?;
209 Ok(())
210 }
211}
212#[cfg(any(
213 feature = "v1_16_5",
214 feature = "v26_1",
215 feature = "v26_2",
216 feature = "v26_3"
217))]
218#[cfg(feature = "testgen")]
219impl<const V: i32> Generate for TabComplete<V> {
220 fn generate(g: &mut Gen) -> Self {
221 {
222 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
223 let v2 = g.string();
224 Self {
225 transaction_id: v1,
226 text: v2,
227 }
228 }
229 }
230}
231
232#[cfg(feature = "v1_16_5")]
233#[derive(Debug, Clone, PartialEq)]
235pub struct WindowClick<const V: i32> {
236 pub window_id: u8,
238 pub slot: i16,
240 pub mouse_button: i8,
242 pub action: i16,
244 pub mode: i8,
246 pub item: crate::types::slot::modern::Slot,
248}
249#[cfg(feature = "v1_16_5")]
250impl<const V: i32> Decode for WindowClick<V> {
251 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
252 Ok({
253 let v1 = r.read_u8()?;
254 let v2 = r.read_i16()?;
255 let v3 = r.read_i8()?;
256 let v4 = r.read_i16()?;
257 let v5 = r.read_i8()?;
258 let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
259 Self {
260 window_id: v1,
261 slot: v2,
262 mouse_button: v3,
263 action: v4,
264 mode: v5,
265 item: v6,
266 }
267 })
268 }
269}
270#[cfg(feature = "v1_16_5")]
271impl<const V: i32> Encode for WindowClick<V> {
272 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
273 w.put_u8((*self).window_id);
274 w.put_i16((*self).slot);
275 w.put_i8((*self).mouse_button);
276 w.put_i16((*self).action);
277 w.put_i8((*self).mode);
278 (*self).item.encode(w)?;
279 Ok(())
280 }
281}
282#[cfg(feature = "v1_16_5")]
283#[cfg(feature = "testgen")]
284impl<const V: i32> Generate for WindowClick<V> {
285 fn generate(g: &mut Gen) -> Self {
286 {
287 let v1 = (g.int_in(0, 255, &[]) as u8);
288 let v2 = (g.int_in(-32768, 32767, &[]) as i16);
289 let v3 = (g.int_in(-128, 127, &[]) as i8);
290 let v4 = (g.int_in(-32768, 32767, &[]) as i16);
291 let v5 = (g.int_in(-128, 127, &[]) as i8);
292 let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
293 Self {
294 window_id: v1,
295 slot: v2,
296 mouse_button: v3,
297 action: v4,
298 mode: v5,
299 item: v6,
300 }
301 }
302 }
303}
304
305#[cfg(feature = "v1_16_5")]
306#[derive(Debug, Clone, PartialEq)]
308pub struct EditBook<const V: i32> {
309 pub new_book: crate::types::slot::modern::Slot,
311 pub signing: bool,
313 pub hand: i32,
315}
316#[cfg(feature = "v1_16_5")]
317impl<const V: i32> Decode for EditBook<V> {
318 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
319 Ok({
320 let v1 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
321 let v2 = r.read_bool()?;
322 let v3 = r.read_varint()?;
323 Self {
324 new_book: v1,
325 signing: v2,
326 hand: v3,
327 }
328 })
329 }
330}
331#[cfg(feature = "v1_16_5")]
332impl<const V: i32> Encode for EditBook<V> {
333 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
334 (*self).new_book.encode(w)?;
335 w.put_bool((*self).signing);
336 w.put_varint((*self).hand);
337 Ok(())
338 }
339}
340#[cfg(feature = "v1_16_5")]
341#[cfg(feature = "testgen")]
342impl<const V: i32> Generate for EditBook<V> {
343 fn generate(g: &mut Gen) -> Self {
344 {
345 let v1 = <crate::types::slot::modern::Slot as Generate>::generate(g);
346 let v2 = g.bool();
347 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
348 Self {
349 new_book: v1,
350 signing: v2,
351 hand: v3,
352 }
353 }
354 }
355}
356
357#[cfg(any(
358 feature = "v1_16_5",
359 feature = "v26_1",
360 feature = "v26_2",
361 feature = "v26_3"
362))]
363#[derive(Debug, Clone, PartialEq)]
365pub struct QueryEntityNbt<const V: i32> {
366 pub transaction_id: i32,
368 pub entity_id: i32,
370}
371#[cfg(any(
372 feature = "v1_16_5",
373 feature = "v26_1",
374 feature = "v26_2",
375 feature = "v26_3"
376))]
377impl<const V: i32> Decode for QueryEntityNbt<V> {
378 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
379 Ok({
380 let v1 = r.read_varint()?;
381 let v2 = r.read_varint()?;
382 Self {
383 transaction_id: v1,
384 entity_id: v2,
385 }
386 })
387 }
388}
389#[cfg(any(
390 feature = "v1_16_5",
391 feature = "v26_1",
392 feature = "v26_2",
393 feature = "v26_3"
394))]
395impl<const V: i32> Encode for QueryEntityNbt<V> {
396 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
397 w.put_varint((*self).transaction_id);
398 w.put_varint((*self).entity_id);
399 Ok(())
400 }
401}
402#[cfg(any(
403 feature = "v1_16_5",
404 feature = "v26_1",
405 feature = "v26_2",
406 feature = "v26_3"
407))]
408#[cfg(feature = "testgen")]
409impl<const V: i32> Generate for QueryEntityNbt<V> {
410 fn generate(g: &mut Gen) -> Self {
411 {
412 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
413 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
414 Self {
415 transaction_id: v1,
416 entity_id: v2,
417 }
418 }
419 }
420}
421
422#[cfg(feature = "v1_16_5")]
423#[derive(Debug, Clone, PartialEq)]
425pub struct UseEntity<const V: i32> {
426 pub target: i32,
428 pub mouse: i32,
430 pub x: Option<f32>,
432 pub y: Option<f32>,
434 pub z: Option<f32>,
436 pub hand: Option<i32>,
438 pub sneaking: bool,
440}
441#[cfg(feature = "v1_16_5")]
442impl<const V: i32> Decode for UseEntity<V> {
443 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
444 Ok({
445 let v1 = r.read_varint()?;
446 let v2 = r.read_varint()?;
447 let v3 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
448 let v4 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
449 let v5 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
450 let v6 = if (v2 == 0) || (v2 == 2) {
451 Some(r.read_varint()?)
452 } else {
453 None
454 };
455 let v7 = r.read_bool()?;
456 Self {
457 target: v1,
458 mouse: v2,
459 x: v3,
460 y: v4,
461 z: v5,
462 hand: v6,
463 sneaking: v7,
464 }
465 })
466 }
467}
468#[cfg(feature = "v1_16_5")]
469impl<const V: i32> Encode for UseEntity<V> {
470 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
471 w.put_varint((*self).target);
472 w.put_varint((*self).mouse);
473 match (&(*self).x, ((*self).mouse == 2)) {
474 (Some(v1), true) => {
475 w.put_f32((*v1));
476 }
477 (None, false) => {}
478 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
479 }
480 match (&(*self).y, ((*self).mouse == 2)) {
481 (Some(v2), true) => {
482 w.put_f32((*v2));
483 }
484 (None, false) => {}
485 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
486 }
487 match (&(*self).z, ((*self).mouse == 2)) {
488 (Some(v3), true) => {
489 w.put_f32((*v3));
490 }
491 (None, false) => {}
492 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
493 }
494 match (&(*self).hand, ((*self).mouse == 0) || ((*self).mouse == 2)) {
495 (Some(v4), true) => {
496 w.put_varint((*v4));
497 }
498 (None, false) => {}
499 _ => {
500 return Err(EncodeError::SwitchMismatch(
501 "play.serverbound.use_entity.hand",
502 ));
503 }
504 }
505 w.put_bool((*self).sneaking);
506 Ok(())
507 }
508}
509#[cfg(feature = "v1_16_5")]
510#[cfg(feature = "testgen")]
511impl<const V: i32> Generate for UseEntity<V> {
512 fn generate(g: &mut Gen) -> Self {
513 {
514 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
515 let v2 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2, 0, 2]) as i32);
516 let v3 = if (v2 == 2) { Some(g.f32()) } else { None };
517 let v4 = if (v2 == 2) { Some(g.f32()) } else { None };
518 let v5 = if (v2 == 2) { Some(g.f32()) } else { None };
519 let v6 = if (v2 == 0) || (v2 == 2) {
520 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
521 } else {
522 None
523 };
524 let v7 = g.bool();
525 Self {
526 target: v1,
527 mouse: v2,
528 x: v3,
529 y: v4,
530 z: v5,
531 hand: v6,
532 sneaking: v7,
533 }
534 }
535 }
536}
537
538#[cfg(any(
539 feature = "v1_16_5",
540 feature = "v26_1",
541 feature = "v26_2",
542 feature = "v26_3"
543))]
544#[derive(Debug, Clone, PartialEq)]
546pub struct GenerateStructure<const V: i32> {
547 pub location: BlockPos,
549 pub levels: i32,
551 pub keep_jigsaws: bool,
553}
554#[cfg(any(
555 feature = "v1_16_5",
556 feature = "v26_1",
557 feature = "v26_2",
558 feature = "v26_3"
559))]
560impl<const V: i32> Decode for GenerateStructure<V> {
561 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
562 Ok({
563 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
564 let v2 = r.read_varint()?;
565 let v3 = r.read_bool()?;
566 Self {
567 location: v1,
568 levels: v2,
569 keep_jigsaws: v3,
570 }
571 })
572 }
573}
574#[cfg(any(
575 feature = "v1_16_5",
576 feature = "v26_1",
577 feature = "v26_2",
578 feature = "v26_3"
579))]
580impl<const V: i32> Encode for GenerateStructure<V> {
581 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
582 (*self).location.write(w, PositionLayout::Xzy)?;
583 w.put_varint((*self).levels);
584 w.put_bool((*self).keep_jigsaws);
585 Ok(())
586 }
587}
588#[cfg(any(
589 feature = "v1_16_5",
590 feature = "v26_1",
591 feature = "v26_2",
592 feature = "v26_3"
593))]
594#[cfg(feature = "testgen")]
595impl<const V: i32> Generate for GenerateStructure<V> {
596 fn generate(g: &mut Gen) -> Self {
597 {
598 let v1 = g.position();
599 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
600 let v3 = g.bool();
601 Self {
602 location: v1,
603 levels: v2,
604 keep_jigsaws: v3,
605 }
606 }
607 }
608}
609
610#[cfg(any(
611 feature = "v1_16_5",
612 feature = "v26_1",
613 feature = "v26_2",
614 feature = "v26_3"
615))]
616#[derive(Debug, Clone, PartialEq)]
618pub struct LockDifficulty<const V: i32> {
619 pub locked: bool,
621}
622#[cfg(any(
623 feature = "v1_16_5",
624 feature = "v26_1",
625 feature = "v26_2",
626 feature = "v26_3"
627))]
628impl<const V: i32> Decode for LockDifficulty<V> {
629 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
630 Ok({
631 let v1 = r.read_bool()?;
632 Self { locked: v1 }
633 })
634 }
635}
636#[cfg(any(
637 feature = "v1_16_5",
638 feature = "v26_1",
639 feature = "v26_2",
640 feature = "v26_3"
641))]
642impl<const V: i32> Encode for LockDifficulty<V> {
643 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
644 w.put_bool((*self).locked);
645 Ok(())
646 }
647}
648#[cfg(any(
649 feature = "v1_16_5",
650 feature = "v26_1",
651 feature = "v26_2",
652 feature = "v26_3"
653))]
654#[cfg(feature = "testgen")]
655impl<const V: i32> Generate for LockDifficulty<V> {
656 fn generate(g: &mut Gen) -> Self {
657 {
658 let v1 = g.bool();
659 Self { locked: v1 }
660 }
661 }
662}
663
664#[cfg(feature = "v1_16_5")]
665#[derive(Debug, Clone, PartialEq)]
667pub struct PickItem<const V: i32> {
668 pub slot: i32,
670}
671#[cfg(feature = "v1_16_5")]
672impl<const V: i32> Decode for PickItem<V> {
673 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
674 Ok({
675 let v1 = r.read_varint()?;
676 Self { slot: v1 }
677 })
678 }
679}
680#[cfg(feature = "v1_16_5")]
681impl<const V: i32> Encode for PickItem<V> {
682 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
683 w.put_varint((*self).slot);
684 Ok(())
685 }
686}
687#[cfg(feature = "v1_16_5")]
688#[cfg(feature = "testgen")]
689impl<const V: i32> Generate for PickItem<V> {
690 fn generate(g: &mut Gen) -> Self {
691 {
692 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
693 Self { slot: v1 }
694 }
695 }
696}
697
698#[cfg(feature = "v1_16_5")]
699#[derive(Debug, Clone, PartialEq)]
701pub struct CraftRecipeRequest<const V: i32> {
702 pub window_id: i8,
704 pub recipe: ByteString,
706 pub make_all: bool,
708}
709#[cfg(feature = "v1_16_5")]
710impl<const V: i32> Decode for CraftRecipeRequest<V> {
711 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
712 Ok({
713 let v1 = r.read_i8()?;
714 let v2 = r.read_string()?;
715 let v3 = r.read_bool()?;
716 Self {
717 window_id: v1,
718 recipe: v2,
719 make_all: v3,
720 }
721 })
722 }
723}
724#[cfg(feature = "v1_16_5")]
725impl<const V: i32> Encode for CraftRecipeRequest<V> {
726 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
727 w.put_i8((*self).window_id);
728 w.put_string(&(*self).recipe)?;
729 w.put_bool((*self).make_all);
730 Ok(())
731 }
732}
733#[cfg(feature = "v1_16_5")]
734#[cfg(feature = "testgen")]
735impl<const V: i32> Generate for CraftRecipeRequest<V> {
736 fn generate(g: &mut Gen) -> Self {
737 {
738 let v1 = (g.int_in(-128, 127, &[]) as i8);
739 let v2 = g.string();
740 let v3 = g.bool();
741 Self {
742 window_id: v1,
743 recipe: v2,
744 make_all: v3,
745 }
746 }
747 }
748}
749
750#[cfg(any(
751 feature = "v1_16_5",
752 feature = "v26_1",
753 feature = "v26_2",
754 feature = "v26_3"
755))]
756#[derive(Debug, Clone, PartialEq)]
758pub struct Abilities<const V: i32> {
759 pub flags: i8,
761}
762#[cfg(any(
763 feature = "v1_16_5",
764 feature = "v26_1",
765 feature = "v26_2",
766 feature = "v26_3"
767))]
768impl<const V: i32> Decode for Abilities<V> {
769 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
770 Ok({
771 let v1 = r.read_i8()?;
772 Self { flags: v1 }
773 })
774 }
775}
776#[cfg(any(
777 feature = "v1_16_5",
778 feature = "v26_1",
779 feature = "v26_2",
780 feature = "v26_3"
781))]
782impl<const V: i32> Encode for Abilities<V> {
783 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
784 w.put_i8((*self).flags);
785 Ok(())
786 }
787}
788#[cfg(any(
789 feature = "v1_16_5",
790 feature = "v26_1",
791 feature = "v26_2",
792 feature = "v26_3"
793))]
794#[cfg(feature = "testgen")]
795impl<const V: i32> Generate for Abilities<V> {
796 fn generate(g: &mut Gen) -> Self {
797 {
798 let v1 = (g.int_in(-128, 127, &[]) as i8);
799 Self { flags: v1 }
800 }
801 }
802}
803
804#[cfg(feature = "v1_16_5")]
805#[derive(Debug, Clone, PartialEq)]
807pub struct BlockDig<const V: i32> {
808 pub status: i32,
810 pub location: BlockPos,
812 pub face: i8,
814}
815#[cfg(feature = "v1_16_5")]
816impl<const V: i32> Decode for BlockDig<V> {
817 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
818 Ok({
819 let v1 = r.read_varint()?;
820 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
821 let v3 = r.read_i8()?;
822 Self {
823 status: v1,
824 location: v2,
825 face: v3,
826 }
827 })
828 }
829}
830#[cfg(feature = "v1_16_5")]
831impl<const V: i32> Encode for BlockDig<V> {
832 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
833 w.put_varint((*self).status);
834 (*self).location.write(w, PositionLayout::Xzy)?;
835 w.put_i8((*self).face);
836 Ok(())
837 }
838}
839#[cfg(feature = "v1_16_5")]
840#[cfg(feature = "testgen")]
841impl<const V: i32> Generate for BlockDig<V> {
842 fn generate(g: &mut Gen) -> Self {
843 {
844 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
845 let v2 = g.position();
846 let v3 = (g.int_in(-128, 127, &[]) as i8);
847 Self {
848 status: v1,
849 location: v2,
850 face: v3,
851 }
852 }
853 }
854}
855
856#[cfg(any(
857 feature = "v1_16_5",
858 feature = "v26_1",
859 feature = "v26_2",
860 feature = "v26_3"
861))]
862#[derive(Debug, Clone, PartialEq)]
864pub struct RecipeBook<const V: i32> {
865 pub book_id: i32,
867 pub book_open: bool,
869 pub filter_active: bool,
871}
872#[cfg(any(
873 feature = "v1_16_5",
874 feature = "v26_1",
875 feature = "v26_2",
876 feature = "v26_3"
877))]
878impl<const V: i32> Decode for RecipeBook<V> {
879 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
880 Ok({
881 let v1 = r.read_varint()?;
882 let v2 = r.read_bool()?;
883 let v3 = r.read_bool()?;
884 Self {
885 book_id: v1,
886 book_open: v2,
887 filter_active: v3,
888 }
889 })
890 }
891}
892#[cfg(any(
893 feature = "v1_16_5",
894 feature = "v26_1",
895 feature = "v26_2",
896 feature = "v26_3"
897))]
898impl<const V: i32> Encode for RecipeBook<V> {
899 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
900 w.put_varint((*self).book_id);
901 w.put_bool((*self).book_open);
902 w.put_bool((*self).filter_active);
903 Ok(())
904 }
905}
906#[cfg(any(
907 feature = "v1_16_5",
908 feature = "v26_1",
909 feature = "v26_2",
910 feature = "v26_3"
911))]
912#[cfg(feature = "testgen")]
913impl<const V: i32> Generate for RecipeBook<V> {
914 fn generate(g: &mut Gen) -> Self {
915 {
916 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
917 let v2 = g.bool();
918 let v3 = g.bool();
919 Self {
920 book_id: v1,
921 book_open: v2,
922 filter_active: v3,
923 }
924 }
925 }
926}
927
928#[cfg(feature = "v1_16_5")]
929#[derive(Debug, Clone, PartialEq)]
931pub struct DisplayedRecipe<const V: i32> {
932 pub recipe_id: ByteString,
934}
935#[cfg(feature = "v1_16_5")]
936impl<const V: i32> Decode for DisplayedRecipe<V> {
937 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
938 Ok({
939 let v1 = r.read_string()?;
940 Self { recipe_id: v1 }
941 })
942 }
943}
944#[cfg(feature = "v1_16_5")]
945impl<const V: i32> Encode for DisplayedRecipe<V> {
946 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
947 w.put_string(&(*self).recipe_id)?;
948 Ok(())
949 }
950}
951#[cfg(feature = "v1_16_5")]
952#[cfg(feature = "testgen")]
953impl<const V: i32> Generate for DisplayedRecipe<V> {
954 fn generate(g: &mut Gen) -> Self {
955 {
956 let v1 = g.string();
957 Self { recipe_id: v1 }
958 }
959 }
960}
961
962#[cfg(any(
963 feature = "v1_16_5",
964 feature = "v26_1",
965 feature = "v26_2",
966 feature = "v26_3"
967))]
968#[derive(Debug, Clone, PartialEq)]
970pub struct NameItem<const V: i32> {
971 pub name: ByteString,
973}
974#[cfg(any(
975 feature = "v1_16_5",
976 feature = "v26_1",
977 feature = "v26_2",
978 feature = "v26_3"
979))]
980impl<const V: i32> Decode for NameItem<V> {
981 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
982 Ok({
983 let v1 = r.read_string()?;
984 Self { name: v1 }
985 })
986 }
987}
988#[cfg(any(
989 feature = "v1_16_5",
990 feature = "v26_1",
991 feature = "v26_2",
992 feature = "v26_3"
993))]
994impl<const V: i32> Encode for NameItem<V> {
995 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
996 w.put_string(&(*self).name)?;
997 Ok(())
998 }
999}
1000#[cfg(any(
1001 feature = "v1_16_5",
1002 feature = "v26_1",
1003 feature = "v26_2",
1004 feature = "v26_3"
1005))]
1006#[cfg(feature = "testgen")]
1007impl<const V: i32> Generate for NameItem<V> {
1008 fn generate(g: &mut Gen) -> Self {
1009 {
1010 let v1 = g.string();
1011 Self { name: v1 }
1012 }
1013 }
1014}
1015
1016#[cfg(any(
1017 feature = "v1_16_5",
1018 feature = "v26_1",
1019 feature = "v26_2",
1020 feature = "v26_3"
1021))]
1022#[derive(Debug, Clone, PartialEq)]
1024pub struct SelectTrade<const V: i32> {
1025 pub slot: i32,
1027}
1028#[cfg(any(
1029 feature = "v1_16_5",
1030 feature = "v26_1",
1031 feature = "v26_2",
1032 feature = "v26_3"
1033))]
1034impl<const V: i32> Decode for SelectTrade<V> {
1035 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1036 Ok({
1037 let v1 = r.read_varint()?;
1038 Self { slot: v1 }
1039 })
1040 }
1041}
1042#[cfg(any(
1043 feature = "v1_16_5",
1044 feature = "v26_1",
1045 feature = "v26_2",
1046 feature = "v26_3"
1047))]
1048impl<const V: i32> Encode for SelectTrade<V> {
1049 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1050 w.put_varint((*self).slot);
1051 Ok(())
1052 }
1053}
1054#[cfg(any(
1055 feature = "v1_16_5",
1056 feature = "v26_1",
1057 feature = "v26_2",
1058 feature = "v26_3"
1059))]
1060#[cfg(feature = "testgen")]
1061impl<const V: i32> Generate for SelectTrade<V> {
1062 fn generate(g: &mut Gen) -> Self {
1063 {
1064 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1065 Self { slot: v1 }
1066 }
1067 }
1068}
1069
1070#[cfg(feature = "v1_16_5")]
1071#[derive(Debug, Clone, PartialEq)]
1073pub struct SetBeaconEffect<const V: i32> {
1074 pub primary_effect: i32,
1076 pub secondary_effect: i32,
1078}
1079#[cfg(feature = "v1_16_5")]
1080impl<const V: i32> Decode for SetBeaconEffect<V> {
1081 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1082 Ok({
1083 let v1 = r.read_varint()?;
1084 let v2 = r.read_varint()?;
1085 Self {
1086 primary_effect: v1,
1087 secondary_effect: v2,
1088 }
1089 })
1090 }
1091}
1092#[cfg(feature = "v1_16_5")]
1093impl<const V: i32> Encode for SetBeaconEffect<V> {
1094 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1095 w.put_varint((*self).primary_effect);
1096 w.put_varint((*self).secondary_effect);
1097 Ok(())
1098 }
1099}
1100#[cfg(feature = "v1_16_5")]
1101#[cfg(feature = "testgen")]
1102impl<const V: i32> Generate for SetBeaconEffect<V> {
1103 fn generate(g: &mut Gen) -> Self {
1104 {
1105 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1106 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1107 Self {
1108 primary_effect: v1,
1109 secondary_effect: v2,
1110 }
1111 }
1112 }
1113}
1114
1115#[cfg(any(
1116 feature = "v1_16_5",
1117 feature = "v26_1",
1118 feature = "v26_2",
1119 feature = "v26_3"
1120))]
1121#[derive(Debug, Clone, PartialEq)]
1123pub struct UpdateCommandBlock<const V: i32> {
1124 pub location: BlockPos,
1126 pub command: ByteString,
1128 pub mode: i32,
1130 pub flags: u8,
1132}
1133#[cfg(any(
1134 feature = "v1_16_5",
1135 feature = "v26_1",
1136 feature = "v26_2",
1137 feature = "v26_3"
1138))]
1139impl<const V: i32> Decode for UpdateCommandBlock<V> {
1140 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1141 Ok({
1142 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1143 let v2 = r.read_string()?;
1144 let v3 = r.read_varint()?;
1145 let v4 = r.read_u8()?;
1146 Self {
1147 location: v1,
1148 command: v2,
1149 mode: v3,
1150 flags: v4,
1151 }
1152 })
1153 }
1154}
1155#[cfg(any(
1156 feature = "v1_16_5",
1157 feature = "v26_1",
1158 feature = "v26_2",
1159 feature = "v26_3"
1160))]
1161impl<const V: i32> Encode for UpdateCommandBlock<V> {
1162 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1163 (*self).location.write(w, PositionLayout::Xzy)?;
1164 w.put_string(&(*self).command)?;
1165 w.put_varint((*self).mode);
1166 w.put_u8((*self).flags);
1167 Ok(())
1168 }
1169}
1170#[cfg(any(
1171 feature = "v1_16_5",
1172 feature = "v26_1",
1173 feature = "v26_2",
1174 feature = "v26_3"
1175))]
1176#[cfg(feature = "testgen")]
1177impl<const V: i32> Generate for UpdateCommandBlock<V> {
1178 fn generate(g: &mut Gen) -> Self {
1179 {
1180 let v1 = g.position();
1181 let v2 = g.string();
1182 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1183 let v4 = (g.int_in(0, 255, &[]) as u8);
1184 Self {
1185 location: v1,
1186 command: v2,
1187 mode: v3,
1188 flags: v4,
1189 }
1190 }
1191 }
1192}
1193
1194#[cfg(any(
1195 feature = "v1_16_5",
1196 feature = "v26_1",
1197 feature = "v26_2",
1198 feature = "v26_3"
1199))]
1200#[derive(Debug, Clone, PartialEq)]
1202pub struct UpdateCommandBlockMinecart<const V: i32> {
1203 pub entity_id: i32,
1205 pub command: ByteString,
1207 pub track_output: bool,
1209}
1210#[cfg(any(
1211 feature = "v1_16_5",
1212 feature = "v26_1",
1213 feature = "v26_2",
1214 feature = "v26_3"
1215))]
1216impl<const V: i32> Decode for UpdateCommandBlockMinecart<V> {
1217 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1218 Ok({
1219 let v1 = r.read_varint()?;
1220 let v2 = r.read_string()?;
1221 let v3 = r.read_bool()?;
1222 Self {
1223 entity_id: v1,
1224 command: v2,
1225 track_output: v3,
1226 }
1227 })
1228 }
1229}
1230#[cfg(any(
1231 feature = "v1_16_5",
1232 feature = "v26_1",
1233 feature = "v26_2",
1234 feature = "v26_3"
1235))]
1236impl<const V: i32> Encode for UpdateCommandBlockMinecart<V> {
1237 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1238 w.put_varint((*self).entity_id);
1239 w.put_string(&(*self).command)?;
1240 w.put_bool((*self).track_output);
1241 Ok(())
1242 }
1243}
1244#[cfg(any(
1245 feature = "v1_16_5",
1246 feature = "v26_1",
1247 feature = "v26_2",
1248 feature = "v26_3"
1249))]
1250#[cfg(feature = "testgen")]
1251impl<const V: i32> Generate for UpdateCommandBlockMinecart<V> {
1252 fn generate(g: &mut Gen) -> Self {
1253 {
1254 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1255 let v2 = g.string();
1256 let v3 = g.bool();
1257 Self {
1258 entity_id: v1,
1259 command: v2,
1260 track_output: v3,
1261 }
1262 }
1263 }
1264}
1265
1266#[cfg(feature = "v1_16_5")]
1267#[derive(Debug, Clone, PartialEq)]
1269pub struct SetCreativeSlot<const V: i32> {
1270 pub slot: i16,
1272 pub item: crate::types::slot::modern::Slot,
1274}
1275#[cfg(feature = "v1_16_5")]
1276impl<const V: i32> Decode for SetCreativeSlot<V> {
1277 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1278 Ok({
1279 let v1 = r.read_i16()?;
1280 let v2 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
1281 Self { slot: v1, item: v2 }
1282 })
1283 }
1284}
1285#[cfg(feature = "v1_16_5")]
1286impl<const V: i32> Encode for SetCreativeSlot<V> {
1287 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1288 w.put_i16((*self).slot);
1289 (*self).item.encode(w)?;
1290 Ok(())
1291 }
1292}
1293#[cfg(feature = "v1_16_5")]
1294#[cfg(feature = "testgen")]
1295impl<const V: i32> Generate for SetCreativeSlot<V> {
1296 fn generate(g: &mut Gen) -> Self {
1297 {
1298 let v1 = (g.int_in(-32768, 32767, &[]) as i16);
1299 let v2 = <crate::types::slot::modern::Slot as Generate>::generate(g);
1300 Self { slot: v1, item: v2 }
1301 }
1302 }
1303}
1304
1305#[cfg(feature = "v1_16_5")]
1306#[derive(Debug, Clone, PartialEq)]
1308pub struct UpdateJigsawBlock<const V: i32> {
1309 pub location: BlockPos,
1311 pub name: ByteString,
1313 pub target: ByteString,
1315 pub pool: ByteString,
1317 pub final_state: ByteString,
1319 pub joint_type: ByteString,
1321}
1322#[cfg(feature = "v1_16_5")]
1323impl<const V: i32> Decode for UpdateJigsawBlock<V> {
1324 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1325 Ok({
1326 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1327 let v2 = r.read_string()?;
1328 let v3 = r.read_string()?;
1329 let v4 = r.read_string()?;
1330 let v5 = r.read_string()?;
1331 let v6 = r.read_string()?;
1332 Self {
1333 location: v1,
1334 name: v2,
1335 target: v3,
1336 pool: v4,
1337 final_state: v5,
1338 joint_type: v6,
1339 }
1340 })
1341 }
1342}
1343#[cfg(feature = "v1_16_5")]
1344impl<const V: i32> Encode for UpdateJigsawBlock<V> {
1345 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1346 (*self).location.write(w, PositionLayout::Xzy)?;
1347 w.put_string(&(*self).name)?;
1348 w.put_string(&(*self).target)?;
1349 w.put_string(&(*self).pool)?;
1350 w.put_string(&(*self).final_state)?;
1351 w.put_string(&(*self).joint_type)?;
1352 Ok(())
1353 }
1354}
1355#[cfg(feature = "v1_16_5")]
1356#[cfg(feature = "testgen")]
1357impl<const V: i32> Generate for UpdateJigsawBlock<V> {
1358 fn generate(g: &mut Gen) -> Self {
1359 {
1360 let v1 = g.position();
1361 let v2 = g.string();
1362 let v3 = g.string();
1363 let v4 = g.string();
1364 let v5 = g.string();
1365 let v6 = g.string();
1366 Self {
1367 location: v1,
1368 name: v2,
1369 target: v3,
1370 pool: v4,
1371 final_state: v5,
1372 joint_type: v6,
1373 }
1374 }
1375 }
1376}
1377
1378#[cfg(feature = "v1_16_5")]
1379#[derive(Debug, Clone, PartialEq)]
1381pub struct UpdateStructureBlock<const V: i32> {
1382 pub location: BlockPos,
1384 pub action: i32,
1386 pub mode: i32,
1388 pub name: ByteString,
1390 pub offset_x: i8,
1392 pub offset_y: i8,
1394 pub offset_z: i8,
1396 pub size_x: i8,
1398 pub size_y: i8,
1400 pub size_z: i8,
1402 pub mirror: i32,
1404 pub rotation: i32,
1406 pub metadata: ByteString,
1408 pub integrity: f32,
1410 pub seed: i64,
1412 pub flags: u8,
1414}
1415#[cfg(feature = "v1_16_5")]
1416impl<const V: i32> Decode for UpdateStructureBlock<V> {
1417 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1418 Ok({
1419 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1420 let v2 = r.read_varint()?;
1421 let v3 = r.read_varint()?;
1422 let v4 = r.read_string()?;
1423 let v5 = r.read_i8()?;
1424 let v6 = r.read_i8()?;
1425 let v7 = r.read_i8()?;
1426 let v8 = r.read_i8()?;
1427 let v9 = r.read_i8()?;
1428 let v10 = r.read_i8()?;
1429 let v11 = r.read_varint()?;
1430 let v12 = r.read_varint()?;
1431 let v13 = r.read_string()?;
1432 let v14 = r.read_f32()?;
1433 let v15 = r.read_varlong()?;
1434 let v16 = r.read_u8()?;
1435 Self {
1436 location: v1,
1437 action: v2,
1438 mode: v3,
1439 name: v4,
1440 offset_x: v5,
1441 offset_y: v6,
1442 offset_z: v7,
1443 size_x: v8,
1444 size_y: v9,
1445 size_z: v10,
1446 mirror: v11,
1447 rotation: v12,
1448 metadata: v13,
1449 integrity: v14,
1450 seed: v15,
1451 flags: v16,
1452 }
1453 })
1454 }
1455}
1456#[cfg(feature = "v1_16_5")]
1457impl<const V: i32> Encode for UpdateStructureBlock<V> {
1458 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1459 (*self).location.write(w, PositionLayout::Xzy)?;
1460 w.put_varint((*self).action);
1461 w.put_varint((*self).mode);
1462 w.put_string(&(*self).name)?;
1463 w.put_i8((*self).offset_x);
1464 w.put_i8((*self).offset_y);
1465 w.put_i8((*self).offset_z);
1466 w.put_i8((*self).size_x);
1467 w.put_i8((*self).size_y);
1468 w.put_i8((*self).size_z);
1469 w.put_varint((*self).mirror);
1470 w.put_varint((*self).rotation);
1471 w.put_string(&(*self).metadata)?;
1472 w.put_f32((*self).integrity);
1473 w.put_varlong((*self).seed);
1474 w.put_u8((*self).flags);
1475 Ok(())
1476 }
1477}
1478#[cfg(feature = "v1_16_5")]
1479#[cfg(feature = "testgen")]
1480impl<const V: i32> Generate for UpdateStructureBlock<V> {
1481 fn generate(g: &mut Gen) -> Self {
1482 {
1483 let v1 = g.position();
1484 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1485 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1486 let v4 = g.string();
1487 let v5 = (g.int_in(-128, 127, &[]) as i8);
1488 let v6 = (g.int_in(-128, 127, &[]) as i8);
1489 let v7 = (g.int_in(-128, 127, &[]) as i8);
1490 let v8 = (g.int_in(-128, 127, &[]) as i8);
1491 let v9 = (g.int_in(-128, 127, &[]) as i8);
1492 let v10 = (g.int_in(-128, 127, &[]) as i8);
1493 let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1494 let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1495 let v13 = g.string();
1496 let v14 = g.f32();
1497 let v15 = g.varlong();
1498 let v16 = (g.int_in(0, 255, &[]) as u8);
1499 Self {
1500 location: v1,
1501 action: v2,
1502 mode: v3,
1503 name: v4,
1504 offset_x: v5,
1505 offset_y: v6,
1506 offset_z: v7,
1507 size_x: v8,
1508 size_y: v9,
1509 size_z: v10,
1510 mirror: v11,
1511 rotation: v12,
1512 metadata: v13,
1513 integrity: v14,
1514 seed: v15,
1515 flags: v16,
1516 }
1517 }
1518 }
1519}
1520
1521#[cfg(feature = "v1_16_5")]
1522#[derive(Debug, Clone, PartialEq)]
1524pub struct UpdateSign<const V: i32> {
1525 pub location: BlockPos,
1527 pub text1: ByteString,
1529 pub text2: ByteString,
1531 pub text3: ByteString,
1533 pub text4: ByteString,
1535}
1536#[cfg(feature = "v1_16_5")]
1537impl<const V: i32> Decode for UpdateSign<V> {
1538 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1539 Ok({
1540 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1541 let v2 = r.read_string()?;
1542 let v3 = r.read_string()?;
1543 let v4 = r.read_string()?;
1544 let v5 = r.read_string()?;
1545 Self {
1546 location: v1,
1547 text1: v2,
1548 text2: v3,
1549 text3: v4,
1550 text4: v5,
1551 }
1552 })
1553 }
1554}
1555#[cfg(feature = "v1_16_5")]
1556impl<const V: i32> Encode for UpdateSign<V> {
1557 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1558 (*self).location.write(w, PositionLayout::Xzy)?;
1559 w.put_string(&(*self).text1)?;
1560 w.put_string(&(*self).text2)?;
1561 w.put_string(&(*self).text3)?;
1562 w.put_string(&(*self).text4)?;
1563 Ok(())
1564 }
1565}
1566#[cfg(feature = "v1_16_5")]
1567#[cfg(feature = "testgen")]
1568impl<const V: i32> Generate for UpdateSign<V> {
1569 fn generate(g: &mut Gen) -> Self {
1570 {
1571 let v1 = g.position();
1572 let v2 = g.string();
1573 let v3 = g.string();
1574 let v4 = g.string();
1575 let v5 = g.string();
1576 Self {
1577 location: v1,
1578 text1: v2,
1579 text2: v3,
1580 text3: v4,
1581 text4: v5,
1582 }
1583 }
1584 }
1585}
1586
1587#[cfg(feature = "v1_16_5")]
1588#[derive(Debug, Clone, PartialEq)]
1590pub struct BlockPlace<const V: i32> {
1591 pub hand: i32,
1593 pub location: BlockPos,
1595 pub direction: i32,
1597 pub cursor_x: f32,
1599 pub cursor_y: f32,
1601 pub cursor_z: f32,
1603 pub inside_block: bool,
1605}
1606#[cfg(feature = "v1_16_5")]
1607impl<const V: i32> Decode for BlockPlace<V> {
1608 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1609 Ok({
1610 let v1 = r.read_varint()?;
1611 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
1612 let v3 = r.read_varint()?;
1613 let v4 = r.read_f32()?;
1614 let v5 = r.read_f32()?;
1615 let v6 = r.read_f32()?;
1616 let v7 = r.read_bool()?;
1617 Self {
1618 hand: v1,
1619 location: v2,
1620 direction: v3,
1621 cursor_x: v4,
1622 cursor_y: v5,
1623 cursor_z: v6,
1624 inside_block: v7,
1625 }
1626 })
1627 }
1628}
1629#[cfg(feature = "v1_16_5")]
1630impl<const V: i32> Encode for BlockPlace<V> {
1631 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1632 w.put_varint((*self).hand);
1633 (*self).location.write(w, PositionLayout::Xzy)?;
1634 w.put_varint((*self).direction);
1635 w.put_f32((*self).cursor_x);
1636 w.put_f32((*self).cursor_y);
1637 w.put_f32((*self).cursor_z);
1638 w.put_bool((*self).inside_block);
1639 Ok(())
1640 }
1641}
1642#[cfg(feature = "v1_16_5")]
1643#[cfg(feature = "testgen")]
1644impl<const V: i32> Generate for BlockPlace<V> {
1645 fn generate(g: &mut Gen) -> Self {
1646 {
1647 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1648 let v2 = g.position();
1649 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1650 let v4 = g.f32();
1651 let v5 = g.f32();
1652 let v6 = g.f32();
1653 let v7 = g.bool();
1654 Self {
1655 hand: v1,
1656 location: v2,
1657 direction: v3,
1658 cursor_x: v4,
1659 cursor_y: v5,
1660 cursor_z: v6,
1661 inside_block: v7,
1662 }
1663 }
1664 }
1665}