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_8::types;
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
30pub struct EntityActionActionId(pub i32);
31impl EntityActionActionId {
32 pub const START_SNEAKING: Self = Self(0);
34 pub const STOP_SNEAKING: Self = Self(1);
36 pub const STOP_SLEEPING: Self = Self(2);
38 pub const START_SPRINTING: Self = Self(3);
40 pub const STOP_SPRINTING: Self = Self(4);
42 pub const START_RIDING_JUMP: Self = Self(5);
44 pub const OPEN_INVENTORY: Self = Self(6);
46 pub const fn name(self) -> Option<&'static str> {
48 match self.0 {
49 0 => Some("start_sneaking"),
50 1 => Some("stop_sneaking"),
51 2 => Some("stop_sleeping"),
52 3 => Some("start_sprinting"),
53 4 => Some("stop_sprinting"),
54 5 => Some("start_riding_jump"),
55 6 => Some("open_inventory"),
56 _ => None,
57 }
58 }
59}
60impl std::fmt::Debug for EntityActionActionId {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 match self.name() {
63 Some(n) => write!(f, "EntityActionActionId::{n}"),
64 None => write!(f, "EntityActionActionId({})", self.0),
65 }
66 }
67}
68
69#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
71pub struct ClientCommandPayload(pub i32);
72impl ClientCommandPayload {
73 pub const PERFORM_RESPAWN: Self = Self(0);
75 pub const REQUEST_STATS: Self = Self(1);
77 pub const OPEN_INVENTORY_ACHIEVEMENT: Self = Self(2);
79 pub const fn name(self) -> Option<&'static str> {
81 match self.0 {
82 0 => Some("perform_respawn"),
83 1 => Some("request_stats"),
84 2 => Some("open_inventory_achievement"),
85 _ => None,
86 }
87 }
88}
89impl std::fmt::Debug for ClientCommandPayload {
90 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
91 match self.name() {
92 Some(n) => write!(f, "ClientCommandPayload::{n}"),
93 None => write!(f, "ClientCommandPayload({})", self.0),
94 }
95 }
96}
97
98pub mod id {
100 pub const KEEP_ALIVE: i32 = 0x00;
102 pub const CHAT: i32 = 0x01;
104 pub const USE_ENTITY: i32 = 0x02;
106 pub const FLYING: i32 = 0x03;
108 pub const POSITION: i32 = 0x04;
110 pub const LOOK: i32 = 0x05;
112 pub const POSITION_LOOK: i32 = 0x06;
114 pub const BLOCK_DIG: i32 = 0x07;
116 pub const BLOCK_PLACE: i32 = 0x08;
118 pub const HELD_ITEM_SLOT: i32 = 0x09;
120 pub const ARM_ANIMATION: i32 = 0x0a;
122 pub const ENTITY_ACTION: i32 = 0x0b;
124 pub const STEER_VEHICLE: i32 = 0x0c;
126 pub const CLOSE_WINDOW: i32 = 0x0d;
128 pub const WINDOW_CLICK: i32 = 0x0e;
130 pub const TRANSACTION: i32 = 0x0f;
132 pub const SET_CREATIVE_SLOT: i32 = 0x10;
134 pub const ENCHANT_ITEM: i32 = 0x11;
136 pub const UPDATE_SIGN: i32 = 0x12;
138 pub const ABILITIES: i32 = 0x13;
140 pub const TAB_COMPLETE: i32 = 0x14;
142 pub const SETTINGS: i32 = 0x15;
144 pub const CLIENT_COMMAND: i32 = 0x16;
146 pub const CUSTOM_PAYLOAD: i32 = 0x17;
148 pub const SPECTATE: i32 = 0x18;
150 pub const RESOURCE_PACK_RECEIVE: i32 = 0x19;
152}
153
154#[derive(Debug, Clone, PartialEq)]
156pub struct KeepAlive {
157 pub keep_alive_id: i32,
159}
160impl crate::packet::Packet for KeepAlive {
161 const ID: i32 = id::KEEP_ALIVE;
162 const NAME: &'static str = "keep_alive";
163 const STATE: State = State::Play;
164 const DIRECTION: Direction = Direction::Serverbound;
165}
166impl Decode for KeepAlive {
167 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
168 Ok({
169 let v887 = r.read_varint()?;
170 KeepAlive {
171 keep_alive_id: v887,
172 }
173 })
174 }
175}
176impl Encode for KeepAlive {
177 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
178 w.put_varint((*self).keep_alive_id);
179 Ok(())
180 }
181}
182#[cfg(feature = "testgen")]
183impl Generate for KeepAlive {
184 fn generate(g: &mut Gen) -> Self {
185 {
186 let v888 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
187 KeepAlive {
188 keep_alive_id: v888,
189 }
190 }
191 }
192}
193impl From<KeepAlive> for ServerboundPlayPacket {
194 fn from(p: KeepAlive) -> Self {
195 Self::KeepAlive(p)
196 }
197}
198
199#[derive(Debug, Clone, PartialEq)]
201pub struct Chat {
202 pub message: ByteString,
204}
205impl crate::packet::Packet for Chat {
206 const ID: i32 = id::CHAT;
207 const NAME: &'static str = "chat";
208 const STATE: State = State::Play;
209 const DIRECTION: Direction = Direction::Serverbound;
210}
211impl Decode for Chat {
212 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
213 Ok({
214 let v889 = r.read_string()?;
215 Chat { message: v889 }
216 })
217 }
218}
219impl Encode for Chat {
220 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
221 w.put_string(&(*self).message)?;
222 Ok(())
223 }
224}
225#[cfg(feature = "testgen")]
226impl Generate for Chat {
227 fn generate(g: &mut Gen) -> Self {
228 {
229 let v890 = g.string();
230 Chat { message: v890 }
231 }
232 }
233}
234impl From<Chat> for ServerboundPlayPacket {
235 fn from(p: Chat) -> Self {
236 Self::Chat(p)
237 }
238}
239
240#[derive(Debug, Clone, PartialEq)]
242pub struct UseEntity {
243 pub target: i32,
245 pub mouse: i32,
247 pub x: Option<f32>,
249 pub y: Option<f32>,
251 pub z: Option<f32>,
253}
254impl crate::packet::Packet for UseEntity {
255 const ID: i32 = id::USE_ENTITY;
256 const NAME: &'static str = "use_entity";
257 const STATE: State = State::Play;
258 const DIRECTION: Direction = Direction::Serverbound;
259}
260impl Decode for UseEntity {
261 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
262 Ok({
263 let v891 = r.read_varint()?;
264 let v892 = r.read_varint()?;
265 let v893 = if (v892 == 2) {
266 Some(r.read_f32()?)
267 } else {
268 None
269 };
270 let v894 = if (v892 == 2) {
271 Some(r.read_f32()?)
272 } else {
273 None
274 };
275 let v895 = if (v892 == 2) {
276 Some(r.read_f32()?)
277 } else {
278 None
279 };
280 UseEntity {
281 target: v891,
282 mouse: v892,
283 x: v893,
284 y: v894,
285 z: v895,
286 }
287 })
288 }
289}
290impl Encode for UseEntity {
291 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
292 w.put_varint((*self).target);
293 w.put_varint((*self).mouse);
294 match (&(*self).x, ((*self).mouse == 2)) {
295 (Some(v896), true) => {
296 w.put_f32((*v896));
297 }
298 (None, false) => {}
299 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
300 }
301 match (&(*self).y, ((*self).mouse == 2)) {
302 (Some(v897), true) => {
303 w.put_f32((*v897));
304 }
305 (None, false) => {}
306 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
307 }
308 match (&(*self).z, ((*self).mouse == 2)) {
309 (Some(v898), true) => {
310 w.put_f32((*v898));
311 }
312 (None, false) => {}
313 _ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
314 }
315 Ok(())
316 }
317}
318#[cfg(feature = "testgen")]
319impl Generate for UseEntity {
320 fn generate(g: &mut Gen) -> Self {
321 {
322 let v899 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
323 let v900 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2]) as i32);
324 let v901 = if (v900 == 2) { Some(g.f32()) } else { None };
325 let v902 = if (v900 == 2) { Some(g.f32()) } else { None };
326 let v903 = if (v900 == 2) { Some(g.f32()) } else { None };
327 UseEntity {
328 target: v899,
329 mouse: v900,
330 x: v901,
331 y: v902,
332 z: v903,
333 }
334 }
335 }
336}
337impl From<UseEntity> for ServerboundPlayPacket {
338 fn from(p: UseEntity) -> Self {
339 Self::UseEntity(p)
340 }
341}
342
343#[derive(Debug, Clone, PartialEq)]
345pub struct Flying {
346 pub on_ground: bool,
348}
349impl crate::packet::Packet for Flying {
350 const ID: i32 = id::FLYING;
351 const NAME: &'static str = "flying";
352 const STATE: State = State::Play;
353 const DIRECTION: Direction = Direction::Serverbound;
354}
355impl Decode for Flying {
356 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
357 Ok({
358 let v904 = r.read_bool()?;
359 Flying { on_ground: v904 }
360 })
361 }
362}
363impl Encode for Flying {
364 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
365 w.put_bool((*self).on_ground);
366 Ok(())
367 }
368}
369#[cfg(feature = "testgen")]
370impl Generate for Flying {
371 fn generate(g: &mut Gen) -> Self {
372 {
373 let v905 = g.bool();
374 Flying { on_ground: v905 }
375 }
376 }
377}
378impl From<Flying> for ServerboundPlayPacket {
379 fn from(p: Flying) -> Self {
380 Self::Flying(p)
381 }
382}
383
384#[derive(Debug, Clone, PartialEq)]
386pub struct Position {
387 pub x: f64,
389 pub y: f64,
391 pub z: f64,
393 pub on_ground: bool,
395}
396impl crate::packet::Packet for Position {
397 const ID: i32 = id::POSITION;
398 const NAME: &'static str = "position";
399 const STATE: State = State::Play;
400 const DIRECTION: Direction = Direction::Serverbound;
401}
402impl Decode for Position {
403 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
404 Ok({
405 let v906 = r.read_f64()?;
406 let v907 = r.read_f64()?;
407 let v908 = r.read_f64()?;
408 let v909 = r.read_bool()?;
409 Position {
410 x: v906,
411 y: v907,
412 z: v908,
413 on_ground: v909,
414 }
415 })
416 }
417}
418impl Encode for Position {
419 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
420 w.put_f64((*self).x);
421 w.put_f64((*self).y);
422 w.put_f64((*self).z);
423 w.put_bool((*self).on_ground);
424 Ok(())
425 }
426}
427#[cfg(feature = "testgen")]
428impl Generate for Position {
429 fn generate(g: &mut Gen) -> Self {
430 {
431 let v910 = g.f64();
432 let v911 = g.f64();
433 let v912 = g.f64();
434 let v913 = g.bool();
435 Position {
436 x: v910,
437 y: v911,
438 z: v912,
439 on_ground: v913,
440 }
441 }
442 }
443}
444impl From<Position> for ServerboundPlayPacket {
445 fn from(p: Position) -> Self {
446 Self::Position(p)
447 }
448}
449
450#[derive(Debug, Clone, PartialEq)]
452pub struct Look {
453 pub yaw: f32,
455 pub pitch: f32,
457 pub on_ground: bool,
459}
460impl crate::packet::Packet for Look {
461 const ID: i32 = id::LOOK;
462 const NAME: &'static str = "look";
463 const STATE: State = State::Play;
464 const DIRECTION: Direction = Direction::Serverbound;
465}
466impl Decode for Look {
467 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
468 Ok({
469 let v914 = r.read_f32()?;
470 let v915 = r.read_f32()?;
471 let v916 = r.read_bool()?;
472 Look {
473 yaw: v914,
474 pitch: v915,
475 on_ground: v916,
476 }
477 })
478 }
479}
480impl Encode for Look {
481 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
482 w.put_f32((*self).yaw);
483 w.put_f32((*self).pitch);
484 w.put_bool((*self).on_ground);
485 Ok(())
486 }
487}
488#[cfg(feature = "testgen")]
489impl Generate for Look {
490 fn generate(g: &mut Gen) -> Self {
491 {
492 let v917 = g.f32();
493 let v918 = g.f32();
494 let v919 = g.bool();
495 Look {
496 yaw: v917,
497 pitch: v918,
498 on_ground: v919,
499 }
500 }
501 }
502}
503impl From<Look> for ServerboundPlayPacket {
504 fn from(p: Look) -> Self {
505 Self::Look(p)
506 }
507}
508
509#[derive(Debug, Clone, PartialEq)]
511pub struct PositionLook {
512 pub x: f64,
514 pub y: f64,
516 pub z: f64,
518 pub yaw: f32,
520 pub pitch: f32,
522 pub on_ground: bool,
524}
525impl crate::packet::Packet for PositionLook {
526 const ID: i32 = id::POSITION_LOOK;
527 const NAME: &'static str = "position_look";
528 const STATE: State = State::Play;
529 const DIRECTION: Direction = Direction::Serverbound;
530}
531impl Decode for PositionLook {
532 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
533 Ok({
534 let v920 = r.read_f64()?;
535 let v921 = r.read_f64()?;
536 let v922 = r.read_f64()?;
537 let v923 = r.read_f32()?;
538 let v924 = r.read_f32()?;
539 let v925 = r.read_bool()?;
540 PositionLook {
541 x: v920,
542 y: v921,
543 z: v922,
544 yaw: v923,
545 pitch: v924,
546 on_ground: v925,
547 }
548 })
549 }
550}
551impl Encode for PositionLook {
552 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
553 w.put_f64((*self).x);
554 w.put_f64((*self).y);
555 w.put_f64((*self).z);
556 w.put_f32((*self).yaw);
557 w.put_f32((*self).pitch);
558 w.put_bool((*self).on_ground);
559 Ok(())
560 }
561}
562#[cfg(feature = "testgen")]
563impl Generate for PositionLook {
564 fn generate(g: &mut Gen) -> Self {
565 {
566 let v926 = g.f64();
567 let v927 = g.f64();
568 let v928 = g.f64();
569 let v929 = g.f32();
570 let v930 = g.f32();
571 let v931 = g.bool();
572 PositionLook {
573 x: v926,
574 y: v927,
575 z: v928,
576 yaw: v929,
577 pitch: v930,
578 on_ground: v931,
579 }
580 }
581 }
582}
583impl From<PositionLook> for ServerboundPlayPacket {
584 fn from(p: PositionLook) -> Self {
585 Self::PositionLook(p)
586 }
587}
588
589#[derive(Debug, Clone, PartialEq)]
591pub struct BlockDig {
592 pub status: i32,
594 pub location: BlockPos,
596 pub face: i8,
598}
599impl crate::packet::Packet for BlockDig {
600 const ID: i32 = id::BLOCK_DIG;
601 const NAME: &'static str = "block_dig";
602 const STATE: State = State::Play;
603 const DIRECTION: Direction = Direction::Serverbound;
604}
605impl Decode for BlockDig {
606 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
607 Ok({
608 let v932 = r.read_varint()?;
609 let v933 = BlockPos::read(r, PositionLayout::Xyz)?;
610 let v934 = r.read_i8()?;
611 BlockDig {
612 status: v932,
613 location: v933,
614 face: v934,
615 }
616 })
617 }
618}
619impl Encode for BlockDig {
620 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
621 w.put_varint((*self).status);
622 (*self).location.write(w, PositionLayout::Xyz)?;
623 w.put_i8((*self).face);
624 Ok(())
625 }
626}
627#[cfg(feature = "testgen")]
628impl Generate for BlockDig {
629 fn generate(g: &mut Gen) -> Self {
630 {
631 let v935 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
632 let v936 = g.position();
633 let v937 = (g.int_in(-128, 127, &[]) as i8);
634 BlockDig {
635 status: v935,
636 location: v936,
637 face: v937,
638 }
639 }
640 }
641}
642impl From<BlockDig> for ServerboundPlayPacket {
643 fn from(p: BlockDig) -> Self {
644 Self::BlockDig(p)
645 }
646}
647
648#[derive(Debug, Clone, PartialEq)]
650pub struct BlockPlace {
651 pub location: BlockPos,
653 pub direction: i8,
655 pub held_item: types::Slot,
657 pub cursor_x: i8,
659 pub cursor_y: i8,
661 pub cursor_z: i8,
663}
664impl crate::packet::Packet for BlockPlace {
665 const ID: i32 = id::BLOCK_PLACE;
666 const NAME: &'static str = "block_place";
667 const STATE: State = State::Play;
668 const DIRECTION: Direction = Direction::Serverbound;
669}
670impl Decode for BlockPlace {
671 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
672 Ok({
673 let v938 = BlockPos::read(r, PositionLayout::Xyz)?;
674 let v939 = r.read_i8()?;
675 let v940 = <types::Slot as Decode>::decode(r)?;
676 let v941 = r.read_i8()?;
677 let v942 = r.read_i8()?;
678 let v943 = r.read_i8()?;
679 BlockPlace {
680 location: v938,
681 direction: v939,
682 held_item: v940,
683 cursor_x: v941,
684 cursor_y: v942,
685 cursor_z: v943,
686 }
687 })
688 }
689}
690impl Encode for BlockPlace {
691 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
692 (*self).location.write(w, PositionLayout::Xyz)?;
693 w.put_i8((*self).direction);
694 (*self).held_item.encode(w)?;
695 w.put_i8((*self).cursor_x);
696 w.put_i8((*self).cursor_y);
697 w.put_i8((*self).cursor_z);
698 Ok(())
699 }
700}
701#[cfg(feature = "testgen")]
702impl Generate for BlockPlace {
703 fn generate(g: &mut Gen) -> Self {
704 {
705 let v944 = g.position();
706 let v945 = (g.int_in(-128, 127, &[]) as i8);
707 let v946 = <types::Slot as Generate>::generate(g);
708 let v947 = (g.int_in(-128, 127, &[]) as i8);
709 let v948 = (g.int_in(-128, 127, &[]) as i8);
710 let v949 = (g.int_in(-128, 127, &[]) as i8);
711 BlockPlace {
712 location: v944,
713 direction: v945,
714 held_item: v946,
715 cursor_x: v947,
716 cursor_y: v948,
717 cursor_z: v949,
718 }
719 }
720 }
721}
722impl From<BlockPlace> for ServerboundPlayPacket {
723 fn from(p: BlockPlace) -> Self {
724 Self::BlockPlace(p)
725 }
726}
727
728#[derive(Debug, Clone, PartialEq)]
730pub struct HeldItemSlot {
731 pub slot_id: i16,
733}
734impl crate::packet::Packet for HeldItemSlot {
735 const ID: i32 = id::HELD_ITEM_SLOT;
736 const NAME: &'static str = "held_item_slot";
737 const STATE: State = State::Play;
738 const DIRECTION: Direction = Direction::Serverbound;
739}
740impl Decode for HeldItemSlot {
741 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
742 Ok({
743 let v950 = r.read_i16()?;
744 HeldItemSlot { slot_id: v950 }
745 })
746 }
747}
748impl Encode for HeldItemSlot {
749 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
750 w.put_i16((*self).slot_id);
751 Ok(())
752 }
753}
754#[cfg(feature = "testgen")]
755impl Generate for HeldItemSlot {
756 fn generate(g: &mut Gen) -> Self {
757 {
758 let v951 = (g.int_in(-32768, 32767, &[]) as i16);
759 HeldItemSlot { slot_id: v951 }
760 }
761 }
762}
763impl From<HeldItemSlot> for ServerboundPlayPacket {
764 fn from(p: HeldItemSlot) -> Self {
765 Self::HeldItemSlot(p)
766 }
767}
768
769#[derive(Debug, Clone, PartialEq)]
771pub struct ArmAnimation {}
772impl crate::packet::Packet for ArmAnimation {
773 const ID: i32 = id::ARM_ANIMATION;
774 const NAME: &'static str = "arm_animation";
775 const STATE: State = State::Play;
776 const DIRECTION: Direction = Direction::Serverbound;
777}
778impl Decode for ArmAnimation {
779 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
780 Ok({ ArmAnimation {} })
781 }
782}
783impl Encode for ArmAnimation {
784 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
785 Ok(())
786 }
787}
788#[cfg(feature = "testgen")]
789impl Generate for ArmAnimation {
790 fn generate(g: &mut Gen) -> Self {
791 { ArmAnimation {} }
792 }
793}
794impl From<ArmAnimation> for ServerboundPlayPacket {
795 fn from(p: ArmAnimation) -> Self {
796 Self::ArmAnimation(p)
797 }
798}
799
800#[derive(Debug, Clone, PartialEq)]
802pub struct EntityAction {
803 pub entity_id: i32,
805 pub action_id: EntityActionActionId,
807 pub jump_boost: i32,
809}
810impl crate::packet::Packet for EntityAction {
811 const ID: i32 = id::ENTITY_ACTION;
812 const NAME: &'static str = "entity_action";
813 const STATE: State = State::Play;
814 const DIRECTION: Direction = Direction::Serverbound;
815}
816impl Decode for EntityAction {
817 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
818 Ok({
819 let v952 = r.read_varint()?;
820 let v953 = EntityActionActionId(r.read_varint()?);
821 let v954 = r.read_varint()?;
822 EntityAction {
823 entity_id: v952,
824 action_id: v953,
825 jump_boost: v954,
826 }
827 })
828 }
829}
830impl Encode for EntityAction {
831 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
832 w.put_varint((*self).entity_id);
833 w.put_varint((*self).action_id.0);
834 w.put_varint((*self).jump_boost);
835 Ok(())
836 }
837}
838#[cfg(feature = "testgen")]
839impl Generate for EntityAction {
840 fn generate(g: &mut Gen) -> Self {
841 {
842 let v955 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
843 let v956 =
844 EntityActionActionId(
845 g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6]) as i32
846 );
847 let v957 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
848 EntityAction {
849 entity_id: v955,
850 action_id: v956,
851 jump_boost: v957,
852 }
853 }
854 }
855}
856impl From<EntityAction> for ServerboundPlayPacket {
857 fn from(p: EntityAction) -> Self {
858 Self::EntityAction(p)
859 }
860}
861
862#[derive(Debug, Clone, PartialEq)]
864pub struct SteerVehicle {
865 pub sideways: f32,
867 pub forward: f32,
869 pub jump: u8,
871}
872impl crate::packet::Packet for SteerVehicle {
873 const ID: i32 = id::STEER_VEHICLE;
874 const NAME: &'static str = "steer_vehicle";
875 const STATE: State = State::Play;
876 const DIRECTION: Direction = Direction::Serverbound;
877}
878impl Decode for SteerVehicle {
879 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
880 Ok({
881 let v958 = r.read_f32()?;
882 let v959 = r.read_f32()?;
883 let v960 = r.read_u8()?;
884 SteerVehicle {
885 sideways: v958,
886 forward: v959,
887 jump: v960,
888 }
889 })
890 }
891}
892impl Encode for SteerVehicle {
893 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
894 w.put_f32((*self).sideways);
895 w.put_f32((*self).forward);
896 w.put_u8((*self).jump);
897 Ok(())
898 }
899}
900#[cfg(feature = "testgen")]
901impl Generate for SteerVehicle {
902 fn generate(g: &mut Gen) -> Self {
903 {
904 let v961 = g.f32();
905 let v962 = g.f32();
906 let v963 = (g.int_in(0, 255, &[]) as u8);
907 SteerVehicle {
908 sideways: v961,
909 forward: v962,
910 jump: v963,
911 }
912 }
913 }
914}
915impl From<SteerVehicle> for ServerboundPlayPacket {
916 fn from(p: SteerVehicle) -> Self {
917 Self::SteerVehicle(p)
918 }
919}
920
921#[derive(Debug, Clone, PartialEq)]
923pub struct CloseWindow {
924 pub window_id: u8,
926}
927impl crate::packet::Packet for CloseWindow {
928 const ID: i32 = id::CLOSE_WINDOW;
929 const NAME: &'static str = "close_window";
930 const STATE: State = State::Play;
931 const DIRECTION: Direction = Direction::Serverbound;
932}
933impl Decode for CloseWindow {
934 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
935 Ok({
936 let v964 = r.read_u8()?;
937 CloseWindow { window_id: v964 }
938 })
939 }
940}
941impl Encode for CloseWindow {
942 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
943 w.put_u8((*self).window_id);
944 Ok(())
945 }
946}
947#[cfg(feature = "testgen")]
948impl Generate for CloseWindow {
949 fn generate(g: &mut Gen) -> Self {
950 {
951 let v965 = (g.int_in(0, 255, &[]) as u8);
952 CloseWindow { window_id: v965 }
953 }
954 }
955}
956impl From<CloseWindow> for ServerboundPlayPacket {
957 fn from(p: CloseWindow) -> Self {
958 Self::CloseWindow(p)
959 }
960}
961
962#[derive(Debug, Clone, PartialEq)]
964pub struct WindowClick {
965 pub window_id: u8,
967 pub slot: i16,
969 pub mouse_button: i8,
971 pub action: i16,
973 pub mode: i8,
975 pub item: types::Slot,
977}
978impl crate::packet::Packet for WindowClick {
979 const ID: i32 = id::WINDOW_CLICK;
980 const NAME: &'static str = "window_click";
981 const STATE: State = State::Play;
982 const DIRECTION: Direction = Direction::Serverbound;
983}
984impl Decode for WindowClick {
985 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
986 Ok({
987 let v966 = r.read_u8()?;
988 let v967 = r.read_i16()?;
989 let v968 = r.read_i8()?;
990 let v969 = r.read_i16()?;
991 let v970 = r.read_i8()?;
992 let v971 = <types::Slot as Decode>::decode(r)?;
993 WindowClick {
994 window_id: v966,
995 slot: v967,
996 mouse_button: v968,
997 action: v969,
998 mode: v970,
999 item: v971,
1000 }
1001 })
1002 }
1003}
1004impl Encode for WindowClick {
1005 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1006 w.put_u8((*self).window_id);
1007 w.put_i16((*self).slot);
1008 w.put_i8((*self).mouse_button);
1009 w.put_i16((*self).action);
1010 w.put_i8((*self).mode);
1011 (*self).item.encode(w)?;
1012 Ok(())
1013 }
1014}
1015#[cfg(feature = "testgen")]
1016impl Generate for WindowClick {
1017 fn generate(g: &mut Gen) -> Self {
1018 {
1019 let v972 = (g.int_in(0, 255, &[]) as u8);
1020 let v973 = (g.int_in(-32768, 32767, &[]) as i16);
1021 let v974 = (g.int_in(-128, 127, &[]) as i8);
1022 let v975 = (g.int_in(-32768, 32767, &[]) as i16);
1023 let v976 = (g.int_in(-128, 127, &[]) as i8);
1024 let v977 = <types::Slot as Generate>::generate(g);
1025 WindowClick {
1026 window_id: v972,
1027 slot: v973,
1028 mouse_button: v974,
1029 action: v975,
1030 mode: v976,
1031 item: v977,
1032 }
1033 }
1034 }
1035}
1036impl From<WindowClick> for ServerboundPlayPacket {
1037 fn from(p: WindowClick) -> Self {
1038 Self::WindowClick(p)
1039 }
1040}
1041
1042#[derive(Debug, Clone, PartialEq)]
1044pub struct Transaction {
1045 pub window_id: i8,
1047 pub action: i16,
1049 pub accepted: bool,
1051}
1052impl crate::packet::Packet for Transaction {
1053 const ID: i32 = id::TRANSACTION;
1054 const NAME: &'static str = "transaction";
1055 const STATE: State = State::Play;
1056 const DIRECTION: Direction = Direction::Serverbound;
1057}
1058impl Decode for Transaction {
1059 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1060 Ok({
1061 let v978 = r.read_i8()?;
1062 let v979 = r.read_i16()?;
1063 let v980 = r.read_bool()?;
1064 Transaction {
1065 window_id: v978,
1066 action: v979,
1067 accepted: v980,
1068 }
1069 })
1070 }
1071}
1072impl Encode for Transaction {
1073 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1074 w.put_i8((*self).window_id);
1075 w.put_i16((*self).action);
1076 w.put_bool((*self).accepted);
1077 Ok(())
1078 }
1079}
1080#[cfg(feature = "testgen")]
1081impl Generate for Transaction {
1082 fn generate(g: &mut Gen) -> Self {
1083 {
1084 let v981 = (g.int_in(-128, 127, &[]) as i8);
1085 let v982 = (g.int_in(-32768, 32767, &[]) as i16);
1086 let v983 = g.bool();
1087 Transaction {
1088 window_id: v981,
1089 action: v982,
1090 accepted: v983,
1091 }
1092 }
1093 }
1094}
1095impl From<Transaction> for ServerboundPlayPacket {
1096 fn from(p: Transaction) -> Self {
1097 Self::Transaction(p)
1098 }
1099}
1100
1101#[derive(Debug, Clone, PartialEq)]
1103pub struct SetCreativeSlot {
1104 pub slot: i16,
1106 pub item: types::Slot,
1108}
1109impl crate::packet::Packet for SetCreativeSlot {
1110 const ID: i32 = id::SET_CREATIVE_SLOT;
1111 const NAME: &'static str = "set_creative_slot";
1112 const STATE: State = State::Play;
1113 const DIRECTION: Direction = Direction::Serverbound;
1114}
1115impl Decode for SetCreativeSlot {
1116 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1117 Ok({
1118 let v984 = r.read_i16()?;
1119 let v985 = <types::Slot as Decode>::decode(r)?;
1120 SetCreativeSlot {
1121 slot: v984,
1122 item: v985,
1123 }
1124 })
1125 }
1126}
1127impl Encode for SetCreativeSlot {
1128 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1129 w.put_i16((*self).slot);
1130 (*self).item.encode(w)?;
1131 Ok(())
1132 }
1133}
1134#[cfg(feature = "testgen")]
1135impl Generate for SetCreativeSlot {
1136 fn generate(g: &mut Gen) -> Self {
1137 {
1138 let v986 = (g.int_in(-32768, 32767, &[]) as i16);
1139 let v987 = <types::Slot as Generate>::generate(g);
1140 SetCreativeSlot {
1141 slot: v986,
1142 item: v987,
1143 }
1144 }
1145 }
1146}
1147impl From<SetCreativeSlot> for ServerboundPlayPacket {
1148 fn from(p: SetCreativeSlot) -> Self {
1149 Self::SetCreativeSlot(p)
1150 }
1151}
1152
1153#[derive(Debug, Clone, PartialEq)]
1155pub struct EnchantItem {
1156 pub window_id: i8,
1158 pub enchantment: i8,
1160}
1161impl crate::packet::Packet for EnchantItem {
1162 const ID: i32 = id::ENCHANT_ITEM;
1163 const NAME: &'static str = "enchant_item";
1164 const STATE: State = State::Play;
1165 const DIRECTION: Direction = Direction::Serverbound;
1166}
1167impl Decode for EnchantItem {
1168 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1169 Ok({
1170 let v988 = r.read_i8()?;
1171 let v989 = r.read_i8()?;
1172 EnchantItem {
1173 window_id: v988,
1174 enchantment: v989,
1175 }
1176 })
1177 }
1178}
1179impl Encode for EnchantItem {
1180 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1181 w.put_i8((*self).window_id);
1182 w.put_i8((*self).enchantment);
1183 Ok(())
1184 }
1185}
1186#[cfg(feature = "testgen")]
1187impl Generate for EnchantItem {
1188 fn generate(g: &mut Gen) -> Self {
1189 {
1190 let v990 = (g.int_in(-128, 127, &[]) as i8);
1191 let v991 = (g.int_in(-128, 127, &[]) as i8);
1192 EnchantItem {
1193 window_id: v990,
1194 enchantment: v991,
1195 }
1196 }
1197 }
1198}
1199impl From<EnchantItem> for ServerboundPlayPacket {
1200 fn from(p: EnchantItem) -> Self {
1201 Self::EnchantItem(p)
1202 }
1203}
1204
1205#[derive(Debug, Clone, PartialEq)]
1207pub struct UpdateSign {
1208 pub location: BlockPos,
1210 pub text1: ByteString,
1212 pub text2: ByteString,
1214 pub text3: ByteString,
1216 pub text4: ByteString,
1218}
1219impl crate::packet::Packet for UpdateSign {
1220 const ID: i32 = id::UPDATE_SIGN;
1221 const NAME: &'static str = "update_sign";
1222 const STATE: State = State::Play;
1223 const DIRECTION: Direction = Direction::Serverbound;
1224}
1225impl Decode for UpdateSign {
1226 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1227 Ok({
1228 let v992 = BlockPos::read(r, PositionLayout::Xyz)?;
1229 let v993 = r.read_string()?;
1230 let v994 = r.read_string()?;
1231 let v995 = r.read_string()?;
1232 let v996 = r.read_string()?;
1233 UpdateSign {
1234 location: v992,
1235 text1: v993,
1236 text2: v994,
1237 text3: v995,
1238 text4: v996,
1239 }
1240 })
1241 }
1242}
1243impl Encode for UpdateSign {
1244 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1245 (*self).location.write(w, PositionLayout::Xyz)?;
1246 w.put_string(&(*self).text1)?;
1247 w.put_string(&(*self).text2)?;
1248 w.put_string(&(*self).text3)?;
1249 w.put_string(&(*self).text4)?;
1250 Ok(())
1251 }
1252}
1253#[cfg(feature = "testgen")]
1254impl Generate for UpdateSign {
1255 fn generate(g: &mut Gen) -> Self {
1256 {
1257 let v997 = g.position();
1258 let v998 = g.string();
1259 let v999 = g.string();
1260 let v1000 = g.string();
1261 let v1001 = g.string();
1262 UpdateSign {
1263 location: v997,
1264 text1: v998,
1265 text2: v999,
1266 text3: v1000,
1267 text4: v1001,
1268 }
1269 }
1270 }
1271}
1272impl From<UpdateSign> for ServerboundPlayPacket {
1273 fn from(p: UpdateSign) -> Self {
1274 Self::UpdateSign(p)
1275 }
1276}
1277
1278#[derive(Debug, Clone, PartialEq)]
1280pub struct Abilities {
1281 pub flags: i8,
1283 pub flying_speed: f32,
1285 pub walking_speed: f32,
1287}
1288impl crate::packet::Packet for Abilities {
1289 const ID: i32 = id::ABILITIES;
1290 const NAME: &'static str = "abilities";
1291 const STATE: State = State::Play;
1292 const DIRECTION: Direction = Direction::Serverbound;
1293}
1294impl Decode for Abilities {
1295 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1296 Ok({
1297 let v1002 = r.read_i8()?;
1298 let v1003 = r.read_f32()?;
1299 let v1004 = r.read_f32()?;
1300 Abilities {
1301 flags: v1002,
1302 flying_speed: v1003,
1303 walking_speed: v1004,
1304 }
1305 })
1306 }
1307}
1308impl Encode for Abilities {
1309 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1310 w.put_i8((*self).flags);
1311 w.put_f32((*self).flying_speed);
1312 w.put_f32((*self).walking_speed);
1313 Ok(())
1314 }
1315}
1316#[cfg(feature = "testgen")]
1317impl Generate for Abilities {
1318 fn generate(g: &mut Gen) -> Self {
1319 {
1320 let v1005 = (g.int_in(-128, 127, &[]) as i8);
1321 let v1006 = g.f32();
1322 let v1007 = g.f32();
1323 Abilities {
1324 flags: v1005,
1325 flying_speed: v1006,
1326 walking_speed: v1007,
1327 }
1328 }
1329 }
1330}
1331impl From<Abilities> for ServerboundPlayPacket {
1332 fn from(p: Abilities) -> Self {
1333 Self::Abilities(p)
1334 }
1335}
1336
1337#[derive(Debug, Clone, PartialEq)]
1339pub struct TabComplete {
1340 pub text: ByteString,
1342 pub block: Option<BlockPos>,
1344}
1345impl crate::packet::Packet for TabComplete {
1346 const ID: i32 = id::TAB_COMPLETE;
1347 const NAME: &'static str = "tab_complete";
1348 const STATE: State = State::Play;
1349 const DIRECTION: Direction = Direction::Serverbound;
1350}
1351impl Decode for TabComplete {
1352 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1353 Ok({
1354 let v1008 = r.read_string()?;
1355 let v1009 = if r.read_bool()? {
1356 Some(BlockPos::read(r, PositionLayout::Xyz)?)
1357 } else {
1358 None
1359 };
1360 TabComplete {
1361 text: v1008,
1362 block: v1009,
1363 }
1364 })
1365 }
1366}
1367impl Encode for TabComplete {
1368 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1369 w.put_string(&(*self).text)?;
1370 match &(*self).block {
1371 Some(v1010) => {
1372 w.put_u8(1);
1373 (*v1010).write(w, PositionLayout::Xyz)?;
1374 }
1375 None => w.put_u8(0),
1376 }
1377 Ok(())
1378 }
1379}
1380#[cfg(feature = "testgen")]
1381impl Generate for TabComplete {
1382 fn generate(g: &mut Gen) -> Self {
1383 {
1384 let v1011 = g.string();
1385 let v1012 = if g.bool() { Some(g.position()) } else { None };
1386 TabComplete {
1387 text: v1011,
1388 block: v1012,
1389 }
1390 }
1391 }
1392}
1393impl From<TabComplete> for ServerboundPlayPacket {
1394 fn from(p: TabComplete) -> Self {
1395 Self::TabComplete(p)
1396 }
1397}
1398
1399#[derive(Debug, Clone, PartialEq)]
1401pub struct Settings {
1402 pub locale: ByteString,
1404 pub view_distance: i8,
1406 pub chat_flags: i8,
1408 pub chat_colors: bool,
1410 pub skin_parts: u8,
1412}
1413impl crate::packet::Packet for Settings {
1414 const ID: i32 = id::SETTINGS;
1415 const NAME: &'static str = "settings";
1416 const STATE: State = State::Play;
1417 const DIRECTION: Direction = Direction::Serverbound;
1418}
1419impl Decode for Settings {
1420 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1421 Ok({
1422 let v1013 = r.read_string()?;
1423 let v1014 = r.read_i8()?;
1424 let v1015 = r.read_i8()?;
1425 let v1016 = r.read_bool()?;
1426 let v1017 = r.read_u8()?;
1427 Settings {
1428 locale: v1013,
1429 view_distance: v1014,
1430 chat_flags: v1015,
1431 chat_colors: v1016,
1432 skin_parts: v1017,
1433 }
1434 })
1435 }
1436}
1437impl Encode for Settings {
1438 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1439 w.put_string(&(*self).locale)?;
1440 w.put_i8((*self).view_distance);
1441 w.put_i8((*self).chat_flags);
1442 w.put_bool((*self).chat_colors);
1443 w.put_u8((*self).skin_parts);
1444 Ok(())
1445 }
1446}
1447#[cfg(feature = "testgen")]
1448impl Generate for Settings {
1449 fn generate(g: &mut Gen) -> Self {
1450 {
1451 let v1018 = g.string();
1452 let v1019 = (g.int_in(-128, 127, &[]) as i8);
1453 let v1020 = (g.int_in(-128, 127, &[]) as i8);
1454 let v1021 = g.bool();
1455 let v1022 = (g.int_in(0, 255, &[]) as u8);
1456 Settings {
1457 locale: v1018,
1458 view_distance: v1019,
1459 chat_flags: v1020,
1460 chat_colors: v1021,
1461 skin_parts: v1022,
1462 }
1463 }
1464 }
1465}
1466impl From<Settings> for ServerboundPlayPacket {
1467 fn from(p: Settings) -> Self {
1468 Self::Settings(p)
1469 }
1470}
1471
1472#[derive(Debug, Clone, PartialEq)]
1474pub struct ClientCommand {
1475 pub payload: ClientCommandPayload,
1477}
1478impl crate::packet::Packet for ClientCommand {
1479 const ID: i32 = id::CLIENT_COMMAND;
1480 const NAME: &'static str = "client_command";
1481 const STATE: State = State::Play;
1482 const DIRECTION: Direction = Direction::Serverbound;
1483}
1484impl Decode for ClientCommand {
1485 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1486 Ok({
1487 let v1023 = ClientCommandPayload(r.read_varint()?);
1488 ClientCommand { payload: v1023 }
1489 })
1490 }
1491}
1492impl Encode for ClientCommand {
1493 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1494 w.put_varint((*self).payload.0);
1495 Ok(())
1496 }
1497}
1498#[cfg(feature = "testgen")]
1499impl Generate for ClientCommand {
1500 fn generate(g: &mut Gen) -> Self {
1501 {
1502 let v1024 = ClientCommandPayload(g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32);
1503 ClientCommand { payload: v1024 }
1504 }
1505 }
1506}
1507impl From<ClientCommand> for ServerboundPlayPacket {
1508 fn from(p: ClientCommand) -> Self {
1509 Self::ClientCommand(p)
1510 }
1511}
1512
1513#[derive(Debug, Clone, PartialEq)]
1515pub struct CustomPayload {
1516 pub channel: ByteString,
1518 pub data: Bytes,
1520}
1521impl crate::packet::Packet for CustomPayload {
1522 const ID: i32 = id::CUSTOM_PAYLOAD;
1523 const NAME: &'static str = "custom_payload";
1524 const STATE: State = State::Play;
1525 const DIRECTION: Direction = Direction::Serverbound;
1526}
1527impl Decode for CustomPayload {
1528 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1529 Ok({
1530 let v1025 = r.read_string()?;
1531 let v1026 = r.read_rest();
1532 CustomPayload {
1533 channel: v1025,
1534 data: v1026,
1535 }
1536 })
1537 }
1538}
1539impl Encode for CustomPayload {
1540 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1541 w.put_string(&(*self).channel)?;
1542 w.put_slice(&(*self).data);
1543 Ok(())
1544 }
1545}
1546#[cfg(feature = "testgen")]
1547impl Generate for CustomPayload {
1548 fn generate(g: &mut Gen) -> Self {
1549 {
1550 let v1027 = g.string();
1551 let v1028 = g.bytes();
1552 CustomPayload {
1553 channel: v1027,
1554 data: v1028,
1555 }
1556 }
1557 }
1558}
1559impl From<CustomPayload> for ServerboundPlayPacket {
1560 fn from(p: CustomPayload) -> Self {
1561 Self::CustomPayload(p)
1562 }
1563}
1564
1565#[derive(Debug, Clone, PartialEq)]
1567pub struct Spectate {
1568 pub target: Uuid,
1570}
1571impl crate::packet::Packet for Spectate {
1572 const ID: i32 = id::SPECTATE;
1573 const NAME: &'static str = "spectate";
1574 const STATE: State = State::Play;
1575 const DIRECTION: Direction = Direction::Serverbound;
1576}
1577impl Decode for Spectate {
1578 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1579 Ok({
1580 let v1029 = r.read_uuid()?;
1581 Spectate { target: v1029 }
1582 })
1583 }
1584}
1585impl Encode for Spectate {
1586 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1587 w.put_uuid(&(*self).target);
1588 Ok(())
1589 }
1590}
1591#[cfg(feature = "testgen")]
1592impl Generate for Spectate {
1593 fn generate(g: &mut Gen) -> Self {
1594 {
1595 let v1030 = g.uuid();
1596 Spectate { target: v1030 }
1597 }
1598 }
1599}
1600impl From<Spectate> for ServerboundPlayPacket {
1601 fn from(p: Spectate) -> Self {
1602 Self::Spectate(p)
1603 }
1604}
1605
1606#[derive(Debug, Clone, PartialEq)]
1608pub struct ResourcePackReceive {
1609 pub hash: ByteString,
1611 pub result: i32,
1613}
1614impl crate::packet::Packet for ResourcePackReceive {
1615 const ID: i32 = id::RESOURCE_PACK_RECEIVE;
1616 const NAME: &'static str = "resource_pack_receive";
1617 const STATE: State = State::Play;
1618 const DIRECTION: Direction = Direction::Serverbound;
1619}
1620impl Decode for ResourcePackReceive {
1621 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1622 Ok({
1623 let v1031 = r.read_string()?;
1624 let v1032 = r.read_varint()?;
1625 ResourcePackReceive {
1626 hash: v1031,
1627 result: v1032,
1628 }
1629 })
1630 }
1631}
1632impl Encode for ResourcePackReceive {
1633 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1634 w.put_string(&(*self).hash)?;
1635 w.put_varint((*self).result);
1636 Ok(())
1637 }
1638}
1639#[cfg(feature = "testgen")]
1640impl Generate for ResourcePackReceive {
1641 fn generate(g: &mut Gen) -> Self {
1642 {
1643 let v1033 = g.string();
1644 let v1034 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1645 ResourcePackReceive {
1646 hash: v1033,
1647 result: v1034,
1648 }
1649 }
1650 }
1651}
1652impl From<ResourcePackReceive> for ServerboundPlayPacket {
1653 fn from(p: ResourcePackReceive) -> Self {
1654 Self::ResourcePackReceive(p)
1655 }
1656}
1657
1658#[derive(Debug, Clone, PartialEq)]
1660pub enum ServerboundPlayPacket {
1661 KeepAlive(KeepAlive),
1663 Chat(Chat),
1665 UseEntity(UseEntity),
1667 Flying(Flying),
1669 Position(Position),
1671 Look(Look),
1673 PositionLook(PositionLook),
1675 BlockDig(BlockDig),
1677 BlockPlace(BlockPlace),
1679 HeldItemSlot(HeldItemSlot),
1681 ArmAnimation(ArmAnimation),
1683 EntityAction(EntityAction),
1685 SteerVehicle(SteerVehicle),
1687 CloseWindow(CloseWindow),
1689 WindowClick(WindowClick),
1691 Transaction(Transaction),
1693 SetCreativeSlot(SetCreativeSlot),
1695 EnchantItem(EnchantItem),
1697 UpdateSign(UpdateSign),
1699 Abilities(Abilities),
1701 TabComplete(TabComplete),
1703 Settings(Settings),
1705 ClientCommand(ClientCommand),
1707 CustomPayload(CustomPayload),
1709 Spectate(Spectate),
1711 ResourcePackReceive(ResourcePackReceive),
1713}
1714
1715impl PacketSet for ServerboundPlayPacket {
1716 const STATE: State = State::Play;
1717 const DIRECTION: Direction = Direction::Serverbound;
1718 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
1719 match raw.id {
1720 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
1721 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
1722 id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
1723 id::FLYING => decode_exact(&raw.body).map(Self::Flying),
1724 id::POSITION => decode_exact(&raw.body).map(Self::Position),
1725 id::LOOK => decode_exact(&raw.body).map(Self::Look),
1726 id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
1727 id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
1728 id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
1729 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
1730 id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
1731 id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
1732 id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
1733 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
1734 id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
1735 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
1736 id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
1737 id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
1738 id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
1739 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
1740 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
1741 id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
1742 id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
1743 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
1744 id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
1745 id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
1746 other => Err(DecodeError::UnknownPacketId(other)),
1747 }
1748 }
1749 fn id(&self) -> i32 {
1750 match *self {
1751 Self::KeepAlive(_) => id::KEEP_ALIVE,
1752 Self::Chat(_) => id::CHAT,
1753 Self::UseEntity(_) => id::USE_ENTITY,
1754 Self::Flying(_) => id::FLYING,
1755 Self::Position(_) => id::POSITION,
1756 Self::Look(_) => id::LOOK,
1757 Self::PositionLook(_) => id::POSITION_LOOK,
1758 Self::BlockDig(_) => id::BLOCK_DIG,
1759 Self::BlockPlace(_) => id::BLOCK_PLACE,
1760 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
1761 Self::ArmAnimation(_) => id::ARM_ANIMATION,
1762 Self::EntityAction(_) => id::ENTITY_ACTION,
1763 Self::SteerVehicle(_) => id::STEER_VEHICLE,
1764 Self::CloseWindow(_) => id::CLOSE_WINDOW,
1765 Self::WindowClick(_) => id::WINDOW_CLICK,
1766 Self::Transaction(_) => id::TRANSACTION,
1767 Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
1768 Self::EnchantItem(_) => id::ENCHANT_ITEM,
1769 Self::UpdateSign(_) => id::UPDATE_SIGN,
1770 Self::Abilities(_) => id::ABILITIES,
1771 Self::TabComplete(_) => id::TAB_COMPLETE,
1772 Self::Settings(_) => id::SETTINGS,
1773 Self::ClientCommand(_) => id::CLIENT_COMMAND,
1774 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
1775 Self::Spectate(_) => id::SPECTATE,
1776 Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
1777 }
1778 }
1779 fn name(&self) -> &'static str {
1780 match *self {
1781 Self::KeepAlive(_) => "keep_alive",
1782 Self::Chat(_) => "chat",
1783 Self::UseEntity(_) => "use_entity",
1784 Self::Flying(_) => "flying",
1785 Self::Position(_) => "position",
1786 Self::Look(_) => "look",
1787 Self::PositionLook(_) => "position_look",
1788 Self::BlockDig(_) => "block_dig",
1789 Self::BlockPlace(_) => "block_place",
1790 Self::HeldItemSlot(_) => "held_item_slot",
1791 Self::ArmAnimation(_) => "arm_animation",
1792 Self::EntityAction(_) => "entity_action",
1793 Self::SteerVehicle(_) => "steer_vehicle",
1794 Self::CloseWindow(_) => "close_window",
1795 Self::WindowClick(_) => "window_click",
1796 Self::Transaction(_) => "transaction",
1797 Self::SetCreativeSlot(_) => "set_creative_slot",
1798 Self::EnchantItem(_) => "enchant_item",
1799 Self::UpdateSign(_) => "update_sign",
1800 Self::Abilities(_) => "abilities",
1801 Self::TabComplete(_) => "tab_complete",
1802 Self::Settings(_) => "settings",
1803 Self::ClientCommand(_) => "client_command",
1804 Self::CustomPayload(_) => "custom_payload",
1805 Self::Spectate(_) => "spectate",
1806 Self::ResourcePackReceive(_) => "resource_pack_receive",
1807 }
1808 }
1809 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
1810 match *self {
1811 Self::KeepAlive(ref p) => p.encode(w),
1812 Self::Chat(ref p) => p.encode(w),
1813 Self::UseEntity(ref p) => p.encode(w),
1814 Self::Flying(ref p) => p.encode(w),
1815 Self::Position(ref p) => p.encode(w),
1816 Self::Look(ref p) => p.encode(w),
1817 Self::PositionLook(ref p) => p.encode(w),
1818 Self::BlockDig(ref p) => p.encode(w),
1819 Self::BlockPlace(ref p) => p.encode(w),
1820 Self::HeldItemSlot(ref p) => p.encode(w),
1821 Self::ArmAnimation(ref p) => p.encode(w),
1822 Self::EntityAction(ref p) => p.encode(w),
1823 Self::SteerVehicle(ref p) => p.encode(w),
1824 Self::CloseWindow(ref p) => p.encode(w),
1825 Self::WindowClick(ref p) => p.encode(w),
1826 Self::Transaction(ref p) => p.encode(w),
1827 Self::SetCreativeSlot(ref p) => p.encode(w),
1828 Self::EnchantItem(ref p) => p.encode(w),
1829 Self::UpdateSign(ref p) => p.encode(w),
1830 Self::Abilities(ref p) => p.encode(w),
1831 Self::TabComplete(ref p) => p.encode(w),
1832 Self::Settings(ref p) => p.encode(w),
1833 Self::ClientCommand(ref p) => p.encode(w),
1834 Self::CustomPayload(ref p) => p.encode(w),
1835 Self::Spectate(ref p) => p.encode(w),
1836 Self::ResourcePackReceive(ref p) => p.encode(w),
1837 }
1838 }
1839 fn name_of(id: i32) -> Option<&'static str> {
1840 match id {
1841 id::KEEP_ALIVE => Some("keep_alive"),
1842 id::CHAT => Some("chat"),
1843 id::USE_ENTITY => Some("use_entity"),
1844 id::FLYING => Some("flying"),
1845 id::POSITION => Some("position"),
1846 id::LOOK => Some("look"),
1847 id::POSITION_LOOK => Some("position_look"),
1848 id::BLOCK_DIG => Some("block_dig"),
1849 id::BLOCK_PLACE => Some("block_place"),
1850 id::HELD_ITEM_SLOT => Some("held_item_slot"),
1851 id::ARM_ANIMATION => Some("arm_animation"),
1852 id::ENTITY_ACTION => Some("entity_action"),
1853 id::STEER_VEHICLE => Some("steer_vehicle"),
1854 id::CLOSE_WINDOW => Some("close_window"),
1855 id::WINDOW_CLICK => Some("window_click"),
1856 id::TRANSACTION => Some("transaction"),
1857 id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
1858 id::ENCHANT_ITEM => Some("enchant_item"),
1859 id::UPDATE_SIGN => Some("update_sign"),
1860 id::ABILITIES => Some("abilities"),
1861 id::TAB_COMPLETE => Some("tab_complete"),
1862 id::SETTINGS => Some("settings"),
1863 id::CLIENT_COMMAND => Some("client_command"),
1864 id::CUSTOM_PAYLOAD => Some("custom_payload"),
1865 id::SPECTATE => Some("spectate"),
1866 id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
1867 _ => None,
1868 }
1869 }
1870}
1871
1872impl ServerboundPlayPacket {
1873 pub const IDS: &'static [i32] = &[
1875 id::KEEP_ALIVE,
1876 id::CHAT,
1877 id::USE_ENTITY,
1878 id::FLYING,
1879 id::POSITION,
1880 id::LOOK,
1881 id::POSITION_LOOK,
1882 id::BLOCK_DIG,
1883 id::BLOCK_PLACE,
1884 id::HELD_ITEM_SLOT,
1885 id::ARM_ANIMATION,
1886 id::ENTITY_ACTION,
1887 id::STEER_VEHICLE,
1888 id::CLOSE_WINDOW,
1889 id::WINDOW_CLICK,
1890 id::TRANSACTION,
1891 id::SET_CREATIVE_SLOT,
1892 id::ENCHANT_ITEM,
1893 id::UPDATE_SIGN,
1894 id::ABILITIES,
1895 id::TAB_COMPLETE,
1896 id::SETTINGS,
1897 id::CLIENT_COMMAND,
1898 id::CUSTOM_PAYLOAD,
1899 id::SPECTATE,
1900 id::RESOURCE_PACK_RECEIVE,
1901 ];
1902 #[cfg(feature = "testgen")]
1904 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
1905 match id {
1906 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
1907 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
1908 id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
1909 id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
1910 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
1911 id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
1912 id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
1913 id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
1914 id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
1915 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
1916 id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
1917 id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
1918 id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
1919 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
1920 id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
1921 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
1922 id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
1923 <SetCreativeSlot as Generate>::generate(g),
1924 )),
1925 id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
1926 id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
1927 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
1928 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
1929 id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
1930 id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
1931 g,
1932 ))),
1933 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
1934 g,
1935 ))),
1936 id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
1937 id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
1938 <ResourcePackReceive as Generate>::generate(g),
1939 )),
1940 _ => None,
1941 }
1942 }
1943}