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 = "v26_1")]
29#[derive(Debug, Clone, PartialEq)]
31pub struct Attack<const V: i32> {
32 pub entity_id: i32,
34}
35#[cfg(feature = "v26_1")]
36impl<const V: i32> Decode for Attack<V> {
37 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
38 Ok({
39 let v1 = r.read_varint()?;
40 Self { entity_id: v1 }
41 })
42 }
43}
44#[cfg(feature = "v26_1")]
45impl<const V: i32> Encode for Attack<V> {
46 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
47 w.put_varint((*self).entity_id);
48 Ok(())
49 }
50}
51#[cfg(feature = "v26_1")]
52#[cfg(feature = "testgen")]
53impl<const V: i32> Generate for Attack<V> {
54 fn generate(g: &mut Gen) -> Self {
55 {
56 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
57 Self { entity_id: v1 }
58 }
59 }
60}
61
62#[cfg(feature = "v26_1")]
63#[derive(Debug, Clone, PartialEq)]
65pub struct SelectBundleItem<const V: i32> {
66 pub slot_id: i32,
68 pub selected_item_index: i32,
70}
71#[cfg(feature = "v26_1")]
72impl<const V: i32> Decode for SelectBundleItem<V> {
73 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
74 Ok({
75 let v1 = r.read_varint()?;
76 let v2 = r.read_varint()?;
77 Self {
78 slot_id: v1,
79 selected_item_index: v2,
80 }
81 })
82 }
83}
84#[cfg(feature = "v26_1")]
85impl<const V: i32> Encode for SelectBundleItem<V> {
86 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
87 w.put_varint((*self).slot_id);
88 w.put_varint((*self).selected_item_index);
89 Ok(())
90 }
91}
92#[cfg(feature = "v26_1")]
93#[cfg(feature = "testgen")]
94impl<const V: i32> Generate for SelectBundleItem<V> {
95 fn generate(g: &mut Gen) -> Self {
96 {
97 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
98 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
99 Self {
100 slot_id: v1,
101 selected_item_index: v2,
102 }
103 }
104 }
105}
106
107#[cfg(feature = "v26_1")]
108#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
110pub struct SetDifficultyNewDifficulty(pub i32);
111#[cfg(feature = "v26_1")]
112impl SetDifficultyNewDifficulty {
113 pub const PEACEFUL: Self = Self(0);
115 pub const EASY: Self = Self(1);
117 pub const NORMAL: Self = Self(2);
119 pub const HARD: Self = Self(3);
121 pub const fn name(self) -> Option<&'static str> {
123 match self.0 {
124 0 => Some("peaceful"),
125 1 => Some("easy"),
126 2 => Some("normal"),
127 3 => Some("hard"),
128 _ => None,
129 }
130 }
131}
132#[cfg(feature = "v26_1")]
133impl std::fmt::Debug for SetDifficultyNewDifficulty {
134 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
135 match self.name() {
136 Some(n) => write!(f, "SetDifficultyNewDifficulty::{n}"),
137 None => write!(f, "SetDifficultyNewDifficulty({})", self.0),
138 }
139 }
140}
141
142#[cfg(feature = "v26_1")]
143#[derive(Debug, Clone, PartialEq)]
145pub struct SetDifficulty<const V: i32> {
146 pub new_difficulty: crate::defs::p775::play::serverbound::SetDifficultyNewDifficulty,
148}
149#[cfg(feature = "v26_1")]
150impl<const V: i32> Decode for SetDifficulty<V> {
151 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
152 Ok({
153 let v1 =
154 crate::defs::p775::play::serverbound::SetDifficultyNewDifficulty(r.read_varint()?);
155 Self { new_difficulty: v1 }
156 })
157 }
158}
159#[cfg(feature = "v26_1")]
160impl<const V: i32> Encode for SetDifficulty<V> {
161 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
162 w.put_varint((*self).new_difficulty.0);
163 Ok(())
164 }
165}
166#[cfg(feature = "v26_1")]
167#[cfg(feature = "testgen")]
168impl<const V: i32> Generate for SetDifficulty<V> {
169 fn generate(g: &mut Gen) -> Self {
170 {
171 let v1 = crate::defs::p775::play::serverbound::SetDifficultyNewDifficulty(g.int_in(
172 -2147483648,
173 2147483647,
174 &[0, 1, 2, 3],
175 )
176 as i32);
177 Self { new_difficulty: v1 }
178 }
179 }
180}
181
182#[cfg(feature = "v26_1")]
183#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
185pub struct ChangeGamemodeMode(pub i32);
186#[cfg(feature = "v26_1")]
187impl ChangeGamemodeMode {
188 pub const SURVIVAL: Self = Self(0);
190 pub const CREATIVE: Self = Self(1);
192 pub const ADVENTURE: Self = Self(2);
194 pub const SPECTATOR: Self = Self(3);
196 pub const fn name(self) -> Option<&'static str> {
198 match self.0 {
199 0 => Some("survival"),
200 1 => Some("creative"),
201 2 => Some("adventure"),
202 3 => Some("spectator"),
203 _ => None,
204 }
205 }
206}
207#[cfg(feature = "v26_1")]
208impl std::fmt::Debug for ChangeGamemodeMode {
209 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
210 match self.name() {
211 Some(n) => write!(f, "ChangeGamemodeMode::{n}"),
212 None => write!(f, "ChangeGamemodeMode({})", self.0),
213 }
214 }
215}
216
217#[cfg(feature = "v26_1")]
218#[derive(Debug, Clone, PartialEq)]
220pub struct ChangeGamemode<const V: i32> {
221 pub mode: crate::defs::p775::play::serverbound::ChangeGamemodeMode,
223}
224#[cfg(feature = "v26_1")]
225impl<const V: i32> Decode for ChangeGamemode<V> {
226 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
227 Ok({
228 let v1 = crate::defs::p775::play::serverbound::ChangeGamemodeMode(r.read_varint()?);
229 Self { mode: v1 }
230 })
231 }
232}
233#[cfg(feature = "v26_1")]
234impl<const V: i32> Encode for ChangeGamemode<V> {
235 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
236 w.put_varint((*self).mode.0);
237 Ok(())
238 }
239}
240#[cfg(feature = "v26_1")]
241#[cfg(feature = "testgen")]
242impl<const V: i32> Generate for ChangeGamemode<V> {
243 fn generate(g: &mut Gen) -> Self {
244 {
245 let v1 = crate::defs::p775::play::serverbound::ChangeGamemodeMode(g.int_in(
246 -2147483648,
247 2147483647,
248 &[0, 1, 2, 3],
249 ) as i32);
250 Self { mode: v1 }
251 }
252 }
253}
254
255#[cfg(feature = "v26_1")]
256#[derive(Debug, Clone, PartialEq)]
258pub struct MessageAcknowledgement<const V: i32> {
259 pub count: i32,
261}
262#[cfg(feature = "v26_1")]
263impl<const V: i32> Decode for MessageAcknowledgement<V> {
264 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
265 Ok({
266 let v1 = r.read_varint()?;
267 Self { count: v1 }
268 })
269 }
270}
271#[cfg(feature = "v26_1")]
272impl<const V: i32> Encode for MessageAcknowledgement<V> {
273 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
274 w.put_varint((*self).count);
275 Ok(())
276 }
277}
278#[cfg(feature = "v26_1")]
279#[cfg(feature = "testgen")]
280impl<const V: i32> Generate for MessageAcknowledgement<V> {
281 fn generate(g: &mut Gen) -> Self {
282 {
283 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
284 Self { count: v1 }
285 }
286 }
287}
288
289#[cfg(feature = "v26_1")]
290#[derive(Debug, Clone, PartialEq)]
292pub struct ChatCommand<const V: i32> {
293 pub command: ByteString,
295}
296#[cfg(feature = "v26_1")]
297impl<const V: i32> Decode for ChatCommand<V> {
298 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
299 Ok({
300 let v1 = r.read_string()?;
301 Self { command: v1 }
302 })
303 }
304}
305#[cfg(feature = "v26_1")]
306impl<const V: i32> Encode for ChatCommand<V> {
307 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
308 w.put_string(&(*self).command)?;
309 Ok(())
310 }
311}
312#[cfg(feature = "v26_1")]
313#[cfg(feature = "testgen")]
314impl<const V: i32> Generate for ChatCommand<V> {
315 fn generate(g: &mut Gen) -> Self {
316 {
317 let v1 = g.string();
318 Self { command: v1 }
319 }
320 }
321}
322
323#[cfg(feature = "v26_1")]
324#[derive(Debug, Clone, PartialEq)]
326pub struct ChatCommandSignedArgumentSignatures {
327 pub argument_name: ByteString,
329 pub signature: Bytes,
331}
332
333#[cfg(feature = "v26_1")]
334#[derive(Debug, Clone, PartialEq)]
336pub struct ChatCommandSigned<const V: i32> {
337 pub command: ByteString,
339 pub timestamp: i64,
341 pub salt: i64,
343 pub argument_signatures:
345 Vec<crate::defs::p775::play::serverbound::ChatCommandSignedArgumentSignatures>,
346 pub message_count: i32,
348 pub acknowledged: Bytes,
350 pub checksum: u8,
352}
353#[cfg(feature = "v26_1")]
354impl<const V: i32> Decode for ChatCommandSigned<V> {
355 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
356 Ok({
357 let v1 = r.read_string()?;
358 let v2 = r.read_i64()?;
359 let v3 = r.read_i64()?;
360 let v4 = {
361 let v5 = {
362 let c = r.read_varint()?;
363 r.check_count(i64::from(c), 257)?
364 };
365 let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
366 for _ in 0..v5 {
367 v6.push({
368 let v7 = r.read_string()?;
369 let v8 = r.read_bytes(256)?;
370 crate::defs::p775::play::serverbound::ChatCommandSignedArgumentSignatures {
371 argument_name: v7,
372 signature: v8,
373 }
374 });
375 }
376 v6
377 };
378 let v9 = r.read_varint()?;
379 let v10 = r.read_bytes(3)?;
380 let v11 = r.read_u8()?;
381 Self {
382 command: v1,
383 timestamp: v2,
384 salt: v3,
385 argument_signatures: v4,
386 message_count: v9,
387 acknowledged: v10,
388 checksum: v11,
389 }
390 })
391 }
392}
393#[cfg(feature = "v26_1")]
394impl<const V: i32> Encode for ChatCommandSigned<V> {
395 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
396 w.put_string(&(*self).command)?;
397 w.put_i64((*self).timestamp);
398 w.put_i64((*self).salt);
399 w.put_len_varint((*self).argument_signatures.len())?;
400 for v1 in (*self).argument_signatures.iter() {
401 w.put_string(&(*v1).argument_name)?;
402 if (*v1).signature.len() != 256 {
403 return Err(EncodeError::CountMismatch {
404 field: "fixed buffer",
405 expected: 256,
406 actual: (*v1).signature.len(),
407 });
408 }
409 w.put_slice(&(*v1).signature);
410 }
411 w.put_varint((*self).message_count);
412 if (*self).acknowledged.len() != 3 {
413 return Err(EncodeError::CountMismatch {
414 field: "fixed buffer",
415 expected: 3,
416 actual: (*self).acknowledged.len(),
417 });
418 }
419 w.put_slice(&(*self).acknowledged);
420 w.put_u8((*self).checksum);
421 Ok(())
422 }
423}
424#[cfg(feature = "v26_1")]
425#[cfg(feature = "testgen")]
426impl<const V: i32> Generate for ChatCommandSigned<V> {
427 fn generate(g: &mut Gen) -> Self {
428 {
429 let v1 = g.string();
430 let v2 = g.i64();
431 let v3 = g.i64();
432 let v4 = {
433 let v5 = g.count();
434 let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
435 for _ in 0..v5 {
436 v6.push({
437 let v7 = g.string();
438 let v8 = g.fixed_bytes(256);
439 crate::defs::p775::play::serverbound::ChatCommandSignedArgumentSignatures {
440 argument_name: v7,
441 signature: v8,
442 }
443 });
444 }
445 v6
446 };
447 let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
448 let v10 = g.fixed_bytes(3);
449 let v11 = (g.int_in(0, 255, &[]) as u8);
450 Self {
451 command: v1,
452 timestamp: v2,
453 salt: v3,
454 argument_signatures: v4,
455 message_count: v9,
456 acknowledged: v10,
457 checksum: v11,
458 }
459 }
460 }
461}
462
463#[cfg(feature = "v26_1")]
464#[derive(Debug, Clone, PartialEq)]
466pub struct ChatMessage<const V: i32> {
467 pub message: ByteString,
469 pub timestamp: i64,
471 pub salt: i64,
473 pub signature: Option<Bytes>,
475 pub offset: i32,
477 pub acknowledged: Bytes,
479 pub checksum: u8,
481}
482#[cfg(feature = "v26_1")]
483impl<const V: i32> Decode for ChatMessage<V> {
484 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
485 Ok({
486 let v1 = r.read_string()?;
487 let v2 = r.read_i64()?;
488 let v3 = r.read_i64()?;
489 let v4 = if r.read_bool()? {
490 Some(r.read_bytes(256)?)
491 } else {
492 None
493 };
494 let v5 = r.read_varint()?;
495 let v6 = r.read_bytes(3)?;
496 let v7 = r.read_u8()?;
497 Self {
498 message: v1,
499 timestamp: v2,
500 salt: v3,
501 signature: v4,
502 offset: v5,
503 acknowledged: v6,
504 checksum: v7,
505 }
506 })
507 }
508}
509#[cfg(feature = "v26_1")]
510impl<const V: i32> Encode for ChatMessage<V> {
511 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
512 w.put_string(&(*self).message)?;
513 w.put_i64((*self).timestamp);
514 w.put_i64((*self).salt);
515 match &(*self).signature {
516 Some(v1) => {
517 w.put_u8(1);
518 if (*v1).len() != 256 {
519 return Err(EncodeError::CountMismatch {
520 field: "fixed buffer",
521 expected: 256,
522 actual: (*v1).len(),
523 });
524 }
525 w.put_slice(&(*v1));
526 }
527 None => w.put_u8(0),
528 }
529 w.put_varint((*self).offset);
530 if (*self).acknowledged.len() != 3 {
531 return Err(EncodeError::CountMismatch {
532 field: "fixed buffer",
533 expected: 3,
534 actual: (*self).acknowledged.len(),
535 });
536 }
537 w.put_slice(&(*self).acknowledged);
538 w.put_u8((*self).checksum);
539 Ok(())
540 }
541}
542#[cfg(feature = "v26_1")]
543#[cfg(feature = "testgen")]
544impl<const V: i32> Generate for ChatMessage<V> {
545 fn generate(g: &mut Gen) -> Self {
546 {
547 let v1 = g.string();
548 let v2 = g.i64();
549 let v3 = g.i64();
550 let v4 = if g.bool() {
551 Some(g.fixed_bytes(256))
552 } else {
553 None
554 };
555 let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
556 let v6 = g.fixed_bytes(3);
557 let v7 = (g.int_in(0, 255, &[]) as u8);
558 Self {
559 message: v1,
560 timestamp: v2,
561 salt: v3,
562 signature: v4,
563 offset: v5,
564 acknowledged: v6,
565 checksum: v7,
566 }
567 }
568 }
569}
570
571#[cfg(feature = "v26_1")]
572#[derive(Debug, Clone, PartialEq)]
574pub struct ChatSessionUpdate<const V: i32> {
575 pub session_uuid: Uuid,
577 pub expire_time: i64,
579 pub public_key: Bytes,
581 pub signature: Bytes,
583}
584#[cfg(feature = "v26_1")]
585impl<const V: i32> Decode for ChatSessionUpdate<V> {
586 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
587 Ok({
588 let v1 = r.read_uuid()?;
589 let v2 = r.read_i64()?;
590 let v3 = r.read_byte_array()?;
591 let v4 = r.read_byte_array()?;
592 Self {
593 session_uuid: v1,
594 expire_time: v2,
595 public_key: v3,
596 signature: v4,
597 }
598 })
599 }
600}
601#[cfg(feature = "v26_1")]
602impl<const V: i32> Encode for ChatSessionUpdate<V> {
603 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
604 w.put_uuid(&(*self).session_uuid);
605 w.put_i64((*self).expire_time);
606 w.put_byte_array(&(*self).public_key)?;
607 w.put_byte_array(&(*self).signature)?;
608 Ok(())
609 }
610}
611#[cfg(feature = "v26_1")]
612#[cfg(feature = "testgen")]
613impl<const V: i32> Generate for ChatSessionUpdate<V> {
614 fn generate(g: &mut Gen) -> Self {
615 {
616 let v1 = g.uuid();
617 let v2 = g.i64();
618 let v3 = g.bytes();
619 let v4 = g.bytes();
620 Self {
621 session_uuid: v1,
622 expire_time: v2,
623 public_key: v3,
624 signature: v4,
625 }
626 }
627 }
628}
629
630#[cfg(feature = "v26_1")]
631#[derive(Debug, Clone, PartialEq)]
633pub struct ChunkBatchReceived<const V: i32> {
634 pub chunks_per_tick: f32,
636}
637#[cfg(feature = "v26_1")]
638impl<const V: i32> Decode for ChunkBatchReceived<V> {
639 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
640 Ok({
641 let v1 = r.read_f32()?;
642 Self {
643 chunks_per_tick: v1,
644 }
645 })
646 }
647}
648#[cfg(feature = "v26_1")]
649impl<const V: i32> Encode for ChunkBatchReceived<V> {
650 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
651 w.put_f32((*self).chunks_per_tick);
652 Ok(())
653 }
654}
655#[cfg(feature = "v26_1")]
656#[cfg(feature = "testgen")]
657impl<const V: i32> Generate for ChunkBatchReceived<V> {
658 fn generate(g: &mut Gen) -> Self {
659 {
660 let v1 = g.f32();
661 Self {
662 chunks_per_tick: v1,
663 }
664 }
665 }
666}
667
668#[cfg(feature = "v26_1")]
669#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
671pub struct ClientCommandActionId(pub i32);
672#[cfg(feature = "v26_1")]
673impl ClientCommandActionId {
674 pub const PERFORM_RESPAWN: Self = Self(0);
676 pub const REQUEST_STATS: Self = Self(1);
678 pub const REQUEST_GAMERULE_VALUES: Self = Self(2);
680 pub const fn name(self) -> Option<&'static str> {
682 match self.0 {
683 0 => Some("perform_respawn"),
684 1 => Some("request_stats"),
685 2 => Some("request_gamerule_values"),
686 _ => None,
687 }
688 }
689}
690#[cfg(feature = "v26_1")]
691impl std::fmt::Debug for ClientCommandActionId {
692 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
693 match self.name() {
694 Some(n) => write!(f, "ClientCommandActionId::{n}"),
695 None => write!(f, "ClientCommandActionId({})", self.0),
696 }
697 }
698}
699
700#[cfg(feature = "v26_1")]
701#[derive(Debug, Clone, PartialEq)]
703pub struct ClientCommand<const V: i32> {
704 pub action_id: crate::defs::p775::play::serverbound::ClientCommandActionId,
706}
707#[cfg(feature = "v26_1")]
708impl<const V: i32> Decode for ClientCommand<V> {
709 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
710 Ok({
711 let v1 = crate::defs::p775::play::serverbound::ClientCommandActionId(r.read_varint()?);
712 Self { action_id: v1 }
713 })
714 }
715}
716#[cfg(feature = "v26_1")]
717impl<const V: i32> Encode for ClientCommand<V> {
718 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
719 w.put_varint((*self).action_id.0);
720 Ok(())
721 }
722}
723#[cfg(feature = "v26_1")]
724#[cfg(feature = "testgen")]
725impl<const V: i32> Generate for ClientCommand<V> {
726 fn generate(g: &mut Gen) -> Self {
727 {
728 let v1 = crate::defs::p775::play::serverbound::ClientCommandActionId(g.int_in(
729 -2147483648,
730 2147483647,
731 &[0, 1, 2],
732 )
733 as i32);
734 Self { action_id: v1 }
735 }
736 }
737}
738
739#[cfg(feature = "v26_1")]
740#[derive(Debug, Clone, PartialEq)]
742pub struct TickEnd<const V: i32> {}
743#[cfg(feature = "v26_1")]
744impl<const V: i32> Decode for TickEnd<V> {
745 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
746 Ok({ Self {} })
747 }
748}
749#[cfg(feature = "v26_1")]
750impl<const V: i32> Encode for TickEnd<V> {
751 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
752 Ok(())
753 }
754}
755#[cfg(feature = "v26_1")]
756#[cfg(feature = "testgen")]
757impl<const V: i32> Generate for TickEnd<V> {
758 fn generate(g: &mut Gen) -> Self {
759 { Self {} }
760 }
761}
762
763#[cfg(feature = "v26_1")]
764#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
766pub struct SettingsParticleStatus(pub i32);
767#[cfg(feature = "v26_1")]
768impl SettingsParticleStatus {
769 pub const ALL: Self = Self(0);
771 pub const DECREASED: Self = Self(1);
773 pub const MINIMAL: Self = Self(2);
775 pub const fn name(self) -> Option<&'static str> {
777 match self.0 {
778 0 => Some("all"),
779 1 => Some("decreased"),
780 2 => Some("minimal"),
781 _ => None,
782 }
783 }
784}
785#[cfg(feature = "v26_1")]
786impl std::fmt::Debug for SettingsParticleStatus {
787 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
788 match self.name() {
789 Some(n) => write!(f, "SettingsParticleStatus::{n}"),
790 None => write!(f, "SettingsParticleStatus({})", self.0),
791 }
792 }
793}
794
795#[cfg(feature = "v26_1")]
796#[derive(Debug, Clone, PartialEq)]
798pub struct Settings<const V: i32> {
799 pub locale: ByteString,
801 pub view_distance: i8,
803 pub chat_flags: i32,
805 pub chat_colors: bool,
807 pub skin_parts: u8,
809 pub main_hand: i32,
811 pub enable_text_filtering: bool,
813 pub enable_server_listing: bool,
815 pub particle_status: crate::defs::p775::play::serverbound::SettingsParticleStatus,
817}
818#[cfg(feature = "v26_1")]
819impl<const V: i32> Decode for Settings<V> {
820 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
821 Ok({
822 let v1 = r.read_string()?;
823 let v2 = r.read_i8()?;
824 let v3 = r.read_varint()?;
825 let v4 = r.read_bool()?;
826 let v5 = r.read_u8()?;
827 let v6 = r.read_varint()?;
828 let v7 = r.read_bool()?;
829 let v8 = r.read_bool()?;
830 let v9 = crate::defs::p775::play::serverbound::SettingsParticleStatus(r.read_varint()?);
831 Self {
832 locale: v1,
833 view_distance: v2,
834 chat_flags: v3,
835 chat_colors: v4,
836 skin_parts: v5,
837 main_hand: v6,
838 enable_text_filtering: v7,
839 enable_server_listing: v8,
840 particle_status: v9,
841 }
842 })
843 }
844}
845#[cfg(feature = "v26_1")]
846impl<const V: i32> Encode for Settings<V> {
847 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
848 w.put_string(&(*self).locale)?;
849 w.put_i8((*self).view_distance);
850 w.put_varint((*self).chat_flags);
851 w.put_bool((*self).chat_colors);
852 w.put_u8((*self).skin_parts);
853 w.put_varint((*self).main_hand);
854 w.put_bool((*self).enable_text_filtering);
855 w.put_bool((*self).enable_server_listing);
856 w.put_varint((*self).particle_status.0);
857 Ok(())
858 }
859}
860#[cfg(feature = "v26_1")]
861#[cfg(feature = "testgen")]
862impl<const V: i32> Generate for Settings<V> {
863 fn generate(g: &mut Gen) -> Self {
864 {
865 let v1 = g.string();
866 let v2 = (g.int_in(-128, 127, &[]) as i8);
867 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
868 let v4 = g.bool();
869 let v5 = (g.int_in(0, 255, &[]) as u8);
870 let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
871 let v7 = g.bool();
872 let v8 = g.bool();
873 let v9 = crate::defs::p775::play::serverbound::SettingsParticleStatus(g.int_in(
874 -2147483648,
875 2147483647,
876 &[0, 1, 2],
877 )
878 as i32);
879 Self {
880 locale: v1,
881 view_distance: v2,
882 chat_flags: v3,
883 chat_colors: v4,
884 skin_parts: v5,
885 main_hand: v6,
886 enable_text_filtering: v7,
887 enable_server_listing: v8,
888 particle_status: v9,
889 }
890 }
891 }
892}
893
894#[cfg(feature = "v26_1")]
895#[derive(Debug, Clone, PartialEq)]
897pub struct ConfigurationAcknowledged<const V: i32> {}
898#[cfg(feature = "v26_1")]
899impl<const V: i32> Decode for ConfigurationAcknowledged<V> {
900 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
901 Ok({ Self {} })
902 }
903}
904#[cfg(feature = "v26_1")]
905impl<const V: i32> Encode for ConfigurationAcknowledged<V> {
906 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
907 Ok(())
908 }
909}
910#[cfg(feature = "v26_1")]
911#[cfg(feature = "testgen")]
912impl<const V: i32> Generate for ConfigurationAcknowledged<V> {
913 fn generate(g: &mut Gen) -> Self {
914 { Self {} }
915 }
916}
917
918#[cfg(feature = "v26_1")]
919#[derive(Debug, Clone, PartialEq)]
921pub struct EnchantItem<const V: i32> {
922 pub window_id: i32,
924 pub enchantment: i32,
926}
927#[cfg(feature = "v26_1")]
928impl<const V: i32> Decode for EnchantItem<V> {
929 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
930 Ok({
931 let v1 = r.read_varint()?;
932 let v2 = r.read_varint()?;
933 Self {
934 window_id: v1,
935 enchantment: v2,
936 }
937 })
938 }
939}
940#[cfg(feature = "v26_1")]
941impl<const V: i32> Encode for EnchantItem<V> {
942 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
943 w.put_varint((*self).window_id);
944 w.put_varint((*self).enchantment);
945 Ok(())
946 }
947}
948#[cfg(feature = "v26_1")]
949#[cfg(feature = "testgen")]
950impl<const V: i32> Generate for EnchantItem<V> {
951 fn generate(g: &mut Gen) -> Self {
952 {
953 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
954 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
955 Self {
956 window_id: v1,
957 enchantment: v2,
958 }
959 }
960 }
961}
962
963#[cfg(feature = "v26_1")]
964#[derive(Debug, Clone, PartialEq)]
966pub struct WindowClickChangedSlots {
967 pub location: i16,
969 pub item: Option<crate::defs::p775::types::HashedSlot>,
971}
972
973#[cfg(feature = "v26_1")]
974#[derive(Debug, Clone, PartialEq)]
976pub struct WindowClick<const V: i32> {
977 pub window_id: i32,
979 pub state_id: i32,
981 pub slot: i16,
983 pub mouse_button: i8,
985 pub mode: i32,
987 pub changed_slots: Vec<crate::defs::p775::play::serverbound::WindowClickChangedSlots>,
989 pub cursor_item: Option<crate::defs::p775::types::HashedSlot>,
991}
992#[cfg(feature = "v26_1")]
993impl<const V: i32> Decode for WindowClick<V> {
994 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
995 Ok({
996 let v1 = r.read_varint()?;
997 let v2 = r.read_varint()?;
998 let v3 = r.read_i16()?;
999 let v4 = r.read_i8()?;
1000 let v5 = r.read_varint()?;
1001 let v6 = {
1002 let v7 = {
1003 let c = r.read_varint()?;
1004 r.check_count(i64::from(c), 3)?
1005 };
1006 let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
1007 for _ in 0..v7 {
1008 v8.push({
1009 let v9 = r.read_i16()?;
1010 let v10 = if r.read_bool()? {
1011 Some(<crate::defs::p775::types::HashedSlot as Decode>::decode(r)?)
1012 } else {
1013 None
1014 };
1015 crate::defs::p775::play::serverbound::WindowClickChangedSlots {
1016 location: v9,
1017 item: v10,
1018 }
1019 });
1020 }
1021 v8
1022 };
1023 let v11 = if r.read_bool()? {
1024 Some(<crate::defs::p775::types::HashedSlot as Decode>::decode(r)?)
1025 } else {
1026 None
1027 };
1028 Self {
1029 window_id: v1,
1030 state_id: v2,
1031 slot: v3,
1032 mouse_button: v4,
1033 mode: v5,
1034 changed_slots: v6,
1035 cursor_item: v11,
1036 }
1037 })
1038 }
1039}
1040#[cfg(feature = "v26_1")]
1041impl<const V: i32> Encode for WindowClick<V> {
1042 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1043 w.put_varint((*self).window_id);
1044 w.put_varint((*self).state_id);
1045 w.put_i16((*self).slot);
1046 w.put_i8((*self).mouse_button);
1047 w.put_varint((*self).mode);
1048 w.put_len_varint((*self).changed_slots.len())?;
1049 for v1 in (*self).changed_slots.iter() {
1050 w.put_i16((*v1).location);
1051 match &(*v1).item {
1052 Some(v2) => {
1053 w.put_u8(1);
1054 (*v2).encode(w)?;
1055 }
1056 None => w.put_u8(0),
1057 }
1058 }
1059 match &(*self).cursor_item {
1060 Some(v3) => {
1061 w.put_u8(1);
1062 (*v3).encode(w)?;
1063 }
1064 None => w.put_u8(0),
1065 }
1066 Ok(())
1067 }
1068}
1069#[cfg(feature = "v26_1")]
1070#[cfg(feature = "testgen")]
1071impl<const V: i32> Generate for WindowClick<V> {
1072 fn generate(g: &mut Gen) -> Self {
1073 {
1074 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1075 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1076 let v3 = (g.int_in(-32768, 32767, &[]) as i16);
1077 let v4 = (g.int_in(-128, 127, &[]) as i8);
1078 let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1079 let v6 = {
1080 let v7 = g.count();
1081 let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
1082 for _ in 0..v7 {
1083 v8.push({
1084 let v9 = (g.int_in(-32768, 32767, &[]) as i16);
1085 let v10 = if g.bool() {
1086 Some(<crate::defs::p775::types::HashedSlot as Generate>::generate(g))
1087 } else {
1088 None
1089 };
1090 crate::defs::p775::play::serverbound::WindowClickChangedSlots {
1091 location: v9,
1092 item: v10,
1093 }
1094 });
1095 }
1096 v8
1097 };
1098 let v11 = if g.bool() {
1099 Some(<crate::defs::p775::types::HashedSlot as Generate>::generate(g))
1100 } else {
1101 None
1102 };
1103 Self {
1104 window_id: v1,
1105 state_id: v2,
1106 slot: v3,
1107 mouse_button: v4,
1108 mode: v5,
1109 changed_slots: v6,
1110 cursor_item: v11,
1111 }
1112 }
1113 }
1114}
1115
1116#[cfg(feature = "v26_1")]
1117#[derive(Debug, Clone, PartialEq)]
1119pub struct CloseWindow<const V: i32> {
1120 pub window_id: i32,
1122}
1123#[cfg(feature = "v26_1")]
1124impl<const V: i32> Decode for CloseWindow<V> {
1125 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1126 Ok({
1127 let v1 = r.read_varint()?;
1128 Self { window_id: v1 }
1129 })
1130 }
1131}
1132#[cfg(feature = "v26_1")]
1133impl<const V: i32> Encode for CloseWindow<V> {
1134 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1135 w.put_varint((*self).window_id);
1136 Ok(())
1137 }
1138}
1139#[cfg(feature = "v26_1")]
1140#[cfg(feature = "testgen")]
1141impl<const V: i32> Generate for CloseWindow<V> {
1142 fn generate(g: &mut Gen) -> Self {
1143 {
1144 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1145 Self { window_id: v1 }
1146 }
1147 }
1148}
1149
1150#[cfg(feature = "v26_1")]
1151#[derive(Debug, Clone, PartialEq)]
1153pub struct SetSlotState<const V: i32> {
1154 pub slot_id: i32,
1156 pub window_id: i32,
1158 pub state: bool,
1160}
1161#[cfg(feature = "v26_1")]
1162impl<const V: i32> Decode for SetSlotState<V> {
1163 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1164 Ok({
1165 let v1 = r.read_varint()?;
1166 let v2 = r.read_varint()?;
1167 let v3 = r.read_bool()?;
1168 Self {
1169 slot_id: v1,
1170 window_id: v2,
1171 state: v3,
1172 }
1173 })
1174 }
1175}
1176#[cfg(feature = "v26_1")]
1177impl<const V: i32> Encode for SetSlotState<V> {
1178 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1179 w.put_varint((*self).slot_id);
1180 w.put_varint((*self).window_id);
1181 w.put_bool((*self).state);
1182 Ok(())
1183 }
1184}
1185#[cfg(feature = "v26_1")]
1186#[cfg(feature = "testgen")]
1187impl<const V: i32> Generate for SetSlotState<V> {
1188 fn generate(g: &mut Gen) -> Self {
1189 {
1190 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1191 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1192 let v3 = g.bool();
1193 Self {
1194 slot_id: v1,
1195 window_id: v2,
1196 state: v3,
1197 }
1198 }
1199 }
1200}
1201
1202#[cfg(feature = "v26_1")]
1203#[derive(Debug, Clone, PartialEq)]
1205pub struct CookieResponse<const V: i32> {
1206 pub key: ByteString,
1208 pub value: Option<Bytes>,
1210}
1211#[cfg(feature = "v26_1")]
1212impl<const V: i32> Decode for CookieResponse<V> {
1213 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1214 Ok({
1215 let v1 = r.read_string()?;
1216 let v2 = if r.read_bool()? {
1217 Some(r.read_byte_array()?)
1218 } else {
1219 None
1220 };
1221 Self { key: v1, value: v2 }
1222 })
1223 }
1224}
1225#[cfg(feature = "v26_1")]
1226impl<const V: i32> Encode for CookieResponse<V> {
1227 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1228 w.put_string(&(*self).key)?;
1229 match &(*self).value {
1230 Some(v1) => {
1231 w.put_u8(1);
1232 w.put_byte_array(&(*v1))?;
1233 }
1234 None => w.put_u8(0),
1235 }
1236 Ok(())
1237 }
1238}
1239#[cfg(feature = "v26_1")]
1240#[cfg(feature = "testgen")]
1241impl<const V: i32> Generate for CookieResponse<V> {
1242 fn generate(g: &mut Gen) -> Self {
1243 {
1244 let v1 = g.string();
1245 let v2 = if g.bool() { Some(g.bytes()) } else { None };
1246 Self { key: v1, value: v2 }
1247 }
1248 }
1249}
1250
1251#[cfg(feature = "v26_1")]
1252#[derive(Debug, Clone, PartialEq)]
1254pub struct DebugSubscriptionRequest<const V: i32> {
1255 pub subscriptions: Vec<crate::defs::p775::types::DebugSubscriptionDataType>,
1257}
1258#[cfg(feature = "v26_1")]
1259impl<const V: i32> Decode for DebugSubscriptionRequest<V> {
1260 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1261 Ok({
1262 let v1 = {
1263 let v2 = {
1264 let c = r.read_varint()?;
1265 r.check_count(i64::from(c), 1)?
1266 };
1267 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1268 for _ in 0..v2 {
1269 v3.push(crate::defs::p775::types::DebugSubscriptionDataType(
1270 r.read_varint()?,
1271 ));
1272 }
1273 v3
1274 };
1275 Self { subscriptions: v1 }
1276 })
1277 }
1278}
1279#[cfg(feature = "v26_1")]
1280impl<const V: i32> Encode for DebugSubscriptionRequest<V> {
1281 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1282 w.put_len_varint((*self).subscriptions.len())?;
1283 for v1 in (*self).subscriptions.iter() {
1284 w.put_varint((*v1).0);
1285 }
1286 Ok(())
1287 }
1288}
1289#[cfg(feature = "v26_1")]
1290#[cfg(feature = "testgen")]
1291impl<const V: i32> Generate for DebugSubscriptionRequest<V> {
1292 fn generate(g: &mut Gen) -> Self {
1293 {
1294 let v1 = {
1295 let v2 = g.count();
1296 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
1297 for _ in 0..v2 {
1298 v3.push(crate::defs::p775::types::DebugSubscriptionDataType(
1299 g.int_in(
1300 -2147483648,
1301 2147483647,
1302 &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
1303 ) as i32,
1304 ));
1305 }
1306 v3
1307 };
1308 Self { subscriptions: v1 }
1309 }
1310 }
1311}
1312
1313#[cfg(feature = "v26_1")]
1314#[derive(Debug, Clone, PartialEq)]
1316pub struct EditBook<const V: i32> {
1317 pub hand: i32,
1319 pub pages: Vec<ByteString>,
1321 pub title: Option<ByteString>,
1323}
1324#[cfg(feature = "v26_1")]
1325impl<const V: i32> Decode for EditBook<V> {
1326 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1327 Ok({
1328 let v1 = r.read_varint()?;
1329 let v2 = {
1330 let v3 = {
1331 let c = r.read_varint()?;
1332 r.check_count(i64::from(c), 1)?
1333 };
1334 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1335 for _ in 0..v3 {
1336 v4.push(r.read_string()?);
1337 }
1338 v4
1339 };
1340 let v5 = if r.read_bool()? {
1341 Some(r.read_string()?)
1342 } else {
1343 None
1344 };
1345 Self {
1346 hand: v1,
1347 pages: v2,
1348 title: v5,
1349 }
1350 })
1351 }
1352}
1353#[cfg(feature = "v26_1")]
1354impl<const V: i32> Encode for EditBook<V> {
1355 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1356 w.put_varint((*self).hand);
1357 w.put_len_varint((*self).pages.len())?;
1358 for v1 in (*self).pages.iter() {
1359 w.put_string(&(*v1))?;
1360 }
1361 match &(*self).title {
1362 Some(v2) => {
1363 w.put_u8(1);
1364 w.put_string(&(*v2))?;
1365 }
1366 None => w.put_u8(0),
1367 }
1368 Ok(())
1369 }
1370}
1371#[cfg(feature = "v26_1")]
1372#[cfg(feature = "testgen")]
1373impl<const V: i32> Generate for EditBook<V> {
1374 fn generate(g: &mut Gen) -> Self {
1375 {
1376 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1377 let v2 = {
1378 let v3 = g.count();
1379 let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
1380 for _ in 0..v3 {
1381 v4.push(g.string());
1382 }
1383 v4
1384 };
1385 let v5 = if g.bool() { Some(g.string()) } else { None };
1386 Self {
1387 hand: v1,
1388 pages: v2,
1389 title: v5,
1390 }
1391 }
1392 }
1393}
1394
1395#[cfg(feature = "v26_1")]
1396#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
1398pub struct UseEntityHand(pub i32);
1399#[cfg(feature = "v26_1")]
1400impl UseEntityHand {
1401 pub const MAIN_HAND: Self = Self(0);
1403 pub const OFF_HAND: Self = Self(1);
1405 pub const fn name(self) -> Option<&'static str> {
1407 match self.0 {
1408 0 => Some("main_hand"),
1409 1 => Some("off_hand"),
1410 _ => None,
1411 }
1412 }
1413}
1414#[cfg(feature = "v26_1")]
1415impl std::fmt::Debug for UseEntityHand {
1416 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1417 match self.name() {
1418 Some(n) => write!(f, "UseEntityHand::{n}"),
1419 None => write!(f, "UseEntityHand({})", self.0),
1420 }
1421 }
1422}
1423
1424#[cfg(feature = "v26_1")]
1425#[derive(Debug, Clone, PartialEq)]
1427pub struct UseEntity<const V: i32> {
1428 pub target: i32,
1430 pub hand: crate::defs::p775::play::serverbound::UseEntityHand,
1432 pub location: LpVec3,
1434 pub sneaking: bool,
1436}
1437#[cfg(feature = "v26_1")]
1438impl<const V: i32> Decode for UseEntity<V> {
1439 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1440 Ok({
1441 let v1 = r.read_varint()?;
1442 let v2 = crate::defs::p775::play::serverbound::UseEntityHand(r.read_varint()?);
1443 let v3 = LpVec3::read(r)?;
1444 let v4 = r.read_bool()?;
1445 Self {
1446 target: v1,
1447 hand: v2,
1448 location: v3,
1449 sneaking: v4,
1450 }
1451 })
1452 }
1453}
1454#[cfg(feature = "v26_1")]
1455impl<const V: i32> Encode for UseEntity<V> {
1456 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1457 w.put_varint((*self).target);
1458 w.put_varint((*self).hand.0);
1459 (*self).location.write(w);
1460 w.put_bool((*self).sneaking);
1461 Ok(())
1462 }
1463}
1464#[cfg(feature = "v26_1")]
1465#[cfg(feature = "testgen")]
1466impl<const V: i32> Generate for UseEntity<V> {
1467 fn generate(g: &mut Gen) -> Self {
1468 {
1469 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1470 let v2 = crate::defs::p775::play::serverbound::UseEntityHand(g.int_in(
1471 -2147483648,
1472 2147483647,
1473 &[0, 1],
1474 ) as i32);
1475 let v3 = <LpVec3 as Generate>::generate(g);
1476 let v4 = g.bool();
1477 Self {
1478 target: v1,
1479 hand: v2,
1480 location: v3,
1481 sneaking: v4,
1482 }
1483 }
1484 }
1485}
1486
1487#[cfg(feature = "v26_1")]
1488#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
1490pub struct MovementFlags(pub u8);
1491#[cfg(feature = "v26_1")]
1492impl MovementFlags {
1493 pub const ON_GROUND: Self = Self(1 << 0);
1495 pub const HAS_HORIZONTAL_COLLISION: Self = Self(1 << 1);
1497 #[inline]
1499 pub const fn contains(self, f: Self) -> bool {
1500 self.0 & f.0 == f.0
1501 }
1502 #[inline]
1504 #[must_use]
1505 pub const fn with(self, f: Self) -> Self {
1506 Self(self.0 | f.0)
1507 }
1508}
1509
1510#[cfg(feature = "v26_1")]
1511#[derive(Debug, Clone, PartialEq)]
1513pub struct Position<const V: i32> {
1514 pub x: f64,
1516 pub y: f64,
1518 pub z: f64,
1520 pub flags: crate::defs::p775::play::serverbound::MovementFlags,
1522}
1523#[cfg(feature = "v26_1")]
1524impl<const V: i32> Decode for Position<V> {
1525 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1526 Ok({
1527 let v1 = r.read_f64()?;
1528 let v2 = r.read_f64()?;
1529 let v3 = r.read_f64()?;
1530 let v4 = crate::defs::p775::play::serverbound::MovementFlags(r.read_u8()?);
1531 Self {
1532 x: v1,
1533 y: v2,
1534 z: v3,
1535 flags: v4,
1536 }
1537 })
1538 }
1539}
1540#[cfg(feature = "v26_1")]
1541impl<const V: i32> Encode for Position<V> {
1542 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1543 w.put_f64((*self).x);
1544 w.put_f64((*self).y);
1545 w.put_f64((*self).z);
1546 w.put_u8((*self).flags.0);
1547 Ok(())
1548 }
1549}
1550#[cfg(feature = "v26_1")]
1551#[cfg(feature = "testgen")]
1552impl<const V: i32> Generate for Position<V> {
1553 fn generate(g: &mut Gen) -> Self {
1554 {
1555 let v1 = g.f64();
1556 let v2 = g.f64();
1557 let v3 = g.f64();
1558 let v4 =
1559 crate::defs::p775::play::serverbound::MovementFlags(g.int_in(0, 255, &[]) as u8);
1560 Self {
1561 x: v1,
1562 y: v2,
1563 z: v3,
1564 flags: v4,
1565 }
1566 }
1567 }
1568}
1569
1570#[cfg(feature = "v26_1")]
1571#[derive(Debug, Clone, PartialEq)]
1573pub struct PositionLook<const V: i32> {
1574 pub x: f64,
1576 pub y: f64,
1578 pub z: f64,
1580 pub yaw: f32,
1582 pub pitch: f32,
1584 pub flags: crate::defs::p775::play::serverbound::MovementFlags,
1586}
1587#[cfg(feature = "v26_1")]
1588impl<const V: i32> Decode for PositionLook<V> {
1589 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1590 Ok({
1591 let v1 = r.read_f64()?;
1592 let v2 = r.read_f64()?;
1593 let v3 = r.read_f64()?;
1594 let v4 = r.read_f32()?;
1595 let v5 = r.read_f32()?;
1596 let v6 = crate::defs::p775::play::serverbound::MovementFlags(r.read_u8()?);
1597 Self {
1598 x: v1,
1599 y: v2,
1600 z: v3,
1601 yaw: v4,
1602 pitch: v5,
1603 flags: v6,
1604 }
1605 })
1606 }
1607}
1608#[cfg(feature = "v26_1")]
1609impl<const V: i32> Encode for PositionLook<V> {
1610 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1611 w.put_f64((*self).x);
1612 w.put_f64((*self).y);
1613 w.put_f64((*self).z);
1614 w.put_f32((*self).yaw);
1615 w.put_f32((*self).pitch);
1616 w.put_u8((*self).flags.0);
1617 Ok(())
1618 }
1619}
1620#[cfg(feature = "v26_1")]
1621#[cfg(feature = "testgen")]
1622impl<const V: i32> Generate for PositionLook<V> {
1623 fn generate(g: &mut Gen) -> Self {
1624 {
1625 let v1 = g.f64();
1626 let v2 = g.f64();
1627 let v3 = g.f64();
1628 let v4 = g.f32();
1629 let v5 = g.f32();
1630 let v6 =
1631 crate::defs::p775::play::serverbound::MovementFlags(g.int_in(0, 255, &[]) as u8);
1632 Self {
1633 x: v1,
1634 y: v2,
1635 z: v3,
1636 yaw: v4,
1637 pitch: v5,
1638 flags: v6,
1639 }
1640 }
1641 }
1642}
1643
1644#[cfg(feature = "v26_1")]
1645#[derive(Debug, Clone, PartialEq)]
1647pub struct Look<const V: i32> {
1648 pub yaw: f32,
1650 pub pitch: f32,
1652 pub flags: crate::defs::p775::play::serverbound::MovementFlags,
1654}
1655#[cfg(feature = "v26_1")]
1656impl<const V: i32> Decode for Look<V> {
1657 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1658 Ok({
1659 let v1 = r.read_f32()?;
1660 let v2 = r.read_f32()?;
1661 let v3 = crate::defs::p775::play::serverbound::MovementFlags(r.read_u8()?);
1662 Self {
1663 yaw: v1,
1664 pitch: v2,
1665 flags: v3,
1666 }
1667 })
1668 }
1669}
1670#[cfg(feature = "v26_1")]
1671impl<const V: i32> Encode for Look<V> {
1672 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1673 w.put_f32((*self).yaw);
1674 w.put_f32((*self).pitch);
1675 w.put_u8((*self).flags.0);
1676 Ok(())
1677 }
1678}
1679#[cfg(feature = "v26_1")]
1680#[cfg(feature = "testgen")]
1681impl<const V: i32> Generate for Look<V> {
1682 fn generate(g: &mut Gen) -> Self {
1683 {
1684 let v1 = g.f32();
1685 let v2 = g.f32();
1686 let v3 =
1687 crate::defs::p775::play::serverbound::MovementFlags(g.int_in(0, 255, &[]) as u8);
1688 Self {
1689 yaw: v1,
1690 pitch: v2,
1691 flags: v3,
1692 }
1693 }
1694 }
1695}
1696
1697#[cfg(feature = "v26_1")]
1698#[derive(Debug, Clone, PartialEq)]
1700pub struct Flying<const V: i32> {
1701 pub flags: crate::defs::p775::play::serverbound::MovementFlags,
1703}
1704#[cfg(feature = "v26_1")]
1705impl<const V: i32> Decode for Flying<V> {
1706 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1707 Ok({
1708 let v1 = crate::defs::p775::play::serverbound::MovementFlags(r.read_u8()?);
1709 Self { flags: v1 }
1710 })
1711 }
1712}
1713#[cfg(feature = "v26_1")]
1714impl<const V: i32> Encode for Flying<V> {
1715 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1716 w.put_u8((*self).flags.0);
1717 Ok(())
1718 }
1719}
1720#[cfg(feature = "v26_1")]
1721#[cfg(feature = "testgen")]
1722impl<const V: i32> Generate for Flying<V> {
1723 fn generate(g: &mut Gen) -> Self {
1724 {
1725 let v1 =
1726 crate::defs::p775::play::serverbound::MovementFlags(g.int_in(0, 255, &[]) as u8);
1727 Self { flags: v1 }
1728 }
1729 }
1730}
1731
1732#[cfg(feature = "v26_1")]
1733#[derive(Debug, Clone, PartialEq)]
1735pub struct VehicleMove<const V: i32> {
1736 pub x: f64,
1738 pub y: f64,
1740 pub z: f64,
1742 pub yaw: f32,
1744 pub pitch: f32,
1746 pub on_ground: bool,
1748}
1749#[cfg(feature = "v26_1")]
1750impl<const V: i32> Decode for VehicleMove<V> {
1751 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1752 Ok({
1753 let v1 = r.read_f64()?;
1754 let v2 = r.read_f64()?;
1755 let v3 = r.read_f64()?;
1756 let v4 = r.read_f32()?;
1757 let v5 = r.read_f32()?;
1758 let v6 = r.read_bool()?;
1759 Self {
1760 x: v1,
1761 y: v2,
1762 z: v3,
1763 yaw: v4,
1764 pitch: v5,
1765 on_ground: v6,
1766 }
1767 })
1768 }
1769}
1770#[cfg(feature = "v26_1")]
1771impl<const V: i32> Encode for VehicleMove<V> {
1772 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1773 w.put_f64((*self).x);
1774 w.put_f64((*self).y);
1775 w.put_f64((*self).z);
1776 w.put_f32((*self).yaw);
1777 w.put_f32((*self).pitch);
1778 w.put_bool((*self).on_ground);
1779 Ok(())
1780 }
1781}
1782#[cfg(feature = "v26_1")]
1783#[cfg(feature = "testgen")]
1784impl<const V: i32> Generate for VehicleMove<V> {
1785 fn generate(g: &mut Gen) -> Self {
1786 {
1787 let v1 = g.f64();
1788 let v2 = g.f64();
1789 let v3 = g.f64();
1790 let v4 = g.f32();
1791 let v5 = g.f32();
1792 let v6 = g.bool();
1793 Self {
1794 x: v1,
1795 y: v2,
1796 z: v3,
1797 yaw: v4,
1798 pitch: v5,
1799 on_ground: v6,
1800 }
1801 }
1802 }
1803}
1804
1805#[cfg(feature = "v26_1")]
1806#[derive(Debug, Clone, PartialEq)]
1808pub struct PickItemFromBlock<const V: i32> {
1809 pub position: BlockPos,
1811 pub include_data: bool,
1813}
1814#[cfg(feature = "v26_1")]
1815impl<const V: i32> Decode for PickItemFromBlock<V> {
1816 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1817 Ok({
1818 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
1819 let v2 = r.read_bool()?;
1820 Self {
1821 position: v1,
1822 include_data: v2,
1823 }
1824 })
1825 }
1826}
1827#[cfg(feature = "v26_1")]
1828impl<const V: i32> Encode for PickItemFromBlock<V> {
1829 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1830 (*self).position.write(w, PositionLayout::Xzy)?;
1831 w.put_bool((*self).include_data);
1832 Ok(())
1833 }
1834}
1835#[cfg(feature = "v26_1")]
1836#[cfg(feature = "testgen")]
1837impl<const V: i32> Generate for PickItemFromBlock<V> {
1838 fn generate(g: &mut Gen) -> Self {
1839 {
1840 let v1 = g.position();
1841 let v2 = g.bool();
1842 Self {
1843 position: v1,
1844 include_data: v2,
1845 }
1846 }
1847 }
1848}
1849
1850#[cfg(feature = "v26_1")]
1851#[derive(Debug, Clone, PartialEq)]
1853pub struct PickItemFromEntity<const V: i32> {
1854 pub entity_id: i32,
1856 pub include_data: bool,
1858}
1859#[cfg(feature = "v26_1")]
1860impl<const V: i32> Decode for PickItemFromEntity<V> {
1861 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1862 Ok({
1863 let v1 = r.read_varint()?;
1864 let v2 = r.read_bool()?;
1865 Self {
1866 entity_id: v1,
1867 include_data: v2,
1868 }
1869 })
1870 }
1871}
1872#[cfg(feature = "v26_1")]
1873impl<const V: i32> Encode for PickItemFromEntity<V> {
1874 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1875 w.put_varint((*self).entity_id);
1876 w.put_bool((*self).include_data);
1877 Ok(())
1878 }
1879}
1880#[cfg(feature = "v26_1")]
1881#[cfg(feature = "testgen")]
1882impl<const V: i32> Generate for PickItemFromEntity<V> {
1883 fn generate(g: &mut Gen) -> Self {
1884 {
1885 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1886 let v2 = g.bool();
1887 Self {
1888 entity_id: v1,
1889 include_data: v2,
1890 }
1891 }
1892 }
1893}
1894
1895#[cfg(feature = "v26_1")]
1896#[derive(Debug, Clone, PartialEq)]
1898pub struct PingRequest<const V: i32> {
1899 pub id: i64,
1901}
1902#[cfg(feature = "v26_1")]
1903impl<const V: i32> Decode for PingRequest<V> {
1904 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1905 Ok({
1906 let v1 = r.read_i64()?;
1907 Self { id: v1 }
1908 })
1909 }
1910}
1911#[cfg(feature = "v26_1")]
1912impl<const V: i32> Encode for PingRequest<V> {
1913 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1914 w.put_i64((*self).id);
1915 Ok(())
1916 }
1917}
1918#[cfg(feature = "v26_1")]
1919#[cfg(feature = "testgen")]
1920impl<const V: i32> Generate for PingRequest<V> {
1921 fn generate(g: &mut Gen) -> Self {
1922 {
1923 let v1 = g.i64();
1924 Self { id: v1 }
1925 }
1926 }
1927}
1928
1929#[cfg(feature = "v26_1")]
1930#[derive(Debug, Clone, PartialEq)]
1932pub struct CraftRecipeRequest<const V: i32> {
1933 pub window_id: i32,
1935 pub recipe_id: i32,
1937 pub make_all: bool,
1939}
1940#[cfg(feature = "v26_1")]
1941impl<const V: i32> Decode for CraftRecipeRequest<V> {
1942 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1943 Ok({
1944 let v1 = r.read_varint()?;
1945 let v2 = r.read_varint()?;
1946 let v3 = r.read_bool()?;
1947 Self {
1948 window_id: v1,
1949 recipe_id: v2,
1950 make_all: v3,
1951 }
1952 })
1953 }
1954}
1955#[cfg(feature = "v26_1")]
1956impl<const V: i32> Encode for CraftRecipeRequest<V> {
1957 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1958 w.put_varint((*self).window_id);
1959 w.put_varint((*self).recipe_id);
1960 w.put_bool((*self).make_all);
1961 Ok(())
1962 }
1963}
1964#[cfg(feature = "v26_1")]
1965#[cfg(feature = "testgen")]
1966impl<const V: i32> Generate for CraftRecipeRequest<V> {
1967 fn generate(g: &mut Gen) -> Self {
1968 {
1969 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1970 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1971 let v3 = g.bool();
1972 Self {
1973 window_id: v1,
1974 recipe_id: v2,
1975 make_all: v3,
1976 }
1977 }
1978 }
1979}
1980
1981#[cfg(feature = "v26_1")]
1982#[derive(Debug, Clone, PartialEq)]
1984pub struct BlockDig<const V: i32> {
1985 pub status: i32,
1987 pub location: BlockPos,
1989 pub face: i8,
1991 pub sequence: i32,
1993}
1994#[cfg(feature = "v26_1")]
1995impl<const V: i32> Decode for BlockDig<V> {
1996 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1997 Ok({
1998 let v1 = r.read_varint()?;
1999 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
2000 let v3 = r.read_i8()?;
2001 let v4 = r.read_varint()?;
2002 Self {
2003 status: v1,
2004 location: v2,
2005 face: v3,
2006 sequence: v4,
2007 }
2008 })
2009 }
2010}
2011#[cfg(feature = "v26_1")]
2012impl<const V: i32> Encode for BlockDig<V> {
2013 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2014 w.put_varint((*self).status);
2015 (*self).location.write(w, PositionLayout::Xzy)?;
2016 w.put_i8((*self).face);
2017 w.put_varint((*self).sequence);
2018 Ok(())
2019 }
2020}
2021#[cfg(feature = "v26_1")]
2022#[cfg(feature = "testgen")]
2023impl<const V: i32> Generate for BlockDig<V> {
2024 fn generate(g: &mut Gen) -> Self {
2025 {
2026 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2027 let v2 = g.position();
2028 let v3 = (g.int_in(-128, 127, &[]) as i8);
2029 let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2030 Self {
2031 status: v1,
2032 location: v2,
2033 face: v3,
2034 sequence: v4,
2035 }
2036 }
2037 }
2038}
2039
2040#[cfg(feature = "v26_1")]
2041#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2043pub struct EntityActionActionId(pub i32);
2044#[cfg(feature = "v26_1")]
2045impl EntityActionActionId {
2046 pub const STOP_SLEEPING: Self = Self(0);
2048 pub const START_SPRINTING: Self = Self(1);
2050 pub const STOP_SPRINTING: Self = Self(2);
2052 pub const START_RIDING_JUMP: Self = Self(3);
2054 pub const STOP_RIDING_JUMP: Self = Self(4);
2056 pub const OPEN_INVENTORY: Self = Self(5);
2058 pub const START_FALL_FLYING: Self = Self(6);
2060 pub const fn name(self) -> Option<&'static str> {
2062 match self.0 {
2063 0 => Some("stop_sleeping"),
2064 1 => Some("start_sprinting"),
2065 2 => Some("stop_sprinting"),
2066 3 => Some("start_riding_jump"),
2067 4 => Some("stop_riding_jump"),
2068 5 => Some("open_inventory"),
2069 6 => Some("start_fall_flying"),
2070 _ => None,
2071 }
2072 }
2073}
2074#[cfg(feature = "v26_1")]
2075impl std::fmt::Debug for EntityActionActionId {
2076 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2077 match self.name() {
2078 Some(n) => write!(f, "EntityActionActionId::{n}"),
2079 None => write!(f, "EntityActionActionId({})", self.0),
2080 }
2081 }
2082}
2083
2084#[cfg(feature = "v26_1")]
2085#[derive(Debug, Clone, PartialEq)]
2087pub struct EntityAction<const V: i32> {
2088 pub entity_id: i32,
2090 pub action_id: crate::defs::p775::play::serverbound::EntityActionActionId,
2092 pub jump_boost: i32,
2094}
2095#[cfg(feature = "v26_1")]
2096impl<const V: i32> Decode for EntityAction<V> {
2097 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2098 Ok({
2099 let v1 = r.read_varint()?;
2100 let v2 = crate::defs::p775::play::serverbound::EntityActionActionId(r.read_varint()?);
2101 let v3 = r.read_varint()?;
2102 Self {
2103 entity_id: v1,
2104 action_id: v2,
2105 jump_boost: v3,
2106 }
2107 })
2108 }
2109}
2110#[cfg(feature = "v26_1")]
2111impl<const V: i32> Encode for EntityAction<V> {
2112 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2113 w.put_varint((*self).entity_id);
2114 w.put_varint((*self).action_id.0);
2115 w.put_varint((*self).jump_boost);
2116 Ok(())
2117 }
2118}
2119#[cfg(feature = "v26_1")]
2120#[cfg(feature = "testgen")]
2121impl<const V: i32> Generate for EntityAction<V> {
2122 fn generate(g: &mut Gen) -> Self {
2123 {
2124 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2125 let v2 = crate::defs::p775::play::serverbound::EntityActionActionId(g.int_in(
2126 -2147483648,
2127 2147483647,
2128 &[0, 1, 2, 3, 4, 5, 6],
2129 )
2130 as i32);
2131 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2132 Self {
2133 entity_id: v1,
2134 action_id: v2,
2135 jump_boost: v3,
2136 }
2137 }
2138 }
2139}
2140
2141#[cfg(feature = "v26_1")]
2142#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2144pub struct PlayerInputInputs(pub u8);
2145#[cfg(feature = "v26_1")]
2146impl PlayerInputInputs {
2147 pub const FORWARD: Self = Self(1 << 0);
2149 pub const BACKWARD: Self = Self(1 << 1);
2151 pub const LEFT: Self = Self(1 << 2);
2153 pub const RIGHT: Self = Self(1 << 3);
2155 pub const JUMP: Self = Self(1 << 4);
2157 pub const SHIFT: Self = Self(1 << 5);
2159 pub const SPRINT: Self = Self(1 << 6);
2161 #[inline]
2163 pub const fn contains(self, f: Self) -> bool {
2164 self.0 & f.0 == f.0
2165 }
2166 #[inline]
2168 #[must_use]
2169 pub const fn with(self, f: Self) -> Self {
2170 Self(self.0 | f.0)
2171 }
2172}
2173
2174#[cfg(feature = "v26_1")]
2175#[derive(Debug, Clone, PartialEq)]
2177pub struct PlayerInput<const V: i32> {
2178 pub inputs: crate::defs::p775::play::serverbound::PlayerInputInputs,
2180}
2181#[cfg(feature = "v26_1")]
2182impl<const V: i32> Decode for PlayerInput<V> {
2183 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2184 Ok({
2185 let v1 = crate::defs::p775::play::serverbound::PlayerInputInputs(r.read_u8()?);
2186 Self { inputs: v1 }
2187 })
2188 }
2189}
2190#[cfg(feature = "v26_1")]
2191impl<const V: i32> Encode for PlayerInput<V> {
2192 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2193 w.put_u8((*self).inputs.0);
2194 Ok(())
2195 }
2196}
2197#[cfg(feature = "v26_1")]
2198#[cfg(feature = "testgen")]
2199impl<const V: i32> Generate for PlayerInput<V> {
2200 fn generate(g: &mut Gen) -> Self {
2201 {
2202 let v1 = crate::defs::p775::play::serverbound::PlayerInputInputs(
2203 g.int_in(0, 255, &[]) as u8
2204 );
2205 Self { inputs: v1 }
2206 }
2207 }
2208}
2209
2210#[cfg(feature = "v26_1")]
2211#[derive(Debug, Clone, PartialEq)]
2213pub struct PlayerLoaded<const V: i32> {}
2214#[cfg(feature = "v26_1")]
2215impl<const V: i32> Decode for PlayerLoaded<V> {
2216 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2217 Ok({ Self {} })
2218 }
2219}
2220#[cfg(feature = "v26_1")]
2221impl<const V: i32> Encode for PlayerLoaded<V> {
2222 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2223 Ok(())
2224 }
2225}
2226#[cfg(feature = "v26_1")]
2227#[cfg(feature = "testgen")]
2228impl<const V: i32> Generate for PlayerLoaded<V> {
2229 fn generate(g: &mut Gen) -> Self {
2230 { Self {} }
2231 }
2232}
2233
2234#[cfg(feature = "v26_1")]
2235#[derive(Debug, Clone, PartialEq)]
2237pub struct Pong<const V: i32> {
2238 pub id: i32,
2240}
2241#[cfg(feature = "v26_1")]
2242impl<const V: i32> Decode for Pong<V> {
2243 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2244 Ok({
2245 let v1 = r.read_i32()?;
2246 Self { id: v1 }
2247 })
2248 }
2249}
2250#[cfg(feature = "v26_1")]
2251impl<const V: i32> Encode for Pong<V> {
2252 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2253 w.put_i32((*self).id);
2254 Ok(())
2255 }
2256}
2257#[cfg(feature = "v26_1")]
2258#[cfg(feature = "testgen")]
2259impl<const V: i32> Generate for Pong<V> {
2260 fn generate(g: &mut Gen) -> Self {
2261 {
2262 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2263 Self { id: v1 }
2264 }
2265 }
2266}
2267
2268#[cfg(feature = "v26_1")]
2269#[derive(Debug, Clone, PartialEq)]
2271pub struct DisplayedRecipe<const V: i32> {
2272 pub recipe_id: i32,
2274}
2275#[cfg(feature = "v26_1")]
2276impl<const V: i32> Decode for DisplayedRecipe<V> {
2277 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2278 Ok({
2279 let v1 = r.read_varint()?;
2280 Self { recipe_id: v1 }
2281 })
2282 }
2283}
2284#[cfg(feature = "v26_1")]
2285impl<const V: i32> Encode for DisplayedRecipe<V> {
2286 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2287 w.put_varint((*self).recipe_id);
2288 Ok(())
2289 }
2290}
2291#[cfg(feature = "v26_1")]
2292#[cfg(feature = "testgen")]
2293impl<const V: i32> Generate for DisplayedRecipe<V> {
2294 fn generate(g: &mut Gen) -> Self {
2295 {
2296 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2297 Self { recipe_id: v1 }
2298 }
2299 }
2300}
2301
2302#[cfg(feature = "v26_1")]
2303#[derive(Debug, Clone, PartialEq)]
2305pub struct ResourcePackReceive<const V: i32> {
2306 pub uuid: Uuid,
2308 pub result: i32,
2310}
2311#[cfg(feature = "v26_1")]
2312impl<const V: i32> Decode for ResourcePackReceive<V> {
2313 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2314 Ok({
2315 let v1 = r.read_uuid()?;
2316 let v2 = r.read_varint()?;
2317 Self {
2318 uuid: v1,
2319 result: v2,
2320 }
2321 })
2322 }
2323}
2324#[cfg(feature = "v26_1")]
2325impl<const V: i32> Encode for ResourcePackReceive<V> {
2326 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2327 w.put_uuid(&(*self).uuid);
2328 w.put_varint((*self).result);
2329 Ok(())
2330 }
2331}
2332#[cfg(feature = "v26_1")]
2333#[cfg(feature = "testgen")]
2334impl<const V: i32> Generate for ResourcePackReceive<V> {
2335 fn generate(g: &mut Gen) -> Self {
2336 {
2337 let v1 = g.uuid();
2338 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2339 Self {
2340 uuid: v1,
2341 result: v2,
2342 }
2343 }
2344 }
2345}
2346
2347#[cfg(feature = "v26_1")]
2348#[derive(Debug, Clone, PartialEq)]
2350pub struct SetBeaconEffect<const V: i32> {
2351 pub primary_effect: Option<i32>,
2353 pub secondary_effect: Option<i32>,
2355}
2356#[cfg(feature = "v26_1")]
2357impl<const V: i32> Decode for SetBeaconEffect<V> {
2358 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2359 Ok({
2360 let v1 = if r.read_bool()? {
2361 Some(r.read_varint()?)
2362 } else {
2363 None
2364 };
2365 let v2 = if r.read_bool()? {
2366 Some(r.read_varint()?)
2367 } else {
2368 None
2369 };
2370 Self {
2371 primary_effect: v1,
2372 secondary_effect: v2,
2373 }
2374 })
2375 }
2376}
2377#[cfg(feature = "v26_1")]
2378impl<const V: i32> Encode for SetBeaconEffect<V> {
2379 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2380 match &(*self).primary_effect {
2381 Some(v1) => {
2382 w.put_u8(1);
2383 w.put_varint((*v1));
2384 }
2385 None => w.put_u8(0),
2386 }
2387 match &(*self).secondary_effect {
2388 Some(v2) => {
2389 w.put_u8(1);
2390 w.put_varint((*v2));
2391 }
2392 None => w.put_u8(0),
2393 }
2394 Ok(())
2395 }
2396}
2397#[cfg(feature = "v26_1")]
2398#[cfg(feature = "testgen")]
2399impl<const V: i32> Generate for SetBeaconEffect<V> {
2400 fn generate(g: &mut Gen) -> Self {
2401 {
2402 let v1 = if g.bool() {
2403 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2404 } else {
2405 None
2406 };
2407 let v2 = if g.bool() {
2408 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2409 } else {
2410 None
2411 };
2412 Self {
2413 primary_effect: v1,
2414 secondary_effect: v2,
2415 }
2416 }
2417 }
2418}
2419
2420#[cfg(feature = "v26_1")]
2421#[derive(Debug, Clone, PartialEq)]
2423pub struct SetCreativeSlot<const V: i32> {
2424 pub slot: i16,
2426 pub item: crate::defs::p775::types::UntrustedSlot,
2428}
2429#[cfg(feature = "v26_1")]
2430impl<const V: i32> Decode for SetCreativeSlot<V> {
2431 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2432 Ok({
2433 let v1 = r.read_i16()?;
2434 let v2 = <crate::defs::p775::types::UntrustedSlot as Decode>::decode(r)?;
2435 Self { slot: v1, item: v2 }
2436 })
2437 }
2438}
2439#[cfg(feature = "v26_1")]
2440impl<const V: i32> Encode for SetCreativeSlot<V> {
2441 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2442 w.put_i16((*self).slot);
2443 (*self).item.encode(w)?;
2444 Ok(())
2445 }
2446}
2447#[cfg(feature = "v26_1")]
2448#[cfg(feature = "testgen")]
2449impl<const V: i32> Generate for SetCreativeSlot<V> {
2450 fn generate(g: &mut Gen) -> Self {
2451 {
2452 let v1 = (g.int_in(-32768, 32767, &[]) as i16);
2453 let v2 = <crate::defs::p775::types::UntrustedSlot as Generate>::generate(g);
2454 Self { slot: v1, item: v2 }
2455 }
2456 }
2457}
2458
2459#[cfg(feature = "v26_1")]
2460#[derive(Debug, Clone, PartialEq)]
2462pub struct SetGameRule<const V: i32> {
2463 pub entries: Vec<crate::defs::p775::types::GameRule>,
2465}
2466#[cfg(feature = "v26_1")]
2467impl<const V: i32> Decode for SetGameRule<V> {
2468 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2469 Ok({
2470 let v1 = {
2471 let v2 = {
2472 let c = r.read_varint()?;
2473 r.check_count(i64::from(c), 2)?
2474 };
2475 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
2476 for _ in 0..v2 {
2477 v3.push(<crate::defs::p775::types::GameRule as Decode>::decode(r)?);
2478 }
2479 v3
2480 };
2481 Self { entries: v1 }
2482 })
2483 }
2484}
2485#[cfg(feature = "v26_1")]
2486impl<const V: i32> Encode for SetGameRule<V> {
2487 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2488 w.put_len_varint((*self).entries.len())?;
2489 for v1 in (*self).entries.iter() {
2490 (*v1).encode(w)?;
2491 }
2492 Ok(())
2493 }
2494}
2495#[cfg(feature = "v26_1")]
2496#[cfg(feature = "testgen")]
2497impl<const V: i32> Generate for SetGameRule<V> {
2498 fn generate(g: &mut Gen) -> Self {
2499 {
2500 let v1 = {
2501 let v2 = g.count();
2502 let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
2503 for _ in 0..v2 {
2504 v3.push(<crate::defs::p775::types::GameRule as Generate>::generate(
2505 g,
2506 ));
2507 }
2508 v3
2509 };
2510 Self { entries: v1 }
2511 }
2512 }
2513}
2514
2515#[cfg(feature = "v26_1")]
2516#[derive(Debug, Clone, PartialEq)]
2518pub struct UpdateJigsawBlock<const V: i32> {
2519 pub location: BlockPos,
2521 pub name: ByteString,
2523 pub target: ByteString,
2525 pub pool: ByteString,
2527 pub final_state: ByteString,
2529 pub joint_type: ByteString,
2531 pub selection_priority: i32,
2533 pub placement_priority: i32,
2535}
2536#[cfg(feature = "v26_1")]
2537impl<const V: i32> Decode for UpdateJigsawBlock<V> {
2538 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2539 Ok({
2540 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
2541 let v2 = r.read_string()?;
2542 let v3 = r.read_string()?;
2543 let v4 = r.read_string()?;
2544 let v5 = r.read_string()?;
2545 let v6 = r.read_string()?;
2546 let v7 = r.read_varint()?;
2547 let v8 = r.read_varint()?;
2548 Self {
2549 location: v1,
2550 name: v2,
2551 target: v3,
2552 pool: v4,
2553 final_state: v5,
2554 joint_type: v6,
2555 selection_priority: v7,
2556 placement_priority: v8,
2557 }
2558 })
2559 }
2560}
2561#[cfg(feature = "v26_1")]
2562impl<const V: i32> Encode for UpdateJigsawBlock<V> {
2563 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2564 (*self).location.write(w, PositionLayout::Xzy)?;
2565 w.put_string(&(*self).name)?;
2566 w.put_string(&(*self).target)?;
2567 w.put_string(&(*self).pool)?;
2568 w.put_string(&(*self).final_state)?;
2569 w.put_string(&(*self).joint_type)?;
2570 w.put_varint((*self).selection_priority);
2571 w.put_varint((*self).placement_priority);
2572 Ok(())
2573 }
2574}
2575#[cfg(feature = "v26_1")]
2576#[cfg(feature = "testgen")]
2577impl<const V: i32> Generate for UpdateJigsawBlock<V> {
2578 fn generate(g: &mut Gen) -> Self {
2579 {
2580 let v1 = g.position();
2581 let v2 = g.string();
2582 let v3 = g.string();
2583 let v4 = g.string();
2584 let v5 = g.string();
2585 let v6 = g.string();
2586 let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2587 let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2588 Self {
2589 location: v1,
2590 name: v2,
2591 target: v3,
2592 pool: v4,
2593 final_state: v5,
2594 joint_type: v6,
2595 selection_priority: v7,
2596 placement_priority: v8,
2597 }
2598 }
2599 }
2600}
2601
2602#[cfg(feature = "v26_1")]
2603#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2605pub struct UpdateStructureBlockFlags(pub u8);
2606#[cfg(feature = "v26_1")]
2607impl UpdateStructureBlockFlags {
2608 pub const IGNORE_ENTITIES: Self = Self(0);
2610 pub const SHOW_AIR: Self = Self(1);
2612 pub const SHOW_BOUNDING_BOX: Self = Self(2);
2614 pub const STRICT: Self = Self(3);
2616 pub const fn name(self) -> Option<&'static str> {
2618 match self.0 {
2619 0 => Some("ignore_entities"),
2620 1 => Some("show_air"),
2621 2 => Some("show_bounding_box"),
2622 3 => Some("strict"),
2623 _ => None,
2624 }
2625 }
2626}
2627#[cfg(feature = "v26_1")]
2628impl std::fmt::Debug for UpdateStructureBlockFlags {
2629 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2630 match self.name() {
2631 Some(n) => write!(f, "UpdateStructureBlockFlags::{n}"),
2632 None => write!(f, "UpdateStructureBlockFlags({})", self.0),
2633 }
2634 }
2635}
2636
2637#[cfg(feature = "v26_1")]
2638#[derive(Debug, Clone, PartialEq)]
2640pub struct UpdateStructureBlock<const V: i32> {
2641 pub location: BlockPos,
2643 pub action: i32,
2645 pub mode: i32,
2647 pub name: ByteString,
2649 pub offset_x: i8,
2651 pub offset_y: i8,
2653 pub offset_z: i8,
2655 pub size_x: i8,
2657 pub size_y: i8,
2659 pub size_z: i8,
2661 pub mirror: i32,
2663 pub rotation: i32,
2665 pub metadata: ByteString,
2667 pub integrity: f32,
2669 pub seed: i32,
2671 pub flags: crate::defs::p775::play::serverbound::UpdateStructureBlockFlags,
2673}
2674#[cfg(feature = "v26_1")]
2675impl<const V: i32> Decode for UpdateStructureBlock<V> {
2676 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2677 Ok({
2678 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
2679 let v2 = r.read_varint()?;
2680 let v3 = r.read_varint()?;
2681 let v4 = r.read_string()?;
2682 let v5 = r.read_i8()?;
2683 let v6 = r.read_i8()?;
2684 let v7 = r.read_i8()?;
2685 let v8 = r.read_i8()?;
2686 let v9 = r.read_i8()?;
2687 let v10 = r.read_i8()?;
2688 let v11 = r.read_varint()?;
2689 let v12 = r.read_varint()?;
2690 let v13 = r.read_string()?;
2691 let v14 = r.read_f32()?;
2692 let v15 = r.read_varint()?;
2693 let v16 = crate::defs::p775::play::serverbound::UpdateStructureBlockFlags(r.read_u8()?);
2694 Self {
2695 location: v1,
2696 action: v2,
2697 mode: v3,
2698 name: v4,
2699 offset_x: v5,
2700 offset_y: v6,
2701 offset_z: v7,
2702 size_x: v8,
2703 size_y: v9,
2704 size_z: v10,
2705 mirror: v11,
2706 rotation: v12,
2707 metadata: v13,
2708 integrity: v14,
2709 seed: v15,
2710 flags: v16,
2711 }
2712 })
2713 }
2714}
2715#[cfg(feature = "v26_1")]
2716impl<const V: i32> Encode for UpdateStructureBlock<V> {
2717 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2718 (*self).location.write(w, PositionLayout::Xzy)?;
2719 w.put_varint((*self).action);
2720 w.put_varint((*self).mode);
2721 w.put_string(&(*self).name)?;
2722 w.put_i8((*self).offset_x);
2723 w.put_i8((*self).offset_y);
2724 w.put_i8((*self).offset_z);
2725 w.put_i8((*self).size_x);
2726 w.put_i8((*self).size_y);
2727 w.put_i8((*self).size_z);
2728 w.put_varint((*self).mirror);
2729 w.put_varint((*self).rotation);
2730 w.put_string(&(*self).metadata)?;
2731 w.put_f32((*self).integrity);
2732 w.put_varint((*self).seed);
2733 w.put_u8((*self).flags.0);
2734 Ok(())
2735 }
2736}
2737#[cfg(feature = "v26_1")]
2738#[cfg(feature = "testgen")]
2739impl<const V: i32> Generate for UpdateStructureBlock<V> {
2740 fn generate(g: &mut Gen) -> Self {
2741 {
2742 let v1 = g.position();
2743 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2744 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2745 let v4 = g.string();
2746 let v5 = (g.int_in(-128, 127, &[]) as i8);
2747 let v6 = (g.int_in(-128, 127, &[]) as i8);
2748 let v7 = (g.int_in(-128, 127, &[]) as i8);
2749 let v8 = (g.int_in(-128, 127, &[]) as i8);
2750 let v9 = (g.int_in(-128, 127, &[]) as i8);
2751 let v10 = (g.int_in(-128, 127, &[]) as i8);
2752 let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2753 let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2754 let v13 = g.string();
2755 let v14 = g.f32();
2756 let v15 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2757 let v16 = crate::defs::p775::play::serverbound::UpdateStructureBlockFlags(g.int_in(
2758 0,
2759 255,
2760 &[0, 1, 2, 3],
2761 )
2762 as u8);
2763 Self {
2764 location: v1,
2765 action: v2,
2766 mode: v3,
2767 name: v4,
2768 offset_x: v5,
2769 offset_y: v6,
2770 offset_z: v7,
2771 size_x: v8,
2772 size_y: v9,
2773 size_z: v10,
2774 mirror: v11,
2775 rotation: v12,
2776 metadata: v13,
2777 integrity: v14,
2778 seed: v15,
2779 flags: v16,
2780 }
2781 }
2782 }
2783}
2784
2785#[cfg(feature = "v26_1")]
2786#[derive(Debug, Clone, PartialEq)]
2788pub struct SetTestBlock<const V: i32> {
2789 pub position: BlockPos,
2791 pub mode: i32,
2793 pub message: ByteString,
2795}
2796#[cfg(feature = "v26_1")]
2797impl<const V: i32> Decode for SetTestBlock<V> {
2798 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2799 Ok({
2800 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
2801 let v2 = r.read_varint()?;
2802 let v3 = r.read_string()?;
2803 Self {
2804 position: v1,
2805 mode: v2,
2806 message: v3,
2807 }
2808 })
2809 }
2810}
2811#[cfg(feature = "v26_1")]
2812impl<const V: i32> Encode for SetTestBlock<V> {
2813 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2814 (*self).position.write(w, PositionLayout::Xzy)?;
2815 w.put_varint((*self).mode);
2816 w.put_string(&(*self).message)?;
2817 Ok(())
2818 }
2819}
2820#[cfg(feature = "v26_1")]
2821#[cfg(feature = "testgen")]
2822impl<const V: i32> Generate for SetTestBlock<V> {
2823 fn generate(g: &mut Gen) -> Self {
2824 {
2825 let v1 = g.position();
2826 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2827 let v3 = g.string();
2828 Self {
2829 position: v1,
2830 mode: v2,
2831 message: v3,
2832 }
2833 }
2834 }
2835}
2836
2837#[cfg(feature = "v26_1")]
2838#[derive(Debug, Clone, PartialEq)]
2840pub struct UpdateSign<const V: i32> {
2841 pub location: BlockPos,
2843 pub is_front_text: bool,
2845 pub text1: ByteString,
2847 pub text2: ByteString,
2849 pub text3: ByteString,
2851 pub text4: ByteString,
2853}
2854#[cfg(feature = "v26_1")]
2855impl<const V: i32> Decode for UpdateSign<V> {
2856 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2857 Ok({
2858 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
2859 let v2 = r.read_bool()?;
2860 let v3 = r.read_string()?;
2861 let v4 = r.read_string()?;
2862 let v5 = r.read_string()?;
2863 let v6 = r.read_string()?;
2864 Self {
2865 location: v1,
2866 is_front_text: v2,
2867 text1: v3,
2868 text2: v4,
2869 text3: v5,
2870 text4: v6,
2871 }
2872 })
2873 }
2874}
2875#[cfg(feature = "v26_1")]
2876impl<const V: i32> Encode for UpdateSign<V> {
2877 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2878 (*self).location.write(w, PositionLayout::Xzy)?;
2879 w.put_bool((*self).is_front_text);
2880 w.put_string(&(*self).text1)?;
2881 w.put_string(&(*self).text2)?;
2882 w.put_string(&(*self).text3)?;
2883 w.put_string(&(*self).text4)?;
2884 Ok(())
2885 }
2886}
2887#[cfg(feature = "v26_1")]
2888#[cfg(feature = "testgen")]
2889impl<const V: i32> Generate for UpdateSign<V> {
2890 fn generate(g: &mut Gen) -> Self {
2891 {
2892 let v1 = g.position();
2893 let v2 = g.bool();
2894 let v3 = g.string();
2895 let v4 = g.string();
2896 let v5 = g.string();
2897 let v6 = g.string();
2898 Self {
2899 location: v1,
2900 is_front_text: v2,
2901 text1: v3,
2902 text2: v4,
2903 text3: v5,
2904 text4: v6,
2905 }
2906 }
2907 }
2908}
2909
2910#[cfg(feature = "v26_1")]
2911#[derive(Debug, Clone, PartialEq)]
2913pub struct SpectateEntity<const V: i32> {
2914 pub entity_id: i32,
2916}
2917#[cfg(feature = "v26_1")]
2918impl<const V: i32> Decode for SpectateEntity<V> {
2919 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2920 Ok({
2921 let v1 = r.read_varint()?;
2922 Self { entity_id: v1 }
2923 })
2924 }
2925}
2926#[cfg(feature = "v26_1")]
2927impl<const V: i32> Encode for SpectateEntity<V> {
2928 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2929 w.put_varint((*self).entity_id);
2930 Ok(())
2931 }
2932}
2933#[cfg(feature = "v26_1")]
2934#[cfg(feature = "testgen")]
2935impl<const V: i32> Generate for SpectateEntity<V> {
2936 fn generate(g: &mut Gen) -> Self {
2937 {
2938 let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2939 Self { entity_id: v1 }
2940 }
2941 }
2942}
2943
2944#[cfg(feature = "v26_1")]
2945#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2947pub struct ArmAnimationHand(pub i32);
2948#[cfg(feature = "v26_1")]
2949impl ArmAnimationHand {
2950 pub const MAIN_HAND: Self = Self(0);
2952 pub const OFF_HAND: Self = Self(1);
2954 pub const fn name(self) -> Option<&'static str> {
2956 match self.0 {
2957 0 => Some("main_hand"),
2958 1 => Some("off_hand"),
2959 _ => None,
2960 }
2961 }
2962}
2963#[cfg(feature = "v26_1")]
2964impl std::fmt::Debug for ArmAnimationHand {
2965 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2966 match self.name() {
2967 Some(n) => write!(f, "ArmAnimationHand::{n}"),
2968 None => write!(f, "ArmAnimationHand({})", self.0),
2969 }
2970 }
2971}
2972
2973#[cfg(feature = "v26_1")]
2974#[derive(Debug, Clone, PartialEq)]
2976pub struct ArmAnimation<const V: i32> {
2977 pub hand: crate::defs::p775::play::serverbound::ArmAnimationHand,
2979}
2980#[cfg(feature = "v26_1")]
2981impl<const V: i32> Decode for ArmAnimation<V> {
2982 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2983 Ok({
2984 let v1 = crate::defs::p775::play::serverbound::ArmAnimationHand(r.read_varint()?);
2985 Self { hand: v1 }
2986 })
2987 }
2988}
2989#[cfg(feature = "v26_1")]
2990impl<const V: i32> Encode for ArmAnimation<V> {
2991 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2992 w.put_varint((*self).hand.0);
2993 Ok(())
2994 }
2995}
2996#[cfg(feature = "v26_1")]
2997#[cfg(feature = "testgen")]
2998impl<const V: i32> Generate for ArmAnimation<V> {
2999 fn generate(g: &mut Gen) -> Self {
3000 {
3001 let v1 = crate::defs::p775::play::serverbound::ArmAnimationHand(g.int_in(
3002 -2147483648,
3003 2147483647,
3004 &[0, 1],
3005 ) as i32);
3006 Self { hand: v1 }
3007 }
3008 }
3009}
3010
3011#[cfg(feature = "v26_1")]
3012#[derive(Debug, Clone, PartialEq)]
3014pub struct TestInstanceBlockActionData {
3015 pub test: Option<ByteString>,
3017 pub size: crate::defs::p775::types::Vec3i,
3019 pub rotation: i32,
3021 pub ignore_entities: bool,
3023 pub status: i32,
3025 pub error_message: Option<AnonNbt>,
3027}
3028
3029#[cfg(feature = "v26_1")]
3030#[derive(Debug, Clone, PartialEq)]
3032pub struct TestInstanceBlockAction<const V: i32> {
3033 pub pos: BlockPos,
3035 pub action: i32,
3037 pub data: crate::defs::p775::play::serverbound::TestInstanceBlockActionData,
3039}
3040#[cfg(feature = "v26_1")]
3041impl<const V: i32> Decode for TestInstanceBlockAction<V> {
3042 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3043 Ok({
3044 let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
3045 let v2 = r.read_varint()?;
3046 let v3 = {
3047 let v4 = if r.read_bool()? {
3048 Some(r.read_string()?)
3049 } else {
3050 None
3051 };
3052 let v5 = <crate::defs::p775::types::Vec3i as Decode>::decode(r)?;
3053 let v6 = r.read_varint()?;
3054 let v7 = r.read_bool()?;
3055 let v8 = r.read_varint()?;
3056 let v9 = if r.read_bool()? {
3057 Some(AnonNbt::read(r)?)
3058 } else {
3059 None
3060 };
3061 crate::defs::p775::play::serverbound::TestInstanceBlockActionData {
3062 test: v4,
3063 size: v5,
3064 rotation: v6,
3065 ignore_entities: v7,
3066 status: v8,
3067 error_message: v9,
3068 }
3069 };
3070 Self {
3071 pos: v1,
3072 action: v2,
3073 data: v3,
3074 }
3075 })
3076 }
3077}
3078#[cfg(feature = "v26_1")]
3079impl<const V: i32> Encode for TestInstanceBlockAction<V> {
3080 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3081 (*self).pos.write(w, PositionLayout::Xzy)?;
3082 w.put_varint((*self).action);
3083 match &(*self).data.test {
3084 Some(v1) => {
3085 w.put_u8(1);
3086 w.put_string(&(*v1))?;
3087 }
3088 None => w.put_u8(0),
3089 }
3090 (*self).data.size.encode(w)?;
3091 w.put_varint((*self).data.rotation);
3092 w.put_bool((*self).data.ignore_entities);
3093 w.put_varint((*self).data.status);
3094 match &(*self).data.error_message {
3095 Some(v2) => {
3096 w.put_u8(1);
3097 (*v2).write(w);
3098 }
3099 None => w.put_u8(0),
3100 }
3101 Ok(())
3102 }
3103}
3104#[cfg(feature = "v26_1")]
3105#[cfg(feature = "testgen")]
3106impl<const V: i32> Generate for TestInstanceBlockAction<V> {
3107 fn generate(g: &mut Gen) -> Self {
3108 {
3109 let v1 = g.position();
3110 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3111 let v3 = {
3112 let v4 = if g.bool() { Some(g.string()) } else { None };
3113 let v5 = <crate::defs::p775::types::Vec3i as Generate>::generate(g);
3114 let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3115 let v7 = g.bool();
3116 let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3117 let v9 = if g.bool() { Some(g.anon_nbt()) } else { None };
3118 crate::defs::p775::play::serverbound::TestInstanceBlockActionData {
3119 test: v4,
3120 size: v5,
3121 rotation: v6,
3122 ignore_entities: v7,
3123 status: v8,
3124 error_message: v9,
3125 }
3126 };
3127 Self {
3128 pos: v1,
3129 action: v2,
3130 data: v3,
3131 }
3132 }
3133 }
3134}
3135
3136#[cfg(feature = "v26_1")]
3137#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
3139pub struct BlockPlaceHand(pub i32);
3140#[cfg(feature = "v26_1")]
3141impl BlockPlaceHand {
3142 pub const MAIN_HAND: Self = Self(0);
3144 pub const OFF_HAND: Self = Self(1);
3146 pub const fn name(self) -> Option<&'static str> {
3148 match self.0 {
3149 0 => Some("main_hand"),
3150 1 => Some("off_hand"),
3151 _ => None,
3152 }
3153 }
3154}
3155#[cfg(feature = "v26_1")]
3156impl std::fmt::Debug for BlockPlaceHand {
3157 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3158 match self.name() {
3159 Some(n) => write!(f, "BlockPlaceHand::{n}"),
3160 None => write!(f, "BlockPlaceHand({})", self.0),
3161 }
3162 }
3163}
3164
3165#[cfg(feature = "v26_1")]
3166#[derive(Debug, Clone, PartialEq)]
3168pub struct BlockPlace<const V: i32> {
3169 pub hand: crate::defs::p775::play::serverbound::BlockPlaceHand,
3171 pub location: BlockPos,
3173 pub direction: i32,
3175 pub cursor_x: f32,
3177 pub cursor_y: f32,
3179 pub cursor_z: f32,
3181 pub inside_block: bool,
3183 pub world_border_hit: bool,
3185 pub sequence: i32,
3187}
3188#[cfg(feature = "v26_1")]
3189impl<const V: i32> Decode for BlockPlace<V> {
3190 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3191 Ok({
3192 let v1 = crate::defs::p775::play::serverbound::BlockPlaceHand(r.read_varint()?);
3193 let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
3194 let v3 = r.read_varint()?;
3195 let v4 = r.read_f32()?;
3196 let v5 = r.read_f32()?;
3197 let v6 = r.read_f32()?;
3198 let v7 = r.read_bool()?;
3199 let v8 = r.read_bool()?;
3200 let v9 = r.read_varint()?;
3201 Self {
3202 hand: v1,
3203 location: v2,
3204 direction: v3,
3205 cursor_x: v4,
3206 cursor_y: v5,
3207 cursor_z: v6,
3208 inside_block: v7,
3209 world_border_hit: v8,
3210 sequence: v9,
3211 }
3212 })
3213 }
3214}
3215#[cfg(feature = "v26_1")]
3216impl<const V: i32> Encode for BlockPlace<V> {
3217 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3218 w.put_varint((*self).hand.0);
3219 (*self).location.write(w, PositionLayout::Xzy)?;
3220 w.put_varint((*self).direction);
3221 w.put_f32((*self).cursor_x);
3222 w.put_f32((*self).cursor_y);
3223 w.put_f32((*self).cursor_z);
3224 w.put_bool((*self).inside_block);
3225 w.put_bool((*self).world_border_hit);
3226 w.put_varint((*self).sequence);
3227 Ok(())
3228 }
3229}
3230#[cfg(feature = "v26_1")]
3231#[cfg(feature = "testgen")]
3232impl<const V: i32> Generate for BlockPlace<V> {
3233 fn generate(g: &mut Gen) -> Self {
3234 {
3235 let v1 = crate::defs::p775::play::serverbound::BlockPlaceHand(g.int_in(
3236 -2147483648,
3237 2147483647,
3238 &[0, 1],
3239 ) as i32);
3240 let v2 = g.position();
3241 let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3242 let v4 = g.f32();
3243 let v5 = g.f32();
3244 let v6 = g.f32();
3245 let v7 = g.bool();
3246 let v8 = g.bool();
3247 let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3248 Self {
3249 hand: v1,
3250 location: v2,
3251 direction: v3,
3252 cursor_x: v4,
3253 cursor_y: v5,
3254 cursor_z: v6,
3255 inside_block: v7,
3256 world_border_hit: v8,
3257 sequence: v9,
3258 }
3259 }
3260 }
3261}
3262
3263#[cfg(feature = "v26_1")]
3264#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
3266pub struct UseItemHand(pub i32);
3267#[cfg(feature = "v26_1")]
3268impl UseItemHand {
3269 pub const MAIN_HAND: Self = Self(0);
3271 pub const OFF_HAND: Self = Self(1);
3273 pub const fn name(self) -> Option<&'static str> {
3275 match self.0 {
3276 0 => Some("main_hand"),
3277 1 => Some("off_hand"),
3278 _ => None,
3279 }
3280 }
3281}
3282#[cfg(feature = "v26_1")]
3283impl std::fmt::Debug for UseItemHand {
3284 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3285 match self.name() {
3286 Some(n) => write!(f, "UseItemHand::{n}"),
3287 None => write!(f, "UseItemHand({})", self.0),
3288 }
3289 }
3290}
3291
3292#[cfg(feature = "v26_1")]
3293#[derive(Debug, Clone, PartialEq)]
3295pub struct UseItem<const V: i32> {
3296 pub hand: crate::defs::p775::play::serverbound::UseItemHand,
3298 pub sequence: i32,
3300 pub rotation: crate::defs::p775::types::Vec2f,
3302}
3303#[cfg(feature = "v26_1")]
3304impl<const V: i32> Decode for UseItem<V> {
3305 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3306 Ok({
3307 let v1 = crate::defs::p775::play::serverbound::UseItemHand(r.read_varint()?);
3308 let v2 = r.read_varint()?;
3309 let v3 = <crate::defs::p775::types::Vec2f as Decode>::decode(r)?;
3310 Self {
3311 hand: v1,
3312 sequence: v2,
3313 rotation: v3,
3314 }
3315 })
3316 }
3317}
3318#[cfg(feature = "v26_1")]
3319impl<const V: i32> Encode for UseItem<V> {
3320 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3321 w.put_varint((*self).hand.0);
3322 w.put_varint((*self).sequence);
3323 (*self).rotation.encode(w)?;
3324 Ok(())
3325 }
3326}
3327#[cfg(feature = "v26_1")]
3328#[cfg(feature = "testgen")]
3329impl<const V: i32> Generate for UseItem<V> {
3330 fn generate(g: &mut Gen) -> Self {
3331 {
3332 let v1 = crate::defs::p775::play::serverbound::UseItemHand(g.int_in(
3333 -2147483648,
3334 2147483647,
3335 &[0, 1],
3336 ) as i32);
3337 let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3338 let v3 = <crate::defs::p775::types::Vec2f as Generate>::generate(g);
3339 Self {
3340 hand: v1,
3341 sequence: v2,
3342 rotation: v3,
3343 }
3344 }
3345 }
3346}
3347
3348#[cfg(feature = "v26_1")]
3349#[derive(Debug, Clone, PartialEq)]
3351pub struct CustomClickAction<const V: i32> {
3352 pub id: ByteString,
3354 pub nbt: Option<AnonNbt>,
3356}
3357#[cfg(feature = "v26_1")]
3358impl<const V: i32> Decode for CustomClickAction<V> {
3359 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3360 Ok({
3361 let v1 = r.read_string()?;
3362 let v2 = if r.read_bool()? {
3363 Some(AnonNbt::read(r)?)
3364 } else {
3365 None
3366 };
3367 Self { id: v1, nbt: v2 }
3368 })
3369 }
3370}
3371#[cfg(feature = "v26_1")]
3372impl<const V: i32> Encode for CustomClickAction<V> {
3373 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3374 w.put_string(&(*self).id)?;
3375 match &(*self).nbt {
3376 Some(v1) => {
3377 w.put_u8(1);
3378 (*v1).write(w);
3379 }
3380 None => w.put_u8(0),
3381 }
3382 Ok(())
3383 }
3384}
3385#[cfg(feature = "v26_1")]
3386#[cfg(feature = "testgen")]
3387impl<const V: i32> Generate for CustomClickAction<V> {
3388 fn generate(g: &mut Gen) -> Self {
3389 {
3390 let v1 = g.string();
3391 let v2 = if g.bool() { Some(g.anon_nbt()) } else { None };
3392 Self { id: v1, nbt: v2 }
3393 }
3394 }
3395}