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(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
29#[derive(Debug, Clone, PartialEq)]
31pub struct QueryBlockNbt<const V: i32> {
32 pub transaction_id: i32,
34 pub location: BlockPos,
36}
37#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
38impl<const V: i32> Decode for QueryBlockNbt<V> {
39 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
40 Ok({
41 let v1 = r.read_varint()?;
42 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
43 Self {
44 transaction_id: v1,
45 location: v2,
46 }
47 })
48 }
49}
50#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
51impl<const V: i32> Encode for QueryBlockNbt<V> {
52 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
53 w.put_varint((*self).transaction_id);
54 (*self).location.write(w, PositionLayout::Xzy)?;
55 Ok(())
56 }
57}
58#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
59#[cfg(feature = "testgen")]
60impl<const V: i32> Generate for QueryBlockNbt<V> {
61 fn generate(g: &mut Gen) -> Self {
62 {
63 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
64 let v2 = g.position();
65 Self {
66 transaction_id: v1,
67 location: v2,
68 }
69 }
70 }
71}
72
73#[cfg(feature = "v1_16_5")]
74#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
76pub struct SetDifficultyNewDifficulty(pub u8);
77#[cfg(feature = "v1_16_5")]
78impl SetDifficultyNewDifficulty {
79 pub const PEACEFUL: Self = Self(0);
81 pub const EASY: Self = Self(1);
83 pub const NORMAL: Self = Self(2);
85 pub const HARD: Self = Self(3);
87 pub const fn name(self) -> Option<&'static str> {
89 match self.0 {
90 0 => Some("peaceful"),
91 1 => Some("easy"),
92 2 => Some("normal"),
93 3 => Some("hard"),
94 _ => None,
95 }
96 }
97}
98#[cfg(feature = "v1_16_5")]
99impl std::fmt::Debug for SetDifficultyNewDifficulty {
100 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101 match self.name() {
102 Some(n) => write!(f, "SetDifficultyNewDifficulty::{n}"),
103 None => write!(f, "SetDifficultyNewDifficulty({})", self.0),
104 }
105 }
106}
107
108#[cfg(feature = "v1_16_5")]
109#[derive(Debug, Clone, PartialEq)]
111pub struct SetDifficulty<const V: i32> {
112 pub new_difficulty: crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty,
114}
115#[cfg(feature = "v1_16_5")]
116impl<const V: i32> Decode for SetDifficulty<V> {
117 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
118 Ok({
119 let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(r.read_u8()?);
120 Self { new_difficulty: v1 }
121 })
122 }
123}
124#[cfg(feature = "v1_16_5")]
125impl<const V: i32> Encode for SetDifficulty<V> {
126 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
127 w.put_u8((*self).new_difficulty.0);
128 Ok(())
129 }
130}
131#[cfg(feature = "v1_16_5")]
132#[cfg(feature = "testgen")]
133impl<const V: i32> Generate for SetDifficulty<V> {
134 fn generate(g: &mut Gen) -> Self {
135 {
136 let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(g.int_in(
137 0,
138 255,
139 &[0, 1, 2, 3],
140 )
141 as u8);
142 Self { new_difficulty: v1 }
143 }
144 }
145}
146
147#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
148#[derive(Debug, Clone, PartialEq)]
150pub struct TabComplete<const V: i32> {
151 pub transaction_id: i32,
153 pub text: ByteString,
155}
156#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
157impl<const V: i32> Decode for TabComplete<V> {
158 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
159 Ok({
160 let v1 = r.read_varint()?;
161 let v2 = r.read_string()?;
162 Self {
163 transaction_id: v1,
164 text: v2,
165 }
166 })
167 }
168}
169#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
170impl<const V: i32> Encode for TabComplete<V> {
171 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
172 w.put_varint((*self).transaction_id);
173 w.put_string(&(*self).text)?;
174 Ok(())
175 }
176}
177#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
178#[cfg(feature = "testgen")]
179impl<const V: i32> Generate for TabComplete<V> {
180 fn generate(g: &mut Gen) -> Self {
181 {
182 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
183 let v2 = g.string();
184 Self {
185 transaction_id: v1,
186 text: v2,
187 }
188 }
189 }
190}
191
192#[cfg(feature = "v1_16_5")]
193#[derive(Debug, Clone, PartialEq)]
195pub struct WindowClick<const V: i32> {
196 pub window_id: u8,
198 pub slot: i16,
200 pub mouse_button: i8,
202 pub action: i16,
204 pub mode: i8,
206 pub item: crate::types::slot::modern::Slot,
208}
209#[cfg(feature = "v1_16_5")]
210impl<const V: i32> Decode for WindowClick<V> {
211 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
212 Ok({
213 let v1 = r.read_u8()?;
214 let v2 = r.read_i16()?;
215 let v3 = r.read_i8()?;
216 let v4 = r.read_i16()?;
217 let v5 = r.read_i8()?;
218 let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
219 Self {
220 window_id: v1,
221 slot: v2,
222 mouse_button: v3,
223 action: v4,
224 mode: v5,
225 item: v6,
226 }
227 })
228 }
229}
230#[cfg(feature = "v1_16_5")]
231impl<const V: i32> Encode for WindowClick<V> {
232 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
233 w.put_u8((*self).window_id);
234 w.put_i16((*self).slot);
235 w.put_i8((*self).mouse_button);
236 w.put_i16((*self).action);
237 w.put_i8((*self).mode);
238 (*self).item.encode(w)?;
239 Ok(())
240 }
241}
242#[cfg(feature = "v1_16_5")]
243#[cfg(feature = "testgen")]
244impl<const V: i32> Generate for WindowClick<V> {
245 fn generate(g: &mut Gen) -> Self {
246 {
247 let v1 = (g.int_in(0, 255, &[]) as u8);
248 let v2 = (g.int_in(-32768, 32767, &[]) as i16);
249 let v3 = (g.int_in(-128, 127, &[]) as i8);
250 let v4 = (g.int_in(-32768, 32767, &[]) as i16);
251 let v5 = (g.int_in(-128, 127, &[]) as i8);
252 let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
253 Self {
254 window_id: v1,
255 slot: v2,
256 mouse_button: v3,
257 action: v4,
258 mode: v5,
259 item: v6,
260 }
261 }
262 }
263}
264
265#[cfg(feature = "v1_16_5")]
266#[derive(Debug, Clone, PartialEq)]
268pub struct EditBook<const V: i32> {
269 pub new_book: crate::types::slot::modern::Slot,
271 pub signing: bool,
273 pub hand: i32,
275}
276#[cfg(feature = "v1_16_5")]
277impl<const V: i32> Decode for EditBook<V> {
278 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
279 Ok({
280 let v1 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
281 let v2 = r.read_bool()?;
282 let v3 = r.read_varint()?;
283 Self {
284 new_book: v1,
285 signing: v2,
286 hand: v3,
287 }
288 })
289 }
290}
291#[cfg(feature = "v1_16_5")]
292impl<const V: i32> Encode for EditBook<V> {
293 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
294 (*self).new_book.encode(w)?;
295 w.put_bool((*self).signing);
296 w.put_varint((*self).hand);
297 Ok(())
298 }
299}
300#[cfg(feature = "v1_16_5")]
301#[cfg(feature = "testgen")]
302impl<const V: i32> Generate for EditBook<V> {
303 fn generate(g: &mut Gen) -> Self {
304 {
305 let v1 = <crate::types::slot::modern::Slot as Generate>::generate(g);
306 let v2 = g.bool();
307 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
308 Self {
309 new_book: v1,
310 signing: v2,
311 hand: v3,
312 }
313 }
314 }
315}
316
317#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
318#[derive(Debug, Clone, PartialEq)]
320pub struct QueryEntityNbt<const V: i32> {
321 pub transaction_id: i32,
323 pub entity_id: i32,
325}
326#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
327impl<const V: i32> Decode for QueryEntityNbt<V> {
328 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
329 Ok({
330 let v1 = r.read_varint()?;
331 let v2 = r.read_varint()?;
332 Self {
333 transaction_id: v1,
334 entity_id: v2,
335 }
336 })
337 }
338}
339#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
340impl<const V: i32> Encode for QueryEntityNbt<V> {
341 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
342 w.put_varint((*self).transaction_id);
343 w.put_varint((*self).entity_id);
344 Ok(())
345 }
346}
347#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
348#[cfg(feature = "testgen")]
349impl<const V: i32> Generate for QueryEntityNbt<V> {
350 fn generate(g: &mut Gen) -> Self {
351 {
352 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
353 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
354 Self {
355 transaction_id: v1,
356 entity_id: v2,
357 }
358 }
359 }
360}
361
362#[cfg(feature = "v1_16_5")]
363#[derive(Debug, Clone, PartialEq)]
365pub struct UseEntity<const V: i32> {
366 pub target: i32,
368 pub mouse: i32,
370 pub x: Option<f32>,
372 pub y: Option<f32>,
374 pub z: Option<f32>,
376 pub hand: Option<i32>,
378 pub sneaking: bool,
380}
381#[cfg(feature = "v1_16_5")]
382impl<const V: i32> Decode for UseEntity<V> {
383 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
384 Ok({
385 let v1 = r.read_varint()?;
386 let v2 = r.read_varint()?;
387 let v3 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
388 let v4 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
389 let v5 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
390 let v6 = if (v2 == 0) || (v2 == 2) {
391 Some(r.read_varint()?)
392 } else {
393 None
394 };
395 let v7 = r.read_bool()?;
396 Self {
397 target: v1,
398 mouse: v2,
399 x: v3,
400 y: v4,
401 z: v5,
402 hand: v6,
403 sneaking: v7,
404 }
405 })
406 }
407}
408#[cfg(feature = "v1_16_5")]
409impl<const V: i32> Encode for UseEntity<V> {
410 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
411 w.put_varint((*self).target);
412 w.put_varint((*self).mouse);
413 match (&(*self).x, ((*self).mouse == 2)) {
414 (Some(v1), true) => {
415 w.put_f32((*v1));
416 }
417 (None, false) => {}
418 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
419 }
420 match (&(*self).y, ((*self).mouse == 2)) {
421 (Some(v2), true) => {
422 w.put_f32((*v2));
423 }
424 (None, false) => {}
425 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
426 }
427 match (&(*self).z, ((*self).mouse == 2)) {
428 (Some(v3), true) => {
429 w.put_f32((*v3));
430 }
431 (None, false) => {}
432 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
433 }
434 match (&(*self).hand, ((*self).mouse == 0) || ((*self).mouse == 2)) {
435 (Some(v4), true) => {
436 w.put_varint((*v4));
437 }
438 (None, false) => {}
439 _ => {
440 return Err(EncodeError::SwitchMismatch(
441 "play.serverbound.use_entity.hand",
442 ));
443 }
444 }
445 w.put_bool((*self).sneaking);
446 Ok(())
447 }
448}
449#[cfg(feature = "v1_16_5")]
450#[cfg(feature = "testgen")]
451impl<const V: i32> Generate for UseEntity<V> {
452 fn generate(g: &mut Gen) -> Self {
453 {
454 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
455 let v2 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2, 0, 2]) as i32);
456 let v3 = if (v2 == 2) { Some(g.f32()) } else { None };
457 let v4 = if (v2 == 2) { Some(g.f32()) } else { None };
458 let v5 = if (v2 == 2) { Some(g.f32()) } else { None };
459 let v6 = if (v2 == 0) || (v2 == 2) {
460 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
461 } else {
462 None
463 };
464 let v7 = g.bool();
465 Self {
466 target: v1,
467 mouse: v2,
468 x: v3,
469 y: v4,
470 z: v5,
471 hand: v6,
472 sneaking: v7,
473 }
474 }
475 }
476}
477
478#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
479#[derive(Debug, Clone, PartialEq)]
481pub struct GenerateStructure<const V: i32> {
482 pub location: BlockPos,
484 pub levels: i32,
486 pub keep_jigsaws: bool,
488}
489#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
490impl<const V: i32> Decode for GenerateStructure<V> {
491 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
492 Ok({
493 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
494 let v2 = r.read_varint()?;
495 let v3 = r.read_bool()?;
496 Self {
497 location: v1,
498 levels: v2,
499 keep_jigsaws: v3,
500 }
501 })
502 }
503}
504#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
505impl<const V: i32> Encode for GenerateStructure<V> {
506 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
507 (*self).location.write(w, PositionLayout::Xzy)?;
508 w.put_varint((*self).levels);
509 w.put_bool((*self).keep_jigsaws);
510 Ok(())
511 }
512}
513#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
514#[cfg(feature = "testgen")]
515impl<const V: i32> Generate for GenerateStructure<V> {
516 fn generate(g: &mut Gen) -> Self {
517 {
518 let v1 = g.position();
519 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
520 let v3 = g.bool();
521 Self {
522 location: v1,
523 levels: v2,
524 keep_jigsaws: v3,
525 }
526 }
527 }
528}
529
530#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
531#[derive(Debug, Clone, PartialEq)]
533pub struct LockDifficulty<const V: i32> {
534 pub locked: bool,
536}
537#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
538impl<const V: i32> Decode for LockDifficulty<V> {
539 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
540 Ok({
541 let v1 = r.read_bool()?;
542 Self { locked: v1 }
543 })
544 }
545}
546#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
547impl<const V: i32> Encode for LockDifficulty<V> {
548 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
549 w.put_bool((*self).locked);
550 Ok(())
551 }
552}
553#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
554#[cfg(feature = "testgen")]
555impl<const V: i32> Generate for LockDifficulty<V> {
556 fn generate(g: &mut Gen) -> Self {
557 {
558 let v1 = g.bool();
559 Self { locked: v1 }
560 }
561 }
562}
563
564#[cfg(feature = "v1_16_5")]
565#[derive(Debug, Clone, PartialEq)]
567pub struct PickItem<const V: i32> {
568 pub slot: i32,
570}
571#[cfg(feature = "v1_16_5")]
572impl<const V: i32> Decode for PickItem<V> {
573 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
574 Ok({
575 let v1 = r.read_varint()?;
576 Self { slot: v1 }
577 })
578 }
579}
580#[cfg(feature = "v1_16_5")]
581impl<const V: i32> Encode for PickItem<V> {
582 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
583 w.put_varint((*self).slot);
584 Ok(())
585 }
586}
587#[cfg(feature = "v1_16_5")]
588#[cfg(feature = "testgen")]
589impl<const V: i32> Generate for PickItem<V> {
590 fn generate(g: &mut Gen) -> Self {
591 {
592 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
593 Self { slot: v1 }
594 }
595 }
596}
597
598#[cfg(feature = "v1_16_5")]
599#[derive(Debug, Clone, PartialEq)]
601pub struct CraftRecipeRequest<const V: i32> {
602 pub window_id: i8,
604 pub recipe: ByteString,
606 pub make_all: bool,
608}
609#[cfg(feature = "v1_16_5")]
610impl<const V: i32> Decode for CraftRecipeRequest<V> {
611 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
612 Ok({
613 let v1 = r.read_i8()?;
614 let v2 = r.read_string()?;
615 let v3 = r.read_bool()?;
616 Self {
617 window_id: v1,
618 recipe: v2,
619 make_all: v3,
620 }
621 })
622 }
623}
624#[cfg(feature = "v1_16_5")]
625impl<const V: i32> Encode for CraftRecipeRequest<V> {
626 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
627 w.put_i8((*self).window_id);
628 w.put_string(&(*self).recipe)?;
629 w.put_bool((*self).make_all);
630 Ok(())
631 }
632}
633#[cfg(feature = "v1_16_5")]
634#[cfg(feature = "testgen")]
635impl<const V: i32> Generate for CraftRecipeRequest<V> {
636 fn generate(g: &mut Gen) -> Self {
637 {
638 let v1 = (g.int_in(-128, 127, &[]) as i8);
639 let v2 = g.string();
640 let v3 = g.bool();
641 Self {
642 window_id: v1,
643 recipe: v2,
644 make_all: v3,
645 }
646 }
647 }
648}
649
650#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
651#[derive(Debug, Clone, PartialEq)]
653pub struct Abilities<const V: i32> {
654 pub flags: i8,
656}
657#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
658impl<const V: i32> Decode for Abilities<V> {
659 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
660 Ok({
661 let v1 = r.read_i8()?;
662 Self { flags: v1 }
663 })
664 }
665}
666#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
667impl<const V: i32> Encode for Abilities<V> {
668 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
669 w.put_i8((*self).flags);
670 Ok(())
671 }
672}
673#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
674#[cfg(feature = "testgen")]
675impl<const V: i32> Generate for Abilities<V> {
676 fn generate(g: &mut Gen) -> Self {
677 {
678 let v1 = (g.int_in(-128, 127, &[]) as i8);
679 Self { flags: v1 }
680 }
681 }
682}
683
684#[cfg(feature = "v1_16_5")]
685#[derive(Debug, Clone, PartialEq)]
687pub struct BlockDig<const V: i32> {
688 pub status: i32,
690 pub location: BlockPos,
692 pub face: i8,
694}
695#[cfg(feature = "v1_16_5")]
696impl<const V: i32> Decode for BlockDig<V> {
697 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
698 Ok({
699 let v1 = r.read_varint()?;
700 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
701 let v3 = r.read_i8()?;
702 Self {
703 status: v1,
704 location: v2,
705 face: v3,
706 }
707 })
708 }
709}
710#[cfg(feature = "v1_16_5")]
711impl<const V: i32> Encode for BlockDig<V> {
712 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
713 w.put_varint((*self).status);
714 (*self).location.write(w, PositionLayout::Xzy)?;
715 w.put_i8((*self).face);
716 Ok(())
717 }
718}
719#[cfg(feature = "v1_16_5")]
720#[cfg(feature = "testgen")]
721impl<const V: i32> Generate for BlockDig<V> {
722 fn generate(g: &mut Gen) -> Self {
723 {
724 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
725 let v2 = g.position();
726 let v3 = (g.int_in(-128, 127, &[]) as i8);
727 Self {
728 status: v1,
729 location: v2,
730 face: v3,
731 }
732 }
733 }
734}
735
736#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
737#[derive(Debug, Clone, PartialEq)]
739pub struct RecipeBook<const V: i32> {
740 pub book_id: i32,
742 pub book_open: bool,
744 pub filter_active: bool,
746}
747#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
748impl<const V: i32> Decode for RecipeBook<V> {
749 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
750 Ok({
751 let v1 = r.read_varint()?;
752 let v2 = r.read_bool()?;
753 let v3 = r.read_bool()?;
754 Self {
755 book_id: v1,
756 book_open: v2,
757 filter_active: v3,
758 }
759 })
760 }
761}
762#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
763impl<const V: i32> Encode for RecipeBook<V> {
764 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
765 w.put_varint((*self).book_id);
766 w.put_bool((*self).book_open);
767 w.put_bool((*self).filter_active);
768 Ok(())
769 }
770}
771#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
772#[cfg(feature = "testgen")]
773impl<const V: i32> Generate for RecipeBook<V> {
774 fn generate(g: &mut Gen) -> Self {
775 {
776 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
777 let v2 = g.bool();
778 let v3 = g.bool();
779 Self {
780 book_id: v1,
781 book_open: v2,
782 filter_active: v3,
783 }
784 }
785 }
786}
787
788#[cfg(feature = "v1_16_5")]
789#[derive(Debug, Clone, PartialEq)]
791pub struct DisplayedRecipe<const V: i32> {
792 pub recipe_id: ByteString,
794}
795#[cfg(feature = "v1_16_5")]
796impl<const V: i32> Decode for DisplayedRecipe<V> {
797 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
798 Ok({
799 let v1 = r.read_string()?;
800 Self { recipe_id: v1 }
801 })
802 }
803}
804#[cfg(feature = "v1_16_5")]
805impl<const V: i32> Encode for DisplayedRecipe<V> {
806 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
807 w.put_string(&(*self).recipe_id)?;
808 Ok(())
809 }
810}
811#[cfg(feature = "v1_16_5")]
812#[cfg(feature = "testgen")]
813impl<const V: i32> Generate for DisplayedRecipe<V> {
814 fn generate(g: &mut Gen) -> Self {
815 {
816 let v1 = g.string();
817 Self { recipe_id: v1 }
818 }
819 }
820}
821
822#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
823#[derive(Debug, Clone, PartialEq)]
825pub struct NameItem<const V: i32> {
826 pub name: ByteString,
828}
829#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
830impl<const V: i32> Decode for NameItem<V> {
831 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
832 Ok({
833 let v1 = r.read_string()?;
834 Self { name: v1 }
835 })
836 }
837}
838#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
839impl<const V: i32> Encode for NameItem<V> {
840 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
841 w.put_string(&(*self).name)?;
842 Ok(())
843 }
844}
845#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
846#[cfg(feature = "testgen")]
847impl<const V: i32> Generate for NameItem<V> {
848 fn generate(g: &mut Gen) -> Self {
849 {
850 let v1 = g.string();
851 Self { name: v1 }
852 }
853 }
854}
855
856#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
857#[derive(Debug, Clone, PartialEq)]
859pub struct SelectTrade<const V: i32> {
860 pub slot: i32,
862}
863#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
864impl<const V: i32> Decode for SelectTrade<V> {
865 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
866 Ok({
867 let v1 = r.read_varint()?;
868 Self { slot: v1 }
869 })
870 }
871}
872#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
873impl<const V: i32> Encode for SelectTrade<V> {
874 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
875 w.put_varint((*self).slot);
876 Ok(())
877 }
878}
879#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
880#[cfg(feature = "testgen")]
881impl<const V: i32> Generate for SelectTrade<V> {
882 fn generate(g: &mut Gen) -> Self {
883 {
884 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
885 Self { slot: v1 }
886 }
887 }
888}
889
890#[cfg(feature = "v1_16_5")]
891#[derive(Debug, Clone, PartialEq)]
893pub struct SetBeaconEffect<const V: i32> {
894 pub primary_effect: i32,
896 pub secondary_effect: i32,
898}
899#[cfg(feature = "v1_16_5")]
900impl<const V: i32> Decode for SetBeaconEffect<V> {
901 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
902 Ok({
903 let v1 = r.read_varint()?;
904 let v2 = r.read_varint()?;
905 Self {
906 primary_effect: v1,
907 secondary_effect: v2,
908 }
909 })
910 }
911}
912#[cfg(feature = "v1_16_5")]
913impl<const V: i32> Encode for SetBeaconEffect<V> {
914 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
915 w.put_varint((*self).primary_effect);
916 w.put_varint((*self).secondary_effect);
917 Ok(())
918 }
919}
920#[cfg(feature = "v1_16_5")]
921#[cfg(feature = "testgen")]
922impl<const V: i32> Generate for SetBeaconEffect<V> {
923 fn generate(g: &mut Gen) -> Self {
924 {
925 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
926 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
927 Self {
928 primary_effect: v1,
929 secondary_effect: v2,
930 }
931 }
932 }
933}
934
935#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
936#[derive(Debug, Clone, PartialEq)]
938pub struct UpdateCommandBlock<const V: i32> {
939 pub location: BlockPos,
941 pub command: ByteString,
943 pub mode: i32,
945 pub flags: u8,
947}
948#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
949impl<const V: i32> Decode for UpdateCommandBlock<V> {
950 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
951 Ok({
952 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
953 let v2 = r.read_string()?;
954 let v3 = r.read_varint()?;
955 let v4 = r.read_u8()?;
956 Self {
957 location: v1,
958 command: v2,
959 mode: v3,
960 flags: v4,
961 }
962 })
963 }
964}
965#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
966impl<const V: i32> Encode for UpdateCommandBlock<V> {
967 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
968 (*self).location.write(w, PositionLayout::Xzy)?;
969 w.put_string(&(*self).command)?;
970 w.put_varint((*self).mode);
971 w.put_u8((*self).flags);
972 Ok(())
973 }
974}
975#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
976#[cfg(feature = "testgen")]
977impl<const V: i32> Generate for UpdateCommandBlock<V> {
978 fn generate(g: &mut Gen) -> Self {
979 {
980 let v1 = g.position();
981 let v2 = g.string();
982 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
983 let v4 = (g.int_in(0, 255, &[]) as u8);
984 Self {
985 location: v1,
986 command: v2,
987 mode: v3,
988 flags: v4,
989 }
990 }
991 }
992}
993
994#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
995#[derive(Debug, Clone, PartialEq)]
997pub struct UpdateCommandBlockMinecart<const V: i32> {
998 pub entity_id: i32,
1000 pub command: ByteString,
1002 pub track_output: bool,
1004}
1005#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
1006impl<const V: i32> Decode for UpdateCommandBlockMinecart<V> {
1007 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1008 Ok({
1009 let v1 = r.read_varint()?;
1010 let v2 = r.read_string()?;
1011 let v3 = r.read_bool()?;
1012 Self {
1013 entity_id: v1,
1014 command: v2,
1015 track_output: v3,
1016 }
1017 })
1018 }
1019}
1020#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
1021impl<const V: i32> Encode for UpdateCommandBlockMinecart<V> {
1022 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1023 w.put_varint((*self).entity_id);
1024 w.put_string(&(*self).command)?;
1025 w.put_bool((*self).track_output);
1026 Ok(())
1027 }
1028}
1029#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
1030#[cfg(feature = "testgen")]
1031impl<const V: i32> Generate for UpdateCommandBlockMinecart<V> {
1032 fn generate(g: &mut Gen) -> Self {
1033 {
1034 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1035 let v2 = g.string();
1036 let v3 = g.bool();
1037 Self {
1038 entity_id: v1,
1039 command: v2,
1040 track_output: v3,
1041 }
1042 }
1043 }
1044}
1045
1046#[cfg(feature = "v1_16_5")]
1047#[derive(Debug, Clone, PartialEq)]
1049pub struct SetCreativeSlot<const V: i32> {
1050 pub slot: i16,
1052 pub item: crate::types::slot::modern::Slot,
1054}
1055#[cfg(feature = "v1_16_5")]
1056impl<const V: i32> Decode for SetCreativeSlot<V> {
1057 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1058 Ok({
1059 let v1 = r.read_i16()?;
1060 let v2 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
1061 Self { slot: v1, item: v2 }
1062 })
1063 }
1064}
1065#[cfg(feature = "v1_16_5")]
1066impl<const V: i32> Encode for SetCreativeSlot<V> {
1067 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1068 w.put_i16((*self).slot);
1069 (*self).item.encode(w)?;
1070 Ok(())
1071 }
1072}
1073#[cfg(feature = "v1_16_5")]
1074#[cfg(feature = "testgen")]
1075impl<const V: i32> Generate for SetCreativeSlot<V> {
1076 fn generate(g: &mut Gen) -> Self {
1077 {
1078 let v1 = (g.int_in(-32768, 32767, &[]) as i16);
1079 let v2 = <crate::types::slot::modern::Slot as Generate>::generate(g);
1080 Self { slot: v1, item: v2 }
1081 }
1082 }
1083}
1084
1085#[cfg(feature = "v1_16_5")]
1086#[derive(Debug, Clone, PartialEq)]
1088pub struct UpdateJigsawBlock<const V: i32> {
1089 pub location: BlockPos,
1091 pub name: ByteString,
1093 pub target: ByteString,
1095 pub pool: ByteString,
1097 pub final_state: ByteString,
1099 pub joint_type: ByteString,
1101}
1102#[cfg(feature = "v1_16_5")]
1103impl<const V: i32> Decode for UpdateJigsawBlock<V> {
1104 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1105 Ok({
1106 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1107 let v2 = r.read_string()?;
1108 let v3 = r.read_string()?;
1109 let v4 = r.read_string()?;
1110 let v5 = r.read_string()?;
1111 let v6 = r.read_string()?;
1112 Self {
1113 location: v1,
1114 name: v2,
1115 target: v3,
1116 pool: v4,
1117 final_state: v5,
1118 joint_type: v6,
1119 }
1120 })
1121 }
1122}
1123#[cfg(feature = "v1_16_5")]
1124impl<const V: i32> Encode for UpdateJigsawBlock<V> {
1125 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1126 (*self).location.write(w, PositionLayout::Xzy)?;
1127 w.put_string(&(*self).name)?;
1128 w.put_string(&(*self).target)?;
1129 w.put_string(&(*self).pool)?;
1130 w.put_string(&(*self).final_state)?;
1131 w.put_string(&(*self).joint_type)?;
1132 Ok(())
1133 }
1134}
1135#[cfg(feature = "v1_16_5")]
1136#[cfg(feature = "testgen")]
1137impl<const V: i32> Generate for UpdateJigsawBlock<V> {
1138 fn generate(g: &mut Gen) -> Self {
1139 {
1140 let v1 = g.position();
1141 let v2 = g.string();
1142 let v3 = g.string();
1143 let v4 = g.string();
1144 let v5 = g.string();
1145 let v6 = g.string();
1146 Self {
1147 location: v1,
1148 name: v2,
1149 target: v3,
1150 pool: v4,
1151 final_state: v5,
1152 joint_type: v6,
1153 }
1154 }
1155 }
1156}
1157
1158#[cfg(feature = "v1_16_5")]
1159#[derive(Debug, Clone, PartialEq)]
1161pub struct UpdateStructureBlock<const V: i32> {
1162 pub location: BlockPos,
1164 pub action: i32,
1166 pub mode: i32,
1168 pub name: ByteString,
1170 pub offset_x: i8,
1172 pub offset_y: i8,
1174 pub offset_z: i8,
1176 pub size_x: i8,
1178 pub size_y: i8,
1180 pub size_z: i8,
1182 pub mirror: i32,
1184 pub rotation: i32,
1186 pub metadata: ByteString,
1188 pub integrity: f32,
1190 pub seed: i64,
1192 pub flags: u8,
1194}
1195#[cfg(feature = "v1_16_5")]
1196impl<const V: i32> Decode for UpdateStructureBlock<V> {
1197 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1198 Ok({
1199 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1200 let v2 = r.read_varint()?;
1201 let v3 = r.read_varint()?;
1202 let v4 = r.read_string()?;
1203 let v5 = r.read_i8()?;
1204 let v6 = r.read_i8()?;
1205 let v7 = r.read_i8()?;
1206 let v8 = r.read_i8()?;
1207 let v9 = r.read_i8()?;
1208 let v10 = r.read_i8()?;
1209 let v11 = r.read_varint()?;
1210 let v12 = r.read_varint()?;
1211 let v13 = r.read_string()?;
1212 let v14 = r.read_f32()?;
1213 let v15 = r.read_varlong()?;
1214 let v16 = r.read_u8()?;
1215 Self {
1216 location: v1,
1217 action: v2,
1218 mode: v3,
1219 name: v4,
1220 offset_x: v5,
1221 offset_y: v6,
1222 offset_z: v7,
1223 size_x: v8,
1224 size_y: v9,
1225 size_z: v10,
1226 mirror: v11,
1227 rotation: v12,
1228 metadata: v13,
1229 integrity: v14,
1230 seed: v15,
1231 flags: v16,
1232 }
1233 })
1234 }
1235}
1236#[cfg(feature = "v1_16_5")]
1237impl<const V: i32> Encode for UpdateStructureBlock<V> {
1238 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1239 (*self).location.write(w, PositionLayout::Xzy)?;
1240 w.put_varint((*self).action);
1241 w.put_varint((*self).mode);
1242 w.put_string(&(*self).name)?;
1243 w.put_i8((*self).offset_x);
1244 w.put_i8((*self).offset_y);
1245 w.put_i8((*self).offset_z);
1246 w.put_i8((*self).size_x);
1247 w.put_i8((*self).size_y);
1248 w.put_i8((*self).size_z);
1249 w.put_varint((*self).mirror);
1250 w.put_varint((*self).rotation);
1251 w.put_string(&(*self).metadata)?;
1252 w.put_f32((*self).integrity);
1253 w.put_varlong((*self).seed);
1254 w.put_u8((*self).flags);
1255 Ok(())
1256 }
1257}
1258#[cfg(feature = "v1_16_5")]
1259#[cfg(feature = "testgen")]
1260impl<const V: i32> Generate for UpdateStructureBlock<V> {
1261 fn generate(g: &mut Gen) -> Self {
1262 {
1263 let v1 = g.position();
1264 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1265 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1266 let v4 = g.string();
1267 let v5 = (g.int_in(-128, 127, &[]) as i8);
1268 let v6 = (g.int_in(-128, 127, &[]) as i8);
1269 let v7 = (g.int_in(-128, 127, &[]) as i8);
1270 let v8 = (g.int_in(-128, 127, &[]) as i8);
1271 let v9 = (g.int_in(-128, 127, &[]) as i8);
1272 let v10 = (g.int_in(-128, 127, &[]) as i8);
1273 let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1274 let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1275 let v13 = g.string();
1276 let v14 = g.f32();
1277 let v15 = g.varlong();
1278 let v16 = (g.int_in(0, 255, &[]) as u8);
1279 Self {
1280 location: v1,
1281 action: v2,
1282 mode: v3,
1283 name: v4,
1284 offset_x: v5,
1285 offset_y: v6,
1286 offset_z: v7,
1287 size_x: v8,
1288 size_y: v9,
1289 size_z: v10,
1290 mirror: v11,
1291 rotation: v12,
1292 metadata: v13,
1293 integrity: v14,
1294 seed: v15,
1295 flags: v16,
1296 }
1297 }
1298 }
1299}
1300
1301#[cfg(feature = "v1_16_5")]
1302#[derive(Debug, Clone, PartialEq)]
1304pub struct UpdateSign<const V: i32> {
1305 pub location: BlockPos,
1307 pub text1: ByteString,
1309 pub text2: ByteString,
1311 pub text3: ByteString,
1313 pub text4: ByteString,
1315}
1316#[cfg(feature = "v1_16_5")]
1317impl<const V: i32> Decode for UpdateSign<V> {
1318 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1319 Ok({
1320 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1321 let v2 = r.read_string()?;
1322 let v3 = r.read_string()?;
1323 let v4 = r.read_string()?;
1324 let v5 = r.read_string()?;
1325 Self {
1326 location: v1,
1327 text1: v2,
1328 text2: v3,
1329 text3: v4,
1330 text4: v5,
1331 }
1332 })
1333 }
1334}
1335#[cfg(feature = "v1_16_5")]
1336impl<const V: i32> Encode for UpdateSign<V> {
1337 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1338 (*self).location.write(w, PositionLayout::Xzy)?;
1339 w.put_string(&(*self).text1)?;
1340 w.put_string(&(*self).text2)?;
1341 w.put_string(&(*self).text3)?;
1342 w.put_string(&(*self).text4)?;
1343 Ok(())
1344 }
1345}
1346#[cfg(feature = "v1_16_5")]
1347#[cfg(feature = "testgen")]
1348impl<const V: i32> Generate for UpdateSign<V> {
1349 fn generate(g: &mut Gen) -> Self {
1350 {
1351 let v1 = g.position();
1352 let v2 = g.string();
1353 let v3 = g.string();
1354 let v4 = g.string();
1355 let v5 = g.string();
1356 Self {
1357 location: v1,
1358 text1: v2,
1359 text2: v3,
1360 text3: v4,
1361 text4: v5,
1362 }
1363 }
1364 }
1365}
1366
1367#[cfg(feature = "v1_16_5")]
1368#[derive(Debug, Clone, PartialEq)]
1370pub struct BlockPlace<const V: i32> {
1371 pub hand: i32,
1373 pub location: BlockPos,
1375 pub direction: i32,
1377 pub cursor_x: f32,
1379 pub cursor_y: f32,
1381 pub cursor_z: f32,
1383 pub inside_block: bool,
1385}
1386#[cfg(feature = "v1_16_5")]
1387impl<const V: i32> Decode for BlockPlace<V> {
1388 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1389 Ok({
1390 let v1 = r.read_varint()?;
1391 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
1392 let v3 = r.read_varint()?;
1393 let v4 = r.read_f32()?;
1394 let v5 = r.read_f32()?;
1395 let v6 = r.read_f32()?;
1396 let v7 = r.read_bool()?;
1397 Self {
1398 hand: v1,
1399 location: v2,
1400 direction: v3,
1401 cursor_x: v4,
1402 cursor_y: v5,
1403 cursor_z: v6,
1404 inside_block: v7,
1405 }
1406 })
1407 }
1408}
1409#[cfg(feature = "v1_16_5")]
1410impl<const V: i32> Encode for BlockPlace<V> {
1411 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1412 w.put_varint((*self).hand);
1413 (*self).location.write(w, PositionLayout::Xzy)?;
1414 w.put_varint((*self).direction);
1415 w.put_f32((*self).cursor_x);
1416 w.put_f32((*self).cursor_y);
1417 w.put_f32((*self).cursor_z);
1418 w.put_bool((*self).inside_block);
1419 Ok(())
1420 }
1421}
1422#[cfg(feature = "v1_16_5")]
1423#[cfg(feature = "testgen")]
1424impl<const V: i32> Generate for BlockPlace<V> {
1425 fn generate(g: &mut Gen) -> Self {
1426 {
1427 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1428 let v2 = g.position();
1429 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1430 let v4 = g.f32();
1431 let v5 = g.f32();
1432 let v6 = g.f32();
1433 let v7 = g.bool();
1434 Self {
1435 hand: v1,
1436 location: v2,
1437 direction: v3,
1438 cursor_x: v4,
1439 cursor_y: v5,
1440 cursor_z: v6,
1441 inside_block: v7,
1442 }
1443 }
1444 }
1445}