1#![allow(
8 unused_imports,
9 unused_variables,
10 unused_mut,
11 unused_parens,
12 unused_braces,
13 clippy::all,
14 clippy::pedantic,
15 non_camel_case_types,
16 non_snake_case
17)]
18use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
19use crate::error::{DecodeError, EncodeError};
20use crate::nbt::RawNbt;
21use crate::packet::{Direction, PacketSet, RawPacket, State};
22#[cfg(feature = "testgen")]
23use crate::testgen::{Gen, Generate};
24use crate::types::{BlockPos, ByteString, PositionLayout, Uuid};
25use crate::v1_12_2::types;
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
30pub struct ClientCommandActionId(pub i32);
31impl ClientCommandActionId {
32 pub const PERFORM_RESPAWN: Self = Self(0);
34 pub const REQUEST_STATS: Self = Self(1);
36 pub const fn name(self) -> Option<&'static str> {
38 match self.0 {
39 0 => Some("perform_respawn"),
40 1 => Some("request_stats"),
41 _ => None,
42 }
43 }
44}
45impl std::fmt::Debug for ClientCommandActionId {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 match self.name() {
48 Some(n) => write!(f, "ClientCommandActionId::{n}"),
49 None => write!(f, "ClientCommandActionId({})", self.0),
50 }
51 }
52}
53
54#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
56pub struct EntityActionActionId(pub i32);
57impl EntityActionActionId {
58 pub const START_SNEAKING: Self = Self(0);
60 pub const STOP_SNEAKING: Self = Self(1);
62 pub const STOP_SLEEPING: Self = Self(2);
64 pub const START_SPRINTING: Self = Self(3);
66 pub const STOP_SPRINTING: Self = Self(4);
68 pub const START_RIDING_JUMP: Self = Self(5);
70 pub const STOP_RIDING_JUMP: Self = Self(6);
72 pub const OPEN_INVENTORY: Self = Self(7);
74 pub const START_FALL_FLYING: Self = Self(8);
76 pub const fn name(self) -> Option<&'static str> {
78 match self.0 {
79 0 => Some("start_sneaking"),
80 1 => Some("stop_sneaking"),
81 2 => Some("stop_sleeping"),
82 3 => Some("start_sprinting"),
83 4 => Some("stop_sprinting"),
84 5 => Some("start_riding_jump"),
85 6 => Some("stop_riding_jump"),
86 7 => Some("open_inventory"),
87 8 => Some("start_fall_flying"),
88 _ => None,
89 }
90 }
91}
92impl std::fmt::Debug for EntityActionActionId {
93 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94 match self.name() {
95 Some(n) => write!(f, "EntityActionActionId::{n}"),
96 None => write!(f, "EntityActionActionId({})", self.0),
97 }
98 }
99}
100
101#[derive(Debug, Clone, PartialEq)]
103pub struct CraftingBookDataBodyCase0 {
104 pub displayed_recipe: i32,
106}
107
108#[derive(Debug, Clone, PartialEq)]
110pub struct CraftingBookDataBodyCase1 {
111 pub crafting_book_open: bool,
113 pub crafting_filter: bool,
115}
116
117#[derive(Debug, Clone, PartialEq)]
119pub enum CraftingBookDataBody {
120 Case0(CraftingBookDataBodyCase0),
122 Case1(CraftingBookDataBodyCase1),
124 Other,
126}
127
128pub mod id {
130 pub const TELEPORT_CONFIRM: i32 = 0x00;
132 pub const TAB_COMPLETE: i32 = 0x01;
134 pub const CHAT: i32 = 0x02;
136 pub const CLIENT_COMMAND: i32 = 0x03;
138 pub const SETTINGS: i32 = 0x04;
140 pub const TRANSACTION: i32 = 0x05;
142 pub const ENCHANT_ITEM: i32 = 0x06;
144 pub const WINDOW_CLICK: i32 = 0x07;
146 pub const CLOSE_WINDOW: i32 = 0x08;
148 pub const CUSTOM_PAYLOAD: i32 = 0x09;
150 pub const USE_ENTITY: i32 = 0x0a;
152 pub const KEEP_ALIVE: i32 = 0x0b;
154 pub const FLYING: i32 = 0x0c;
156 pub const POSITION: i32 = 0x0d;
158 pub const POSITION_LOOK: i32 = 0x0e;
160 pub const LOOK: i32 = 0x0f;
162 pub const VEHICLE_MOVE: i32 = 0x10;
164 pub const STEER_BOAT: i32 = 0x11;
166 pub const CRAFT_RECIPE_REQUEST: i32 = 0x12;
168 pub const ABILITIES: i32 = 0x13;
170 pub const BLOCK_DIG: i32 = 0x14;
172 pub const ENTITY_ACTION: i32 = 0x15;
174 pub const STEER_VEHICLE: i32 = 0x16;
176 pub const CRAFTING_BOOK_DATA: i32 = 0x17;
178 pub const RESOURCE_PACK_RECEIVE: i32 = 0x18;
180 pub const ADVANCEMENT_TAB: i32 = 0x19;
182 pub const HELD_ITEM_SLOT: i32 = 0x1a;
184 pub const SET_CREATIVE_SLOT: i32 = 0x1b;
186 pub const UPDATE_SIGN: i32 = 0x1c;
188 pub const ARM_ANIMATION: i32 = 0x1d;
190 pub const SPECTATE: i32 = 0x1e;
192 pub const BLOCK_PLACE: i32 = 0x1f;
194 pub const USE_ITEM: i32 = 0x20;
196}
197
198#[derive(Debug, Clone, PartialEq)]
200pub struct TeleportConfirm {
201 pub teleport_id: i32,
203}
204impl crate::packet::Packet for TeleportConfirm {
205 const ID: i32 = id::TELEPORT_CONFIRM;
206 const NAME: &'static str = "teleport_confirm";
207 const STATE: State = State::Play;
208 const DIRECTION: Direction = Direction::Serverbound;
209}
210impl Decode for TeleportConfirm {
211 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
212 Ok({
213 let v1074 = r.read_varint()?;
214 TeleportConfirm { teleport_id: v1074 }
215 })
216 }
217}
218impl Encode for TeleportConfirm {
219 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
220 w.put_varint((*self).teleport_id);
221 Ok(())
222 }
223}
224#[cfg(feature = "testgen")]
225impl Generate for TeleportConfirm {
226 fn generate(g: &mut Gen) -> Self {
227 {
228 let v1075 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
229 TeleportConfirm { teleport_id: v1075 }
230 }
231 }
232}
233impl From<TeleportConfirm> for ServerboundPlayPacket {
234 fn from(p: TeleportConfirm) -> Self {
235 Self::TeleportConfirm(p)
236 }
237}
238
239#[derive(Debug, Clone, PartialEq)]
241pub struct TabComplete {
242 pub text: ByteString,
244 pub assume_command: bool,
246 pub looked_at_block: Option<BlockPos>,
248}
249impl crate::packet::Packet for TabComplete {
250 const ID: i32 = id::TAB_COMPLETE;
251 const NAME: &'static str = "tab_complete";
252 const STATE: State = State::Play;
253 const DIRECTION: Direction = Direction::Serverbound;
254}
255impl Decode for TabComplete {
256 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
257 Ok({
258 let v1076 = r.read_string()?;
259 let v1077 = r.read_bool()?;
260 let v1078 = if r.read_bool()? {
261 Some(BlockPos::read(r, PositionLayout::Xyz)?)
262 } else {
263 None
264 };
265 TabComplete {
266 text: v1076,
267 assume_command: v1077,
268 looked_at_block: v1078,
269 }
270 })
271 }
272}
273impl Encode for TabComplete {
274 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
275 w.put_string(&(*self).text)?;
276 w.put_bool((*self).assume_command);
277 match &(*self).looked_at_block {
278 Some(v1079) => {
279 w.put_u8(1);
280 (*v1079).write(w, PositionLayout::Xyz)?;
281 }
282 None => w.put_u8(0),
283 }
284 Ok(())
285 }
286}
287#[cfg(feature = "testgen")]
288impl Generate for TabComplete {
289 fn generate(g: &mut Gen) -> Self {
290 {
291 let v1080 = g.string();
292 let v1081 = g.bool();
293 let v1082 = if g.bool() { Some(g.position()) } else { None };
294 TabComplete {
295 text: v1080,
296 assume_command: v1081,
297 looked_at_block: v1082,
298 }
299 }
300 }
301}
302impl From<TabComplete> for ServerboundPlayPacket {
303 fn from(p: TabComplete) -> Self {
304 Self::TabComplete(p)
305 }
306}
307
308#[derive(Debug, Clone, PartialEq)]
310pub struct Chat {
311 pub message: ByteString,
313}
314impl crate::packet::Packet for Chat {
315 const ID: i32 = id::CHAT;
316 const NAME: &'static str = "chat";
317 const STATE: State = State::Play;
318 const DIRECTION: Direction = Direction::Serverbound;
319}
320impl Decode for Chat {
321 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
322 Ok({
323 let v1083 = r.read_string()?;
324 Chat { message: v1083 }
325 })
326 }
327}
328impl Encode for Chat {
329 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
330 w.put_string(&(*self).message)?;
331 Ok(())
332 }
333}
334#[cfg(feature = "testgen")]
335impl Generate for Chat {
336 fn generate(g: &mut Gen) -> Self {
337 {
338 let v1084 = g.string();
339 Chat { message: v1084 }
340 }
341 }
342}
343impl From<Chat> for ServerboundPlayPacket {
344 fn from(p: Chat) -> Self {
345 Self::Chat(p)
346 }
347}
348
349#[derive(Debug, Clone, PartialEq)]
351pub struct ClientCommand {
352 pub action_id: ClientCommandActionId,
354}
355impl crate::packet::Packet for ClientCommand {
356 const ID: i32 = id::CLIENT_COMMAND;
357 const NAME: &'static str = "client_command";
358 const STATE: State = State::Play;
359 const DIRECTION: Direction = Direction::Serverbound;
360}
361impl Decode for ClientCommand {
362 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
363 Ok({
364 let v1085 = ClientCommandActionId(r.read_varint()?);
365 ClientCommand { action_id: v1085 }
366 })
367 }
368}
369impl Encode for ClientCommand {
370 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
371 w.put_varint((*self).action_id.0);
372 Ok(())
373 }
374}
375#[cfg(feature = "testgen")]
376impl Generate for ClientCommand {
377 fn generate(g: &mut Gen) -> Self {
378 {
379 let v1086 = ClientCommandActionId(g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
380 ClientCommand { action_id: v1086 }
381 }
382 }
383}
384impl From<ClientCommand> for ServerboundPlayPacket {
385 fn from(p: ClientCommand) -> Self {
386 Self::ClientCommand(p)
387 }
388}
389
390#[derive(Debug, Clone, PartialEq)]
392pub struct Settings {
393 pub locale: ByteString,
395 pub view_distance: i8,
397 pub chat_flags: i32,
399 pub chat_colors: bool,
401 pub skin_parts: u8,
403 pub main_hand: i32,
405}
406impl crate::packet::Packet for Settings {
407 const ID: i32 = id::SETTINGS;
408 const NAME: &'static str = "settings";
409 const STATE: State = State::Play;
410 const DIRECTION: Direction = Direction::Serverbound;
411}
412impl Decode for Settings {
413 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
414 Ok({
415 let v1087 = r.read_string()?;
416 let v1088 = r.read_i8()?;
417 let v1089 = r.read_varint()?;
418 let v1090 = r.read_bool()?;
419 let v1091 = r.read_u8()?;
420 let v1092 = r.read_varint()?;
421 Settings {
422 locale: v1087,
423 view_distance: v1088,
424 chat_flags: v1089,
425 chat_colors: v1090,
426 skin_parts: v1091,
427 main_hand: v1092,
428 }
429 })
430 }
431}
432impl Encode for Settings {
433 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
434 w.put_string(&(*self).locale)?;
435 w.put_i8((*self).view_distance);
436 w.put_varint((*self).chat_flags);
437 w.put_bool((*self).chat_colors);
438 w.put_u8((*self).skin_parts);
439 w.put_varint((*self).main_hand);
440 Ok(())
441 }
442}
443#[cfg(feature = "testgen")]
444impl Generate for Settings {
445 fn generate(g: &mut Gen) -> Self {
446 {
447 let v1093 = g.string();
448 let v1094 = (g.int_in(-128, 127, &[]) as i8);
449 let v1095 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
450 let v1096 = g.bool();
451 let v1097 = (g.int_in(0, 255, &[]) as u8);
452 let v1098 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
453 Settings {
454 locale: v1093,
455 view_distance: v1094,
456 chat_flags: v1095,
457 chat_colors: v1096,
458 skin_parts: v1097,
459 main_hand: v1098,
460 }
461 }
462 }
463}
464impl From<Settings> for ServerboundPlayPacket {
465 fn from(p: Settings) -> Self {
466 Self::Settings(p)
467 }
468}
469
470#[derive(Debug, Clone, PartialEq)]
472pub struct Transaction {
473 pub window_id: i8,
475 pub action: i16,
477 pub accepted: bool,
479}
480impl crate::packet::Packet for Transaction {
481 const ID: i32 = id::TRANSACTION;
482 const NAME: &'static str = "transaction";
483 const STATE: State = State::Play;
484 const DIRECTION: Direction = Direction::Serverbound;
485}
486impl Decode for Transaction {
487 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
488 Ok({
489 let v1099 = r.read_i8()?;
490 let v1100 = r.read_i16()?;
491 let v1101 = r.read_bool()?;
492 Transaction {
493 window_id: v1099,
494 action: v1100,
495 accepted: v1101,
496 }
497 })
498 }
499}
500impl Encode for Transaction {
501 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
502 w.put_i8((*self).window_id);
503 w.put_i16((*self).action);
504 w.put_bool((*self).accepted);
505 Ok(())
506 }
507}
508#[cfg(feature = "testgen")]
509impl Generate for Transaction {
510 fn generate(g: &mut Gen) -> Self {
511 {
512 let v1102 = (g.int_in(-128, 127, &[]) as i8);
513 let v1103 = (g.int_in(-32768, 32767, &[]) as i16);
514 let v1104 = g.bool();
515 Transaction {
516 window_id: v1102,
517 action: v1103,
518 accepted: v1104,
519 }
520 }
521 }
522}
523impl From<Transaction> for ServerboundPlayPacket {
524 fn from(p: Transaction) -> Self {
525 Self::Transaction(p)
526 }
527}
528
529#[derive(Debug, Clone, PartialEq)]
531pub struct EnchantItem {
532 pub window_id: i8,
534 pub enchantment: i8,
536}
537impl crate::packet::Packet for EnchantItem {
538 const ID: i32 = id::ENCHANT_ITEM;
539 const NAME: &'static str = "enchant_item";
540 const STATE: State = State::Play;
541 const DIRECTION: Direction = Direction::Serverbound;
542}
543impl Decode for EnchantItem {
544 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
545 Ok({
546 let v1105 = r.read_i8()?;
547 let v1106 = r.read_i8()?;
548 EnchantItem {
549 window_id: v1105,
550 enchantment: v1106,
551 }
552 })
553 }
554}
555impl Encode for EnchantItem {
556 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
557 w.put_i8((*self).window_id);
558 w.put_i8((*self).enchantment);
559 Ok(())
560 }
561}
562#[cfg(feature = "testgen")]
563impl Generate for EnchantItem {
564 fn generate(g: &mut Gen) -> Self {
565 {
566 let v1107 = (g.int_in(-128, 127, &[]) as i8);
567 let v1108 = (g.int_in(-128, 127, &[]) as i8);
568 EnchantItem {
569 window_id: v1107,
570 enchantment: v1108,
571 }
572 }
573 }
574}
575impl From<EnchantItem> for ServerboundPlayPacket {
576 fn from(p: EnchantItem) -> Self {
577 Self::EnchantItem(p)
578 }
579}
580
581#[derive(Debug, Clone, PartialEq)]
583pub struct WindowClick {
584 pub window_id: u8,
586 pub slot: i16,
588 pub mouse_button: i8,
590 pub action: i16,
592 pub mode: i8,
594 pub item: types::Slot,
596}
597impl crate::packet::Packet for WindowClick {
598 const ID: i32 = id::WINDOW_CLICK;
599 const NAME: &'static str = "window_click";
600 const STATE: State = State::Play;
601 const DIRECTION: Direction = Direction::Serverbound;
602}
603impl Decode for WindowClick {
604 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
605 Ok({
606 let v1109 = r.read_u8()?;
607 let v1110 = r.read_i16()?;
608 let v1111 = r.read_i8()?;
609 let v1112 = r.read_i16()?;
610 let v1113 = r.read_i8()?;
611 let v1114 = <types::Slot as Decode>::decode(r)?;
612 WindowClick {
613 window_id: v1109,
614 slot: v1110,
615 mouse_button: v1111,
616 action: v1112,
617 mode: v1113,
618 item: v1114,
619 }
620 })
621 }
622}
623impl Encode for WindowClick {
624 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
625 w.put_u8((*self).window_id);
626 w.put_i16((*self).slot);
627 w.put_i8((*self).mouse_button);
628 w.put_i16((*self).action);
629 w.put_i8((*self).mode);
630 (*self).item.encode(w)?;
631 Ok(())
632 }
633}
634#[cfg(feature = "testgen")]
635impl Generate for WindowClick {
636 fn generate(g: &mut Gen) -> Self {
637 {
638 let v1115 = (g.int_in(0, 255, &[]) as u8);
639 let v1116 = (g.int_in(-32768, 32767, &[]) as i16);
640 let v1117 = (g.int_in(-128, 127, &[]) as i8);
641 let v1118 = (g.int_in(-32768, 32767, &[]) as i16);
642 let v1119 = (g.int_in(-128, 127, &[]) as i8);
643 let v1120 = <types::Slot as Generate>::generate(g);
644 WindowClick {
645 window_id: v1115,
646 slot: v1116,
647 mouse_button: v1117,
648 action: v1118,
649 mode: v1119,
650 item: v1120,
651 }
652 }
653 }
654}
655impl From<WindowClick> for ServerboundPlayPacket {
656 fn from(p: WindowClick) -> Self {
657 Self::WindowClick(p)
658 }
659}
660
661#[derive(Debug, Clone, PartialEq)]
663pub struct CloseWindow {
664 pub window_id: u8,
666}
667impl crate::packet::Packet for CloseWindow {
668 const ID: i32 = id::CLOSE_WINDOW;
669 const NAME: &'static str = "close_window";
670 const STATE: State = State::Play;
671 const DIRECTION: Direction = Direction::Serverbound;
672}
673impl Decode for CloseWindow {
674 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
675 Ok({
676 let v1121 = r.read_u8()?;
677 CloseWindow { window_id: v1121 }
678 })
679 }
680}
681impl Encode for CloseWindow {
682 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
683 w.put_u8((*self).window_id);
684 Ok(())
685 }
686}
687#[cfg(feature = "testgen")]
688impl Generate for CloseWindow {
689 fn generate(g: &mut Gen) -> Self {
690 {
691 let v1122 = (g.int_in(0, 255, &[]) as u8);
692 CloseWindow { window_id: v1122 }
693 }
694 }
695}
696impl From<CloseWindow> for ServerboundPlayPacket {
697 fn from(p: CloseWindow) -> Self {
698 Self::CloseWindow(p)
699 }
700}
701
702#[derive(Debug, Clone, PartialEq)]
704pub struct CustomPayload {
705 pub channel: ByteString,
707 pub data: Bytes,
709}
710impl crate::packet::Packet for CustomPayload {
711 const ID: i32 = id::CUSTOM_PAYLOAD;
712 const NAME: &'static str = "custom_payload";
713 const STATE: State = State::Play;
714 const DIRECTION: Direction = Direction::Serverbound;
715}
716impl Decode for CustomPayload {
717 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
718 Ok({
719 let v1123 = r.read_string()?;
720 let v1124 = r.read_rest();
721 CustomPayload {
722 channel: v1123,
723 data: v1124,
724 }
725 })
726 }
727}
728impl Encode for CustomPayload {
729 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
730 w.put_string(&(*self).channel)?;
731 w.put_slice(&(*self).data);
732 Ok(())
733 }
734}
735#[cfg(feature = "testgen")]
736impl Generate for CustomPayload {
737 fn generate(g: &mut Gen) -> Self {
738 {
739 let v1125 = g.string();
740 let v1126 = g.bytes();
741 CustomPayload {
742 channel: v1125,
743 data: v1126,
744 }
745 }
746 }
747}
748impl From<CustomPayload> for ServerboundPlayPacket {
749 fn from(p: CustomPayload) -> Self {
750 Self::CustomPayload(p)
751 }
752}
753
754#[derive(Debug, Clone, PartialEq)]
756pub struct UseEntity {
757 pub target: i32,
759 pub mouse: i32,
761 pub x: Option<f32>,
763 pub y: Option<f32>,
765 pub z: Option<f32>,
767 pub hand: Option<i32>,
769}
770impl crate::packet::Packet for UseEntity {
771 const ID: i32 = id::USE_ENTITY;
772 const NAME: &'static str = "use_entity";
773 const STATE: State = State::Play;
774 const DIRECTION: Direction = Direction::Serverbound;
775}
776impl Decode for UseEntity {
777 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
778 Ok({
779 let v1127 = r.read_varint()?;
780 let v1128 = r.read_varint()?;
781 let v1129 = if (v1128 == 2) {
782 Some(r.read_f32()?)
783 } else {
784 None
785 };
786 let v1130 = if (v1128 == 2) {
787 Some(r.read_f32()?)
788 } else {
789 None
790 };
791 let v1131 = if (v1128 == 2) {
792 Some(r.read_f32()?)
793 } else {
794 None
795 };
796 let v1132 = if (v1128 == 0) || (v1128 == 2) {
797 Some(r.read_varint()?)
798 } else {
799 None
800 };
801 UseEntity {
802 target: v1127,
803 mouse: v1128,
804 x: v1129,
805 y: v1130,
806 z: v1131,
807 hand: v1132,
808 }
809 })
810 }
811}
812impl Encode for UseEntity {
813 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
814 w.put_varint((*self).target);
815 w.put_varint((*self).mouse);
816 match (&(*self).x, ((*self).mouse == 2)) {
817 (Some(v1133), true) => {
818 w.put_f32((*v1133));
819 }
820 (None, false) => {}
821 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
822 }
823 match (&(*self).y, ((*self).mouse == 2)) {
824 (Some(v1134), true) => {
825 w.put_f32((*v1134));
826 }
827 (None, false) => {}
828 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
829 }
830 match (&(*self).z, ((*self).mouse == 2)) {
831 (Some(v1135), true) => {
832 w.put_f32((*v1135));
833 }
834 (None, false) => {}
835 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
836 }
837 match (&(*self).hand, ((*self).mouse == 0) || ((*self).mouse == 2)) {
838 (Some(v1136), true) => {
839 w.put_varint((*v1136));
840 }
841 (None, false) => {}
842 _ => {
843 return Err(EncodeError::SwitchMismatch(
844 "play.serverbound.use_entity.hand",
845 ));
846 }
847 }
848 Ok(())
849 }
850}
851#[cfg(feature = "testgen")]
852impl Generate for UseEntity {
853 fn generate(g: &mut Gen) -> Self {
854 {
855 let v1137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
856 let v1138 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2, 0, 2]) as i32);
857 let v1139 = if (v1138 == 2) { Some(g.f32()) } else { None };
858 let v1140 = if (v1138 == 2) { Some(g.f32()) } else { None };
859 let v1141 = if (v1138 == 2) { Some(g.f32()) } else { None };
860 let v1142 = if (v1138 == 0) || (v1138 == 2) {
861 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
862 } else {
863 None
864 };
865 UseEntity {
866 target: v1137,
867 mouse: v1138,
868 x: v1139,
869 y: v1140,
870 z: v1141,
871 hand: v1142,
872 }
873 }
874 }
875}
876impl From<UseEntity> for ServerboundPlayPacket {
877 fn from(p: UseEntity) -> Self {
878 Self::UseEntity(p)
879 }
880}
881
882#[derive(Debug, Clone, PartialEq)]
884pub struct KeepAlive {
885 pub keep_alive_id: i64,
887}
888impl crate::packet::Packet for KeepAlive {
889 const ID: i32 = id::KEEP_ALIVE;
890 const NAME: &'static str = "keep_alive";
891 const STATE: State = State::Play;
892 const DIRECTION: Direction = Direction::Serverbound;
893}
894impl Decode for KeepAlive {
895 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
896 Ok({
897 let v1143 = r.read_i64()?;
898 KeepAlive {
899 keep_alive_id: v1143,
900 }
901 })
902 }
903}
904impl Encode for KeepAlive {
905 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
906 w.put_i64((*self).keep_alive_id);
907 Ok(())
908 }
909}
910#[cfg(feature = "testgen")]
911impl Generate for KeepAlive {
912 fn generate(g: &mut Gen) -> Self {
913 {
914 let v1144 = g.i64();
915 KeepAlive {
916 keep_alive_id: v1144,
917 }
918 }
919 }
920}
921impl From<KeepAlive> for ServerboundPlayPacket {
922 fn from(p: KeepAlive) -> Self {
923 Self::KeepAlive(p)
924 }
925}
926
927#[derive(Debug, Clone, PartialEq)]
929pub struct Flying {
930 pub on_ground: bool,
932}
933impl crate::packet::Packet for Flying {
934 const ID: i32 = id::FLYING;
935 const NAME: &'static str = "flying";
936 const STATE: State = State::Play;
937 const DIRECTION: Direction = Direction::Serverbound;
938}
939impl Decode for Flying {
940 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
941 Ok({
942 let v1145 = r.read_bool()?;
943 Flying { on_ground: v1145 }
944 })
945 }
946}
947impl Encode for Flying {
948 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
949 w.put_bool((*self).on_ground);
950 Ok(())
951 }
952}
953#[cfg(feature = "testgen")]
954impl Generate for Flying {
955 fn generate(g: &mut Gen) -> Self {
956 {
957 let v1146 = g.bool();
958 Flying { on_ground: v1146 }
959 }
960 }
961}
962impl From<Flying> for ServerboundPlayPacket {
963 fn from(p: Flying) -> Self {
964 Self::Flying(p)
965 }
966}
967
968#[derive(Debug, Clone, PartialEq)]
970pub struct Position {
971 pub x: f64,
973 pub y: f64,
975 pub z: f64,
977 pub on_ground: bool,
979}
980impl crate::packet::Packet for Position {
981 const ID: i32 = id::POSITION;
982 const NAME: &'static str = "position";
983 const STATE: State = State::Play;
984 const DIRECTION: Direction = Direction::Serverbound;
985}
986impl Decode for Position {
987 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
988 Ok({
989 let v1147 = r.read_f64()?;
990 let v1148 = r.read_f64()?;
991 let v1149 = r.read_f64()?;
992 let v1150 = r.read_bool()?;
993 Position {
994 x: v1147,
995 y: v1148,
996 z: v1149,
997 on_ground: v1150,
998 }
999 })
1000 }
1001}
1002impl Encode for Position {
1003 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1004 w.put_f64((*self).x);
1005 w.put_f64((*self).y);
1006 w.put_f64((*self).z);
1007 w.put_bool((*self).on_ground);
1008 Ok(())
1009 }
1010}
1011#[cfg(feature = "testgen")]
1012impl Generate for Position {
1013 fn generate(g: &mut Gen) -> Self {
1014 {
1015 let v1151 = g.f64();
1016 let v1152 = g.f64();
1017 let v1153 = g.f64();
1018 let v1154 = g.bool();
1019 Position {
1020 x: v1151,
1021 y: v1152,
1022 z: v1153,
1023 on_ground: v1154,
1024 }
1025 }
1026 }
1027}
1028impl From<Position> for ServerboundPlayPacket {
1029 fn from(p: Position) -> Self {
1030 Self::Position(p)
1031 }
1032}
1033
1034#[derive(Debug, Clone, PartialEq)]
1036pub struct PositionLook {
1037 pub x: f64,
1039 pub y: f64,
1041 pub z: f64,
1043 pub yaw: f32,
1045 pub pitch: f32,
1047 pub on_ground: bool,
1049}
1050impl crate::packet::Packet for PositionLook {
1051 const ID: i32 = id::POSITION_LOOK;
1052 const NAME: &'static str = "position_look";
1053 const STATE: State = State::Play;
1054 const DIRECTION: Direction = Direction::Serverbound;
1055}
1056impl Decode for PositionLook {
1057 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1058 Ok({
1059 let v1155 = r.read_f64()?;
1060 let v1156 = r.read_f64()?;
1061 let v1157 = r.read_f64()?;
1062 let v1158 = r.read_f32()?;
1063 let v1159 = r.read_f32()?;
1064 let v1160 = r.read_bool()?;
1065 PositionLook {
1066 x: v1155,
1067 y: v1156,
1068 z: v1157,
1069 yaw: v1158,
1070 pitch: v1159,
1071 on_ground: v1160,
1072 }
1073 })
1074 }
1075}
1076impl Encode for PositionLook {
1077 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1078 w.put_f64((*self).x);
1079 w.put_f64((*self).y);
1080 w.put_f64((*self).z);
1081 w.put_f32((*self).yaw);
1082 w.put_f32((*self).pitch);
1083 w.put_bool((*self).on_ground);
1084 Ok(())
1085 }
1086}
1087#[cfg(feature = "testgen")]
1088impl Generate for PositionLook {
1089 fn generate(g: &mut Gen) -> Self {
1090 {
1091 let v1161 = g.f64();
1092 let v1162 = g.f64();
1093 let v1163 = g.f64();
1094 let v1164 = g.f32();
1095 let v1165 = g.f32();
1096 let v1166 = g.bool();
1097 PositionLook {
1098 x: v1161,
1099 y: v1162,
1100 z: v1163,
1101 yaw: v1164,
1102 pitch: v1165,
1103 on_ground: v1166,
1104 }
1105 }
1106 }
1107}
1108impl From<PositionLook> for ServerboundPlayPacket {
1109 fn from(p: PositionLook) -> Self {
1110 Self::PositionLook(p)
1111 }
1112}
1113
1114#[derive(Debug, Clone, PartialEq)]
1116pub struct Look {
1117 pub yaw: f32,
1119 pub pitch: f32,
1121 pub on_ground: bool,
1123}
1124impl crate::packet::Packet for Look {
1125 const ID: i32 = id::LOOK;
1126 const NAME: &'static str = "look";
1127 const STATE: State = State::Play;
1128 const DIRECTION: Direction = Direction::Serverbound;
1129}
1130impl Decode for Look {
1131 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1132 Ok({
1133 let v1167 = r.read_f32()?;
1134 let v1168 = r.read_f32()?;
1135 let v1169 = r.read_bool()?;
1136 Look {
1137 yaw: v1167,
1138 pitch: v1168,
1139 on_ground: v1169,
1140 }
1141 })
1142 }
1143}
1144impl Encode for Look {
1145 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1146 w.put_f32((*self).yaw);
1147 w.put_f32((*self).pitch);
1148 w.put_bool((*self).on_ground);
1149 Ok(())
1150 }
1151}
1152#[cfg(feature = "testgen")]
1153impl Generate for Look {
1154 fn generate(g: &mut Gen) -> Self {
1155 {
1156 let v1170 = g.f32();
1157 let v1171 = g.f32();
1158 let v1172 = g.bool();
1159 Look {
1160 yaw: v1170,
1161 pitch: v1171,
1162 on_ground: v1172,
1163 }
1164 }
1165 }
1166}
1167impl From<Look> for ServerboundPlayPacket {
1168 fn from(p: Look) -> Self {
1169 Self::Look(p)
1170 }
1171}
1172
1173#[derive(Debug, Clone, PartialEq)]
1175pub struct VehicleMove {
1176 pub x: f64,
1178 pub y: f64,
1180 pub z: f64,
1182 pub yaw: f32,
1184 pub pitch: f32,
1186}
1187impl crate::packet::Packet for VehicleMove {
1188 const ID: i32 = id::VEHICLE_MOVE;
1189 const NAME: &'static str = "vehicle_move";
1190 const STATE: State = State::Play;
1191 const DIRECTION: Direction = Direction::Serverbound;
1192}
1193impl Decode for VehicleMove {
1194 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1195 Ok({
1196 let v1173 = r.read_f64()?;
1197 let v1174 = r.read_f64()?;
1198 let v1175 = r.read_f64()?;
1199 let v1176 = r.read_f32()?;
1200 let v1177 = r.read_f32()?;
1201 VehicleMove {
1202 x: v1173,
1203 y: v1174,
1204 z: v1175,
1205 yaw: v1176,
1206 pitch: v1177,
1207 }
1208 })
1209 }
1210}
1211impl Encode for VehicleMove {
1212 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1213 w.put_f64((*self).x);
1214 w.put_f64((*self).y);
1215 w.put_f64((*self).z);
1216 w.put_f32((*self).yaw);
1217 w.put_f32((*self).pitch);
1218 Ok(())
1219 }
1220}
1221#[cfg(feature = "testgen")]
1222impl Generate for VehicleMove {
1223 fn generate(g: &mut Gen) -> Self {
1224 {
1225 let v1178 = g.f64();
1226 let v1179 = g.f64();
1227 let v1180 = g.f64();
1228 let v1181 = g.f32();
1229 let v1182 = g.f32();
1230 VehicleMove {
1231 x: v1178,
1232 y: v1179,
1233 z: v1180,
1234 yaw: v1181,
1235 pitch: v1182,
1236 }
1237 }
1238 }
1239}
1240impl From<VehicleMove> for ServerboundPlayPacket {
1241 fn from(p: VehicleMove) -> Self {
1242 Self::VehicleMove(p)
1243 }
1244}
1245
1246#[derive(Debug, Clone, PartialEq)]
1248pub struct SteerBoat {
1249 pub left_paddle: bool,
1251 pub right_paddle: bool,
1253}
1254impl crate::packet::Packet for SteerBoat {
1255 const ID: i32 = id::STEER_BOAT;
1256 const NAME: &'static str = "steer_boat";
1257 const STATE: State = State::Play;
1258 const DIRECTION: Direction = Direction::Serverbound;
1259}
1260impl Decode for SteerBoat {
1261 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1262 Ok({
1263 let v1183 = r.read_bool()?;
1264 let v1184 = r.read_bool()?;
1265 SteerBoat {
1266 left_paddle: v1183,
1267 right_paddle: v1184,
1268 }
1269 })
1270 }
1271}
1272impl Encode for SteerBoat {
1273 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1274 w.put_bool((*self).left_paddle);
1275 w.put_bool((*self).right_paddle);
1276 Ok(())
1277 }
1278}
1279#[cfg(feature = "testgen")]
1280impl Generate for SteerBoat {
1281 fn generate(g: &mut Gen) -> Self {
1282 {
1283 let v1185 = g.bool();
1284 let v1186 = g.bool();
1285 SteerBoat {
1286 left_paddle: v1185,
1287 right_paddle: v1186,
1288 }
1289 }
1290 }
1291}
1292impl From<SteerBoat> for ServerboundPlayPacket {
1293 fn from(p: SteerBoat) -> Self {
1294 Self::SteerBoat(p)
1295 }
1296}
1297
1298#[derive(Debug, Clone, PartialEq)]
1300pub struct CraftRecipeRequest {
1301 pub window_id: i8,
1303 pub recipe: i32,
1305 pub make_all: bool,
1307}
1308impl crate::packet::Packet for CraftRecipeRequest {
1309 const ID: i32 = id::CRAFT_RECIPE_REQUEST;
1310 const NAME: &'static str = "craft_recipe_request";
1311 const STATE: State = State::Play;
1312 const DIRECTION: Direction = Direction::Serverbound;
1313}
1314impl Decode for CraftRecipeRequest {
1315 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1316 Ok({
1317 let v1187 = r.read_i8()?;
1318 let v1188 = r.read_varint()?;
1319 let v1189 = r.read_bool()?;
1320 CraftRecipeRequest {
1321 window_id: v1187,
1322 recipe: v1188,
1323 make_all: v1189,
1324 }
1325 })
1326 }
1327}
1328impl Encode for CraftRecipeRequest {
1329 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1330 w.put_i8((*self).window_id);
1331 w.put_varint((*self).recipe);
1332 w.put_bool((*self).make_all);
1333 Ok(())
1334 }
1335}
1336#[cfg(feature = "testgen")]
1337impl Generate for CraftRecipeRequest {
1338 fn generate(g: &mut Gen) -> Self {
1339 {
1340 let v1190 = (g.int_in(-128, 127, &[]) as i8);
1341 let v1191 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1342 let v1192 = g.bool();
1343 CraftRecipeRequest {
1344 window_id: v1190,
1345 recipe: v1191,
1346 make_all: v1192,
1347 }
1348 }
1349 }
1350}
1351impl From<CraftRecipeRequest> for ServerboundPlayPacket {
1352 fn from(p: CraftRecipeRequest) -> Self {
1353 Self::CraftRecipeRequest(p)
1354 }
1355}
1356
1357#[derive(Debug, Clone, PartialEq)]
1359pub struct Abilities {
1360 pub flags: i8,
1362 pub flying_speed: f32,
1364 pub walking_speed: f32,
1366}
1367impl crate::packet::Packet for Abilities {
1368 const ID: i32 = id::ABILITIES;
1369 const NAME: &'static str = "abilities";
1370 const STATE: State = State::Play;
1371 const DIRECTION: Direction = Direction::Serverbound;
1372}
1373impl Decode for Abilities {
1374 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1375 Ok({
1376 let v1193 = r.read_i8()?;
1377 let v1194 = r.read_f32()?;
1378 let v1195 = r.read_f32()?;
1379 Abilities {
1380 flags: v1193,
1381 flying_speed: v1194,
1382 walking_speed: v1195,
1383 }
1384 })
1385 }
1386}
1387impl Encode for Abilities {
1388 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1389 w.put_i8((*self).flags);
1390 w.put_f32((*self).flying_speed);
1391 w.put_f32((*self).walking_speed);
1392 Ok(())
1393 }
1394}
1395#[cfg(feature = "testgen")]
1396impl Generate for Abilities {
1397 fn generate(g: &mut Gen) -> Self {
1398 {
1399 let v1196 = (g.int_in(-128, 127, &[]) as i8);
1400 let v1197 = g.f32();
1401 let v1198 = g.f32();
1402 Abilities {
1403 flags: v1196,
1404 flying_speed: v1197,
1405 walking_speed: v1198,
1406 }
1407 }
1408 }
1409}
1410impl From<Abilities> for ServerboundPlayPacket {
1411 fn from(p: Abilities) -> Self {
1412 Self::Abilities(p)
1413 }
1414}
1415
1416#[derive(Debug, Clone, PartialEq)]
1418pub struct BlockDig {
1419 pub status: i32,
1421 pub location: BlockPos,
1423 pub face: i8,
1425}
1426impl crate::packet::Packet for BlockDig {
1427 const ID: i32 = id::BLOCK_DIG;
1428 const NAME: &'static str = "block_dig";
1429 const STATE: State = State::Play;
1430 const DIRECTION: Direction = Direction::Serverbound;
1431}
1432impl Decode for BlockDig {
1433 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1434 Ok({
1435 let v1199 = r.read_varint()?;
1436 let v1200 = BlockPos::read(r, PositionLayout::Xyz)?;
1437 let v1201 = r.read_i8()?;
1438 BlockDig {
1439 status: v1199,
1440 location: v1200,
1441 face: v1201,
1442 }
1443 })
1444 }
1445}
1446impl Encode for BlockDig {
1447 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1448 w.put_varint((*self).status);
1449 (*self).location.write(w, PositionLayout::Xyz)?;
1450 w.put_i8((*self).face);
1451 Ok(())
1452 }
1453}
1454#[cfg(feature = "testgen")]
1455impl Generate for BlockDig {
1456 fn generate(g: &mut Gen) -> Self {
1457 {
1458 let v1202 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1459 let v1203 = g.position();
1460 let v1204 = (g.int_in(-128, 127, &[]) as i8);
1461 BlockDig {
1462 status: v1202,
1463 location: v1203,
1464 face: v1204,
1465 }
1466 }
1467 }
1468}
1469impl From<BlockDig> for ServerboundPlayPacket {
1470 fn from(p: BlockDig) -> Self {
1471 Self::BlockDig(p)
1472 }
1473}
1474
1475#[derive(Debug, Clone, PartialEq)]
1477pub struct EntityAction {
1478 pub entity_id: i32,
1480 pub action_id: EntityActionActionId,
1482 pub jump_boost: i32,
1484}
1485impl crate::packet::Packet for EntityAction {
1486 const ID: i32 = id::ENTITY_ACTION;
1487 const NAME: &'static str = "entity_action";
1488 const STATE: State = State::Play;
1489 const DIRECTION: Direction = Direction::Serverbound;
1490}
1491impl Decode for EntityAction {
1492 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1493 Ok({
1494 let v1205 = r.read_varint()?;
1495 let v1206 = EntityActionActionId(r.read_varint()?);
1496 let v1207 = r.read_varint()?;
1497 EntityAction {
1498 entity_id: v1205,
1499 action_id: v1206,
1500 jump_boost: v1207,
1501 }
1502 })
1503 }
1504}
1505impl Encode for EntityAction {
1506 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1507 w.put_varint((*self).entity_id);
1508 w.put_varint((*self).action_id.0);
1509 w.put_varint((*self).jump_boost);
1510 Ok(())
1511 }
1512}
1513#[cfg(feature = "testgen")]
1514impl Generate for EntityAction {
1515 fn generate(g: &mut Gen) -> Self {
1516 {
1517 let v1208 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1518 let v1209 =
1519 EntityActionActionId(
1520 g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8]) as i32,
1521 );
1522 let v1210 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1523 EntityAction {
1524 entity_id: v1208,
1525 action_id: v1209,
1526 jump_boost: v1210,
1527 }
1528 }
1529 }
1530}
1531impl From<EntityAction> for ServerboundPlayPacket {
1532 fn from(p: EntityAction) -> Self {
1533 Self::EntityAction(p)
1534 }
1535}
1536
1537#[derive(Debug, Clone, PartialEq)]
1539pub struct SteerVehicle {
1540 pub sideways: f32,
1542 pub forward: f32,
1544 pub jump: u8,
1546}
1547impl crate::packet::Packet for SteerVehicle {
1548 const ID: i32 = id::STEER_VEHICLE;
1549 const NAME: &'static str = "steer_vehicle";
1550 const STATE: State = State::Play;
1551 const DIRECTION: Direction = Direction::Serverbound;
1552}
1553impl Decode for SteerVehicle {
1554 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1555 Ok({
1556 let v1211 = r.read_f32()?;
1557 let v1212 = r.read_f32()?;
1558 let v1213 = r.read_u8()?;
1559 SteerVehicle {
1560 sideways: v1211,
1561 forward: v1212,
1562 jump: v1213,
1563 }
1564 })
1565 }
1566}
1567impl Encode for SteerVehicle {
1568 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1569 w.put_f32((*self).sideways);
1570 w.put_f32((*self).forward);
1571 w.put_u8((*self).jump);
1572 Ok(())
1573 }
1574}
1575#[cfg(feature = "testgen")]
1576impl Generate for SteerVehicle {
1577 fn generate(g: &mut Gen) -> Self {
1578 {
1579 let v1214 = g.f32();
1580 let v1215 = g.f32();
1581 let v1216 = (g.int_in(0, 255, &[]) as u8);
1582 SteerVehicle {
1583 sideways: v1214,
1584 forward: v1215,
1585 jump: v1216,
1586 }
1587 }
1588 }
1589}
1590impl From<SteerVehicle> for ServerboundPlayPacket {
1591 fn from(p: SteerVehicle) -> Self {
1592 Self::SteerVehicle(p)
1593 }
1594}
1595
1596#[derive(Debug, Clone, PartialEq)]
1598pub struct CraftingBookData {
1599 pub r#type: i32,
1601 pub body: CraftingBookDataBody,
1603}
1604impl crate::packet::Packet for CraftingBookData {
1605 const ID: i32 = id::CRAFTING_BOOK_DATA;
1606 const NAME: &'static str = "crafting_book_data";
1607 const STATE: State = State::Play;
1608 const DIRECTION: Direction = Direction::Serverbound;
1609}
1610impl Decode for CraftingBookData {
1611 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1612 Ok({
1613 let v1217 = r.read_varint()?;
1614 let v1218 = (if (v1217 == 0) {
1615 CraftingBookDataBody::Case0({
1616 let v1219 = r.read_i32()?;
1617 CraftingBookDataBodyCase0 {
1618 displayed_recipe: v1219,
1619 }
1620 })
1621 } else if (v1217 == 1) {
1622 CraftingBookDataBody::Case1({
1623 let v1220 = r.read_bool()?;
1624 let v1221 = r.read_bool()?;
1625 CraftingBookDataBodyCase1 {
1626 crafting_book_open: v1220,
1627 crafting_filter: v1221,
1628 }
1629 })
1630 } else {
1631 CraftingBookDataBody::Other
1632 });
1633 CraftingBookData {
1634 r#type: v1217,
1635 body: v1218,
1636 }
1637 })
1638 }
1639}
1640impl Encode for CraftingBookData {
1641 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1642 w.put_varint((*self).r#type);
1643 match &(*self).body {
1644 CraftingBookDataBody::Case0(v1222) => {
1645 if !((*self).r#type == 0) {
1646 return Err(EncodeError::SwitchMismatch(
1647 "play.serverbound.crafting_book_data.body",
1648 ));
1649 }
1650 w.put_i32((*v1222).displayed_recipe);
1651 }
1652 CraftingBookDataBody::Case1(v1223) => {
1653 if !((*self).r#type == 1) {
1654 return Err(EncodeError::SwitchMismatch(
1655 "play.serverbound.crafting_book_data.body",
1656 ));
1657 }
1658 w.put_bool((*v1223).crafting_book_open);
1659 w.put_bool((*v1223).crafting_filter);
1660 }
1661 CraftingBookDataBody::Other => {
1662 if !(!(((*self).r#type == 0) || ((*self).r#type == 1))) {
1663 return Err(EncodeError::SwitchMismatch(
1664 "play.serverbound.crafting_book_data.body",
1665 ));
1666 }
1667 }
1668 }
1669 Ok(())
1670 }
1671}
1672#[cfg(feature = "testgen")]
1673impl Generate for CraftingBookData {
1674 fn generate(g: &mut Gen) -> Self {
1675 {
1676 let v1224 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
1677 let v1225 = (if (v1224 == 0) {
1678 CraftingBookDataBody::Case0({
1679 let v1226 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1680 CraftingBookDataBodyCase0 {
1681 displayed_recipe: v1226,
1682 }
1683 })
1684 } else if (v1224 == 1) {
1685 CraftingBookDataBody::Case1({
1686 let v1227 = g.bool();
1687 let v1228 = g.bool();
1688 CraftingBookDataBodyCase1 {
1689 crafting_book_open: v1227,
1690 crafting_filter: v1228,
1691 }
1692 })
1693 } else {
1694 CraftingBookDataBody::Other
1695 });
1696 CraftingBookData {
1697 r#type: v1224,
1698 body: v1225,
1699 }
1700 }
1701 }
1702}
1703impl From<CraftingBookData> for ServerboundPlayPacket {
1704 fn from(p: CraftingBookData) -> Self {
1705 Self::CraftingBookData(p)
1706 }
1707}
1708
1709#[derive(Debug, Clone, PartialEq)]
1711pub struct ResourcePackReceive {
1712 pub result: i32,
1714}
1715impl crate::packet::Packet for ResourcePackReceive {
1716 const ID: i32 = id::RESOURCE_PACK_RECEIVE;
1717 const NAME: &'static str = "resource_pack_receive";
1718 const STATE: State = State::Play;
1719 const DIRECTION: Direction = Direction::Serverbound;
1720}
1721impl Decode for ResourcePackReceive {
1722 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1723 Ok({
1724 let v1229 = r.read_varint()?;
1725 ResourcePackReceive { result: v1229 }
1726 })
1727 }
1728}
1729impl Encode for ResourcePackReceive {
1730 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1731 w.put_varint((*self).result);
1732 Ok(())
1733 }
1734}
1735#[cfg(feature = "testgen")]
1736impl Generate for ResourcePackReceive {
1737 fn generate(g: &mut Gen) -> Self {
1738 {
1739 let v1230 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1740 ResourcePackReceive { result: v1230 }
1741 }
1742 }
1743}
1744impl From<ResourcePackReceive> for ServerboundPlayPacket {
1745 fn from(p: ResourcePackReceive) -> Self {
1746 Self::ResourcePackReceive(p)
1747 }
1748}
1749
1750#[derive(Debug, Clone, PartialEq)]
1752pub struct AdvancementTab {
1753 pub action: i32,
1755 pub tab_id: Option<ByteString>,
1757}
1758impl crate::packet::Packet for AdvancementTab {
1759 const ID: i32 = id::ADVANCEMENT_TAB;
1760 const NAME: &'static str = "advancement_tab";
1761 const STATE: State = State::Play;
1762 const DIRECTION: Direction = Direction::Serverbound;
1763}
1764impl Decode for AdvancementTab {
1765 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1766 Ok({
1767 let v1231 = r.read_varint()?;
1768 let v1232 = if (v1231 == 0) {
1769 Some(r.read_string()?)
1770 } else {
1771 None
1772 };
1773 AdvancementTab {
1774 action: v1231,
1775 tab_id: v1232,
1776 }
1777 })
1778 }
1779}
1780impl Encode for AdvancementTab {
1781 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1782 w.put_varint((*self).action);
1783 match (&(*self).tab_id, ((*self).action == 0)) {
1784 (Some(v1233), true) => {
1785 w.put_string(&(*v1233))?;
1786 }
1787 (None, false) => {}
1788 _ => {
1789 return Err(EncodeError::SwitchMismatch(
1790 "play.serverbound.advancement_tab.tabId",
1791 ));
1792 }
1793 }
1794 Ok(())
1795 }
1796}
1797#[cfg(feature = "testgen")]
1798impl Generate for AdvancementTab {
1799 fn generate(g: &mut Gen) -> Self {
1800 {
1801 let v1234 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
1802 let v1235 = if (v1234 == 0) { Some(g.string()) } else { None };
1803 AdvancementTab {
1804 action: v1234,
1805 tab_id: v1235,
1806 }
1807 }
1808 }
1809}
1810impl From<AdvancementTab> for ServerboundPlayPacket {
1811 fn from(p: AdvancementTab) -> Self {
1812 Self::AdvancementTab(p)
1813 }
1814}
1815
1816#[derive(Debug, Clone, PartialEq)]
1818pub struct HeldItemSlot {
1819 pub slot_id: i16,
1821}
1822impl crate::packet::Packet for HeldItemSlot {
1823 const ID: i32 = id::HELD_ITEM_SLOT;
1824 const NAME: &'static str = "held_item_slot";
1825 const STATE: State = State::Play;
1826 const DIRECTION: Direction = Direction::Serverbound;
1827}
1828impl Decode for HeldItemSlot {
1829 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1830 Ok({
1831 let v1236 = r.read_i16()?;
1832 HeldItemSlot { slot_id: v1236 }
1833 })
1834 }
1835}
1836impl Encode for HeldItemSlot {
1837 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1838 w.put_i16((*self).slot_id);
1839 Ok(())
1840 }
1841}
1842#[cfg(feature = "testgen")]
1843impl Generate for HeldItemSlot {
1844 fn generate(g: &mut Gen) -> Self {
1845 {
1846 let v1237 = (g.int_in(-32768, 32767, &[]) as i16);
1847 HeldItemSlot { slot_id: v1237 }
1848 }
1849 }
1850}
1851impl From<HeldItemSlot> for ServerboundPlayPacket {
1852 fn from(p: HeldItemSlot) -> Self {
1853 Self::HeldItemSlot(p)
1854 }
1855}
1856
1857#[derive(Debug, Clone, PartialEq)]
1859pub struct SetCreativeSlot {
1860 pub slot: i16,
1862 pub item: types::Slot,
1864}
1865impl crate::packet::Packet for SetCreativeSlot {
1866 const ID: i32 = id::SET_CREATIVE_SLOT;
1867 const NAME: &'static str = "set_creative_slot";
1868 const STATE: State = State::Play;
1869 const DIRECTION: Direction = Direction::Serverbound;
1870}
1871impl Decode for SetCreativeSlot {
1872 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1873 Ok({
1874 let v1238 = r.read_i16()?;
1875 let v1239 = <types::Slot as Decode>::decode(r)?;
1876 SetCreativeSlot {
1877 slot: v1238,
1878 item: v1239,
1879 }
1880 })
1881 }
1882}
1883impl Encode for SetCreativeSlot {
1884 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1885 w.put_i16((*self).slot);
1886 (*self).item.encode(w)?;
1887 Ok(())
1888 }
1889}
1890#[cfg(feature = "testgen")]
1891impl Generate for SetCreativeSlot {
1892 fn generate(g: &mut Gen) -> Self {
1893 {
1894 let v1240 = (g.int_in(-32768, 32767, &[]) as i16);
1895 let v1241 = <types::Slot as Generate>::generate(g);
1896 SetCreativeSlot {
1897 slot: v1240,
1898 item: v1241,
1899 }
1900 }
1901 }
1902}
1903impl From<SetCreativeSlot> for ServerboundPlayPacket {
1904 fn from(p: SetCreativeSlot) -> Self {
1905 Self::SetCreativeSlot(p)
1906 }
1907}
1908
1909#[derive(Debug, Clone, PartialEq)]
1911pub struct UpdateSign {
1912 pub location: BlockPos,
1914 pub text1: ByteString,
1916 pub text2: ByteString,
1918 pub text3: ByteString,
1920 pub text4: ByteString,
1922}
1923impl crate::packet::Packet for UpdateSign {
1924 const ID: i32 = id::UPDATE_SIGN;
1925 const NAME: &'static str = "update_sign";
1926 const STATE: State = State::Play;
1927 const DIRECTION: Direction = Direction::Serverbound;
1928}
1929impl Decode for UpdateSign {
1930 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1931 Ok({
1932 let v1242 = BlockPos::read(r, PositionLayout::Xyz)?;
1933 let v1243 = r.read_string()?;
1934 let v1244 = r.read_string()?;
1935 let v1245 = r.read_string()?;
1936 let v1246 = r.read_string()?;
1937 UpdateSign {
1938 location: v1242,
1939 text1: v1243,
1940 text2: v1244,
1941 text3: v1245,
1942 text4: v1246,
1943 }
1944 })
1945 }
1946}
1947impl Encode for UpdateSign {
1948 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1949 (*self).location.write(w, PositionLayout::Xyz)?;
1950 w.put_string(&(*self).text1)?;
1951 w.put_string(&(*self).text2)?;
1952 w.put_string(&(*self).text3)?;
1953 w.put_string(&(*self).text4)?;
1954 Ok(())
1955 }
1956}
1957#[cfg(feature = "testgen")]
1958impl Generate for UpdateSign {
1959 fn generate(g: &mut Gen) -> Self {
1960 {
1961 let v1247 = g.position();
1962 let v1248 = g.string();
1963 let v1249 = g.string();
1964 let v1250 = g.string();
1965 let v1251 = g.string();
1966 UpdateSign {
1967 location: v1247,
1968 text1: v1248,
1969 text2: v1249,
1970 text3: v1250,
1971 text4: v1251,
1972 }
1973 }
1974 }
1975}
1976impl From<UpdateSign> for ServerboundPlayPacket {
1977 fn from(p: UpdateSign) -> Self {
1978 Self::UpdateSign(p)
1979 }
1980}
1981
1982#[derive(Debug, Clone, PartialEq)]
1984pub struct ArmAnimation {
1985 pub hand: i32,
1987}
1988impl crate::packet::Packet for ArmAnimation {
1989 const ID: i32 = id::ARM_ANIMATION;
1990 const NAME: &'static str = "arm_animation";
1991 const STATE: State = State::Play;
1992 const DIRECTION: Direction = Direction::Serverbound;
1993}
1994impl Decode for ArmAnimation {
1995 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1996 Ok({
1997 let v1252 = r.read_varint()?;
1998 ArmAnimation { hand: v1252 }
1999 })
2000 }
2001}
2002impl Encode for ArmAnimation {
2003 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2004 w.put_varint((*self).hand);
2005 Ok(())
2006 }
2007}
2008#[cfg(feature = "testgen")]
2009impl Generate for ArmAnimation {
2010 fn generate(g: &mut Gen) -> Self {
2011 {
2012 let v1253 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2013 ArmAnimation { hand: v1253 }
2014 }
2015 }
2016}
2017impl From<ArmAnimation> for ServerboundPlayPacket {
2018 fn from(p: ArmAnimation) -> Self {
2019 Self::ArmAnimation(p)
2020 }
2021}
2022
2023#[derive(Debug, Clone, PartialEq)]
2025pub struct Spectate {
2026 pub target: Uuid,
2028}
2029impl crate::packet::Packet for Spectate {
2030 const ID: i32 = id::SPECTATE;
2031 const NAME: &'static str = "spectate";
2032 const STATE: State = State::Play;
2033 const DIRECTION: Direction = Direction::Serverbound;
2034}
2035impl Decode for Spectate {
2036 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2037 Ok({
2038 let v1254 = r.read_uuid()?;
2039 Spectate { target: v1254 }
2040 })
2041 }
2042}
2043impl Encode for Spectate {
2044 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2045 w.put_uuid(&(*self).target);
2046 Ok(())
2047 }
2048}
2049#[cfg(feature = "testgen")]
2050impl Generate for Spectate {
2051 fn generate(g: &mut Gen) -> Self {
2052 {
2053 let v1255 = g.uuid();
2054 Spectate { target: v1255 }
2055 }
2056 }
2057}
2058impl From<Spectate> for ServerboundPlayPacket {
2059 fn from(p: Spectate) -> Self {
2060 Self::Spectate(p)
2061 }
2062}
2063
2064#[derive(Debug, Clone, PartialEq)]
2066pub struct BlockPlace {
2067 pub location: BlockPos,
2069 pub direction: i32,
2071 pub hand: i32,
2073 pub cursor_x: f32,
2075 pub cursor_y: f32,
2077 pub cursor_z: f32,
2079}
2080impl crate::packet::Packet for BlockPlace {
2081 const ID: i32 = id::BLOCK_PLACE;
2082 const NAME: &'static str = "block_place";
2083 const STATE: State = State::Play;
2084 const DIRECTION: Direction = Direction::Serverbound;
2085}
2086impl Decode for BlockPlace {
2087 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2088 Ok({
2089 let v1256 = BlockPos::read(r, PositionLayout::Xyz)?;
2090 let v1257 = r.read_varint()?;
2091 let v1258 = r.read_varint()?;
2092 let v1259 = r.read_f32()?;
2093 let v1260 = r.read_f32()?;
2094 let v1261 = r.read_f32()?;
2095 BlockPlace {
2096 location: v1256,
2097 direction: v1257,
2098 hand: v1258,
2099 cursor_x: v1259,
2100 cursor_y: v1260,
2101 cursor_z: v1261,
2102 }
2103 })
2104 }
2105}
2106impl Encode for BlockPlace {
2107 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2108 (*self).location.write(w, PositionLayout::Xyz)?;
2109 w.put_varint((*self).direction);
2110 w.put_varint((*self).hand);
2111 w.put_f32((*self).cursor_x);
2112 w.put_f32((*self).cursor_y);
2113 w.put_f32((*self).cursor_z);
2114 Ok(())
2115 }
2116}
2117#[cfg(feature = "testgen")]
2118impl Generate for BlockPlace {
2119 fn generate(g: &mut Gen) -> Self {
2120 {
2121 let v1262 = g.position();
2122 let v1263 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2123 let v1264 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2124 let v1265 = g.f32();
2125 let v1266 = g.f32();
2126 let v1267 = g.f32();
2127 BlockPlace {
2128 location: v1262,
2129 direction: v1263,
2130 hand: v1264,
2131 cursor_x: v1265,
2132 cursor_y: v1266,
2133 cursor_z: v1267,
2134 }
2135 }
2136 }
2137}
2138impl From<BlockPlace> for ServerboundPlayPacket {
2139 fn from(p: BlockPlace) -> Self {
2140 Self::BlockPlace(p)
2141 }
2142}
2143
2144#[derive(Debug, Clone, PartialEq)]
2146pub struct UseItem {
2147 pub hand: i32,
2149}
2150impl crate::packet::Packet for UseItem {
2151 const ID: i32 = id::USE_ITEM;
2152 const NAME: &'static str = "use_item";
2153 const STATE: State = State::Play;
2154 const DIRECTION: Direction = Direction::Serverbound;
2155}
2156impl Decode for UseItem {
2157 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2158 Ok({
2159 let v1268 = r.read_varint()?;
2160 UseItem { hand: v1268 }
2161 })
2162 }
2163}
2164impl Encode for UseItem {
2165 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2166 w.put_varint((*self).hand);
2167 Ok(())
2168 }
2169}
2170#[cfg(feature = "testgen")]
2171impl Generate for UseItem {
2172 fn generate(g: &mut Gen) -> Self {
2173 {
2174 let v1269 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2175 UseItem { hand: v1269 }
2176 }
2177 }
2178}
2179impl From<UseItem> for ServerboundPlayPacket {
2180 fn from(p: UseItem) -> Self {
2181 Self::UseItem(p)
2182 }
2183}
2184
2185#[derive(Debug, Clone, PartialEq)]
2187pub enum ServerboundPlayPacket {
2188 TeleportConfirm(TeleportConfirm),
2190 TabComplete(TabComplete),
2192 Chat(Chat),
2194 ClientCommand(ClientCommand),
2196 Settings(Settings),
2198 Transaction(Transaction),
2200 EnchantItem(EnchantItem),
2202 WindowClick(WindowClick),
2204 CloseWindow(CloseWindow),
2206 CustomPayload(CustomPayload),
2208 UseEntity(UseEntity),
2210 KeepAlive(KeepAlive),
2212 Flying(Flying),
2214 Position(Position),
2216 PositionLook(PositionLook),
2218 Look(Look),
2220 VehicleMove(VehicleMove),
2222 SteerBoat(SteerBoat),
2224 CraftRecipeRequest(CraftRecipeRequest),
2226 Abilities(Abilities),
2228 BlockDig(BlockDig),
2230 EntityAction(EntityAction),
2232 SteerVehicle(SteerVehicle),
2234 CraftingBookData(CraftingBookData),
2236 ResourcePackReceive(ResourcePackReceive),
2238 AdvancementTab(AdvancementTab),
2240 HeldItemSlot(HeldItemSlot),
2242 SetCreativeSlot(SetCreativeSlot),
2244 UpdateSign(UpdateSign),
2246 ArmAnimation(ArmAnimation),
2248 Spectate(Spectate),
2250 BlockPlace(BlockPlace),
2252 UseItem(UseItem),
2254}
2255
2256impl PacketSet for ServerboundPlayPacket {
2257 const STATE: State = State::Play;
2258 const DIRECTION: Direction = Direction::Serverbound;
2259 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
2260 match raw.id {
2261 id::TELEPORT_CONFIRM => decode_exact(&raw.body).map(Self::TeleportConfirm),
2262 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
2263 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
2264 id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
2265 id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
2266 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
2267 id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
2268 id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
2269 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
2270 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
2271 id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
2272 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
2273 id::FLYING => decode_exact(&raw.body).map(Self::Flying),
2274 id::POSITION => decode_exact(&raw.body).map(Self::Position),
2275 id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
2276 id::LOOK => decode_exact(&raw.body).map(Self::Look),
2277 id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
2278 id::STEER_BOAT => decode_exact(&raw.body).map(Self::SteerBoat),
2279 id::CRAFT_RECIPE_REQUEST => decode_exact(&raw.body).map(Self::CraftRecipeRequest),
2280 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
2281 id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
2282 id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
2283 id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
2284 id::CRAFTING_BOOK_DATA => decode_exact(&raw.body).map(Self::CraftingBookData),
2285 id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
2286 id::ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::AdvancementTab),
2287 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
2288 id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
2289 id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
2290 id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
2291 id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
2292 id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
2293 id::USE_ITEM => decode_exact(&raw.body).map(Self::UseItem),
2294 other => Err(DecodeError::UnknownPacketId(other)),
2295 }
2296 }
2297 fn id(&self) -> i32 {
2298 match *self {
2299 Self::TeleportConfirm(_) => id::TELEPORT_CONFIRM,
2300 Self::TabComplete(_) => id::TAB_COMPLETE,
2301 Self::Chat(_) => id::CHAT,
2302 Self::ClientCommand(_) => id::CLIENT_COMMAND,
2303 Self::Settings(_) => id::SETTINGS,
2304 Self::Transaction(_) => id::TRANSACTION,
2305 Self::EnchantItem(_) => id::ENCHANT_ITEM,
2306 Self::WindowClick(_) => id::WINDOW_CLICK,
2307 Self::CloseWindow(_) => id::CLOSE_WINDOW,
2308 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
2309 Self::UseEntity(_) => id::USE_ENTITY,
2310 Self::KeepAlive(_) => id::KEEP_ALIVE,
2311 Self::Flying(_) => id::FLYING,
2312 Self::Position(_) => id::POSITION,
2313 Self::PositionLook(_) => id::POSITION_LOOK,
2314 Self::Look(_) => id::LOOK,
2315 Self::VehicleMove(_) => id::VEHICLE_MOVE,
2316 Self::SteerBoat(_) => id::STEER_BOAT,
2317 Self::CraftRecipeRequest(_) => id::CRAFT_RECIPE_REQUEST,
2318 Self::Abilities(_) => id::ABILITIES,
2319 Self::BlockDig(_) => id::BLOCK_DIG,
2320 Self::EntityAction(_) => id::ENTITY_ACTION,
2321 Self::SteerVehicle(_) => id::STEER_VEHICLE,
2322 Self::CraftingBookData(_) => id::CRAFTING_BOOK_DATA,
2323 Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
2324 Self::AdvancementTab(_) => id::ADVANCEMENT_TAB,
2325 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
2326 Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
2327 Self::UpdateSign(_) => id::UPDATE_SIGN,
2328 Self::ArmAnimation(_) => id::ARM_ANIMATION,
2329 Self::Spectate(_) => id::SPECTATE,
2330 Self::BlockPlace(_) => id::BLOCK_PLACE,
2331 Self::UseItem(_) => id::USE_ITEM,
2332 }
2333 }
2334 fn name(&self) -> &'static str {
2335 match *self {
2336 Self::TeleportConfirm(_) => "teleport_confirm",
2337 Self::TabComplete(_) => "tab_complete",
2338 Self::Chat(_) => "chat",
2339 Self::ClientCommand(_) => "client_command",
2340 Self::Settings(_) => "settings",
2341 Self::Transaction(_) => "transaction",
2342 Self::EnchantItem(_) => "enchant_item",
2343 Self::WindowClick(_) => "window_click",
2344 Self::CloseWindow(_) => "close_window",
2345 Self::CustomPayload(_) => "custom_payload",
2346 Self::UseEntity(_) => "use_entity",
2347 Self::KeepAlive(_) => "keep_alive",
2348 Self::Flying(_) => "flying",
2349 Self::Position(_) => "position",
2350 Self::PositionLook(_) => "position_look",
2351 Self::Look(_) => "look",
2352 Self::VehicleMove(_) => "vehicle_move",
2353 Self::SteerBoat(_) => "steer_boat",
2354 Self::CraftRecipeRequest(_) => "craft_recipe_request",
2355 Self::Abilities(_) => "abilities",
2356 Self::BlockDig(_) => "block_dig",
2357 Self::EntityAction(_) => "entity_action",
2358 Self::SteerVehicle(_) => "steer_vehicle",
2359 Self::CraftingBookData(_) => "crafting_book_data",
2360 Self::ResourcePackReceive(_) => "resource_pack_receive",
2361 Self::AdvancementTab(_) => "advancement_tab",
2362 Self::HeldItemSlot(_) => "held_item_slot",
2363 Self::SetCreativeSlot(_) => "set_creative_slot",
2364 Self::UpdateSign(_) => "update_sign",
2365 Self::ArmAnimation(_) => "arm_animation",
2366 Self::Spectate(_) => "spectate",
2367 Self::BlockPlace(_) => "block_place",
2368 Self::UseItem(_) => "use_item",
2369 }
2370 }
2371 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
2372 match *self {
2373 Self::TeleportConfirm(ref p) => p.encode(w),
2374 Self::TabComplete(ref p) => p.encode(w),
2375 Self::Chat(ref p) => p.encode(w),
2376 Self::ClientCommand(ref p) => p.encode(w),
2377 Self::Settings(ref p) => p.encode(w),
2378 Self::Transaction(ref p) => p.encode(w),
2379 Self::EnchantItem(ref p) => p.encode(w),
2380 Self::WindowClick(ref p) => p.encode(w),
2381 Self::CloseWindow(ref p) => p.encode(w),
2382 Self::CustomPayload(ref p) => p.encode(w),
2383 Self::UseEntity(ref p) => p.encode(w),
2384 Self::KeepAlive(ref p) => p.encode(w),
2385 Self::Flying(ref p) => p.encode(w),
2386 Self::Position(ref p) => p.encode(w),
2387 Self::PositionLook(ref p) => p.encode(w),
2388 Self::Look(ref p) => p.encode(w),
2389 Self::VehicleMove(ref p) => p.encode(w),
2390 Self::SteerBoat(ref p) => p.encode(w),
2391 Self::CraftRecipeRequest(ref p) => p.encode(w),
2392 Self::Abilities(ref p) => p.encode(w),
2393 Self::BlockDig(ref p) => p.encode(w),
2394 Self::EntityAction(ref p) => p.encode(w),
2395 Self::SteerVehicle(ref p) => p.encode(w),
2396 Self::CraftingBookData(ref p) => p.encode(w),
2397 Self::ResourcePackReceive(ref p) => p.encode(w),
2398 Self::AdvancementTab(ref p) => p.encode(w),
2399 Self::HeldItemSlot(ref p) => p.encode(w),
2400 Self::SetCreativeSlot(ref p) => p.encode(w),
2401 Self::UpdateSign(ref p) => p.encode(w),
2402 Self::ArmAnimation(ref p) => p.encode(w),
2403 Self::Spectate(ref p) => p.encode(w),
2404 Self::BlockPlace(ref p) => p.encode(w),
2405 Self::UseItem(ref p) => p.encode(w),
2406 }
2407 }
2408 fn name_of(id: i32) -> Option<&'static str> {
2409 match id {
2410 id::TELEPORT_CONFIRM => Some("teleport_confirm"),
2411 id::TAB_COMPLETE => Some("tab_complete"),
2412 id::CHAT => Some("chat"),
2413 id::CLIENT_COMMAND => Some("client_command"),
2414 id::SETTINGS => Some("settings"),
2415 id::TRANSACTION => Some("transaction"),
2416 id::ENCHANT_ITEM => Some("enchant_item"),
2417 id::WINDOW_CLICK => Some("window_click"),
2418 id::CLOSE_WINDOW => Some("close_window"),
2419 id::CUSTOM_PAYLOAD => Some("custom_payload"),
2420 id::USE_ENTITY => Some("use_entity"),
2421 id::KEEP_ALIVE => Some("keep_alive"),
2422 id::FLYING => Some("flying"),
2423 id::POSITION => Some("position"),
2424 id::POSITION_LOOK => Some("position_look"),
2425 id::LOOK => Some("look"),
2426 id::VEHICLE_MOVE => Some("vehicle_move"),
2427 id::STEER_BOAT => Some("steer_boat"),
2428 id::CRAFT_RECIPE_REQUEST => Some("craft_recipe_request"),
2429 id::ABILITIES => Some("abilities"),
2430 id::BLOCK_DIG => Some("block_dig"),
2431 id::ENTITY_ACTION => Some("entity_action"),
2432 id::STEER_VEHICLE => Some("steer_vehicle"),
2433 id::CRAFTING_BOOK_DATA => Some("crafting_book_data"),
2434 id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
2435 id::ADVANCEMENT_TAB => Some("advancement_tab"),
2436 id::HELD_ITEM_SLOT => Some("held_item_slot"),
2437 id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
2438 id::UPDATE_SIGN => Some("update_sign"),
2439 id::ARM_ANIMATION => Some("arm_animation"),
2440 id::SPECTATE => Some("spectate"),
2441 id::BLOCK_PLACE => Some("block_place"),
2442 id::USE_ITEM => Some("use_item"),
2443 _ => None,
2444 }
2445 }
2446}
2447
2448impl ServerboundPlayPacket {
2449 pub const IDS: &'static [i32] = &[
2451 id::TELEPORT_CONFIRM,
2452 id::TAB_COMPLETE,
2453 id::CHAT,
2454 id::CLIENT_COMMAND,
2455 id::SETTINGS,
2456 id::TRANSACTION,
2457 id::ENCHANT_ITEM,
2458 id::WINDOW_CLICK,
2459 id::CLOSE_WINDOW,
2460 id::CUSTOM_PAYLOAD,
2461 id::USE_ENTITY,
2462 id::KEEP_ALIVE,
2463 id::FLYING,
2464 id::POSITION,
2465 id::POSITION_LOOK,
2466 id::LOOK,
2467 id::VEHICLE_MOVE,
2468 id::STEER_BOAT,
2469 id::CRAFT_RECIPE_REQUEST,
2470 id::ABILITIES,
2471 id::BLOCK_DIG,
2472 id::ENTITY_ACTION,
2473 id::STEER_VEHICLE,
2474 id::CRAFTING_BOOK_DATA,
2475 id::RESOURCE_PACK_RECEIVE,
2476 id::ADVANCEMENT_TAB,
2477 id::HELD_ITEM_SLOT,
2478 id::SET_CREATIVE_SLOT,
2479 id::UPDATE_SIGN,
2480 id::ARM_ANIMATION,
2481 id::SPECTATE,
2482 id::BLOCK_PLACE,
2483 id::USE_ITEM,
2484 ];
2485 #[cfg(feature = "testgen")]
2487 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
2488 match id {
2489 id::TELEPORT_CONFIRM => Some(Self::TeleportConfirm(
2490 <TeleportConfirm as Generate>::generate(g),
2491 )),
2492 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
2493 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
2494 id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
2495 g,
2496 ))),
2497 id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
2498 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
2499 id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
2500 id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
2501 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
2502 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
2503 g,
2504 ))),
2505 id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
2506 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
2507 id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
2508 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
2509 id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
2510 id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
2511 id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
2512 id::STEER_BOAT => Some(Self::SteerBoat(<SteerBoat as Generate>::generate(g))),
2513 id::CRAFT_RECIPE_REQUEST => Some(Self::CraftRecipeRequest(
2514 <CraftRecipeRequest as Generate>::generate(g),
2515 )),
2516 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
2517 id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
2518 id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
2519 id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
2520 id::CRAFTING_BOOK_DATA => Some(Self::CraftingBookData(
2521 <CraftingBookData as Generate>::generate(g),
2522 )),
2523 id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
2524 <ResourcePackReceive as Generate>::generate(g),
2525 )),
2526 id::ADVANCEMENT_TAB => Some(Self::AdvancementTab(
2527 <AdvancementTab as Generate>::generate(g),
2528 )),
2529 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
2530 id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
2531 <SetCreativeSlot as Generate>::generate(g),
2532 )),
2533 id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
2534 id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
2535 id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
2536 id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
2537 id::USE_ITEM => Some(Self::UseItem(<UseItem as Generate>::generate(g))),
2538 _ => None,
2539 }
2540 }
2541}