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(Debug, Clone, PartialEq)]
30pub struct UpdateAttributesPropertiesModifiers {
31 pub uuid: Uuid,
33 pub amount: f64,
35 pub operation: i8,
37}
38
39#[derive(Debug, Clone, PartialEq)]
41pub struct UpdateAttributesProperties {
42 pub key: ByteString,
44 pub value: f64,
46 pub modifiers: Vec<UpdateAttributesPropertiesModifiers>,
48}
49
50#[derive(Debug, Clone, PartialEq)]
52pub struct MultiBlockChangeRecords {
53 pub horizontal_pos: u8,
55 pub y: u8,
57 pub block_id: i32,
59}
60
61#[derive(Debug, Clone, PartialEq)]
63pub struct MapChunkBulkMeta {
64 pub x: i32,
66 pub z: i32,
68 pub bit_map: u16,
70}
71
72#[derive(Debug, Clone, PartialEq)]
74pub struct ExplosionAffectedBlockOffsets {
75 pub x: i8,
77 pub y: i8,
79 pub z: i8,
81}
82
83#[derive(Debug, Clone, PartialEq)]
85pub enum WorldParticlesData {
86 Case36(Vec<i32>),
88 Case37(Vec<i32>),
90 Case38(Vec<i32>),
92 Other,
94}
95
96#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
98pub struct GameStateChangeReason(pub u8);
99impl GameStateChangeReason {
100 pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
102 pub const START_RAINING: Self = Self(1);
104 pub const STOP_RAINING: Self = Self(2);
106 pub const CHANGE_GAME_MODE: Self = Self(3);
108 pub const WIN_GAME: Self = Self(4);
110 pub const DEMO_EVENT: Self = Self(5);
112 pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
114 pub const RAIN_LEVEL_CHANGE: Self = Self(7);
116 pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
118 pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
120 pub const fn name(self) -> Option<&'static str> {
122 match self.0 {
123 0 => Some("no_respawn_block_available"),
124 1 => Some("start_raining"),
125 2 => Some("stop_raining"),
126 3 => Some("change_game_mode"),
127 4 => Some("win_game"),
128 5 => Some("demo_event"),
129 6 => Some("play_arrow_hit_sound"),
130 7 => Some("rain_level_change"),
131 8 => Some("thunder_level_change"),
132 10 => Some("guardian_elder_effect"),
133 _ => None,
134 }
135 }
136}
137impl std::fmt::Debug for GameStateChangeReason {
138 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139 match self.name() {
140 Some(n) => write!(f, "GameStateChangeReason::{n}"),
141 None => write!(f, "GameStateChangeReason({})", self.0),
142 }
143 }
144}
145
146#[derive(Debug, Clone, PartialEq)]
148pub struct MapIcons {
149 pub direction_and_type: i8,
151 pub x: i8,
153 pub z: i8,
155}
156
157#[derive(Debug, Clone, PartialEq)]
159pub struct StatisticsEntries {
160 pub name: ByteString,
162 pub value: i32,
164}
165
166#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
168pub struct PlayerInfoAction(pub i32);
169impl PlayerInfoAction {
170 pub const ADD_PLAYER: Self = Self(0);
172 pub const UPDATE_GAME_MODE: Self = Self(1);
174 pub const UPDATE_LATENCY: Self = Self(2);
176 pub const UPDATE_DISPLAY_NAME: Self = Self(3);
178 pub const REMOVE_PLAYER: Self = Self(4);
180 pub const fn name(self) -> Option<&'static str> {
182 match self.0 {
183 0 => Some("add_player"),
184 1 => Some("update_game_mode"),
185 2 => Some("update_latency"),
186 3 => Some("update_display_name"),
187 4 => Some("remove_player"),
188 _ => None,
189 }
190 }
191}
192impl std::fmt::Debug for PlayerInfoAction {
193 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
194 match self.name() {
195 Some(n) => write!(f, "PlayerInfoAction::{n}"),
196 None => write!(f, "PlayerInfoAction({})", self.0),
197 }
198 }
199}
200
201#[derive(Debug, Clone, PartialEq)]
203pub struct PlayerInfoDataBodyAddPlayerProperties {
204 pub name: ByteString,
206 pub value: ByteString,
208 pub signature: Option<ByteString>,
210}
211
212#[derive(Debug, Clone, PartialEq)]
214pub struct PlayerInfoDataBodyAddPlayer {
215 pub name: ByteString,
217 pub properties: Vec<PlayerInfoDataBodyAddPlayerProperties>,
219 pub gamemode: i32,
221 pub ping: i32,
223 pub display_name: Option<ByteString>,
225}
226
227#[derive(Debug, Clone, PartialEq)]
229pub struct PlayerInfoDataBodyUpdateGameMode {
230 pub gamemode: i32,
232}
233
234#[derive(Debug, Clone, PartialEq)]
236pub struct PlayerInfoDataBodyUpdateLatency {
237 pub ping: i32,
239}
240
241#[derive(Debug, Clone, PartialEq)]
243pub struct PlayerInfoDataBodyUpdateDisplayName {
244 pub display_name: Option<ByteString>,
246}
247
248#[derive(Debug, Clone, PartialEq)]
250pub enum PlayerInfoDataBody {
251 AddPlayer(PlayerInfoDataBodyAddPlayer),
253 UpdateGameMode(PlayerInfoDataBodyUpdateGameMode),
255 UpdateLatency(PlayerInfoDataBodyUpdateLatency),
257 UpdateDisplayName(PlayerInfoDataBodyUpdateDisplayName),
259 RemovePlayer,
261 Other,
263}
264
265#[derive(Debug, Clone, PartialEq)]
267pub struct PlayerInfoData {
268 pub uuid: Uuid,
270 pub body: PlayerInfoDataBody,
272}
273
274#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
276pub struct DifficultyDifficulty(pub u8);
277impl DifficultyDifficulty {
278 pub const PEACEFUL: Self = Self(0);
280 pub const EASY: Self = Self(1);
282 pub const NORMAL: Self = Self(2);
284 pub const HARD: Self = Self(3);
286 pub const fn name(self) -> Option<&'static str> {
288 match self.0 {
289 0 => Some("peaceful"),
290 1 => Some("easy"),
291 2 => Some("normal"),
292 3 => Some("hard"),
293 _ => None,
294 }
295 }
296}
297impl std::fmt::Debug for DifficultyDifficulty {
298 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
299 match self.name() {
300 Some(n) => write!(f, "DifficultyDifficulty::{n}"),
301 None => write!(f, "DifficultyDifficulty({})", self.0),
302 }
303 }
304}
305
306pub mod id {
308 pub const KEEP_ALIVE: i32 = 0x00;
310 pub const LOGIN: i32 = 0x01;
312 pub const CHAT: i32 = 0x02;
314 pub const UPDATE_TIME: i32 = 0x03;
316 pub const ENTITY_EQUIPMENT: i32 = 0x04;
318 pub const SPAWN_POSITION: i32 = 0x05;
320 pub const UPDATE_HEALTH: i32 = 0x06;
322 pub const RESPAWN: i32 = 0x07;
324 pub const POSITION: i32 = 0x08;
326 pub const HELD_ITEM_SLOT: i32 = 0x09;
328 pub const BED: i32 = 0x0a;
330 pub const ANIMATION: i32 = 0x0b;
332 pub const NAMED_ENTITY_SPAWN: i32 = 0x0c;
334 pub const COLLECT: i32 = 0x0d;
336 pub const SPAWN_ENTITY: i32 = 0x0e;
338 pub const SPAWN_ENTITY_LIVING: i32 = 0x0f;
340 pub const SPAWN_ENTITY_PAINTING: i32 = 0x10;
342 pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x11;
344 pub const ENTITY_VELOCITY: i32 = 0x12;
346 pub const ENTITY_DESTROY: i32 = 0x13;
348 pub const ENTITY: i32 = 0x14;
350 pub const REL_ENTITY_MOVE: i32 = 0x15;
352 pub const ENTITY_LOOK: i32 = 0x16;
354 pub const ENTITY_MOVE_LOOK: i32 = 0x17;
356 pub const ENTITY_TELEPORT: i32 = 0x18;
358 pub const ENTITY_HEAD_ROTATION: i32 = 0x19;
360 pub const ENTITY_STATUS: i32 = 0x1a;
362 pub const ATTACH_ENTITY: i32 = 0x1b;
364 pub const ENTITY_METADATA: i32 = 0x1c;
366 pub const ENTITY_EFFECT: i32 = 0x1d;
368 pub const REMOVE_ENTITY_EFFECT: i32 = 0x1e;
370 pub const EXPERIENCE: i32 = 0x1f;
372 pub const UPDATE_ATTRIBUTES: i32 = 0x20;
374 pub const MAP_CHUNK: i32 = 0x21;
376 pub const MULTI_BLOCK_CHANGE: i32 = 0x22;
378 pub const BLOCK_CHANGE: i32 = 0x23;
380 pub const BLOCK_ACTION: i32 = 0x24;
382 pub const BLOCK_BREAK_ANIMATION: i32 = 0x25;
384 pub const MAP_CHUNK_BULK: i32 = 0x26;
386 pub const EXPLOSION: i32 = 0x27;
388 pub const WORLD_EVENT: i32 = 0x28;
390 pub const NAMED_SOUND_EFFECT: i32 = 0x29;
392 pub const WORLD_PARTICLES: i32 = 0x2a;
394 pub const GAME_STATE_CHANGE: i32 = 0x2b;
396 pub const SPAWN_ENTITY_WEATHER: i32 = 0x2c;
398 pub const OPEN_WINDOW: i32 = 0x2d;
400 pub const CLOSE_WINDOW: i32 = 0x2e;
402 pub const SET_SLOT: i32 = 0x2f;
404 pub const WINDOW_ITEMS: i32 = 0x30;
406 pub const CRAFT_PROGRESS_BAR: i32 = 0x31;
408 pub const TRANSACTION: i32 = 0x32;
410 pub const UPDATE_SIGN: i32 = 0x33;
412 pub const MAP: i32 = 0x34;
414 pub const TILE_ENTITY_DATA: i32 = 0x35;
416 pub const OPEN_SIGN_ENTITY: i32 = 0x36;
418 pub const STATISTICS: i32 = 0x37;
420 pub const PLAYER_INFO: i32 = 0x38;
422 pub const ABILITIES: i32 = 0x39;
424 pub const TAB_COMPLETE: i32 = 0x3a;
426 pub const SCOREBOARD_OBJECTIVE: i32 = 0x3b;
428 pub const SCOREBOARD_SCORE: i32 = 0x3c;
430 pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x3d;
432 pub const SCOREBOARD_TEAM: i32 = 0x3e;
434 pub const CUSTOM_PAYLOAD: i32 = 0x3f;
436 pub const KICK_DISCONNECT: i32 = 0x40;
438 pub const DIFFICULTY: i32 = 0x41;
440 pub const COMBAT_EVENT: i32 = 0x42;
442 pub const CAMERA: i32 = 0x43;
444 pub const WORLD_BORDER: i32 = 0x44;
446 pub const TITLE: i32 = 0x45;
448 pub const SET_COMPRESSION: i32 = 0x46;
450 pub const PLAYERLIST_HEADER: i32 = 0x47;
452 pub const RESOURCE_PACK_SEND: i32 = 0x48;
454 pub const UPDATE_ENTITY_NBT: i32 = 0x49;
456}
457
458#[derive(Debug, Clone, PartialEq)]
460pub struct KeepAlive {
461 pub keep_alive_id: i32,
463}
464impl crate::packet::Packet for KeepAlive {
465 const ID: i32 = id::KEEP_ALIVE;
466 const NAME: &'static str = "keep_alive";
467 const STATE: State = State::Play;
468 const DIRECTION: Direction = Direction::Clientbound;
469}
470impl Decode for KeepAlive {
471 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
472 Ok({
473 let v37 = r.read_varint()?;
474 KeepAlive { keep_alive_id: v37 }
475 })
476 }
477}
478impl Encode for KeepAlive {
479 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
480 w.put_varint((*self).keep_alive_id);
481 Ok(())
482 }
483}
484#[cfg(feature = "testgen")]
485impl Generate for KeepAlive {
486 fn generate(g: &mut Gen) -> Self {
487 {
488 let v38 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
489 KeepAlive { keep_alive_id: v38 }
490 }
491 }
492}
493impl From<KeepAlive> for ClientboundPlayPacket {
494 fn from(p: KeepAlive) -> Self {
495 Self::KeepAlive(p)
496 }
497}
498
499#[derive(Debug, Clone, PartialEq)]
501pub struct Login {
502 pub entity_id: i32,
504 pub game_mode: u8,
506 pub dimension: i8,
508 pub difficulty: u8,
510 pub max_players: u8,
512 pub level_type: ByteString,
514 pub reduced_debug_info: bool,
516}
517impl crate::packet::Packet for Login {
518 const ID: i32 = id::LOGIN;
519 const NAME: &'static str = "login";
520 const STATE: State = State::Play;
521 const DIRECTION: Direction = Direction::Clientbound;
522}
523impl Decode for Login {
524 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
525 Ok({
526 let v39 = r.read_i32()?;
527 let v40 = r.read_u8()?;
528 let v41 = r.read_i8()?;
529 let v42 = r.read_u8()?;
530 let v43 = r.read_u8()?;
531 let v44 = r.read_string()?;
532 let v45 = r.read_bool()?;
533 Login {
534 entity_id: v39,
535 game_mode: v40,
536 dimension: v41,
537 difficulty: v42,
538 max_players: v43,
539 level_type: v44,
540 reduced_debug_info: v45,
541 }
542 })
543 }
544}
545impl Encode for Login {
546 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
547 w.put_i32((*self).entity_id);
548 w.put_u8((*self).game_mode);
549 w.put_i8((*self).dimension);
550 w.put_u8((*self).difficulty);
551 w.put_u8((*self).max_players);
552 w.put_string(&(*self).level_type)?;
553 w.put_bool((*self).reduced_debug_info);
554 Ok(())
555 }
556}
557#[cfg(feature = "testgen")]
558impl Generate for Login {
559 fn generate(g: &mut Gen) -> Self {
560 {
561 let v46 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
562 let v47 = (g.int_in(0, 255, &[]) as u8);
563 let v48 = (g.int_in(-128, 127, &[]) as i8);
564 let v49 = (g.int_in(0, 255, &[]) as u8);
565 let v50 = (g.int_in(0, 255, &[]) as u8);
566 let v51 = g.string();
567 let v52 = g.bool();
568 Login {
569 entity_id: v46,
570 game_mode: v47,
571 dimension: v48,
572 difficulty: v49,
573 max_players: v50,
574 level_type: v51,
575 reduced_debug_info: v52,
576 }
577 }
578 }
579}
580impl From<Login> for ClientboundPlayPacket {
581 fn from(p: Login) -> Self {
582 Self::Login(p)
583 }
584}
585
586#[derive(Debug, Clone, PartialEq)]
588pub struct Chat {
589 pub message: ByteString,
591 pub position: i8,
593}
594impl crate::packet::Packet for Chat {
595 const ID: i32 = id::CHAT;
596 const NAME: &'static str = "chat";
597 const STATE: State = State::Play;
598 const DIRECTION: Direction = Direction::Clientbound;
599}
600impl Decode for Chat {
601 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
602 Ok({
603 let v53 = r.read_string()?;
604 let v54 = r.read_i8()?;
605 Chat {
606 message: v53,
607 position: v54,
608 }
609 })
610 }
611}
612impl Encode for Chat {
613 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
614 w.put_string(&(*self).message)?;
615 w.put_i8((*self).position);
616 Ok(())
617 }
618}
619#[cfg(feature = "testgen")]
620impl Generate for Chat {
621 fn generate(g: &mut Gen) -> Self {
622 {
623 let v55 = g.string();
624 let v56 = (g.int_in(-128, 127, &[]) as i8);
625 Chat {
626 message: v55,
627 position: v56,
628 }
629 }
630 }
631}
632impl From<Chat> for ClientboundPlayPacket {
633 fn from(p: Chat) -> Self {
634 Self::Chat(p)
635 }
636}
637
638#[derive(Debug, Clone, PartialEq)]
640pub struct UpdateTime {
641 pub age: i64,
643 pub time: i64,
645}
646impl crate::packet::Packet for UpdateTime {
647 const ID: i32 = id::UPDATE_TIME;
648 const NAME: &'static str = "update_time";
649 const STATE: State = State::Play;
650 const DIRECTION: Direction = Direction::Clientbound;
651}
652impl Decode for UpdateTime {
653 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
654 Ok({
655 let v57 = r.read_i64()?;
656 let v58 = r.read_i64()?;
657 UpdateTime {
658 age: v57,
659 time: v58,
660 }
661 })
662 }
663}
664impl Encode for UpdateTime {
665 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
666 w.put_i64((*self).age);
667 w.put_i64((*self).time);
668 Ok(())
669 }
670}
671#[cfg(feature = "testgen")]
672impl Generate for UpdateTime {
673 fn generate(g: &mut Gen) -> Self {
674 {
675 let v59 = g.i64();
676 let v60 = g.i64();
677 UpdateTime {
678 age: v59,
679 time: v60,
680 }
681 }
682 }
683}
684impl From<UpdateTime> for ClientboundPlayPacket {
685 fn from(p: UpdateTime) -> Self {
686 Self::UpdateTime(p)
687 }
688}
689
690#[derive(Debug, Clone, PartialEq)]
692pub struct EntityEquipment {
693 pub entity_id: i32,
695 pub slot: i16,
697 pub item: types::Slot,
699}
700impl crate::packet::Packet for EntityEquipment {
701 const ID: i32 = id::ENTITY_EQUIPMENT;
702 const NAME: &'static str = "entity_equipment";
703 const STATE: State = State::Play;
704 const DIRECTION: Direction = Direction::Clientbound;
705}
706impl Decode for EntityEquipment {
707 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
708 Ok({
709 let v61 = r.read_varint()?;
710 let v62 = r.read_i16()?;
711 let v63 = <types::Slot as Decode>::decode(r)?;
712 EntityEquipment {
713 entity_id: v61,
714 slot: v62,
715 item: v63,
716 }
717 })
718 }
719}
720impl Encode for EntityEquipment {
721 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
722 w.put_varint((*self).entity_id);
723 w.put_i16((*self).slot);
724 (*self).item.encode(w)?;
725 Ok(())
726 }
727}
728#[cfg(feature = "testgen")]
729impl Generate for EntityEquipment {
730 fn generate(g: &mut Gen) -> Self {
731 {
732 let v64 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
733 let v65 = (g.int_in(-32768, 32767, &[]) as i16);
734 let v66 = <types::Slot as Generate>::generate(g);
735 EntityEquipment {
736 entity_id: v64,
737 slot: v65,
738 item: v66,
739 }
740 }
741 }
742}
743impl From<EntityEquipment> for ClientboundPlayPacket {
744 fn from(p: EntityEquipment) -> Self {
745 Self::EntityEquipment(p)
746 }
747}
748
749#[derive(Debug, Clone, PartialEq)]
751pub struct SpawnPosition {
752 pub location: BlockPos,
754}
755impl crate::packet::Packet for SpawnPosition {
756 const ID: i32 = id::SPAWN_POSITION;
757 const NAME: &'static str = "spawn_position";
758 const STATE: State = State::Play;
759 const DIRECTION: Direction = Direction::Clientbound;
760}
761impl Decode for SpawnPosition {
762 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
763 Ok({
764 let v67 = BlockPos::read(r, PositionLayout::Xyz)?;
765 SpawnPosition { location: v67 }
766 })
767 }
768}
769impl Encode for SpawnPosition {
770 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
771 (*self).location.write(w, PositionLayout::Xyz)?;
772 Ok(())
773 }
774}
775#[cfg(feature = "testgen")]
776impl Generate for SpawnPosition {
777 fn generate(g: &mut Gen) -> Self {
778 {
779 let v68 = g.position();
780 SpawnPosition { location: v68 }
781 }
782 }
783}
784impl From<SpawnPosition> for ClientboundPlayPacket {
785 fn from(p: SpawnPosition) -> Self {
786 Self::SpawnPosition(p)
787 }
788}
789
790#[derive(Debug, Clone, PartialEq)]
792pub struct UpdateHealth {
793 pub health: f32,
795 pub food: i32,
797 pub food_saturation: f32,
799}
800impl crate::packet::Packet for UpdateHealth {
801 const ID: i32 = id::UPDATE_HEALTH;
802 const NAME: &'static str = "update_health";
803 const STATE: State = State::Play;
804 const DIRECTION: Direction = Direction::Clientbound;
805}
806impl Decode for UpdateHealth {
807 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
808 Ok({
809 let v69 = r.read_f32()?;
810 let v70 = r.read_varint()?;
811 let v71 = r.read_f32()?;
812 UpdateHealth {
813 health: v69,
814 food: v70,
815 food_saturation: v71,
816 }
817 })
818 }
819}
820impl Encode for UpdateHealth {
821 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
822 w.put_f32((*self).health);
823 w.put_varint((*self).food);
824 w.put_f32((*self).food_saturation);
825 Ok(())
826 }
827}
828#[cfg(feature = "testgen")]
829impl Generate for UpdateHealth {
830 fn generate(g: &mut Gen) -> Self {
831 {
832 let v72 = g.f32();
833 let v73 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
834 let v74 = g.f32();
835 UpdateHealth {
836 health: v72,
837 food: v73,
838 food_saturation: v74,
839 }
840 }
841 }
842}
843impl From<UpdateHealth> for ClientboundPlayPacket {
844 fn from(p: UpdateHealth) -> Self {
845 Self::UpdateHealth(p)
846 }
847}
848
849#[derive(Debug, Clone, PartialEq)]
851pub struct Respawn {
852 pub dimension: i32,
854 pub difficulty: u8,
856 pub gamemode: u8,
858 pub level_type: ByteString,
860}
861impl crate::packet::Packet for Respawn {
862 const ID: i32 = id::RESPAWN;
863 const NAME: &'static str = "respawn";
864 const STATE: State = State::Play;
865 const DIRECTION: Direction = Direction::Clientbound;
866}
867impl Decode for Respawn {
868 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
869 Ok({
870 let v75 = r.read_i32()?;
871 let v76 = r.read_u8()?;
872 let v77 = r.read_u8()?;
873 let v78 = r.read_string()?;
874 Respawn {
875 dimension: v75,
876 difficulty: v76,
877 gamemode: v77,
878 level_type: v78,
879 }
880 })
881 }
882}
883impl Encode for Respawn {
884 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
885 w.put_i32((*self).dimension);
886 w.put_u8((*self).difficulty);
887 w.put_u8((*self).gamemode);
888 w.put_string(&(*self).level_type)?;
889 Ok(())
890 }
891}
892#[cfg(feature = "testgen")]
893impl Generate for Respawn {
894 fn generate(g: &mut Gen) -> Self {
895 {
896 let v79 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
897 let v80 = (g.int_in(0, 255, &[]) as u8);
898 let v81 = (g.int_in(0, 255, &[]) as u8);
899 let v82 = g.string();
900 Respawn {
901 dimension: v79,
902 difficulty: v80,
903 gamemode: v81,
904 level_type: v82,
905 }
906 }
907 }
908}
909impl From<Respawn> for ClientboundPlayPacket {
910 fn from(p: Respawn) -> Self {
911 Self::Respawn(p)
912 }
913}
914
915#[derive(Debug, Clone, PartialEq)]
917pub struct Position {
918 pub x: f64,
920 pub y: f64,
922 pub z: f64,
924 pub yaw: f32,
926 pub pitch: f32,
928 pub flags: i8,
930}
931impl crate::packet::Packet for Position {
932 const ID: i32 = id::POSITION;
933 const NAME: &'static str = "position";
934 const STATE: State = State::Play;
935 const DIRECTION: Direction = Direction::Clientbound;
936}
937impl Decode for Position {
938 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
939 Ok({
940 let v83 = r.read_f64()?;
941 let v84 = r.read_f64()?;
942 let v85 = r.read_f64()?;
943 let v86 = r.read_f32()?;
944 let v87 = r.read_f32()?;
945 let v88 = r.read_i8()?;
946 Position {
947 x: v83,
948 y: v84,
949 z: v85,
950 yaw: v86,
951 pitch: v87,
952 flags: v88,
953 }
954 })
955 }
956}
957impl Encode for Position {
958 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
959 w.put_f64((*self).x);
960 w.put_f64((*self).y);
961 w.put_f64((*self).z);
962 w.put_f32((*self).yaw);
963 w.put_f32((*self).pitch);
964 w.put_i8((*self).flags);
965 Ok(())
966 }
967}
968#[cfg(feature = "testgen")]
969impl Generate for Position {
970 fn generate(g: &mut Gen) -> Self {
971 {
972 let v89 = g.f64();
973 let v90 = g.f64();
974 let v91 = g.f64();
975 let v92 = g.f32();
976 let v93 = g.f32();
977 let v94 = (g.int_in(-128, 127, &[]) as i8);
978 Position {
979 x: v89,
980 y: v90,
981 z: v91,
982 yaw: v92,
983 pitch: v93,
984 flags: v94,
985 }
986 }
987 }
988}
989impl From<Position> for ClientboundPlayPacket {
990 fn from(p: Position) -> Self {
991 Self::Position(p)
992 }
993}
994
995#[derive(Debug, Clone, PartialEq)]
997pub struct HeldItemSlot {
998 pub slot: i8,
1000}
1001impl crate::packet::Packet for HeldItemSlot {
1002 const ID: i32 = id::HELD_ITEM_SLOT;
1003 const NAME: &'static str = "held_item_slot";
1004 const STATE: State = State::Play;
1005 const DIRECTION: Direction = Direction::Clientbound;
1006}
1007impl Decode for HeldItemSlot {
1008 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1009 Ok({
1010 let v95 = r.read_i8()?;
1011 HeldItemSlot { slot: v95 }
1012 })
1013 }
1014}
1015impl Encode for HeldItemSlot {
1016 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1017 w.put_i8((*self).slot);
1018 Ok(())
1019 }
1020}
1021#[cfg(feature = "testgen")]
1022impl Generate for HeldItemSlot {
1023 fn generate(g: &mut Gen) -> Self {
1024 {
1025 let v96 = (g.int_in(-128, 127, &[]) as i8);
1026 HeldItemSlot { slot: v96 }
1027 }
1028 }
1029}
1030impl From<HeldItemSlot> for ClientboundPlayPacket {
1031 fn from(p: HeldItemSlot) -> Self {
1032 Self::HeldItemSlot(p)
1033 }
1034}
1035
1036#[derive(Debug, Clone, PartialEq)]
1038pub struct Bed {
1039 pub entity_id: i32,
1041 pub location: BlockPos,
1043}
1044impl crate::packet::Packet for Bed {
1045 const ID: i32 = id::BED;
1046 const NAME: &'static str = "bed";
1047 const STATE: State = State::Play;
1048 const DIRECTION: Direction = Direction::Clientbound;
1049}
1050impl Decode for Bed {
1051 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1052 Ok({
1053 let v97 = r.read_varint()?;
1054 let v98 = BlockPos::read(r, PositionLayout::Xyz)?;
1055 Bed {
1056 entity_id: v97,
1057 location: v98,
1058 }
1059 })
1060 }
1061}
1062impl Encode for Bed {
1063 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1064 w.put_varint((*self).entity_id);
1065 (*self).location.write(w, PositionLayout::Xyz)?;
1066 Ok(())
1067 }
1068}
1069#[cfg(feature = "testgen")]
1070impl Generate for Bed {
1071 fn generate(g: &mut Gen) -> Self {
1072 {
1073 let v99 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1074 let v100 = g.position();
1075 Bed {
1076 entity_id: v99,
1077 location: v100,
1078 }
1079 }
1080 }
1081}
1082impl From<Bed> for ClientboundPlayPacket {
1083 fn from(p: Bed) -> Self {
1084 Self::Bed(p)
1085 }
1086}
1087
1088#[derive(Debug, Clone, PartialEq)]
1090pub struct Animation {
1091 pub entity_id: i32,
1093 pub animation: u8,
1095}
1096impl crate::packet::Packet for Animation {
1097 const ID: i32 = id::ANIMATION;
1098 const NAME: &'static str = "animation";
1099 const STATE: State = State::Play;
1100 const DIRECTION: Direction = Direction::Clientbound;
1101}
1102impl Decode for Animation {
1103 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1104 Ok({
1105 let v101 = r.read_varint()?;
1106 let v102 = r.read_u8()?;
1107 Animation {
1108 entity_id: v101,
1109 animation: v102,
1110 }
1111 })
1112 }
1113}
1114impl Encode for Animation {
1115 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1116 w.put_varint((*self).entity_id);
1117 w.put_u8((*self).animation);
1118 Ok(())
1119 }
1120}
1121#[cfg(feature = "testgen")]
1122impl Generate for Animation {
1123 fn generate(g: &mut Gen) -> Self {
1124 {
1125 let v103 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1126 let v104 = (g.int_in(0, 255, &[]) as u8);
1127 Animation {
1128 entity_id: v103,
1129 animation: v104,
1130 }
1131 }
1132 }
1133}
1134impl From<Animation> for ClientboundPlayPacket {
1135 fn from(p: Animation) -> Self {
1136 Self::Animation(p)
1137 }
1138}
1139
1140#[derive(Debug, Clone, PartialEq)]
1142pub struct NamedEntitySpawn {
1143 pub entity_id: i32,
1145 pub player_uuid: Uuid,
1147 pub x: i32,
1149 pub y: i32,
1151 pub z: i32,
1153 pub yaw: i8,
1155 pub pitch: i8,
1157 pub current_item: i16,
1159 pub metadata: Vec<types::EntityMetadataEntry>,
1161}
1162impl crate::packet::Packet for NamedEntitySpawn {
1163 const ID: i32 = id::NAMED_ENTITY_SPAWN;
1164 const NAME: &'static str = "named_entity_spawn";
1165 const STATE: State = State::Play;
1166 const DIRECTION: Direction = Direction::Clientbound;
1167}
1168impl Decode for NamedEntitySpawn {
1169 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1170 Ok({
1171 let v105 = r.read_varint()?;
1172 let v106 = r.read_uuid()?;
1173 let v107 = r.read_i32()?;
1174 let v108 = r.read_i32()?;
1175 let v109 = r.read_i32()?;
1176 let v110 = r.read_i8()?;
1177 let v111 = r.read_i8()?;
1178 let v112 = r.read_i16()?;
1179 let v113 = {
1180 let mut v114 = Vec::new();
1181 loop {
1182 if r.peek_u8()? == 127 {
1183 r.skip(1)?;
1184 break;
1185 }
1186 v114.push({
1187 let v115 = u64::from(r.read_u8()?);
1188 let v116 = (((v115 >> 5) & 0x7) as u8);
1189 let v117 = (((v115 >> 0) & 0x1f) as u8);
1190 let v118 = (if (v116 == 0) {
1191 types::EntityMetadataValue::Byte(r.read_i8()?)
1192 } else if (v116 == 1) {
1193 types::EntityMetadataValue::Short(r.read_i16()?)
1194 } else if (v116 == 2) {
1195 types::EntityMetadataValue::Int(r.read_i32()?)
1196 } else if (v116 == 3) {
1197 types::EntityMetadataValue::Float(r.read_f32()?)
1198 } else if (v116 == 4) {
1199 types::EntityMetadataValue::String(r.read_string()?)
1200 } else if (v116 == 5) {
1201 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
1202 } else if (v116 == 6) {
1203 types::EntityMetadataValue::BlockPos({
1204 let v119 = r.read_i32()?;
1205 let v120 = r.read_i32()?;
1206 let v121 = r.read_i32()?;
1207 types::EntityMetadataValueBlockPos {
1208 x: v119,
1209 y: v120,
1210 z: v121,
1211 }
1212 })
1213 } else if (v116 == 7) {
1214 types::EntityMetadataValue::Rotation({
1215 let v122 = r.read_f32()?;
1216 let v123 = r.read_f32()?;
1217 let v124 = r.read_f32()?;
1218 types::EntityMetadataValueRotation {
1219 pitch: v122,
1220 yaw: v123,
1221 roll: v124,
1222 }
1223 })
1224 } else {
1225 types::EntityMetadataValue::Other
1226 });
1227 types::EntityMetadataEntry {
1228 r#type: v116,
1229 key: v117,
1230 value: v118,
1231 }
1232 });
1233 }
1234 v114
1235 };
1236 NamedEntitySpawn {
1237 entity_id: v105,
1238 player_uuid: v106,
1239 x: v107,
1240 y: v108,
1241 z: v109,
1242 yaw: v110,
1243 pitch: v111,
1244 current_item: v112,
1245 metadata: v113,
1246 }
1247 })
1248 }
1249}
1250impl Encode for NamedEntitySpawn {
1251 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1252 w.put_varint((*self).entity_id);
1253 w.put_uuid(&(*self).player_uuid);
1254 w.put_i32((*self).x);
1255 w.put_i32((*self).y);
1256 w.put_i32((*self).z);
1257 w.put_i8((*self).yaw);
1258 w.put_i8((*self).pitch);
1259 w.put_i16((*self).current_item);
1260 for v125 in (*self).metadata.iter() {
1261 let v126 = w.len();
1262 {
1263 let mut bits: u64 = 0;
1264 {
1265 let x = i128::from((*v125).r#type);
1266 if x < 0 || x > 7 {
1267 return Err(EncodeError::OutOfRange("type"));
1268 }
1269 bits = (bits << 3) | ((x as u64) & 0x7);
1270 }
1271 {
1272 let x = i128::from((*v125).key);
1273 if x < 0 || x > 31 {
1274 return Err(EncodeError::OutOfRange("key"));
1275 }
1276 bits = (bits << 5) | ((x as u64) & 0x1f);
1277 }
1278 w.put_u8(bits as u8);
1279 }
1280 match &(*v125).value {
1281 types::EntityMetadataValue::Byte(v127) => {
1282 if !((*v125).r#type == 0) {
1283 return Err(EncodeError::SwitchMismatch(
1284 "play.clientbound.named_entity_spawn.metadata.value",
1285 ));
1286 }
1287 w.put_i8((*v127));
1288 }
1289 types::EntityMetadataValue::Short(v128) => {
1290 if !((*v125).r#type == 1) {
1291 return Err(EncodeError::SwitchMismatch(
1292 "play.clientbound.named_entity_spawn.metadata.value",
1293 ));
1294 }
1295 w.put_i16((*v128));
1296 }
1297 types::EntityMetadataValue::Int(v129) => {
1298 if !((*v125).r#type == 2) {
1299 return Err(EncodeError::SwitchMismatch(
1300 "play.clientbound.named_entity_spawn.metadata.value",
1301 ));
1302 }
1303 w.put_i32((*v129));
1304 }
1305 types::EntityMetadataValue::Float(v130) => {
1306 if !((*v125).r#type == 3) {
1307 return Err(EncodeError::SwitchMismatch(
1308 "play.clientbound.named_entity_spawn.metadata.value",
1309 ));
1310 }
1311 w.put_f32((*v130));
1312 }
1313 types::EntityMetadataValue::String(v131) => {
1314 if !((*v125).r#type == 4) {
1315 return Err(EncodeError::SwitchMismatch(
1316 "play.clientbound.named_entity_spawn.metadata.value",
1317 ));
1318 }
1319 w.put_string(&(*v131))?;
1320 }
1321 types::EntityMetadataValue::Slot(v132) => {
1322 if !((*v125).r#type == 5) {
1323 return Err(EncodeError::SwitchMismatch(
1324 "play.clientbound.named_entity_spawn.metadata.value",
1325 ));
1326 }
1327 (*v132).encode(w)?;
1328 }
1329 types::EntityMetadataValue::BlockPos(v133) => {
1330 if !((*v125).r#type == 6) {
1331 return Err(EncodeError::SwitchMismatch(
1332 "play.clientbound.named_entity_spawn.metadata.value",
1333 ));
1334 }
1335 w.put_i32((*v133).x);
1336 w.put_i32((*v133).y);
1337 w.put_i32((*v133).z);
1338 }
1339 types::EntityMetadataValue::Rotation(v134) => {
1340 if !((*v125).r#type == 7) {
1341 return Err(EncodeError::SwitchMismatch(
1342 "play.clientbound.named_entity_spawn.metadata.value",
1343 ));
1344 }
1345 w.put_f32((*v134).pitch);
1346 w.put_f32((*v134).yaw);
1347 w.put_f32((*v134).roll);
1348 }
1349 types::EntityMetadataValue::Other => {
1350 if !(!(((*v125).r#type == 0)
1351 || ((*v125).r#type == 1)
1352 || ((*v125).r#type == 2)
1353 || ((*v125).r#type == 3)
1354 || ((*v125).r#type == 4)
1355 || ((*v125).r#type == 5)
1356 || ((*v125).r#type == 6)
1357 || ((*v125).r#type == 7)))
1358 {
1359 return Err(EncodeError::SwitchMismatch(
1360 "play.clientbound.named_entity_spawn.metadata.value",
1361 ));
1362 }
1363 }
1364 }
1365 if w.get(v126) == Some(&127) {
1366 return Err(EncodeError::OutOfRange(
1367 "play.clientbound.named_entity_spawn.metadata",
1368 ));
1369 }
1370 }
1371 w.put_u8(127);
1372 Ok(())
1373 }
1374}
1375#[cfg(feature = "testgen")]
1376impl Generate for NamedEntitySpawn {
1377 fn generate(g: &mut Gen) -> Self {
1378 {
1379 let v135 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1380 let v136 = g.uuid();
1381 let v137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1382 let v138 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1383 let v139 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1384 let v140 = (g.int_in(-128, 127, &[]) as i8);
1385 let v141 = (g.int_in(-128, 127, &[]) as i8);
1386 let v142 = (g.int_in(-32768, 32767, &[]) as i16);
1387 let v143 = {
1388 let n = g.count();
1389 let mut v144 = Vec::with_capacity(n);
1390 for _ in 0..n {
1391 v144.push(loop { let v145 = { let v147 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v148 = (g.int_in(0, 31, &[]) as u8);let v149 = (if (v147 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v147 == 1) { types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v147 == 2) { types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v147 == 3) { types::EntityMetadataValue::Float(g.f32()) } else if (v147 == 4) { types::EntityMetadataValue::String(g.string()) } else if (v147 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v147 == 6) { types::EntityMetadataValue::BlockPos({ let v150 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v151 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v152 = (g.int_in(-2147483648, 2147483647, &[]) as i32); types::EntityMetadataValueBlockPos { x: v150, y: v151, z: v152 } }) } else if (v147 == 7) { types::EntityMetadataValue::Rotation({ let v153 = g.f32();let v154 = g.f32();let v155 = g.f32(); types::EntityMetadataValueRotation { pitch: v153, yaw: v154, roll: v155 } }) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { r#type: v147, key: v148, value: v149 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v145.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v145.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v145.value { types::EntityMetadataValue::Byte(v156) => { if !((v145.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v156)); }types::EntityMetadataValue::Short(v157) => { if !((v145.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i16((*v157)); }types::EntityMetadataValue::Int(v158) => { if !((v145.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v158)); }types::EntityMetadataValue::Float(v159) => { if !((v145.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v159)); }types::EntityMetadataValue::String(v160) => { if !((v145.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v160))?; }types::EntityMetadataValue::Slot(v161) => { if !((v145.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v161).encode(w)?; }types::EntityMetadataValue::BlockPos(v162) => { if !((v145.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v162).x);w.put_i32((*v162).y);w.put_i32((*v162).z); }types::EntityMetadataValue::Rotation(v163) => { if !((v145.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v163).pitch);w.put_f32((*v163).yaw);w.put_f32((*v163).roll); }types::EntityMetadataValue::Other => { if !(!((v145.r#type == 0) || (v145.r#type == 1) || (v145.r#type == 2) || (v145.r#type == 3) || (v145.r#type == 4) || (v145.r#type == 5) || (v145.r#type == 6) || (v145.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v145; } });
1392 }
1393 v144
1394 };
1395 NamedEntitySpawn {
1396 entity_id: v135,
1397 player_uuid: v136,
1398 x: v137,
1399 y: v138,
1400 z: v139,
1401 yaw: v140,
1402 pitch: v141,
1403 current_item: v142,
1404 metadata: v143,
1405 }
1406 }
1407 }
1408}
1409impl From<NamedEntitySpawn> for ClientboundPlayPacket {
1410 fn from(p: NamedEntitySpawn) -> Self {
1411 Self::NamedEntitySpawn(p)
1412 }
1413}
1414
1415#[derive(Debug, Clone, PartialEq)]
1417pub struct Collect {
1418 pub collected_entity_id: i32,
1420 pub collector_entity_id: i32,
1422}
1423impl crate::packet::Packet for Collect {
1424 const ID: i32 = id::COLLECT;
1425 const NAME: &'static str = "collect";
1426 const STATE: State = State::Play;
1427 const DIRECTION: Direction = Direction::Clientbound;
1428}
1429impl Decode for Collect {
1430 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1431 Ok({
1432 let v164 = r.read_varint()?;
1433 let v165 = r.read_varint()?;
1434 Collect {
1435 collected_entity_id: v164,
1436 collector_entity_id: v165,
1437 }
1438 })
1439 }
1440}
1441impl Encode for Collect {
1442 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1443 w.put_varint((*self).collected_entity_id);
1444 w.put_varint((*self).collector_entity_id);
1445 Ok(())
1446 }
1447}
1448#[cfg(feature = "testgen")]
1449impl Generate for Collect {
1450 fn generate(g: &mut Gen) -> Self {
1451 {
1452 let v166 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1453 let v167 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1454 Collect {
1455 collected_entity_id: v166,
1456 collector_entity_id: v167,
1457 }
1458 }
1459 }
1460}
1461impl From<Collect> for ClientboundPlayPacket {
1462 fn from(p: Collect) -> Self {
1463 Self::Collect(p)
1464 }
1465}
1466
1467#[derive(Debug, Clone, PartialEq)]
1469pub struct SpawnEntity {
1470 pub entity_id: i32,
1472 pub r#type: i8,
1474 pub x: i32,
1476 pub y: i32,
1478 pub z: i32,
1480 pub pitch: i8,
1482 pub yaw: i8,
1484 pub object_data: i32,
1486 pub velocity: Option<types::Vec3i16>,
1488}
1489impl crate::packet::Packet for SpawnEntity {
1490 const ID: i32 = id::SPAWN_ENTITY;
1491 const NAME: &'static str = "spawn_entity";
1492 const STATE: State = State::Play;
1493 const DIRECTION: Direction = Direction::Clientbound;
1494}
1495impl Decode for SpawnEntity {
1496 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1497 Ok({
1498 let v168 = r.read_varint()?;
1499 let v169 = r.read_i8()?;
1500 let v170 = r.read_i32()?;
1501 let v171 = r.read_i32()?;
1502 let v172 = r.read_i32()?;
1503 let v173 = r.read_i8()?;
1504 let v174 = r.read_i8()?;
1505 let v175 = r.read_i32()?;
1506 let v176 = if (v175 > 0) {
1507 Some(<types::Vec3i16 as Decode>::decode(r)?)
1508 } else {
1509 None
1510 };
1511 SpawnEntity {
1512 entity_id: v168,
1513 r#type: v169,
1514 x: v170,
1515 y: v171,
1516 z: v172,
1517 pitch: v173,
1518 yaw: v174,
1519 object_data: v175,
1520 velocity: v176,
1521 }
1522 })
1523 }
1524}
1525impl Encode for SpawnEntity {
1526 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1527 w.put_varint((*self).entity_id);
1528 w.put_i8((*self).r#type);
1529 w.put_i32((*self).x);
1530 w.put_i32((*self).y);
1531 w.put_i32((*self).z);
1532 w.put_i8((*self).pitch);
1533 w.put_i8((*self).yaw);
1534 w.put_i32((*self).object_data);
1535 match (&(*self).velocity, ((*self).object_data > 0)) {
1536 (Some(v177), true) => {
1537 (*v177).encode(w)?;
1538 }
1539 (None, false) => {}
1540 _ => {
1541 return Err(EncodeError::SwitchMismatch(
1542 "play.clientbound.spawn_entity.velocity",
1543 ));
1544 }
1545 }
1546 Ok(())
1547 }
1548}
1549#[cfg(feature = "testgen")]
1550impl Generate for SpawnEntity {
1551 fn generate(g: &mut Gen) -> Self {
1552 {
1553 let v178 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1554 let v179 = (g.int_in(-128, 127, &[]) as i8);
1555 let v180 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1556 let v181 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1557 let v182 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1558 let v183 = (g.int_in(-128, 127, &[]) as i8);
1559 let v184 = (g.int_in(-128, 127, &[]) as i8);
1560 let v185 = (g.int_in(-2147483648, 2147483647, &[0, 1, -1, 5, -2147483648]) as i32);
1561 let v186 = if (v185 > 0) {
1562 Some(<types::Vec3i16 as Generate>::generate(g))
1563 } else {
1564 None
1565 };
1566 SpawnEntity {
1567 entity_id: v178,
1568 r#type: v179,
1569 x: v180,
1570 y: v181,
1571 z: v182,
1572 pitch: v183,
1573 yaw: v184,
1574 object_data: v185,
1575 velocity: v186,
1576 }
1577 }
1578 }
1579}
1580impl From<SpawnEntity> for ClientboundPlayPacket {
1581 fn from(p: SpawnEntity) -> Self {
1582 Self::SpawnEntity(p)
1583 }
1584}
1585
1586#[derive(Debug, Clone, PartialEq)]
1588pub struct SpawnEntityLiving {
1589 pub entity_id: i32,
1591 pub r#type: u8,
1593 pub x: i32,
1595 pub y: i32,
1597 pub z: i32,
1599 pub yaw: i8,
1601 pub pitch: i8,
1603 pub head_pitch: i8,
1605 pub velocity: types::Vec3i16,
1607 pub metadata: Vec<types::EntityMetadataEntry>,
1609}
1610impl crate::packet::Packet for SpawnEntityLiving {
1611 const ID: i32 = id::SPAWN_ENTITY_LIVING;
1612 const NAME: &'static str = "spawn_entity_living";
1613 const STATE: State = State::Play;
1614 const DIRECTION: Direction = Direction::Clientbound;
1615}
1616impl Decode for SpawnEntityLiving {
1617 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1618 Ok({
1619 let v187 = r.read_varint()?;
1620 let v188 = r.read_u8()?;
1621 let v189 = r.read_i32()?;
1622 let v190 = r.read_i32()?;
1623 let v191 = r.read_i32()?;
1624 let v192 = r.read_i8()?;
1625 let v193 = r.read_i8()?;
1626 let v194 = r.read_i8()?;
1627 let v195 = <types::Vec3i16 as Decode>::decode(r)?;
1628 let v196 = {
1629 let mut v197 = Vec::new();
1630 loop {
1631 if r.peek_u8()? == 127 {
1632 r.skip(1)?;
1633 break;
1634 }
1635 v197.push({
1636 let v198 = u64::from(r.read_u8()?);
1637 let v199 = (((v198 >> 5) & 0x7) as u8);
1638 let v200 = (((v198 >> 0) & 0x1f) as u8);
1639 let v201 = (if (v199 == 0) {
1640 types::EntityMetadataValue::Byte(r.read_i8()?)
1641 } else if (v199 == 1) {
1642 types::EntityMetadataValue::Short(r.read_i16()?)
1643 } else if (v199 == 2) {
1644 types::EntityMetadataValue::Int(r.read_i32()?)
1645 } else if (v199 == 3) {
1646 types::EntityMetadataValue::Float(r.read_f32()?)
1647 } else if (v199 == 4) {
1648 types::EntityMetadataValue::String(r.read_string()?)
1649 } else if (v199 == 5) {
1650 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
1651 } else if (v199 == 6) {
1652 types::EntityMetadataValue::BlockPos({
1653 let v202 = r.read_i32()?;
1654 let v203 = r.read_i32()?;
1655 let v204 = r.read_i32()?;
1656 types::EntityMetadataValueBlockPos {
1657 x: v202,
1658 y: v203,
1659 z: v204,
1660 }
1661 })
1662 } else if (v199 == 7) {
1663 types::EntityMetadataValue::Rotation({
1664 let v205 = r.read_f32()?;
1665 let v206 = r.read_f32()?;
1666 let v207 = r.read_f32()?;
1667 types::EntityMetadataValueRotation {
1668 pitch: v205,
1669 yaw: v206,
1670 roll: v207,
1671 }
1672 })
1673 } else {
1674 types::EntityMetadataValue::Other
1675 });
1676 types::EntityMetadataEntry {
1677 r#type: v199,
1678 key: v200,
1679 value: v201,
1680 }
1681 });
1682 }
1683 v197
1684 };
1685 SpawnEntityLiving {
1686 entity_id: v187,
1687 r#type: v188,
1688 x: v189,
1689 y: v190,
1690 z: v191,
1691 yaw: v192,
1692 pitch: v193,
1693 head_pitch: v194,
1694 velocity: v195,
1695 metadata: v196,
1696 }
1697 })
1698 }
1699}
1700impl Encode for SpawnEntityLiving {
1701 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1702 w.put_varint((*self).entity_id);
1703 w.put_u8((*self).r#type);
1704 w.put_i32((*self).x);
1705 w.put_i32((*self).y);
1706 w.put_i32((*self).z);
1707 w.put_i8((*self).yaw);
1708 w.put_i8((*self).pitch);
1709 w.put_i8((*self).head_pitch);
1710 (*self).velocity.encode(w)?;
1711 for v208 in (*self).metadata.iter() {
1712 let v209 = w.len();
1713 {
1714 let mut bits: u64 = 0;
1715 {
1716 let x = i128::from((*v208).r#type);
1717 if x < 0 || x > 7 {
1718 return Err(EncodeError::OutOfRange("type"));
1719 }
1720 bits = (bits << 3) | ((x as u64) & 0x7);
1721 }
1722 {
1723 let x = i128::from((*v208).key);
1724 if x < 0 || x > 31 {
1725 return Err(EncodeError::OutOfRange("key"));
1726 }
1727 bits = (bits << 5) | ((x as u64) & 0x1f);
1728 }
1729 w.put_u8(bits as u8);
1730 }
1731 match &(*v208).value {
1732 types::EntityMetadataValue::Byte(v210) => {
1733 if !((*v208).r#type == 0) {
1734 return Err(EncodeError::SwitchMismatch(
1735 "play.clientbound.spawn_entity_living.metadata.value",
1736 ));
1737 }
1738 w.put_i8((*v210));
1739 }
1740 types::EntityMetadataValue::Short(v211) => {
1741 if !((*v208).r#type == 1) {
1742 return Err(EncodeError::SwitchMismatch(
1743 "play.clientbound.spawn_entity_living.metadata.value",
1744 ));
1745 }
1746 w.put_i16((*v211));
1747 }
1748 types::EntityMetadataValue::Int(v212) => {
1749 if !((*v208).r#type == 2) {
1750 return Err(EncodeError::SwitchMismatch(
1751 "play.clientbound.spawn_entity_living.metadata.value",
1752 ));
1753 }
1754 w.put_i32((*v212));
1755 }
1756 types::EntityMetadataValue::Float(v213) => {
1757 if !((*v208).r#type == 3) {
1758 return Err(EncodeError::SwitchMismatch(
1759 "play.clientbound.spawn_entity_living.metadata.value",
1760 ));
1761 }
1762 w.put_f32((*v213));
1763 }
1764 types::EntityMetadataValue::String(v214) => {
1765 if !((*v208).r#type == 4) {
1766 return Err(EncodeError::SwitchMismatch(
1767 "play.clientbound.spawn_entity_living.metadata.value",
1768 ));
1769 }
1770 w.put_string(&(*v214))?;
1771 }
1772 types::EntityMetadataValue::Slot(v215) => {
1773 if !((*v208).r#type == 5) {
1774 return Err(EncodeError::SwitchMismatch(
1775 "play.clientbound.spawn_entity_living.metadata.value",
1776 ));
1777 }
1778 (*v215).encode(w)?;
1779 }
1780 types::EntityMetadataValue::BlockPos(v216) => {
1781 if !((*v208).r#type == 6) {
1782 return Err(EncodeError::SwitchMismatch(
1783 "play.clientbound.spawn_entity_living.metadata.value",
1784 ));
1785 }
1786 w.put_i32((*v216).x);
1787 w.put_i32((*v216).y);
1788 w.put_i32((*v216).z);
1789 }
1790 types::EntityMetadataValue::Rotation(v217) => {
1791 if !((*v208).r#type == 7) {
1792 return Err(EncodeError::SwitchMismatch(
1793 "play.clientbound.spawn_entity_living.metadata.value",
1794 ));
1795 }
1796 w.put_f32((*v217).pitch);
1797 w.put_f32((*v217).yaw);
1798 w.put_f32((*v217).roll);
1799 }
1800 types::EntityMetadataValue::Other => {
1801 if !(!(((*v208).r#type == 0)
1802 || ((*v208).r#type == 1)
1803 || ((*v208).r#type == 2)
1804 || ((*v208).r#type == 3)
1805 || ((*v208).r#type == 4)
1806 || ((*v208).r#type == 5)
1807 || ((*v208).r#type == 6)
1808 || ((*v208).r#type == 7)))
1809 {
1810 return Err(EncodeError::SwitchMismatch(
1811 "play.clientbound.spawn_entity_living.metadata.value",
1812 ));
1813 }
1814 }
1815 }
1816 if w.get(v209) == Some(&127) {
1817 return Err(EncodeError::OutOfRange(
1818 "play.clientbound.spawn_entity_living.metadata",
1819 ));
1820 }
1821 }
1822 w.put_u8(127);
1823 Ok(())
1824 }
1825}
1826#[cfg(feature = "testgen")]
1827impl Generate for SpawnEntityLiving {
1828 fn generate(g: &mut Gen) -> Self {
1829 {
1830 let v218 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1831 let v219 = (g.int_in(0, 255, &[]) as u8);
1832 let v220 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1833 let v221 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1834 let v222 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1835 let v223 = (g.int_in(-128, 127, &[]) as i8);
1836 let v224 = (g.int_in(-128, 127, &[]) as i8);
1837 let v225 = (g.int_in(-128, 127, &[]) as i8);
1838 let v226 = <types::Vec3i16 as Generate>::generate(g);
1839 let v227 = {
1840 let n = g.count();
1841 let mut v228 = Vec::with_capacity(n);
1842 for _ in 0..n {
1843 v228.push(loop { let v229 = { let v231 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v232 = (g.int_in(0, 31, &[]) as u8);let v233 = (if (v231 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v231 == 1) { types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v231 == 2) { types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v231 == 3) { types::EntityMetadataValue::Float(g.f32()) } else if (v231 == 4) { types::EntityMetadataValue::String(g.string()) } else if (v231 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v231 == 6) { types::EntityMetadataValue::BlockPos({ let v234 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v235 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v236 = (g.int_in(-2147483648, 2147483647, &[]) as i32); types::EntityMetadataValueBlockPos { x: v234, y: v235, z: v236 } }) } else if (v231 == 7) { types::EntityMetadataValue::Rotation({ let v237 = g.f32();let v238 = g.f32();let v239 = g.f32(); types::EntityMetadataValueRotation { pitch: v237, yaw: v238, roll: v239 } }) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { r#type: v231, key: v232, value: v233 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v229.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v229.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v229.value { types::EntityMetadataValue::Byte(v240) => { if !((v229.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v240)); }types::EntityMetadataValue::Short(v241) => { if !((v229.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i16((*v241)); }types::EntityMetadataValue::Int(v242) => { if !((v229.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v242)); }types::EntityMetadataValue::Float(v243) => { if !((v229.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v243)); }types::EntityMetadataValue::String(v244) => { if !((v229.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v244))?; }types::EntityMetadataValue::Slot(v245) => { if !((v229.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v245).encode(w)?; }types::EntityMetadataValue::BlockPos(v246) => { if !((v229.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v246).x);w.put_i32((*v246).y);w.put_i32((*v246).z); }types::EntityMetadataValue::Rotation(v247) => { if !((v229.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v247).pitch);w.put_f32((*v247).yaw);w.put_f32((*v247).roll); }types::EntityMetadataValue::Other => { if !(!((v229.r#type == 0) || (v229.r#type == 1) || (v229.r#type == 2) || (v229.r#type == 3) || (v229.r#type == 4) || (v229.r#type == 5) || (v229.r#type == 6) || (v229.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v229; } });
1844 }
1845 v228
1846 };
1847 SpawnEntityLiving {
1848 entity_id: v218,
1849 r#type: v219,
1850 x: v220,
1851 y: v221,
1852 z: v222,
1853 yaw: v223,
1854 pitch: v224,
1855 head_pitch: v225,
1856 velocity: v226,
1857 metadata: v227,
1858 }
1859 }
1860 }
1861}
1862impl From<SpawnEntityLiving> for ClientboundPlayPacket {
1863 fn from(p: SpawnEntityLiving) -> Self {
1864 Self::SpawnEntityLiving(p)
1865 }
1866}
1867
1868#[derive(Debug, Clone, PartialEq)]
1870pub struct SpawnEntityPainting {
1871 pub entity_id: i32,
1873 pub title: ByteString,
1875 pub location: BlockPos,
1877 pub direction: u8,
1879}
1880impl crate::packet::Packet for SpawnEntityPainting {
1881 const ID: i32 = id::SPAWN_ENTITY_PAINTING;
1882 const NAME: &'static str = "spawn_entity_painting";
1883 const STATE: State = State::Play;
1884 const DIRECTION: Direction = Direction::Clientbound;
1885}
1886impl Decode for SpawnEntityPainting {
1887 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1888 Ok({
1889 let v248 = r.read_varint()?;
1890 let v249 = r.read_string()?;
1891 let v250 = BlockPos::read(r, PositionLayout::Xyz)?;
1892 let v251 = r.read_u8()?;
1893 SpawnEntityPainting {
1894 entity_id: v248,
1895 title: v249,
1896 location: v250,
1897 direction: v251,
1898 }
1899 })
1900 }
1901}
1902impl Encode for SpawnEntityPainting {
1903 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1904 w.put_varint((*self).entity_id);
1905 w.put_string(&(*self).title)?;
1906 (*self).location.write(w, PositionLayout::Xyz)?;
1907 w.put_u8((*self).direction);
1908 Ok(())
1909 }
1910}
1911#[cfg(feature = "testgen")]
1912impl Generate for SpawnEntityPainting {
1913 fn generate(g: &mut Gen) -> Self {
1914 {
1915 let v252 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1916 let v253 = g.string();
1917 let v254 = g.position();
1918 let v255 = (g.int_in(0, 255, &[]) as u8);
1919 SpawnEntityPainting {
1920 entity_id: v252,
1921 title: v253,
1922 location: v254,
1923 direction: v255,
1924 }
1925 }
1926 }
1927}
1928impl From<SpawnEntityPainting> for ClientboundPlayPacket {
1929 fn from(p: SpawnEntityPainting) -> Self {
1930 Self::SpawnEntityPainting(p)
1931 }
1932}
1933
1934#[derive(Debug, Clone, PartialEq)]
1936pub struct SpawnEntityExperienceOrb {
1937 pub entity_id: i32,
1939 pub x: i32,
1941 pub y: i32,
1943 pub z: i32,
1945 pub count: i16,
1947}
1948impl crate::packet::Packet for SpawnEntityExperienceOrb {
1949 const ID: i32 = id::SPAWN_ENTITY_EXPERIENCE_ORB;
1950 const NAME: &'static str = "spawn_entity_experience_orb";
1951 const STATE: State = State::Play;
1952 const DIRECTION: Direction = Direction::Clientbound;
1953}
1954impl Decode for SpawnEntityExperienceOrb {
1955 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1956 Ok({
1957 let v256 = r.read_varint()?;
1958 let v257 = r.read_i32()?;
1959 let v258 = r.read_i32()?;
1960 let v259 = r.read_i32()?;
1961 let v260 = r.read_i16()?;
1962 SpawnEntityExperienceOrb {
1963 entity_id: v256,
1964 x: v257,
1965 y: v258,
1966 z: v259,
1967 count: v260,
1968 }
1969 })
1970 }
1971}
1972impl Encode for SpawnEntityExperienceOrb {
1973 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1974 w.put_varint((*self).entity_id);
1975 w.put_i32((*self).x);
1976 w.put_i32((*self).y);
1977 w.put_i32((*self).z);
1978 w.put_i16((*self).count);
1979 Ok(())
1980 }
1981}
1982#[cfg(feature = "testgen")]
1983impl Generate for SpawnEntityExperienceOrb {
1984 fn generate(g: &mut Gen) -> Self {
1985 {
1986 let v261 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1987 let v262 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1988 let v263 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1989 let v264 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1990 let v265 = (g.int_in(-32768, 32767, &[]) as i16);
1991 SpawnEntityExperienceOrb {
1992 entity_id: v261,
1993 x: v262,
1994 y: v263,
1995 z: v264,
1996 count: v265,
1997 }
1998 }
1999 }
2000}
2001impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
2002 fn from(p: SpawnEntityExperienceOrb) -> Self {
2003 Self::SpawnEntityExperienceOrb(p)
2004 }
2005}
2006
2007#[derive(Debug, Clone, PartialEq)]
2009pub struct EntityVelocity {
2010 pub entity_id: i32,
2012 pub velocity: types::Vec3i16,
2014}
2015impl crate::packet::Packet for EntityVelocity {
2016 const ID: i32 = id::ENTITY_VELOCITY;
2017 const NAME: &'static str = "entity_velocity";
2018 const STATE: State = State::Play;
2019 const DIRECTION: Direction = Direction::Clientbound;
2020}
2021impl Decode for EntityVelocity {
2022 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2023 Ok({
2024 let v266 = r.read_varint()?;
2025 let v267 = <types::Vec3i16 as Decode>::decode(r)?;
2026 EntityVelocity {
2027 entity_id: v266,
2028 velocity: v267,
2029 }
2030 })
2031 }
2032}
2033impl Encode for EntityVelocity {
2034 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2035 w.put_varint((*self).entity_id);
2036 (*self).velocity.encode(w)?;
2037 Ok(())
2038 }
2039}
2040#[cfg(feature = "testgen")]
2041impl Generate for EntityVelocity {
2042 fn generate(g: &mut Gen) -> Self {
2043 {
2044 let v268 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2045 let v269 = <types::Vec3i16 as Generate>::generate(g);
2046 EntityVelocity {
2047 entity_id: v268,
2048 velocity: v269,
2049 }
2050 }
2051 }
2052}
2053impl From<EntityVelocity> for ClientboundPlayPacket {
2054 fn from(p: EntityVelocity) -> Self {
2055 Self::EntityVelocity(p)
2056 }
2057}
2058
2059#[derive(Debug, Clone, PartialEq)]
2061pub struct EntityDestroy {
2062 pub entity_ids: Vec<i32>,
2064}
2065impl crate::packet::Packet for EntityDestroy {
2066 const ID: i32 = id::ENTITY_DESTROY;
2067 const NAME: &'static str = "entity_destroy";
2068 const STATE: State = State::Play;
2069 const DIRECTION: Direction = Direction::Clientbound;
2070}
2071impl Decode for EntityDestroy {
2072 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2073 Ok({
2074 let v270 = {
2075 let v271 = {
2076 let c = r.read_varint()?;
2077 r.check_count(i64::from(c), 1)?
2078 };
2079 let mut v272 = Vec::with_capacity(v271.min(crate::codec::PREALLOC_LIMIT));
2080 for _ in 0..v271 {
2081 v272.push(r.read_varint()?);
2082 }
2083 v272
2084 };
2085 EntityDestroy { entity_ids: v270 }
2086 })
2087 }
2088}
2089impl Encode for EntityDestroy {
2090 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2091 w.put_len_varint((*self).entity_ids.len())?;
2092 for v273 in (*self).entity_ids.iter() {
2093 w.put_varint((*v273));
2094 }
2095 Ok(())
2096 }
2097}
2098#[cfg(feature = "testgen")]
2099impl Generate for EntityDestroy {
2100 fn generate(g: &mut Gen) -> Self {
2101 {
2102 let v274 = {
2103 let v275 = g.count();
2104 let mut v276 = Vec::with_capacity(v275.min(crate::codec::PREALLOC_LIMIT));
2105 for _ in 0..v275 {
2106 v276.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
2107 }
2108 v276
2109 };
2110 EntityDestroy { entity_ids: v274 }
2111 }
2112 }
2113}
2114impl From<EntityDestroy> for ClientboundPlayPacket {
2115 fn from(p: EntityDestroy) -> Self {
2116 Self::EntityDestroy(p)
2117 }
2118}
2119
2120#[derive(Debug, Clone, PartialEq)]
2122pub struct Entity {
2123 pub entity_id: i32,
2125}
2126impl crate::packet::Packet for Entity {
2127 const ID: i32 = id::ENTITY;
2128 const NAME: &'static str = "entity";
2129 const STATE: State = State::Play;
2130 const DIRECTION: Direction = Direction::Clientbound;
2131}
2132impl Decode for Entity {
2133 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2134 Ok({
2135 let v277 = r.read_varint()?;
2136 Entity { entity_id: v277 }
2137 })
2138 }
2139}
2140impl Encode for Entity {
2141 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2142 w.put_varint((*self).entity_id);
2143 Ok(())
2144 }
2145}
2146#[cfg(feature = "testgen")]
2147impl Generate for Entity {
2148 fn generate(g: &mut Gen) -> Self {
2149 {
2150 let v278 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2151 Entity { entity_id: v278 }
2152 }
2153 }
2154}
2155impl From<Entity> for ClientboundPlayPacket {
2156 fn from(p: Entity) -> Self {
2157 Self::Entity(p)
2158 }
2159}
2160
2161#[derive(Debug, Clone, PartialEq)]
2163pub struct RelEntityMove {
2164 pub entity_id: i32,
2166 pub d_x: i8,
2168 pub d_y: i8,
2170 pub d_z: i8,
2172 pub on_ground: bool,
2174}
2175impl crate::packet::Packet for RelEntityMove {
2176 const ID: i32 = id::REL_ENTITY_MOVE;
2177 const NAME: &'static str = "rel_entity_move";
2178 const STATE: State = State::Play;
2179 const DIRECTION: Direction = Direction::Clientbound;
2180}
2181impl Decode for RelEntityMove {
2182 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2183 Ok({
2184 let v279 = r.read_varint()?;
2185 let v280 = r.read_i8()?;
2186 let v281 = r.read_i8()?;
2187 let v282 = r.read_i8()?;
2188 let v283 = r.read_bool()?;
2189 RelEntityMove {
2190 entity_id: v279,
2191 d_x: v280,
2192 d_y: v281,
2193 d_z: v282,
2194 on_ground: v283,
2195 }
2196 })
2197 }
2198}
2199impl Encode for RelEntityMove {
2200 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2201 w.put_varint((*self).entity_id);
2202 w.put_i8((*self).d_x);
2203 w.put_i8((*self).d_y);
2204 w.put_i8((*self).d_z);
2205 w.put_bool((*self).on_ground);
2206 Ok(())
2207 }
2208}
2209#[cfg(feature = "testgen")]
2210impl Generate for RelEntityMove {
2211 fn generate(g: &mut Gen) -> Self {
2212 {
2213 let v284 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2214 let v285 = (g.int_in(-128, 127, &[]) as i8);
2215 let v286 = (g.int_in(-128, 127, &[]) as i8);
2216 let v287 = (g.int_in(-128, 127, &[]) as i8);
2217 let v288 = g.bool();
2218 RelEntityMove {
2219 entity_id: v284,
2220 d_x: v285,
2221 d_y: v286,
2222 d_z: v287,
2223 on_ground: v288,
2224 }
2225 }
2226 }
2227}
2228impl From<RelEntityMove> for ClientboundPlayPacket {
2229 fn from(p: RelEntityMove) -> Self {
2230 Self::RelEntityMove(p)
2231 }
2232}
2233
2234#[derive(Debug, Clone, PartialEq)]
2236pub struct EntityLook {
2237 pub entity_id: i32,
2239 pub yaw: i8,
2241 pub pitch: i8,
2243 pub on_ground: bool,
2245}
2246impl crate::packet::Packet for EntityLook {
2247 const ID: i32 = id::ENTITY_LOOK;
2248 const NAME: &'static str = "entity_look";
2249 const STATE: State = State::Play;
2250 const DIRECTION: Direction = Direction::Clientbound;
2251}
2252impl Decode for EntityLook {
2253 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2254 Ok({
2255 let v289 = r.read_varint()?;
2256 let v290 = r.read_i8()?;
2257 let v291 = r.read_i8()?;
2258 let v292 = r.read_bool()?;
2259 EntityLook {
2260 entity_id: v289,
2261 yaw: v290,
2262 pitch: v291,
2263 on_ground: v292,
2264 }
2265 })
2266 }
2267}
2268impl Encode for EntityLook {
2269 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2270 w.put_varint((*self).entity_id);
2271 w.put_i8((*self).yaw);
2272 w.put_i8((*self).pitch);
2273 w.put_bool((*self).on_ground);
2274 Ok(())
2275 }
2276}
2277#[cfg(feature = "testgen")]
2278impl Generate for EntityLook {
2279 fn generate(g: &mut Gen) -> Self {
2280 {
2281 let v293 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2282 let v294 = (g.int_in(-128, 127, &[]) as i8);
2283 let v295 = (g.int_in(-128, 127, &[]) as i8);
2284 let v296 = g.bool();
2285 EntityLook {
2286 entity_id: v293,
2287 yaw: v294,
2288 pitch: v295,
2289 on_ground: v296,
2290 }
2291 }
2292 }
2293}
2294impl From<EntityLook> for ClientboundPlayPacket {
2295 fn from(p: EntityLook) -> Self {
2296 Self::EntityLook(p)
2297 }
2298}
2299
2300#[derive(Debug, Clone, PartialEq)]
2302pub struct EntityMoveLook {
2303 pub entity_id: i32,
2305 pub d_x: i8,
2307 pub d_y: i8,
2309 pub d_z: i8,
2311 pub yaw: i8,
2313 pub pitch: i8,
2315 pub on_ground: bool,
2317}
2318impl crate::packet::Packet for EntityMoveLook {
2319 const ID: i32 = id::ENTITY_MOVE_LOOK;
2320 const NAME: &'static str = "entity_move_look";
2321 const STATE: State = State::Play;
2322 const DIRECTION: Direction = Direction::Clientbound;
2323}
2324impl Decode for EntityMoveLook {
2325 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2326 Ok({
2327 let v297 = r.read_varint()?;
2328 let v298 = r.read_i8()?;
2329 let v299 = r.read_i8()?;
2330 let v300 = r.read_i8()?;
2331 let v301 = r.read_i8()?;
2332 let v302 = r.read_i8()?;
2333 let v303 = r.read_bool()?;
2334 EntityMoveLook {
2335 entity_id: v297,
2336 d_x: v298,
2337 d_y: v299,
2338 d_z: v300,
2339 yaw: v301,
2340 pitch: v302,
2341 on_ground: v303,
2342 }
2343 })
2344 }
2345}
2346impl Encode for EntityMoveLook {
2347 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2348 w.put_varint((*self).entity_id);
2349 w.put_i8((*self).d_x);
2350 w.put_i8((*self).d_y);
2351 w.put_i8((*self).d_z);
2352 w.put_i8((*self).yaw);
2353 w.put_i8((*self).pitch);
2354 w.put_bool((*self).on_ground);
2355 Ok(())
2356 }
2357}
2358#[cfg(feature = "testgen")]
2359impl Generate for EntityMoveLook {
2360 fn generate(g: &mut Gen) -> Self {
2361 {
2362 let v304 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2363 let v305 = (g.int_in(-128, 127, &[]) as i8);
2364 let v306 = (g.int_in(-128, 127, &[]) as i8);
2365 let v307 = (g.int_in(-128, 127, &[]) as i8);
2366 let v308 = (g.int_in(-128, 127, &[]) as i8);
2367 let v309 = (g.int_in(-128, 127, &[]) as i8);
2368 let v310 = g.bool();
2369 EntityMoveLook {
2370 entity_id: v304,
2371 d_x: v305,
2372 d_y: v306,
2373 d_z: v307,
2374 yaw: v308,
2375 pitch: v309,
2376 on_ground: v310,
2377 }
2378 }
2379 }
2380}
2381impl From<EntityMoveLook> for ClientboundPlayPacket {
2382 fn from(p: EntityMoveLook) -> Self {
2383 Self::EntityMoveLook(p)
2384 }
2385}
2386
2387#[derive(Debug, Clone, PartialEq)]
2389pub struct EntityTeleport {
2390 pub entity_id: i32,
2392 pub x: i32,
2394 pub y: i32,
2396 pub z: i32,
2398 pub yaw: i8,
2400 pub pitch: i8,
2402 pub on_ground: bool,
2404}
2405impl crate::packet::Packet for EntityTeleport {
2406 const ID: i32 = id::ENTITY_TELEPORT;
2407 const NAME: &'static str = "entity_teleport";
2408 const STATE: State = State::Play;
2409 const DIRECTION: Direction = Direction::Clientbound;
2410}
2411impl Decode for EntityTeleport {
2412 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2413 Ok({
2414 let v311 = r.read_varint()?;
2415 let v312 = r.read_i32()?;
2416 let v313 = r.read_i32()?;
2417 let v314 = r.read_i32()?;
2418 let v315 = r.read_i8()?;
2419 let v316 = r.read_i8()?;
2420 let v317 = r.read_bool()?;
2421 EntityTeleport {
2422 entity_id: v311,
2423 x: v312,
2424 y: v313,
2425 z: v314,
2426 yaw: v315,
2427 pitch: v316,
2428 on_ground: v317,
2429 }
2430 })
2431 }
2432}
2433impl Encode for EntityTeleport {
2434 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2435 w.put_varint((*self).entity_id);
2436 w.put_i32((*self).x);
2437 w.put_i32((*self).y);
2438 w.put_i32((*self).z);
2439 w.put_i8((*self).yaw);
2440 w.put_i8((*self).pitch);
2441 w.put_bool((*self).on_ground);
2442 Ok(())
2443 }
2444}
2445#[cfg(feature = "testgen")]
2446impl Generate for EntityTeleport {
2447 fn generate(g: &mut Gen) -> Self {
2448 {
2449 let v318 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2450 let v319 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2451 let v320 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2452 let v321 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2453 let v322 = (g.int_in(-128, 127, &[]) as i8);
2454 let v323 = (g.int_in(-128, 127, &[]) as i8);
2455 let v324 = g.bool();
2456 EntityTeleport {
2457 entity_id: v318,
2458 x: v319,
2459 y: v320,
2460 z: v321,
2461 yaw: v322,
2462 pitch: v323,
2463 on_ground: v324,
2464 }
2465 }
2466 }
2467}
2468impl From<EntityTeleport> for ClientboundPlayPacket {
2469 fn from(p: EntityTeleport) -> Self {
2470 Self::EntityTeleport(p)
2471 }
2472}
2473
2474#[derive(Debug, Clone, PartialEq)]
2476pub struct EntityHeadRotation {
2477 pub entity_id: i32,
2479 pub head_yaw: i8,
2481}
2482impl crate::packet::Packet for EntityHeadRotation {
2483 const ID: i32 = id::ENTITY_HEAD_ROTATION;
2484 const NAME: &'static str = "entity_head_rotation";
2485 const STATE: State = State::Play;
2486 const DIRECTION: Direction = Direction::Clientbound;
2487}
2488impl Decode for EntityHeadRotation {
2489 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2490 Ok({
2491 let v325 = r.read_varint()?;
2492 let v326 = r.read_i8()?;
2493 EntityHeadRotation {
2494 entity_id: v325,
2495 head_yaw: v326,
2496 }
2497 })
2498 }
2499}
2500impl Encode for EntityHeadRotation {
2501 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2502 w.put_varint((*self).entity_id);
2503 w.put_i8((*self).head_yaw);
2504 Ok(())
2505 }
2506}
2507#[cfg(feature = "testgen")]
2508impl Generate for EntityHeadRotation {
2509 fn generate(g: &mut Gen) -> Self {
2510 {
2511 let v327 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2512 let v328 = (g.int_in(-128, 127, &[]) as i8);
2513 EntityHeadRotation {
2514 entity_id: v327,
2515 head_yaw: v328,
2516 }
2517 }
2518 }
2519}
2520impl From<EntityHeadRotation> for ClientboundPlayPacket {
2521 fn from(p: EntityHeadRotation) -> Self {
2522 Self::EntityHeadRotation(p)
2523 }
2524}
2525
2526#[derive(Debug, Clone, PartialEq)]
2528pub struct EntityStatus {
2529 pub entity_id: i32,
2531 pub entity_status: i8,
2533}
2534impl crate::packet::Packet for EntityStatus {
2535 const ID: i32 = id::ENTITY_STATUS;
2536 const NAME: &'static str = "entity_status";
2537 const STATE: State = State::Play;
2538 const DIRECTION: Direction = Direction::Clientbound;
2539}
2540impl Decode for EntityStatus {
2541 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2542 Ok({
2543 let v329 = r.read_i32()?;
2544 let v330 = r.read_i8()?;
2545 EntityStatus {
2546 entity_id: v329,
2547 entity_status: v330,
2548 }
2549 })
2550 }
2551}
2552impl Encode for EntityStatus {
2553 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2554 w.put_i32((*self).entity_id);
2555 w.put_i8((*self).entity_status);
2556 Ok(())
2557 }
2558}
2559#[cfg(feature = "testgen")]
2560impl Generate for EntityStatus {
2561 fn generate(g: &mut Gen) -> Self {
2562 {
2563 let v331 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2564 let v332 = (g.int_in(-128, 127, &[]) as i8);
2565 EntityStatus {
2566 entity_id: v331,
2567 entity_status: v332,
2568 }
2569 }
2570 }
2571}
2572impl From<EntityStatus> for ClientboundPlayPacket {
2573 fn from(p: EntityStatus) -> Self {
2574 Self::EntityStatus(p)
2575 }
2576}
2577
2578#[derive(Debug, Clone, PartialEq)]
2580pub struct AttachEntity {
2581 pub entity_id: i32,
2583 pub vehicle_id: i32,
2585 pub leash: bool,
2587}
2588impl crate::packet::Packet for AttachEntity {
2589 const ID: i32 = id::ATTACH_ENTITY;
2590 const NAME: &'static str = "attach_entity";
2591 const STATE: State = State::Play;
2592 const DIRECTION: Direction = Direction::Clientbound;
2593}
2594impl Decode for AttachEntity {
2595 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2596 Ok({
2597 let v333 = r.read_i32()?;
2598 let v334 = r.read_i32()?;
2599 let v335 = r.read_bool()?;
2600 AttachEntity {
2601 entity_id: v333,
2602 vehicle_id: v334,
2603 leash: v335,
2604 }
2605 })
2606 }
2607}
2608impl Encode for AttachEntity {
2609 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2610 w.put_i32((*self).entity_id);
2611 w.put_i32((*self).vehicle_id);
2612 w.put_bool((*self).leash);
2613 Ok(())
2614 }
2615}
2616#[cfg(feature = "testgen")]
2617impl Generate for AttachEntity {
2618 fn generate(g: &mut Gen) -> Self {
2619 {
2620 let v336 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2621 let v337 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2622 let v338 = g.bool();
2623 AttachEntity {
2624 entity_id: v336,
2625 vehicle_id: v337,
2626 leash: v338,
2627 }
2628 }
2629 }
2630}
2631impl From<AttachEntity> for ClientboundPlayPacket {
2632 fn from(p: AttachEntity) -> Self {
2633 Self::AttachEntity(p)
2634 }
2635}
2636
2637#[derive(Debug, Clone, PartialEq)]
2639pub struct EntityMetadata {
2640 pub entity_id: i32,
2642 pub metadata: Vec<types::EntityMetadataEntry>,
2644}
2645impl crate::packet::Packet for EntityMetadata {
2646 const ID: i32 = id::ENTITY_METADATA;
2647 const NAME: &'static str = "entity_metadata";
2648 const STATE: State = State::Play;
2649 const DIRECTION: Direction = Direction::Clientbound;
2650}
2651impl Decode for EntityMetadata {
2652 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2653 Ok({
2654 let v339 = r.read_varint()?;
2655 let v340 = {
2656 let mut v341 = Vec::new();
2657 loop {
2658 if r.peek_u8()? == 127 {
2659 r.skip(1)?;
2660 break;
2661 }
2662 v341.push({
2663 let v342 = u64::from(r.read_u8()?);
2664 let v343 = (((v342 >> 5) & 0x7) as u8);
2665 let v344 = (((v342 >> 0) & 0x1f) as u8);
2666 let v345 = (if (v343 == 0) {
2667 types::EntityMetadataValue::Byte(r.read_i8()?)
2668 } else if (v343 == 1) {
2669 types::EntityMetadataValue::Short(r.read_i16()?)
2670 } else if (v343 == 2) {
2671 types::EntityMetadataValue::Int(r.read_i32()?)
2672 } else if (v343 == 3) {
2673 types::EntityMetadataValue::Float(r.read_f32()?)
2674 } else if (v343 == 4) {
2675 types::EntityMetadataValue::String(r.read_string()?)
2676 } else if (v343 == 5) {
2677 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
2678 } else if (v343 == 6) {
2679 types::EntityMetadataValue::BlockPos({
2680 let v346 = r.read_i32()?;
2681 let v347 = r.read_i32()?;
2682 let v348 = r.read_i32()?;
2683 types::EntityMetadataValueBlockPos {
2684 x: v346,
2685 y: v347,
2686 z: v348,
2687 }
2688 })
2689 } else if (v343 == 7) {
2690 types::EntityMetadataValue::Rotation({
2691 let v349 = r.read_f32()?;
2692 let v350 = r.read_f32()?;
2693 let v351 = r.read_f32()?;
2694 types::EntityMetadataValueRotation {
2695 pitch: v349,
2696 yaw: v350,
2697 roll: v351,
2698 }
2699 })
2700 } else {
2701 types::EntityMetadataValue::Other
2702 });
2703 types::EntityMetadataEntry {
2704 r#type: v343,
2705 key: v344,
2706 value: v345,
2707 }
2708 });
2709 }
2710 v341
2711 };
2712 EntityMetadata {
2713 entity_id: v339,
2714 metadata: v340,
2715 }
2716 })
2717 }
2718}
2719impl Encode for EntityMetadata {
2720 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2721 w.put_varint((*self).entity_id);
2722 for v352 in (*self).metadata.iter() {
2723 let v353 = w.len();
2724 {
2725 let mut bits: u64 = 0;
2726 {
2727 let x = i128::from((*v352).r#type);
2728 if x < 0 || x > 7 {
2729 return Err(EncodeError::OutOfRange("type"));
2730 }
2731 bits = (bits << 3) | ((x as u64) & 0x7);
2732 }
2733 {
2734 let x = i128::from((*v352).key);
2735 if x < 0 || x > 31 {
2736 return Err(EncodeError::OutOfRange("key"));
2737 }
2738 bits = (bits << 5) | ((x as u64) & 0x1f);
2739 }
2740 w.put_u8(bits as u8);
2741 }
2742 match &(*v352).value {
2743 types::EntityMetadataValue::Byte(v354) => {
2744 if !((*v352).r#type == 0) {
2745 return Err(EncodeError::SwitchMismatch(
2746 "play.clientbound.entity_metadata.metadata.value",
2747 ));
2748 }
2749 w.put_i8((*v354));
2750 }
2751 types::EntityMetadataValue::Short(v355) => {
2752 if !((*v352).r#type == 1) {
2753 return Err(EncodeError::SwitchMismatch(
2754 "play.clientbound.entity_metadata.metadata.value",
2755 ));
2756 }
2757 w.put_i16((*v355));
2758 }
2759 types::EntityMetadataValue::Int(v356) => {
2760 if !((*v352).r#type == 2) {
2761 return Err(EncodeError::SwitchMismatch(
2762 "play.clientbound.entity_metadata.metadata.value",
2763 ));
2764 }
2765 w.put_i32((*v356));
2766 }
2767 types::EntityMetadataValue::Float(v357) => {
2768 if !((*v352).r#type == 3) {
2769 return Err(EncodeError::SwitchMismatch(
2770 "play.clientbound.entity_metadata.metadata.value",
2771 ));
2772 }
2773 w.put_f32((*v357));
2774 }
2775 types::EntityMetadataValue::String(v358) => {
2776 if !((*v352).r#type == 4) {
2777 return Err(EncodeError::SwitchMismatch(
2778 "play.clientbound.entity_metadata.metadata.value",
2779 ));
2780 }
2781 w.put_string(&(*v358))?;
2782 }
2783 types::EntityMetadataValue::Slot(v359) => {
2784 if !((*v352).r#type == 5) {
2785 return Err(EncodeError::SwitchMismatch(
2786 "play.clientbound.entity_metadata.metadata.value",
2787 ));
2788 }
2789 (*v359).encode(w)?;
2790 }
2791 types::EntityMetadataValue::BlockPos(v360) => {
2792 if !((*v352).r#type == 6) {
2793 return Err(EncodeError::SwitchMismatch(
2794 "play.clientbound.entity_metadata.metadata.value",
2795 ));
2796 }
2797 w.put_i32((*v360).x);
2798 w.put_i32((*v360).y);
2799 w.put_i32((*v360).z);
2800 }
2801 types::EntityMetadataValue::Rotation(v361) => {
2802 if !((*v352).r#type == 7) {
2803 return Err(EncodeError::SwitchMismatch(
2804 "play.clientbound.entity_metadata.metadata.value",
2805 ));
2806 }
2807 w.put_f32((*v361).pitch);
2808 w.put_f32((*v361).yaw);
2809 w.put_f32((*v361).roll);
2810 }
2811 types::EntityMetadataValue::Other => {
2812 if !(!(((*v352).r#type == 0)
2813 || ((*v352).r#type == 1)
2814 || ((*v352).r#type == 2)
2815 || ((*v352).r#type == 3)
2816 || ((*v352).r#type == 4)
2817 || ((*v352).r#type == 5)
2818 || ((*v352).r#type == 6)
2819 || ((*v352).r#type == 7)))
2820 {
2821 return Err(EncodeError::SwitchMismatch(
2822 "play.clientbound.entity_metadata.metadata.value",
2823 ));
2824 }
2825 }
2826 }
2827 if w.get(v353) == Some(&127) {
2828 return Err(EncodeError::OutOfRange(
2829 "play.clientbound.entity_metadata.metadata",
2830 ));
2831 }
2832 }
2833 w.put_u8(127);
2834 Ok(())
2835 }
2836}
2837#[cfg(feature = "testgen")]
2838impl Generate for EntityMetadata {
2839 fn generate(g: &mut Gen) -> Self {
2840 {
2841 let v362 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2842 let v363 = {
2843 let n = g.count();
2844 let mut v364 = Vec::with_capacity(n);
2845 for _ in 0..n {
2846 v364.push(loop {
2847 let v365 = {
2848 let v367 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);
2849 let v368 = (g.int_in(0, 31, &[]) as u8);
2850 let v369 = (if (v367 == 0) {
2851 types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
2852 } else if (v367 == 1) {
2853 types::EntityMetadataValue::Short(
2854 (g.int_in(-32768, 32767, &[]) as i16),
2855 )
2856 } else if (v367 == 2) {
2857 types::EntityMetadataValue::Int(
2858 (g.int_in(-2147483648, 2147483647, &[]) as i32),
2859 )
2860 } else if (v367 == 3) {
2861 types::EntityMetadataValue::Float(g.f32())
2862 } else if (v367 == 4) {
2863 types::EntityMetadataValue::String(g.string())
2864 } else if (v367 == 5) {
2865 types::EntityMetadataValue::Slot(
2866 <types::Slot as Generate>::generate(g),
2867 )
2868 } else if (v367 == 6) {
2869 types::EntityMetadataValue::BlockPos({
2870 let v370 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2871 let v371 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2872 let v372 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2873 types::EntityMetadataValueBlockPos {
2874 x: v370,
2875 y: v371,
2876 z: v372,
2877 }
2878 })
2879 } else if (v367 == 7) {
2880 types::EntityMetadataValue::Rotation({
2881 let v373 = g.f32();
2882 let v374 = g.f32();
2883 let v375 = g.f32();
2884 types::EntityMetadataValueRotation {
2885 pitch: v373,
2886 yaw: v374,
2887 roll: v375,
2888 }
2889 })
2890 } else {
2891 types::EntityMetadataValue::Other
2892 });
2893 types::EntityMetadataEntry {
2894 r#type: v367,
2895 key: v368,
2896 value: v369,
2897 }
2898 };
2899 if crate::testgen::first_byte_ok(
2900 |w: &mut BytesMut| -> EncodeResult {
2901 {
2902 let mut bits: u64 = 0;
2903 {
2904 let x = i128::from(v365.r#type);
2905 if x < 0 || x > 7 {
2906 return Err(EncodeError::OutOfRange("type"));
2907 }
2908 bits = (bits << 3) | ((x as u64) & 0x7);
2909 }
2910 {
2911 let x = i128::from(v365.key);
2912 if x < 0 || x > 31 {
2913 return Err(EncodeError::OutOfRange("key"));
2914 }
2915 bits = (bits << 5) | ((x as u64) & 0x1f);
2916 }
2917 w.put_u8(bits as u8);
2918 }
2919 match &v365.value {
2920 types::EntityMetadataValue::Byte(v376) => {
2921 if !(v365.r#type == 0) {
2922 return Err(EncodeError::SwitchMismatch(
2923 "play.clientbound.entity_metadata.metadata.value",
2924 ));
2925 }
2926 w.put_i8((*v376));
2927 }
2928 types::EntityMetadataValue::Short(v377) => {
2929 if !(v365.r#type == 1) {
2930 return Err(EncodeError::SwitchMismatch(
2931 "play.clientbound.entity_metadata.metadata.value",
2932 ));
2933 }
2934 w.put_i16((*v377));
2935 }
2936 types::EntityMetadataValue::Int(v378) => {
2937 if !(v365.r#type == 2) {
2938 return Err(EncodeError::SwitchMismatch(
2939 "play.clientbound.entity_metadata.metadata.value",
2940 ));
2941 }
2942 w.put_i32((*v378));
2943 }
2944 types::EntityMetadataValue::Float(v379) => {
2945 if !(v365.r#type == 3) {
2946 return Err(EncodeError::SwitchMismatch(
2947 "play.clientbound.entity_metadata.metadata.value",
2948 ));
2949 }
2950 w.put_f32((*v379));
2951 }
2952 types::EntityMetadataValue::String(v380) => {
2953 if !(v365.r#type == 4) {
2954 return Err(EncodeError::SwitchMismatch(
2955 "play.clientbound.entity_metadata.metadata.value",
2956 ));
2957 }
2958 w.put_string(&(*v380))?;
2959 }
2960 types::EntityMetadataValue::Slot(v381) => {
2961 if !(v365.r#type == 5) {
2962 return Err(EncodeError::SwitchMismatch(
2963 "play.clientbound.entity_metadata.metadata.value",
2964 ));
2965 }
2966 (*v381).encode(w)?;
2967 }
2968 types::EntityMetadataValue::BlockPos(v382) => {
2969 if !(v365.r#type == 6) {
2970 return Err(EncodeError::SwitchMismatch(
2971 "play.clientbound.entity_metadata.metadata.value",
2972 ));
2973 }
2974 w.put_i32((*v382).x);
2975 w.put_i32((*v382).y);
2976 w.put_i32((*v382).z);
2977 }
2978 types::EntityMetadataValue::Rotation(v383) => {
2979 if !(v365.r#type == 7) {
2980 return Err(EncodeError::SwitchMismatch(
2981 "play.clientbound.entity_metadata.metadata.value",
2982 ));
2983 }
2984 w.put_f32((*v383).pitch);
2985 w.put_f32((*v383).yaw);
2986 w.put_f32((*v383).roll);
2987 }
2988 types::EntityMetadataValue::Other => {
2989 if !(!((v365.r#type == 0)
2990 || (v365.r#type == 1)
2991 || (v365.r#type == 2)
2992 || (v365.r#type == 3)
2993 || (v365.r#type == 4)
2994 || (v365.r#type == 5)
2995 || (v365.r#type == 6)
2996 || (v365.r#type == 7)))
2997 {
2998 return Err(EncodeError::SwitchMismatch(
2999 "play.clientbound.entity_metadata.metadata.value",
3000 ));
3001 }
3002 }
3003 }
3004 Ok(())
3005 },
3006 |b| b != 127,
3007 ) {
3008 break v365;
3009 }
3010 });
3011 }
3012 v364
3013 };
3014 EntityMetadata {
3015 entity_id: v362,
3016 metadata: v363,
3017 }
3018 }
3019 }
3020}
3021impl From<EntityMetadata> for ClientboundPlayPacket {
3022 fn from(p: EntityMetadata) -> Self {
3023 Self::EntityMetadata(p)
3024 }
3025}
3026
3027#[derive(Debug, Clone, PartialEq)]
3029pub struct EntityEffect {
3030 pub entity_id: i32,
3032 pub effect_id: i8,
3034 pub amplifier: i8,
3036 pub duration: i32,
3038 pub hide_particles: bool,
3040}
3041impl crate::packet::Packet for EntityEffect {
3042 const ID: i32 = id::ENTITY_EFFECT;
3043 const NAME: &'static str = "entity_effect";
3044 const STATE: State = State::Play;
3045 const DIRECTION: Direction = Direction::Clientbound;
3046}
3047impl Decode for EntityEffect {
3048 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3049 Ok({
3050 let v384 = r.read_varint()?;
3051 let v385 = r.read_i8()?;
3052 let v386 = r.read_i8()?;
3053 let v387 = r.read_varint()?;
3054 let v388 = r.read_bool()?;
3055 EntityEffect {
3056 entity_id: v384,
3057 effect_id: v385,
3058 amplifier: v386,
3059 duration: v387,
3060 hide_particles: v388,
3061 }
3062 })
3063 }
3064}
3065impl Encode for EntityEffect {
3066 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3067 w.put_varint((*self).entity_id);
3068 w.put_i8((*self).effect_id);
3069 w.put_i8((*self).amplifier);
3070 w.put_varint((*self).duration);
3071 w.put_bool((*self).hide_particles);
3072 Ok(())
3073 }
3074}
3075#[cfg(feature = "testgen")]
3076impl Generate for EntityEffect {
3077 fn generate(g: &mut Gen) -> Self {
3078 {
3079 let v389 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3080 let v390 = (g.int_in(-128, 127, &[]) as i8);
3081 let v391 = (g.int_in(-128, 127, &[]) as i8);
3082 let v392 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3083 let v393 = g.bool();
3084 EntityEffect {
3085 entity_id: v389,
3086 effect_id: v390,
3087 amplifier: v391,
3088 duration: v392,
3089 hide_particles: v393,
3090 }
3091 }
3092 }
3093}
3094impl From<EntityEffect> for ClientboundPlayPacket {
3095 fn from(p: EntityEffect) -> Self {
3096 Self::EntityEffect(p)
3097 }
3098}
3099
3100#[derive(Debug, Clone, PartialEq)]
3102pub struct RemoveEntityEffect {
3103 pub entity_id: i32,
3105 pub effect_id: i8,
3107}
3108impl crate::packet::Packet for RemoveEntityEffect {
3109 const ID: i32 = id::REMOVE_ENTITY_EFFECT;
3110 const NAME: &'static str = "remove_entity_effect";
3111 const STATE: State = State::Play;
3112 const DIRECTION: Direction = Direction::Clientbound;
3113}
3114impl Decode for RemoveEntityEffect {
3115 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3116 Ok({
3117 let v394 = r.read_varint()?;
3118 let v395 = r.read_i8()?;
3119 RemoveEntityEffect {
3120 entity_id: v394,
3121 effect_id: v395,
3122 }
3123 })
3124 }
3125}
3126impl Encode for RemoveEntityEffect {
3127 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3128 w.put_varint((*self).entity_id);
3129 w.put_i8((*self).effect_id);
3130 Ok(())
3131 }
3132}
3133#[cfg(feature = "testgen")]
3134impl Generate for RemoveEntityEffect {
3135 fn generate(g: &mut Gen) -> Self {
3136 {
3137 let v396 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3138 let v397 = (g.int_in(-128, 127, &[]) as i8);
3139 RemoveEntityEffect {
3140 entity_id: v396,
3141 effect_id: v397,
3142 }
3143 }
3144 }
3145}
3146impl From<RemoveEntityEffect> for ClientboundPlayPacket {
3147 fn from(p: RemoveEntityEffect) -> Self {
3148 Self::RemoveEntityEffect(p)
3149 }
3150}
3151
3152#[derive(Debug, Clone, PartialEq)]
3154pub struct Experience {
3155 pub experience_bar: f32,
3157 pub level: i32,
3159 pub total_experience: i32,
3161}
3162impl crate::packet::Packet for Experience {
3163 const ID: i32 = id::EXPERIENCE;
3164 const NAME: &'static str = "experience";
3165 const STATE: State = State::Play;
3166 const DIRECTION: Direction = Direction::Clientbound;
3167}
3168impl Decode for Experience {
3169 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3170 Ok({
3171 let v398 = r.read_f32()?;
3172 let v399 = r.read_varint()?;
3173 let v400 = r.read_varint()?;
3174 Experience {
3175 experience_bar: v398,
3176 level: v399,
3177 total_experience: v400,
3178 }
3179 })
3180 }
3181}
3182impl Encode for Experience {
3183 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3184 w.put_f32((*self).experience_bar);
3185 w.put_varint((*self).level);
3186 w.put_varint((*self).total_experience);
3187 Ok(())
3188 }
3189}
3190#[cfg(feature = "testgen")]
3191impl Generate for Experience {
3192 fn generate(g: &mut Gen) -> Self {
3193 {
3194 let v401 = g.f32();
3195 let v402 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3196 let v403 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3197 Experience {
3198 experience_bar: v401,
3199 level: v402,
3200 total_experience: v403,
3201 }
3202 }
3203 }
3204}
3205impl From<Experience> for ClientboundPlayPacket {
3206 fn from(p: Experience) -> Self {
3207 Self::Experience(p)
3208 }
3209}
3210
3211#[derive(Debug, Clone, PartialEq)]
3213pub struct UpdateAttributes {
3214 pub entity_id: i32,
3216 pub properties: Vec<UpdateAttributesProperties>,
3218}
3219impl crate::packet::Packet for UpdateAttributes {
3220 const ID: i32 = id::UPDATE_ATTRIBUTES;
3221 const NAME: &'static str = "update_attributes";
3222 const STATE: State = State::Play;
3223 const DIRECTION: Direction = Direction::Clientbound;
3224}
3225impl Decode for UpdateAttributes {
3226 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3227 Ok({
3228 let v404 = r.read_varint()?;
3229 let v405 = {
3230 let v406 = {
3231 let c = r.read_i32()?;
3232 r.check_count(i64::from(c), 10)?
3233 };
3234 let mut v407 = Vec::with_capacity(v406.min(crate::codec::PREALLOC_LIMIT));
3235 for _ in 0..v406 {
3236 v407.push({
3237 let v408 = r.read_string()?;
3238 let v409 = r.read_f64()?;
3239 let v410 = {
3240 let v411 = {
3241 let c = r.read_varint()?;
3242 r.check_count(i64::from(c), 25)?
3243 };
3244 let mut v412 =
3245 Vec::with_capacity(v411.min(crate::codec::PREALLOC_LIMIT));
3246 for _ in 0..v411 {
3247 v412.push({
3248 let v413 = r.read_uuid()?;
3249 let v414 = r.read_f64()?;
3250 let v415 = r.read_i8()?;
3251 UpdateAttributesPropertiesModifiers {
3252 uuid: v413,
3253 amount: v414,
3254 operation: v415,
3255 }
3256 });
3257 }
3258 v412
3259 };
3260 UpdateAttributesProperties {
3261 key: v408,
3262 value: v409,
3263 modifiers: v410,
3264 }
3265 });
3266 }
3267 v407
3268 };
3269 UpdateAttributes {
3270 entity_id: v404,
3271 properties: v405,
3272 }
3273 })
3274 }
3275}
3276impl Encode for UpdateAttributes {
3277 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3278 w.put_varint((*self).entity_id);
3279 w.put_i32(crate::codec::count_i32((*self).properties.len())?);
3280 for v416 in (*self).properties.iter() {
3281 w.put_string(&(*v416).key)?;
3282 w.put_f64((*v416).value);
3283 w.put_len_varint((*v416).modifiers.len())?;
3284 for v417 in (*v416).modifiers.iter() {
3285 w.put_uuid(&(*v417).uuid);
3286 w.put_f64((*v417).amount);
3287 w.put_i8((*v417).operation);
3288 }
3289 }
3290 Ok(())
3291 }
3292}
3293#[cfg(feature = "testgen")]
3294impl Generate for UpdateAttributes {
3295 fn generate(g: &mut Gen) -> Self {
3296 {
3297 let v418 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3298 let v419 = {
3299 let v420 = g.count();
3300 let mut v421 = Vec::with_capacity(v420.min(crate::codec::PREALLOC_LIMIT));
3301 for _ in 0..v420 {
3302 v421.push({
3303 let v422 = g.string();
3304 let v423 = g.f64();
3305 let v424 = {
3306 let v425 = g.count();
3307 let mut v426 =
3308 Vec::with_capacity(v425.min(crate::codec::PREALLOC_LIMIT));
3309 for _ in 0..v425 {
3310 v426.push({
3311 let v427 = g.uuid();
3312 let v428 = g.f64();
3313 let v429 = (g.int_in(-128, 127, &[]) as i8);
3314 UpdateAttributesPropertiesModifiers {
3315 uuid: v427,
3316 amount: v428,
3317 operation: v429,
3318 }
3319 });
3320 }
3321 v426
3322 };
3323 UpdateAttributesProperties {
3324 key: v422,
3325 value: v423,
3326 modifiers: v424,
3327 }
3328 });
3329 }
3330 v421
3331 };
3332 UpdateAttributes {
3333 entity_id: v418,
3334 properties: v419,
3335 }
3336 }
3337 }
3338}
3339impl From<UpdateAttributes> for ClientboundPlayPacket {
3340 fn from(p: UpdateAttributes) -> Self {
3341 Self::UpdateAttributes(p)
3342 }
3343}
3344
3345#[derive(Debug, Clone, PartialEq)]
3347pub struct MapChunk {
3348 pub x: i32,
3350 pub z: i32,
3352 pub ground_up: bool,
3354 pub bit_map: u16,
3356 pub chunk_data: Bytes,
3358}
3359impl crate::packet::Packet for MapChunk {
3360 const ID: i32 = id::MAP_CHUNK;
3361 const NAME: &'static str = "map_chunk";
3362 const STATE: State = State::Play;
3363 const DIRECTION: Direction = Direction::Clientbound;
3364}
3365impl Decode for MapChunk {
3366 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3367 Ok({
3368 let v430 = r.read_i32()?;
3369 let v431 = r.read_i32()?;
3370 let v432 = r.read_bool()?;
3371 let v433 = r.read_u16()?;
3372 let v434 = r.read_byte_array()?;
3373 MapChunk {
3374 x: v430,
3375 z: v431,
3376 ground_up: v432,
3377 bit_map: v433,
3378 chunk_data: v434,
3379 }
3380 })
3381 }
3382}
3383impl Encode for MapChunk {
3384 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3385 w.put_i32((*self).x);
3386 w.put_i32((*self).z);
3387 w.put_bool((*self).ground_up);
3388 w.put_u16((*self).bit_map);
3389 w.put_byte_array(&(*self).chunk_data)?;
3390 Ok(())
3391 }
3392}
3393#[cfg(feature = "testgen")]
3394impl Generate for MapChunk {
3395 fn generate(g: &mut Gen) -> Self {
3396 {
3397 let v435 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3398 let v436 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3399 let v437 = g.bool();
3400 let v438 = (g.int_in(0, 65535, &[]) as u16);
3401 let v439 = g.bytes();
3402 MapChunk {
3403 x: v435,
3404 z: v436,
3405 ground_up: v437,
3406 bit_map: v438,
3407 chunk_data: v439,
3408 }
3409 }
3410 }
3411}
3412impl From<MapChunk> for ClientboundPlayPacket {
3413 fn from(p: MapChunk) -> Self {
3414 Self::MapChunk(p)
3415 }
3416}
3417
3418#[derive(Debug, Clone, PartialEq)]
3420pub struct MultiBlockChange {
3421 pub chunk_x: i32,
3423 pub chunk_z: i32,
3425 pub records: Vec<MultiBlockChangeRecords>,
3427}
3428impl crate::packet::Packet for MultiBlockChange {
3429 const ID: i32 = id::MULTI_BLOCK_CHANGE;
3430 const NAME: &'static str = "multi_block_change";
3431 const STATE: State = State::Play;
3432 const DIRECTION: Direction = Direction::Clientbound;
3433}
3434impl Decode for MultiBlockChange {
3435 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3436 Ok({
3437 let v440 = r.read_i32()?;
3438 let v441 = r.read_i32()?;
3439 let v442 = {
3440 let v443 = {
3441 let c = r.read_varint()?;
3442 r.check_count(i64::from(c), 3)?
3443 };
3444 let mut v444 = Vec::with_capacity(v443.min(crate::codec::PREALLOC_LIMIT));
3445 for _ in 0..v443 {
3446 v444.push({
3447 let v445 = r.read_u8()?;
3448 let v446 = r.read_u8()?;
3449 let v447 = r.read_varint()?;
3450 MultiBlockChangeRecords {
3451 horizontal_pos: v445,
3452 y: v446,
3453 block_id: v447,
3454 }
3455 });
3456 }
3457 v444
3458 };
3459 MultiBlockChange {
3460 chunk_x: v440,
3461 chunk_z: v441,
3462 records: v442,
3463 }
3464 })
3465 }
3466}
3467impl Encode for MultiBlockChange {
3468 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3469 w.put_i32((*self).chunk_x);
3470 w.put_i32((*self).chunk_z);
3471 w.put_len_varint((*self).records.len())?;
3472 for v448 in (*self).records.iter() {
3473 w.put_u8((*v448).horizontal_pos);
3474 w.put_u8((*v448).y);
3475 w.put_varint((*v448).block_id);
3476 }
3477 Ok(())
3478 }
3479}
3480#[cfg(feature = "testgen")]
3481impl Generate for MultiBlockChange {
3482 fn generate(g: &mut Gen) -> Self {
3483 {
3484 let v449 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3485 let v450 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3486 let v451 = {
3487 let v452 = g.count();
3488 let mut v453 = Vec::with_capacity(v452.min(crate::codec::PREALLOC_LIMIT));
3489 for _ in 0..v452 {
3490 v453.push({
3491 let v454 = (g.int_in(0, 255, &[]) as u8);
3492 let v455 = (g.int_in(0, 255, &[]) as u8);
3493 let v456 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3494 MultiBlockChangeRecords {
3495 horizontal_pos: v454,
3496 y: v455,
3497 block_id: v456,
3498 }
3499 });
3500 }
3501 v453
3502 };
3503 MultiBlockChange {
3504 chunk_x: v449,
3505 chunk_z: v450,
3506 records: v451,
3507 }
3508 }
3509 }
3510}
3511impl From<MultiBlockChange> for ClientboundPlayPacket {
3512 fn from(p: MultiBlockChange) -> Self {
3513 Self::MultiBlockChange(p)
3514 }
3515}
3516
3517#[derive(Debug, Clone, PartialEq)]
3519pub struct BlockChange {
3520 pub location: BlockPos,
3522 pub r#type: i32,
3524}
3525impl crate::packet::Packet for BlockChange {
3526 const ID: i32 = id::BLOCK_CHANGE;
3527 const NAME: &'static str = "block_change";
3528 const STATE: State = State::Play;
3529 const DIRECTION: Direction = Direction::Clientbound;
3530}
3531impl Decode for BlockChange {
3532 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3533 Ok({
3534 let v457 = BlockPos::read(r, PositionLayout::Xyz)?;
3535 let v458 = r.read_varint()?;
3536 BlockChange {
3537 location: v457,
3538 r#type: v458,
3539 }
3540 })
3541 }
3542}
3543impl Encode for BlockChange {
3544 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3545 (*self).location.write(w, PositionLayout::Xyz)?;
3546 w.put_varint((*self).r#type);
3547 Ok(())
3548 }
3549}
3550#[cfg(feature = "testgen")]
3551impl Generate for BlockChange {
3552 fn generate(g: &mut Gen) -> Self {
3553 {
3554 let v459 = g.position();
3555 let v460 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3556 BlockChange {
3557 location: v459,
3558 r#type: v460,
3559 }
3560 }
3561 }
3562}
3563impl From<BlockChange> for ClientboundPlayPacket {
3564 fn from(p: BlockChange) -> Self {
3565 Self::BlockChange(p)
3566 }
3567}
3568
3569#[derive(Debug, Clone, PartialEq)]
3571pub struct BlockAction {
3572 pub location: BlockPos,
3574 pub byte1: u8,
3576 pub byte2: u8,
3578 pub block_id: i32,
3580}
3581impl crate::packet::Packet for BlockAction {
3582 const ID: i32 = id::BLOCK_ACTION;
3583 const NAME: &'static str = "block_action";
3584 const STATE: State = State::Play;
3585 const DIRECTION: Direction = Direction::Clientbound;
3586}
3587impl Decode for BlockAction {
3588 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3589 Ok({
3590 let v461 = BlockPos::read(r, PositionLayout::Xyz)?;
3591 let v462 = r.read_u8()?;
3592 let v463 = r.read_u8()?;
3593 let v464 = r.read_varint()?;
3594 BlockAction {
3595 location: v461,
3596 byte1: v462,
3597 byte2: v463,
3598 block_id: v464,
3599 }
3600 })
3601 }
3602}
3603impl Encode for BlockAction {
3604 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3605 (*self).location.write(w, PositionLayout::Xyz)?;
3606 w.put_u8((*self).byte1);
3607 w.put_u8((*self).byte2);
3608 w.put_varint((*self).block_id);
3609 Ok(())
3610 }
3611}
3612#[cfg(feature = "testgen")]
3613impl Generate for BlockAction {
3614 fn generate(g: &mut Gen) -> Self {
3615 {
3616 let v465 = g.position();
3617 let v466 = (g.int_in(0, 255, &[]) as u8);
3618 let v467 = (g.int_in(0, 255, &[]) as u8);
3619 let v468 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3620 BlockAction {
3621 location: v465,
3622 byte1: v466,
3623 byte2: v467,
3624 block_id: v468,
3625 }
3626 }
3627 }
3628}
3629impl From<BlockAction> for ClientboundPlayPacket {
3630 fn from(p: BlockAction) -> Self {
3631 Self::BlockAction(p)
3632 }
3633}
3634
3635#[derive(Debug, Clone, PartialEq)]
3637pub struct BlockBreakAnimation {
3638 pub entity_id: i32,
3640 pub location: BlockPos,
3642 pub destroy_stage: i8,
3644}
3645impl crate::packet::Packet for BlockBreakAnimation {
3646 const ID: i32 = id::BLOCK_BREAK_ANIMATION;
3647 const NAME: &'static str = "block_break_animation";
3648 const STATE: State = State::Play;
3649 const DIRECTION: Direction = Direction::Clientbound;
3650}
3651impl Decode for BlockBreakAnimation {
3652 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3653 Ok({
3654 let v469 = r.read_varint()?;
3655 let v470 = BlockPos::read(r, PositionLayout::Xyz)?;
3656 let v471 = r.read_i8()?;
3657 BlockBreakAnimation {
3658 entity_id: v469,
3659 location: v470,
3660 destroy_stage: v471,
3661 }
3662 })
3663 }
3664}
3665impl Encode for BlockBreakAnimation {
3666 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3667 w.put_varint((*self).entity_id);
3668 (*self).location.write(w, PositionLayout::Xyz)?;
3669 w.put_i8((*self).destroy_stage);
3670 Ok(())
3671 }
3672}
3673#[cfg(feature = "testgen")]
3674impl Generate for BlockBreakAnimation {
3675 fn generate(g: &mut Gen) -> Self {
3676 {
3677 let v472 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3678 let v473 = g.position();
3679 let v474 = (g.int_in(-128, 127, &[]) as i8);
3680 BlockBreakAnimation {
3681 entity_id: v472,
3682 location: v473,
3683 destroy_stage: v474,
3684 }
3685 }
3686 }
3687}
3688impl From<BlockBreakAnimation> for ClientboundPlayPacket {
3689 fn from(p: BlockBreakAnimation) -> Self {
3690 Self::BlockBreakAnimation(p)
3691 }
3692}
3693
3694#[derive(Debug, Clone, PartialEq)]
3696pub struct MapChunkBulk {
3697 pub sky_light_sent: bool,
3699 pub meta: Vec<MapChunkBulkMeta>,
3701 pub data: Bytes,
3703}
3704impl crate::packet::Packet for MapChunkBulk {
3705 const ID: i32 = id::MAP_CHUNK_BULK;
3706 const NAME: &'static str = "map_chunk_bulk";
3707 const STATE: State = State::Play;
3708 const DIRECTION: Direction = Direction::Clientbound;
3709}
3710impl Decode for MapChunkBulk {
3711 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3712 Ok({
3713 let v475 = r.read_bool()?;
3714 let v476 = {
3715 let v477 = {
3716 let c = r.read_varint()?;
3717 r.check_count(i64::from(c), 10)?
3718 };
3719 let mut v478 = Vec::with_capacity(v477.min(crate::codec::PREALLOC_LIMIT));
3720 for _ in 0..v477 {
3721 v478.push({
3722 let v479 = r.read_i32()?;
3723 let v480 = r.read_i32()?;
3724 let v481 = r.read_u16()?;
3725 MapChunkBulkMeta {
3726 x: v479,
3727 z: v480,
3728 bit_map: v481,
3729 }
3730 });
3731 }
3732 v478
3733 };
3734 let v482 = r.read_rest();
3735 MapChunkBulk {
3736 sky_light_sent: v475,
3737 meta: v476,
3738 data: v482,
3739 }
3740 })
3741 }
3742}
3743impl Encode for MapChunkBulk {
3744 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3745 w.put_bool((*self).sky_light_sent);
3746 w.put_len_varint((*self).meta.len())?;
3747 for v483 in (*self).meta.iter() {
3748 w.put_i32((*v483).x);
3749 w.put_i32((*v483).z);
3750 w.put_u16((*v483).bit_map);
3751 }
3752 w.put_slice(&(*self).data);
3753 Ok(())
3754 }
3755}
3756#[cfg(feature = "testgen")]
3757impl Generate for MapChunkBulk {
3758 fn generate(g: &mut Gen) -> Self {
3759 {
3760 let v484 = g.bool();
3761 let v485 = {
3762 let v486 = g.count();
3763 let mut v487 = Vec::with_capacity(v486.min(crate::codec::PREALLOC_LIMIT));
3764 for _ in 0..v486 {
3765 v487.push({
3766 let v488 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3767 let v489 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3768 let v490 = (g.int_in(0, 65535, &[]) as u16);
3769 MapChunkBulkMeta {
3770 x: v488,
3771 z: v489,
3772 bit_map: v490,
3773 }
3774 });
3775 }
3776 v487
3777 };
3778 let v491 = g.bytes();
3779 MapChunkBulk {
3780 sky_light_sent: v484,
3781 meta: v485,
3782 data: v491,
3783 }
3784 }
3785 }
3786}
3787impl From<MapChunkBulk> for ClientboundPlayPacket {
3788 fn from(p: MapChunkBulk) -> Self {
3789 Self::MapChunkBulk(p)
3790 }
3791}
3792
3793#[derive(Debug, Clone, PartialEq)]
3795pub struct Explosion {
3796 pub x: f32,
3798 pub y: f32,
3800 pub z: f32,
3802 pub radius: f32,
3804 pub affected_block_offsets: Vec<ExplosionAffectedBlockOffsets>,
3806 pub player_motion_x: f32,
3808 pub player_motion_y: f32,
3810 pub player_motion_z: f32,
3812}
3813impl crate::packet::Packet for Explosion {
3814 const ID: i32 = id::EXPLOSION;
3815 const NAME: &'static str = "explosion";
3816 const STATE: State = State::Play;
3817 const DIRECTION: Direction = Direction::Clientbound;
3818}
3819impl Decode for Explosion {
3820 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3821 Ok({
3822 let v492 = r.read_f32()?;
3823 let v493 = r.read_f32()?;
3824 let v494 = r.read_f32()?;
3825 let v495 = r.read_f32()?;
3826 let v496 = {
3827 let v497 = {
3828 let c = r.read_i32()?;
3829 r.check_count(i64::from(c), 3)?
3830 };
3831 let mut v498 = Vec::with_capacity(v497.min(crate::codec::PREALLOC_LIMIT));
3832 for _ in 0..v497 {
3833 v498.push({
3834 let v499 = r.read_i8()?;
3835 let v500 = r.read_i8()?;
3836 let v501 = r.read_i8()?;
3837 ExplosionAffectedBlockOffsets {
3838 x: v499,
3839 y: v500,
3840 z: v501,
3841 }
3842 });
3843 }
3844 v498
3845 };
3846 let v502 = r.read_f32()?;
3847 let v503 = r.read_f32()?;
3848 let v504 = r.read_f32()?;
3849 Explosion {
3850 x: v492,
3851 y: v493,
3852 z: v494,
3853 radius: v495,
3854 affected_block_offsets: v496,
3855 player_motion_x: v502,
3856 player_motion_y: v503,
3857 player_motion_z: v504,
3858 }
3859 })
3860 }
3861}
3862impl Encode for Explosion {
3863 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3864 w.put_f32((*self).x);
3865 w.put_f32((*self).y);
3866 w.put_f32((*self).z);
3867 w.put_f32((*self).radius);
3868 w.put_i32(crate::codec::count_i32(
3869 (*self).affected_block_offsets.len(),
3870 )?);
3871 for v505 in (*self).affected_block_offsets.iter() {
3872 w.put_i8((*v505).x);
3873 w.put_i8((*v505).y);
3874 w.put_i8((*v505).z);
3875 }
3876 w.put_f32((*self).player_motion_x);
3877 w.put_f32((*self).player_motion_y);
3878 w.put_f32((*self).player_motion_z);
3879 Ok(())
3880 }
3881}
3882#[cfg(feature = "testgen")]
3883impl Generate for Explosion {
3884 fn generate(g: &mut Gen) -> Self {
3885 {
3886 let v506 = g.f32();
3887 let v507 = g.f32();
3888 let v508 = g.f32();
3889 let v509 = g.f32();
3890 let v510 = {
3891 let v511 = g.count();
3892 let mut v512 = Vec::with_capacity(v511.min(crate::codec::PREALLOC_LIMIT));
3893 for _ in 0..v511 {
3894 v512.push({
3895 let v513 = (g.int_in(-128, 127, &[]) as i8);
3896 let v514 = (g.int_in(-128, 127, &[]) as i8);
3897 let v515 = (g.int_in(-128, 127, &[]) as i8);
3898 ExplosionAffectedBlockOffsets {
3899 x: v513,
3900 y: v514,
3901 z: v515,
3902 }
3903 });
3904 }
3905 v512
3906 };
3907 let v516 = g.f32();
3908 let v517 = g.f32();
3909 let v518 = g.f32();
3910 Explosion {
3911 x: v506,
3912 y: v507,
3913 z: v508,
3914 radius: v509,
3915 affected_block_offsets: v510,
3916 player_motion_x: v516,
3917 player_motion_y: v517,
3918 player_motion_z: v518,
3919 }
3920 }
3921 }
3922}
3923impl From<Explosion> for ClientboundPlayPacket {
3924 fn from(p: Explosion) -> Self {
3925 Self::Explosion(p)
3926 }
3927}
3928
3929#[derive(Debug, Clone, PartialEq)]
3931pub struct WorldEvent {
3932 pub effect_id: i32,
3934 pub location: BlockPos,
3936 pub data: i32,
3938 pub global: bool,
3940}
3941impl crate::packet::Packet for WorldEvent {
3942 const ID: i32 = id::WORLD_EVENT;
3943 const NAME: &'static str = "world_event";
3944 const STATE: State = State::Play;
3945 const DIRECTION: Direction = Direction::Clientbound;
3946}
3947impl Decode for WorldEvent {
3948 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3949 Ok({
3950 let v519 = r.read_i32()?;
3951 let v520 = BlockPos::read(r, PositionLayout::Xyz)?;
3952 let v521 = r.read_i32()?;
3953 let v522 = r.read_bool()?;
3954 WorldEvent {
3955 effect_id: v519,
3956 location: v520,
3957 data: v521,
3958 global: v522,
3959 }
3960 })
3961 }
3962}
3963impl Encode for WorldEvent {
3964 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3965 w.put_i32((*self).effect_id);
3966 (*self).location.write(w, PositionLayout::Xyz)?;
3967 w.put_i32((*self).data);
3968 w.put_bool((*self).global);
3969 Ok(())
3970 }
3971}
3972#[cfg(feature = "testgen")]
3973impl Generate for WorldEvent {
3974 fn generate(g: &mut Gen) -> Self {
3975 {
3976 let v523 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3977 let v524 = g.position();
3978 let v525 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3979 let v526 = g.bool();
3980 WorldEvent {
3981 effect_id: v523,
3982 location: v524,
3983 data: v525,
3984 global: v526,
3985 }
3986 }
3987 }
3988}
3989impl From<WorldEvent> for ClientboundPlayPacket {
3990 fn from(p: WorldEvent) -> Self {
3991 Self::WorldEvent(p)
3992 }
3993}
3994
3995#[derive(Debug, Clone, PartialEq)]
3997pub struct NamedSoundEffect {
3998 pub sound_name: ByteString,
4000 pub x: i32,
4002 pub y: i32,
4004 pub z: i32,
4006 pub volume: f32,
4008 pub pitch: u8,
4010}
4011impl crate::packet::Packet for NamedSoundEffect {
4012 const ID: i32 = id::NAMED_SOUND_EFFECT;
4013 const NAME: &'static str = "named_sound_effect";
4014 const STATE: State = State::Play;
4015 const DIRECTION: Direction = Direction::Clientbound;
4016}
4017impl Decode for NamedSoundEffect {
4018 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4019 Ok({
4020 let v527 = r.read_string()?;
4021 let v528 = r.read_i32()?;
4022 let v529 = r.read_i32()?;
4023 let v530 = r.read_i32()?;
4024 let v531 = r.read_f32()?;
4025 let v532 = r.read_u8()?;
4026 NamedSoundEffect {
4027 sound_name: v527,
4028 x: v528,
4029 y: v529,
4030 z: v530,
4031 volume: v531,
4032 pitch: v532,
4033 }
4034 })
4035 }
4036}
4037impl Encode for NamedSoundEffect {
4038 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4039 w.put_string(&(*self).sound_name)?;
4040 w.put_i32((*self).x);
4041 w.put_i32((*self).y);
4042 w.put_i32((*self).z);
4043 w.put_f32((*self).volume);
4044 w.put_u8((*self).pitch);
4045 Ok(())
4046 }
4047}
4048#[cfg(feature = "testgen")]
4049impl Generate for NamedSoundEffect {
4050 fn generate(g: &mut Gen) -> Self {
4051 {
4052 let v533 = g.string();
4053 let v534 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4054 let v535 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4055 let v536 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4056 let v537 = g.f32();
4057 let v538 = (g.int_in(0, 255, &[]) as u8);
4058 NamedSoundEffect {
4059 sound_name: v533,
4060 x: v534,
4061 y: v535,
4062 z: v536,
4063 volume: v537,
4064 pitch: v538,
4065 }
4066 }
4067 }
4068}
4069impl From<NamedSoundEffect> for ClientboundPlayPacket {
4070 fn from(p: NamedSoundEffect) -> Self {
4071 Self::NamedSoundEffect(p)
4072 }
4073}
4074
4075#[derive(Debug, Clone, PartialEq)]
4077pub struct WorldParticles {
4078 pub particle_id: i32,
4080 pub long_distance: bool,
4082 pub x: f32,
4084 pub y: f32,
4086 pub z: f32,
4088 pub offset_x: f32,
4090 pub offset_y: f32,
4092 pub offset_z: f32,
4094 pub particle_data: f32,
4096 pub particles: i32,
4098 pub data: WorldParticlesData,
4100}
4101impl crate::packet::Packet for WorldParticles {
4102 const ID: i32 = id::WORLD_PARTICLES;
4103 const NAME: &'static str = "world_particles";
4104 const STATE: State = State::Play;
4105 const DIRECTION: Direction = Direction::Clientbound;
4106}
4107impl Decode for WorldParticles {
4108 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4109 Ok({
4110 let v539 = r.read_i32()?;
4111 let v540 = r.read_bool()?;
4112 let v541 = r.read_f32()?;
4113 let v542 = r.read_f32()?;
4114 let v543 = r.read_f32()?;
4115 let v544 = r.read_f32()?;
4116 let v545 = r.read_f32()?;
4117 let v546 = r.read_f32()?;
4118 let v547 = r.read_f32()?;
4119 let v548 = r.read_i32()?;
4120 let v549 = (if (v539 == 36) {
4121 WorldParticlesData::Case36({
4122 let v550 = 2;
4123 let mut v551 = Vec::with_capacity(v550.min(crate::codec::PREALLOC_LIMIT));
4124 for _ in 0..v550 {
4125 v551.push(r.read_varint()?);
4126 }
4127 v551
4128 })
4129 } else if (v539 == 37) {
4130 WorldParticlesData::Case37({
4131 let v552 = 1;
4132 let mut v553 = Vec::with_capacity(v552.min(crate::codec::PREALLOC_LIMIT));
4133 for _ in 0..v552 {
4134 v553.push(r.read_varint()?);
4135 }
4136 v553
4137 })
4138 } else if (v539 == 38) {
4139 WorldParticlesData::Case38({
4140 let v554 = 1;
4141 let mut v555 = Vec::with_capacity(v554.min(crate::codec::PREALLOC_LIMIT));
4142 for _ in 0..v554 {
4143 v555.push(r.read_varint()?);
4144 }
4145 v555
4146 })
4147 } else {
4148 WorldParticlesData::Other
4149 });
4150 WorldParticles {
4151 particle_id: v539,
4152 long_distance: v540,
4153 x: v541,
4154 y: v542,
4155 z: v543,
4156 offset_x: v544,
4157 offset_y: v545,
4158 offset_z: v546,
4159 particle_data: v547,
4160 particles: v548,
4161 data: v549,
4162 }
4163 })
4164 }
4165}
4166impl Encode for WorldParticles {
4167 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4168 w.put_i32((*self).particle_id);
4169 w.put_bool((*self).long_distance);
4170 w.put_f32((*self).x);
4171 w.put_f32((*self).y);
4172 w.put_f32((*self).z);
4173 w.put_f32((*self).offset_x);
4174 w.put_f32((*self).offset_y);
4175 w.put_f32((*self).offset_z);
4176 w.put_f32((*self).particle_data);
4177 w.put_i32((*self).particles);
4178 match &(*self).data {
4179 WorldParticlesData::Case36(v556) => {
4180 if !((*self).particle_id == 36) {
4181 return Err(EncodeError::SwitchMismatch(
4182 "play.clientbound.world_particles.data",
4183 ));
4184 }
4185 if (*v556).len() != 2 {
4186 return Err(EncodeError::CountMismatch {
4187 field: "play.clientbound.world_particles.data",
4188 expected: 2,
4189 actual: (*v556).len(),
4190 });
4191 }
4192 for v557 in (*v556).iter() {
4193 w.put_varint((*v557));
4194 }
4195 }
4196 WorldParticlesData::Case37(v558) => {
4197 if !((*self).particle_id == 37) {
4198 return Err(EncodeError::SwitchMismatch(
4199 "play.clientbound.world_particles.data",
4200 ));
4201 }
4202 if (*v558).len() != 1 {
4203 return Err(EncodeError::CountMismatch {
4204 field: "play.clientbound.world_particles.data",
4205 expected: 1,
4206 actual: (*v558).len(),
4207 });
4208 }
4209 for v559 in (*v558).iter() {
4210 w.put_varint((*v559));
4211 }
4212 }
4213 WorldParticlesData::Case38(v560) => {
4214 if !((*self).particle_id == 38) {
4215 return Err(EncodeError::SwitchMismatch(
4216 "play.clientbound.world_particles.data",
4217 ));
4218 }
4219 if (*v560).len() != 1 {
4220 return Err(EncodeError::CountMismatch {
4221 field: "play.clientbound.world_particles.data",
4222 expected: 1,
4223 actual: (*v560).len(),
4224 });
4225 }
4226 for v561 in (*v560).iter() {
4227 w.put_varint((*v561));
4228 }
4229 }
4230 WorldParticlesData::Other => {
4231 if !(!(((*self).particle_id == 36)
4232 || ((*self).particle_id == 37)
4233 || ((*self).particle_id == 38)))
4234 {
4235 return Err(EncodeError::SwitchMismatch(
4236 "play.clientbound.world_particles.data",
4237 ));
4238 }
4239 }
4240 }
4241 Ok(())
4242 }
4243}
4244#[cfg(feature = "testgen")]
4245impl Generate for WorldParticles {
4246 fn generate(g: &mut Gen) -> Self {
4247 {
4248 let v562 = (g.int_in(-2147483648, 2147483647, &[36, 37, 38]) as i32);
4249 let v563 = g.bool();
4250 let v564 = g.f32();
4251 let v565 = g.f32();
4252 let v566 = g.f32();
4253 let v567 = g.f32();
4254 let v568 = g.f32();
4255 let v569 = g.f32();
4256 let v570 = g.f32();
4257 let v571 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4258 let v572 = (if (v562 == 36) {
4259 WorldParticlesData::Case36({
4260 let v573 = 2;
4261 let mut v574 = Vec::with_capacity(v573.min(crate::codec::PREALLOC_LIMIT));
4262 for _ in 0..v573 {
4263 v574.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
4264 }
4265 v574
4266 })
4267 } else if (v562 == 37) {
4268 WorldParticlesData::Case37({
4269 let v575 = 1;
4270 let mut v576 = Vec::with_capacity(v575.min(crate::codec::PREALLOC_LIMIT));
4271 for _ in 0..v575 {
4272 v576.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
4273 }
4274 v576
4275 })
4276 } else if (v562 == 38) {
4277 WorldParticlesData::Case38({
4278 let v577 = 1;
4279 let mut v578 = Vec::with_capacity(v577.min(crate::codec::PREALLOC_LIMIT));
4280 for _ in 0..v577 {
4281 v578.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
4282 }
4283 v578
4284 })
4285 } else {
4286 WorldParticlesData::Other
4287 });
4288 WorldParticles {
4289 particle_id: v562,
4290 long_distance: v563,
4291 x: v564,
4292 y: v565,
4293 z: v566,
4294 offset_x: v567,
4295 offset_y: v568,
4296 offset_z: v569,
4297 particle_data: v570,
4298 particles: v571,
4299 data: v572,
4300 }
4301 }
4302 }
4303}
4304impl From<WorldParticles> for ClientboundPlayPacket {
4305 fn from(p: WorldParticles) -> Self {
4306 Self::WorldParticles(p)
4307 }
4308}
4309
4310#[derive(Debug, Clone, PartialEq)]
4312pub struct GameStateChange {
4313 pub reason: GameStateChangeReason,
4315 pub game_mode: f32,
4317}
4318impl crate::packet::Packet for GameStateChange {
4319 const ID: i32 = id::GAME_STATE_CHANGE;
4320 const NAME: &'static str = "game_state_change";
4321 const STATE: State = State::Play;
4322 const DIRECTION: Direction = Direction::Clientbound;
4323}
4324impl Decode for GameStateChange {
4325 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4326 Ok({
4327 let v579 = GameStateChangeReason(r.read_u8()?);
4328 let v580 = r.read_f32()?;
4329 GameStateChange {
4330 reason: v579,
4331 game_mode: v580,
4332 }
4333 })
4334 }
4335}
4336impl Encode for GameStateChange {
4337 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4338 w.put_u8((*self).reason.0);
4339 w.put_f32((*self).game_mode);
4340 Ok(())
4341 }
4342}
4343#[cfg(feature = "testgen")]
4344impl Generate for GameStateChange {
4345 fn generate(g: &mut Gen) -> Self {
4346 {
4347 let v581 =
4348 GameStateChangeReason(g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) as u8);
4349 let v582 = g.f32();
4350 GameStateChange {
4351 reason: v581,
4352 game_mode: v582,
4353 }
4354 }
4355 }
4356}
4357impl From<GameStateChange> for ClientboundPlayPacket {
4358 fn from(p: GameStateChange) -> Self {
4359 Self::GameStateChange(p)
4360 }
4361}
4362
4363#[derive(Debug, Clone, PartialEq)]
4365pub struct SpawnEntityWeather {
4366 pub entity_id: i32,
4368 pub r#type: i8,
4370 pub x: i32,
4372 pub y: i32,
4374 pub z: i32,
4376}
4377impl crate::packet::Packet for SpawnEntityWeather {
4378 const ID: i32 = id::SPAWN_ENTITY_WEATHER;
4379 const NAME: &'static str = "spawn_entity_weather";
4380 const STATE: State = State::Play;
4381 const DIRECTION: Direction = Direction::Clientbound;
4382}
4383impl Decode for SpawnEntityWeather {
4384 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4385 Ok({
4386 let v583 = r.read_varint()?;
4387 let v584 = r.read_i8()?;
4388 let v585 = r.read_i32()?;
4389 let v586 = r.read_i32()?;
4390 let v587 = r.read_i32()?;
4391 SpawnEntityWeather {
4392 entity_id: v583,
4393 r#type: v584,
4394 x: v585,
4395 y: v586,
4396 z: v587,
4397 }
4398 })
4399 }
4400}
4401impl Encode for SpawnEntityWeather {
4402 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4403 w.put_varint((*self).entity_id);
4404 w.put_i8((*self).r#type);
4405 w.put_i32((*self).x);
4406 w.put_i32((*self).y);
4407 w.put_i32((*self).z);
4408 Ok(())
4409 }
4410}
4411#[cfg(feature = "testgen")]
4412impl Generate for SpawnEntityWeather {
4413 fn generate(g: &mut Gen) -> Self {
4414 {
4415 let v588 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4416 let v589 = (g.int_in(-128, 127, &[]) as i8);
4417 let v590 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4418 let v591 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4419 let v592 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4420 SpawnEntityWeather {
4421 entity_id: v588,
4422 r#type: v589,
4423 x: v590,
4424 y: v591,
4425 z: v592,
4426 }
4427 }
4428 }
4429}
4430impl From<SpawnEntityWeather> for ClientboundPlayPacket {
4431 fn from(p: SpawnEntityWeather) -> Self {
4432 Self::SpawnEntityWeather(p)
4433 }
4434}
4435
4436#[derive(Debug, Clone, PartialEq)]
4438pub struct OpenWindow {
4439 pub window_id: u8,
4441 pub inventory_type: ByteString,
4443 pub window_title: ByteString,
4445 pub slot_count: u8,
4447 pub entity_id: Option<i32>,
4449}
4450impl crate::packet::Packet for OpenWindow {
4451 const ID: i32 = id::OPEN_WINDOW;
4452 const NAME: &'static str = "open_window";
4453 const STATE: State = State::Play;
4454 const DIRECTION: Direction = Direction::Clientbound;
4455}
4456impl Decode for OpenWindow {
4457 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4458 Ok({
4459 let v593 = r.read_u8()?;
4460 let v594 = r.read_string()?;
4461 let v595 = r.read_string()?;
4462 let v596 = r.read_u8()?;
4463 let v597 = if (&*v594 == "EntityHorse") {
4464 Some(r.read_i32()?)
4465 } else {
4466 None
4467 };
4468 OpenWindow {
4469 window_id: v593,
4470 inventory_type: v594,
4471 window_title: v595,
4472 slot_count: v596,
4473 entity_id: v597,
4474 }
4475 })
4476 }
4477}
4478impl Encode for OpenWindow {
4479 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4480 w.put_u8((*self).window_id);
4481 w.put_string(&(*self).inventory_type)?;
4482 w.put_string(&(*self).window_title)?;
4483 w.put_u8((*self).slot_count);
4484 match (
4485 &(*self).entity_id,
4486 (&*(*self).inventory_type == "EntityHorse"),
4487 ) {
4488 (Some(v598), true) => {
4489 w.put_i32((*v598));
4490 }
4491 (None, false) => {}
4492 _ => {
4493 return Err(EncodeError::SwitchMismatch(
4494 "play.clientbound.open_window.entityId",
4495 ));
4496 }
4497 }
4498 Ok(())
4499 }
4500}
4501#[cfg(feature = "testgen")]
4502impl Generate for OpenWindow {
4503 fn generate(g: &mut Gen) -> Self {
4504 {
4505 let v599 = (g.int_in(0, 255, &[]) as u8);
4506 let v600 = g.string_in(&["EntityHorse"]);
4507 let v601 = g.string();
4508 let v602 = (g.int_in(0, 255, &[]) as u8);
4509 let v603 = if (&*v600 == "EntityHorse") {
4510 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4511 } else {
4512 None
4513 };
4514 OpenWindow {
4515 window_id: v599,
4516 inventory_type: v600,
4517 window_title: v601,
4518 slot_count: v602,
4519 entity_id: v603,
4520 }
4521 }
4522 }
4523}
4524impl From<OpenWindow> for ClientboundPlayPacket {
4525 fn from(p: OpenWindow) -> Self {
4526 Self::OpenWindow(p)
4527 }
4528}
4529
4530#[derive(Debug, Clone, PartialEq)]
4532pub struct CloseWindow {
4533 pub window_id: u8,
4535}
4536impl crate::packet::Packet for CloseWindow {
4537 const ID: i32 = id::CLOSE_WINDOW;
4538 const NAME: &'static str = "close_window";
4539 const STATE: State = State::Play;
4540 const DIRECTION: Direction = Direction::Clientbound;
4541}
4542impl Decode for CloseWindow {
4543 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4544 Ok({
4545 let v604 = r.read_u8()?;
4546 CloseWindow { window_id: v604 }
4547 })
4548 }
4549}
4550impl Encode for CloseWindow {
4551 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4552 w.put_u8((*self).window_id);
4553 Ok(())
4554 }
4555}
4556#[cfg(feature = "testgen")]
4557impl Generate for CloseWindow {
4558 fn generate(g: &mut Gen) -> Self {
4559 {
4560 let v605 = (g.int_in(0, 255, &[]) as u8);
4561 CloseWindow { window_id: v605 }
4562 }
4563 }
4564}
4565impl From<CloseWindow> for ClientboundPlayPacket {
4566 fn from(p: CloseWindow) -> Self {
4567 Self::CloseWindow(p)
4568 }
4569}
4570
4571#[derive(Debug, Clone, PartialEq)]
4573pub struct SetSlot {
4574 pub window_id: i8,
4576 pub slot: i16,
4578 pub item: types::Slot,
4580}
4581impl crate::packet::Packet for SetSlot {
4582 const ID: i32 = id::SET_SLOT;
4583 const NAME: &'static str = "set_slot";
4584 const STATE: State = State::Play;
4585 const DIRECTION: Direction = Direction::Clientbound;
4586}
4587impl Decode for SetSlot {
4588 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4589 Ok({
4590 let v606 = r.read_i8()?;
4591 let v607 = r.read_i16()?;
4592 let v608 = <types::Slot as Decode>::decode(r)?;
4593 SetSlot {
4594 window_id: v606,
4595 slot: v607,
4596 item: v608,
4597 }
4598 })
4599 }
4600}
4601impl Encode for SetSlot {
4602 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4603 w.put_i8((*self).window_id);
4604 w.put_i16((*self).slot);
4605 (*self).item.encode(w)?;
4606 Ok(())
4607 }
4608}
4609#[cfg(feature = "testgen")]
4610impl Generate for SetSlot {
4611 fn generate(g: &mut Gen) -> Self {
4612 {
4613 let v609 = (g.int_in(-128, 127, &[]) as i8);
4614 let v610 = (g.int_in(-32768, 32767, &[]) as i16);
4615 let v611 = <types::Slot as Generate>::generate(g);
4616 SetSlot {
4617 window_id: v609,
4618 slot: v610,
4619 item: v611,
4620 }
4621 }
4622 }
4623}
4624impl From<SetSlot> for ClientboundPlayPacket {
4625 fn from(p: SetSlot) -> Self {
4626 Self::SetSlot(p)
4627 }
4628}
4629
4630#[derive(Debug, Clone, PartialEq)]
4632pub struct WindowItems {
4633 pub window_id: u8,
4635 pub items: Vec<types::Slot>,
4637}
4638impl crate::packet::Packet for WindowItems {
4639 const ID: i32 = id::WINDOW_ITEMS;
4640 const NAME: &'static str = "window_items";
4641 const STATE: State = State::Play;
4642 const DIRECTION: Direction = Direction::Clientbound;
4643}
4644impl Decode for WindowItems {
4645 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4646 Ok({
4647 let v612 = r.read_u8()?;
4648 let v613 = {
4649 let v614 = {
4650 let c = r.read_i16()?;
4651 r.check_count(i64::from(c), 1)?
4652 };
4653 let mut v615 = Vec::with_capacity(v614.min(crate::codec::PREALLOC_LIMIT));
4654 for _ in 0..v614 {
4655 v615.push(<types::Slot as Decode>::decode(r)?);
4656 }
4657 v615
4658 };
4659 WindowItems {
4660 window_id: v612,
4661 items: v613,
4662 }
4663 })
4664 }
4665}
4666impl Encode for WindowItems {
4667 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4668 w.put_u8((*self).window_id);
4669 w.put_i16(crate::codec::count_i16((*self).items.len())?);
4670 for v616 in (*self).items.iter() {
4671 (*v616).encode(w)?;
4672 }
4673 Ok(())
4674 }
4675}
4676#[cfg(feature = "testgen")]
4677impl Generate for WindowItems {
4678 fn generate(g: &mut Gen) -> Self {
4679 {
4680 let v617 = (g.int_in(0, 255, &[]) as u8);
4681 let v618 = {
4682 let v619 = g.count();
4683 let mut v620 = Vec::with_capacity(v619.min(crate::codec::PREALLOC_LIMIT));
4684 for _ in 0..v619 {
4685 v620.push(<types::Slot as Generate>::generate(g));
4686 }
4687 v620
4688 };
4689 WindowItems {
4690 window_id: v617,
4691 items: v618,
4692 }
4693 }
4694 }
4695}
4696impl From<WindowItems> for ClientboundPlayPacket {
4697 fn from(p: WindowItems) -> Self {
4698 Self::WindowItems(p)
4699 }
4700}
4701
4702#[derive(Debug, Clone, PartialEq)]
4704pub struct CraftProgressBar {
4705 pub window_id: u8,
4707 pub property: i16,
4709 pub value: i16,
4711}
4712impl crate::packet::Packet for CraftProgressBar {
4713 const ID: i32 = id::CRAFT_PROGRESS_BAR;
4714 const NAME: &'static str = "craft_progress_bar";
4715 const STATE: State = State::Play;
4716 const DIRECTION: Direction = Direction::Clientbound;
4717}
4718impl Decode for CraftProgressBar {
4719 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4720 Ok({
4721 let v621 = r.read_u8()?;
4722 let v622 = r.read_i16()?;
4723 let v623 = r.read_i16()?;
4724 CraftProgressBar {
4725 window_id: v621,
4726 property: v622,
4727 value: v623,
4728 }
4729 })
4730 }
4731}
4732impl Encode for CraftProgressBar {
4733 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4734 w.put_u8((*self).window_id);
4735 w.put_i16((*self).property);
4736 w.put_i16((*self).value);
4737 Ok(())
4738 }
4739}
4740#[cfg(feature = "testgen")]
4741impl Generate for CraftProgressBar {
4742 fn generate(g: &mut Gen) -> Self {
4743 {
4744 let v624 = (g.int_in(0, 255, &[]) as u8);
4745 let v625 = (g.int_in(-32768, 32767, &[]) as i16);
4746 let v626 = (g.int_in(-32768, 32767, &[]) as i16);
4747 CraftProgressBar {
4748 window_id: v624,
4749 property: v625,
4750 value: v626,
4751 }
4752 }
4753 }
4754}
4755impl From<CraftProgressBar> for ClientboundPlayPacket {
4756 fn from(p: CraftProgressBar) -> Self {
4757 Self::CraftProgressBar(p)
4758 }
4759}
4760
4761#[derive(Debug, Clone, PartialEq)]
4763pub struct Transaction {
4764 pub window_id: i8,
4766 pub action: i16,
4768 pub accepted: bool,
4770}
4771impl crate::packet::Packet for Transaction {
4772 const ID: i32 = id::TRANSACTION;
4773 const NAME: &'static str = "transaction";
4774 const STATE: State = State::Play;
4775 const DIRECTION: Direction = Direction::Clientbound;
4776}
4777impl Decode for Transaction {
4778 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4779 Ok({
4780 let v627 = r.read_i8()?;
4781 let v628 = r.read_i16()?;
4782 let v629 = r.read_bool()?;
4783 Transaction {
4784 window_id: v627,
4785 action: v628,
4786 accepted: v629,
4787 }
4788 })
4789 }
4790}
4791impl Encode for Transaction {
4792 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4793 w.put_i8((*self).window_id);
4794 w.put_i16((*self).action);
4795 w.put_bool((*self).accepted);
4796 Ok(())
4797 }
4798}
4799#[cfg(feature = "testgen")]
4800impl Generate for Transaction {
4801 fn generate(g: &mut Gen) -> Self {
4802 {
4803 let v630 = (g.int_in(-128, 127, &[]) as i8);
4804 let v631 = (g.int_in(-32768, 32767, &[]) as i16);
4805 let v632 = g.bool();
4806 Transaction {
4807 window_id: v630,
4808 action: v631,
4809 accepted: v632,
4810 }
4811 }
4812 }
4813}
4814impl From<Transaction> for ClientboundPlayPacket {
4815 fn from(p: Transaction) -> Self {
4816 Self::Transaction(p)
4817 }
4818}
4819
4820#[derive(Debug, Clone, PartialEq)]
4822pub struct UpdateSign {
4823 pub location: BlockPos,
4825 pub text1: ByteString,
4827 pub text2: ByteString,
4829 pub text3: ByteString,
4831 pub text4: ByteString,
4833}
4834impl crate::packet::Packet for UpdateSign {
4835 const ID: i32 = id::UPDATE_SIGN;
4836 const NAME: &'static str = "update_sign";
4837 const STATE: State = State::Play;
4838 const DIRECTION: Direction = Direction::Clientbound;
4839}
4840impl Decode for UpdateSign {
4841 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4842 Ok({
4843 let v633 = BlockPos::read(r, PositionLayout::Xyz)?;
4844 let v634 = r.read_string()?;
4845 let v635 = r.read_string()?;
4846 let v636 = r.read_string()?;
4847 let v637 = r.read_string()?;
4848 UpdateSign {
4849 location: v633,
4850 text1: v634,
4851 text2: v635,
4852 text3: v636,
4853 text4: v637,
4854 }
4855 })
4856 }
4857}
4858impl Encode for UpdateSign {
4859 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4860 (*self).location.write(w, PositionLayout::Xyz)?;
4861 w.put_string(&(*self).text1)?;
4862 w.put_string(&(*self).text2)?;
4863 w.put_string(&(*self).text3)?;
4864 w.put_string(&(*self).text4)?;
4865 Ok(())
4866 }
4867}
4868#[cfg(feature = "testgen")]
4869impl Generate for UpdateSign {
4870 fn generate(g: &mut Gen) -> Self {
4871 {
4872 let v638 = g.position();
4873 let v639 = g.string();
4874 let v640 = g.string();
4875 let v641 = g.string();
4876 let v642 = g.string();
4877 UpdateSign {
4878 location: v638,
4879 text1: v639,
4880 text2: v640,
4881 text3: v641,
4882 text4: v642,
4883 }
4884 }
4885 }
4886}
4887impl From<UpdateSign> for ClientboundPlayPacket {
4888 fn from(p: UpdateSign) -> Self {
4889 Self::UpdateSign(p)
4890 }
4891}
4892
4893#[derive(Debug, Clone, PartialEq)]
4895pub struct Map {
4896 pub item_damage: i32,
4898 pub scale: i8,
4900 pub icons: Vec<MapIcons>,
4902 pub columns: i8,
4904 pub rows: Option<i8>,
4906 pub x: Option<i8>,
4908 pub y: Option<i8>,
4910 pub data: Option<Bytes>,
4912}
4913impl crate::packet::Packet for Map {
4914 const ID: i32 = id::MAP;
4915 const NAME: &'static str = "map";
4916 const STATE: State = State::Play;
4917 const DIRECTION: Direction = Direction::Clientbound;
4918}
4919impl Decode for Map {
4920 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4921 Ok({
4922 let v643 = r.read_varint()?;
4923 let v644 = r.read_i8()?;
4924 let v645 = {
4925 let v646 = {
4926 let c = r.read_varint()?;
4927 r.check_count(i64::from(c), 3)?
4928 };
4929 let mut v647 = Vec::with_capacity(v646.min(crate::codec::PREALLOC_LIMIT));
4930 for _ in 0..v646 {
4931 v647.push({
4932 let v648 = r.read_i8()?;
4933 let v649 = r.read_i8()?;
4934 let v650 = r.read_i8()?;
4935 MapIcons {
4936 direction_and_type: v648,
4937 x: v649,
4938 z: v650,
4939 }
4940 });
4941 }
4942 v647
4943 };
4944 let v651 = r.read_i8()?;
4945 let v652 = if !(v651 == 0) {
4946 Some(r.read_i8()?)
4947 } else {
4948 None
4949 };
4950 let v653 = if !(v651 == 0) {
4951 Some(r.read_i8()?)
4952 } else {
4953 None
4954 };
4955 let v654 = if !(v651 == 0) {
4956 Some(r.read_i8()?)
4957 } else {
4958 None
4959 };
4960 let v655 = if !(v651 == 0) {
4961 Some(r.read_byte_array()?)
4962 } else {
4963 None
4964 };
4965 Map {
4966 item_damage: v643,
4967 scale: v644,
4968 icons: v645,
4969 columns: v651,
4970 rows: v652,
4971 x: v653,
4972 y: v654,
4973 data: v655,
4974 }
4975 })
4976 }
4977}
4978impl Encode for Map {
4979 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4980 w.put_varint((*self).item_damage);
4981 w.put_i8((*self).scale);
4982 w.put_len_varint((*self).icons.len())?;
4983 for v656 in (*self).icons.iter() {
4984 w.put_i8((*v656).direction_and_type);
4985 w.put_i8((*v656).x);
4986 w.put_i8((*v656).z);
4987 }
4988 w.put_i8((*self).columns);
4989 match (&(*self).rows, !((*self).columns == 0)) {
4990 (Some(v657), true) => {
4991 w.put_i8((*v657));
4992 }
4993 (None, false) => {}
4994 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
4995 }
4996 match (&(*self).x, !((*self).columns == 0)) {
4997 (Some(v658), true) => {
4998 w.put_i8((*v658));
4999 }
5000 (None, false) => {}
5001 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
5002 }
5003 match (&(*self).y, !((*self).columns == 0)) {
5004 (Some(v659), true) => {
5005 w.put_i8((*v659));
5006 }
5007 (None, false) => {}
5008 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
5009 }
5010 match (&(*self).data, !((*self).columns == 0)) {
5011 (Some(v660), true) => {
5012 w.put_byte_array(&(*v660))?;
5013 }
5014 (None, false) => {}
5015 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
5016 }
5017 Ok(())
5018 }
5019}
5020#[cfg(feature = "testgen")]
5021impl Generate for Map {
5022 fn generate(g: &mut Gen) -> Self {
5023 {
5024 let v661 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5025 let v662 = (g.int_in(-128, 127, &[]) as i8);
5026 let v663 = {
5027 let v664 = g.count();
5028 let mut v665 = Vec::with_capacity(v664.min(crate::codec::PREALLOC_LIMIT));
5029 for _ in 0..v664 {
5030 v665.push({
5031 let v666 = (g.int_in(-128, 127, &[]) as i8);
5032 let v667 = (g.int_in(-128, 127, &[]) as i8);
5033 let v668 = (g.int_in(-128, 127, &[]) as i8);
5034 MapIcons {
5035 direction_and_type: v666,
5036 x: v667,
5037 z: v668,
5038 }
5039 });
5040 }
5041 v665
5042 };
5043 let v669 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
5044 let v670 = if !(v669 == 0) {
5045 Some((g.int_in(-128, 127, &[]) as i8))
5046 } else {
5047 None
5048 };
5049 let v671 = if !(v669 == 0) {
5050 Some((g.int_in(-128, 127, &[]) as i8))
5051 } else {
5052 None
5053 };
5054 let v672 = if !(v669 == 0) {
5055 Some((g.int_in(-128, 127, &[]) as i8))
5056 } else {
5057 None
5058 };
5059 let v673 = if !(v669 == 0) { Some(g.bytes()) } else { None };
5060 Map {
5061 item_damage: v661,
5062 scale: v662,
5063 icons: v663,
5064 columns: v669,
5065 rows: v670,
5066 x: v671,
5067 y: v672,
5068 data: v673,
5069 }
5070 }
5071 }
5072}
5073impl From<Map> for ClientboundPlayPacket {
5074 fn from(p: Map) -> Self {
5075 Self::Map(p)
5076 }
5077}
5078
5079#[derive(Debug, Clone, PartialEq)]
5081pub struct TileEntityData {
5082 pub location: BlockPos,
5084 pub action: u8,
5086 pub nbt_data: Option<RawNbt>,
5088}
5089impl crate::packet::Packet for TileEntityData {
5090 const ID: i32 = id::TILE_ENTITY_DATA;
5091 const NAME: &'static str = "tile_entity_data";
5092 const STATE: State = State::Play;
5093 const DIRECTION: Direction = Direction::Clientbound;
5094}
5095impl Decode for TileEntityData {
5096 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5097 Ok({
5098 let v674 = BlockPos::read(r, PositionLayout::Xyz)?;
5099 let v675 = r.read_u8()?;
5100 let v676 = RawNbt::read_optional(r)?;
5101 TileEntityData {
5102 location: v674,
5103 action: v675,
5104 nbt_data: v676,
5105 }
5106 })
5107 }
5108}
5109impl Encode for TileEntityData {
5110 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5111 (*self).location.write(w, PositionLayout::Xyz)?;
5112 w.put_u8((*self).action);
5113 RawNbt::write_optional(&(*self).nbt_data, w);
5114 Ok(())
5115 }
5116}
5117#[cfg(feature = "testgen")]
5118impl Generate for TileEntityData {
5119 fn generate(g: &mut Gen) -> Self {
5120 {
5121 let v677 = g.position();
5122 let v678 = (g.int_in(0, 255, &[]) as u8);
5123 let v679 = g.opt_nbt();
5124 TileEntityData {
5125 location: v677,
5126 action: v678,
5127 nbt_data: v679,
5128 }
5129 }
5130 }
5131}
5132impl From<TileEntityData> for ClientboundPlayPacket {
5133 fn from(p: TileEntityData) -> Self {
5134 Self::TileEntityData(p)
5135 }
5136}
5137
5138#[derive(Debug, Clone, PartialEq)]
5140pub struct OpenSignEntity {
5141 pub location: BlockPos,
5143}
5144impl crate::packet::Packet for OpenSignEntity {
5145 const ID: i32 = id::OPEN_SIGN_ENTITY;
5146 const NAME: &'static str = "open_sign_entity";
5147 const STATE: State = State::Play;
5148 const DIRECTION: Direction = Direction::Clientbound;
5149}
5150impl Decode for OpenSignEntity {
5151 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5152 Ok({
5153 let v680 = BlockPos::read(r, PositionLayout::Xyz)?;
5154 OpenSignEntity { location: v680 }
5155 })
5156 }
5157}
5158impl Encode for OpenSignEntity {
5159 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5160 (*self).location.write(w, PositionLayout::Xyz)?;
5161 Ok(())
5162 }
5163}
5164#[cfg(feature = "testgen")]
5165impl Generate for OpenSignEntity {
5166 fn generate(g: &mut Gen) -> Self {
5167 {
5168 let v681 = g.position();
5169 OpenSignEntity { location: v681 }
5170 }
5171 }
5172}
5173impl From<OpenSignEntity> for ClientboundPlayPacket {
5174 fn from(p: OpenSignEntity) -> Self {
5175 Self::OpenSignEntity(p)
5176 }
5177}
5178
5179#[derive(Debug, Clone, PartialEq)]
5181pub struct Statistics {
5182 pub entries: Vec<StatisticsEntries>,
5184}
5185impl crate::packet::Packet for Statistics {
5186 const ID: i32 = id::STATISTICS;
5187 const NAME: &'static str = "statistics";
5188 const STATE: State = State::Play;
5189 const DIRECTION: Direction = Direction::Clientbound;
5190}
5191impl Decode for Statistics {
5192 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5193 Ok({
5194 let v682 = {
5195 let v683 = {
5196 let c = r.read_varint()?;
5197 r.check_count(i64::from(c), 2)?
5198 };
5199 let mut v684 = Vec::with_capacity(v683.min(crate::codec::PREALLOC_LIMIT));
5200 for _ in 0..v683 {
5201 v684.push({
5202 let v685 = r.read_string()?;
5203 let v686 = r.read_varint()?;
5204 StatisticsEntries {
5205 name: v685,
5206 value: v686,
5207 }
5208 });
5209 }
5210 v684
5211 };
5212 Statistics { entries: v682 }
5213 })
5214 }
5215}
5216impl Encode for Statistics {
5217 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5218 w.put_len_varint((*self).entries.len())?;
5219 for v687 in (*self).entries.iter() {
5220 w.put_string(&(*v687).name)?;
5221 w.put_varint((*v687).value);
5222 }
5223 Ok(())
5224 }
5225}
5226#[cfg(feature = "testgen")]
5227impl Generate for Statistics {
5228 fn generate(g: &mut Gen) -> Self {
5229 {
5230 let v688 = {
5231 let v689 = g.count();
5232 let mut v690 = Vec::with_capacity(v689.min(crate::codec::PREALLOC_LIMIT));
5233 for _ in 0..v689 {
5234 v690.push({
5235 let v691 = g.string();
5236 let v692 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5237 StatisticsEntries {
5238 name: v691,
5239 value: v692,
5240 }
5241 });
5242 }
5243 v690
5244 };
5245 Statistics { entries: v688 }
5246 }
5247 }
5248}
5249impl From<Statistics> for ClientboundPlayPacket {
5250 fn from(p: Statistics) -> Self {
5251 Self::Statistics(p)
5252 }
5253}
5254
5255#[derive(Debug, Clone, PartialEq)]
5257pub struct PlayerInfo {
5258 pub action: PlayerInfoAction,
5260 pub data: Vec<PlayerInfoData>,
5262}
5263impl crate::packet::Packet for PlayerInfo {
5264 const ID: i32 = id::PLAYER_INFO;
5265 const NAME: &'static str = "player_info";
5266 const STATE: State = State::Play;
5267 const DIRECTION: Direction = Direction::Clientbound;
5268}
5269impl Decode for PlayerInfo {
5270 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5271 Ok({
5272 let v693 = PlayerInfoAction(r.read_varint()?);
5273 let v694 = {
5274 let v695 = {
5275 let c = r.read_varint()?;
5276 r.check_count(i64::from(c), 16)?
5277 };
5278 let mut v696 = Vec::with_capacity(v695.min(crate::codec::PREALLOC_LIMIT));
5279 for _ in 0..v695 {
5280 v696.push({
5281 let v697 = r.read_uuid()?;
5282 let v698 = (if (v693.0 == 0) {
5283 PlayerInfoDataBody::AddPlayer({
5284 let v699 = r.read_string()?;
5285 let v700 = {
5286 let v701 = {
5287 let c = r.read_varint()?;
5288 r.check_count(i64::from(c), 3)?
5289 };
5290 let mut v702 =
5291 Vec::with_capacity(v701.min(crate::codec::PREALLOC_LIMIT));
5292 for _ in 0..v701 {
5293 v702.push({
5294 let v703 = r.read_string()?;
5295 let v704 = r.read_string()?;
5296 let v705 = if r.read_bool()? {
5297 Some(r.read_string()?)
5298 } else {
5299 None
5300 };
5301 PlayerInfoDataBodyAddPlayerProperties {
5302 name: v703,
5303 value: v704,
5304 signature: v705,
5305 }
5306 });
5307 }
5308 v702
5309 };
5310 let v706 = r.read_varint()?;
5311 let v707 = r.read_varint()?;
5312 let v708 = if r.read_bool()? {
5313 Some(r.read_string()?)
5314 } else {
5315 None
5316 };
5317 PlayerInfoDataBodyAddPlayer {
5318 name: v699,
5319 properties: v700,
5320 gamemode: v706,
5321 ping: v707,
5322 display_name: v708,
5323 }
5324 })
5325 } else if (v693.0 == 1) {
5326 PlayerInfoDataBody::UpdateGameMode({
5327 let v709 = r.read_varint()?;
5328 PlayerInfoDataBodyUpdateGameMode { gamemode: v709 }
5329 })
5330 } else if (v693.0 == 2) {
5331 PlayerInfoDataBody::UpdateLatency({
5332 let v710 = r.read_varint()?;
5333 PlayerInfoDataBodyUpdateLatency { ping: v710 }
5334 })
5335 } else if (v693.0 == 3) {
5336 PlayerInfoDataBody::UpdateDisplayName({
5337 let v711 = if r.read_bool()? {
5338 Some(r.read_string()?)
5339 } else {
5340 None
5341 };
5342 PlayerInfoDataBodyUpdateDisplayName { display_name: v711 }
5343 })
5344 } else if (v693.0 == 4) {
5345 PlayerInfoDataBody::RemovePlayer
5346 } else {
5347 PlayerInfoDataBody::Other
5348 });
5349 PlayerInfoData {
5350 uuid: v697,
5351 body: v698,
5352 }
5353 });
5354 }
5355 v696
5356 };
5357 PlayerInfo {
5358 action: v693,
5359 data: v694,
5360 }
5361 })
5362 }
5363}
5364impl Encode for PlayerInfo {
5365 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5366 w.put_varint((*self).action.0);
5367 w.put_len_varint((*self).data.len())?;
5368 for v712 in (*self).data.iter() {
5369 w.put_uuid(&(*v712).uuid);
5370 match &(*v712).body {
5371 PlayerInfoDataBody::AddPlayer(v713) => {
5372 if !((*self).action.0 == 0) {
5373 return Err(EncodeError::SwitchMismatch(
5374 "play.clientbound.player_info.data.body",
5375 ));
5376 }
5377 w.put_string(&(*v713).name)?;
5378 w.put_len_varint((*v713).properties.len())?;
5379 for v714 in (*v713).properties.iter() {
5380 w.put_string(&(*v714).name)?;
5381 w.put_string(&(*v714).value)?;
5382 match &(*v714).signature {
5383 Some(v715) => {
5384 w.put_u8(1);
5385 w.put_string(&(*v715))?;
5386 }
5387 None => w.put_u8(0),
5388 }
5389 }
5390 w.put_varint((*v713).gamemode);
5391 w.put_varint((*v713).ping);
5392 match &(*v713).display_name {
5393 Some(v716) => {
5394 w.put_u8(1);
5395 w.put_string(&(*v716))?;
5396 }
5397 None => w.put_u8(0),
5398 }
5399 }
5400 PlayerInfoDataBody::UpdateGameMode(v717) => {
5401 if !((*self).action.0 == 1) {
5402 return Err(EncodeError::SwitchMismatch(
5403 "play.clientbound.player_info.data.body",
5404 ));
5405 }
5406 w.put_varint((*v717).gamemode);
5407 }
5408 PlayerInfoDataBody::UpdateLatency(v718) => {
5409 if !((*self).action.0 == 2) {
5410 return Err(EncodeError::SwitchMismatch(
5411 "play.clientbound.player_info.data.body",
5412 ));
5413 }
5414 w.put_varint((*v718).ping);
5415 }
5416 PlayerInfoDataBody::UpdateDisplayName(v719) => {
5417 if !((*self).action.0 == 3) {
5418 return Err(EncodeError::SwitchMismatch(
5419 "play.clientbound.player_info.data.body",
5420 ));
5421 }
5422 match &(*v719).display_name {
5423 Some(v720) => {
5424 w.put_u8(1);
5425 w.put_string(&(*v720))?;
5426 }
5427 None => w.put_u8(0),
5428 }
5429 }
5430 PlayerInfoDataBody::RemovePlayer => {
5431 if !((*self).action.0 == 4) {
5432 return Err(EncodeError::SwitchMismatch(
5433 "play.clientbound.player_info.data.body",
5434 ));
5435 }
5436 }
5437 PlayerInfoDataBody::Other => {
5438 if !(!(((*self).action.0 == 0)
5439 || ((*self).action.0 == 1)
5440 || ((*self).action.0 == 2)
5441 || ((*self).action.0 == 3)
5442 || ((*self).action.0 == 4)))
5443 {
5444 return Err(EncodeError::SwitchMismatch(
5445 "play.clientbound.player_info.data.body",
5446 ));
5447 }
5448 }
5449 }
5450 }
5451 Ok(())
5452 }
5453}
5454#[cfg(feature = "testgen")]
5455impl Generate for PlayerInfo {
5456 fn generate(g: &mut Gen) -> Self {
5457 {
5458 let v721 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
5459 let v722 = {
5460 let v723 = g.count();
5461 let mut v724 = Vec::with_capacity(v723.min(crate::codec::PREALLOC_LIMIT));
5462 for _ in 0..v723 {
5463 v724.push({
5464 let v725 = g.uuid();
5465 let v726 = (if (v721.0 == 0) {
5466 PlayerInfoDataBody::AddPlayer({
5467 let v727 = g.string();
5468 let v728 = {
5469 let v729 = g.count();
5470 let mut v730 =
5471 Vec::with_capacity(v729.min(crate::codec::PREALLOC_LIMIT));
5472 for _ in 0..v729 {
5473 v730.push({
5474 let v731 = g.string();
5475 let v732 = g.string();
5476 let v733 =
5477 if g.bool() { Some(g.string()) } else { None };
5478 PlayerInfoDataBodyAddPlayerProperties {
5479 name: v731,
5480 value: v732,
5481 signature: v733,
5482 }
5483 });
5484 }
5485 v730
5486 };
5487 let v734 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5488 let v735 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5489 let v736 = if g.bool() { Some(g.string()) } else { None };
5490 PlayerInfoDataBodyAddPlayer {
5491 name: v727,
5492 properties: v728,
5493 gamemode: v734,
5494 ping: v735,
5495 display_name: v736,
5496 }
5497 })
5498 } else if (v721.0 == 1) {
5499 PlayerInfoDataBody::UpdateGameMode({
5500 let v737 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5501 PlayerInfoDataBodyUpdateGameMode { gamemode: v737 }
5502 })
5503 } else if (v721.0 == 2) {
5504 PlayerInfoDataBody::UpdateLatency({
5505 let v738 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5506 PlayerInfoDataBodyUpdateLatency { ping: v738 }
5507 })
5508 } else if (v721.0 == 3) {
5509 PlayerInfoDataBody::UpdateDisplayName({
5510 let v739 = if g.bool() { Some(g.string()) } else { None };
5511 PlayerInfoDataBodyUpdateDisplayName { display_name: v739 }
5512 })
5513 } else if (v721.0 == 4) {
5514 PlayerInfoDataBody::RemovePlayer
5515 } else {
5516 PlayerInfoDataBody::Other
5517 });
5518 PlayerInfoData {
5519 uuid: v725,
5520 body: v726,
5521 }
5522 });
5523 }
5524 v724
5525 };
5526 PlayerInfo {
5527 action: v721,
5528 data: v722,
5529 }
5530 }
5531 }
5532}
5533impl From<PlayerInfo> for ClientboundPlayPacket {
5534 fn from(p: PlayerInfo) -> Self {
5535 Self::PlayerInfo(p)
5536 }
5537}
5538
5539#[derive(Debug, Clone, PartialEq)]
5541pub struct Abilities {
5542 pub flags: i8,
5544 pub flying_speed: f32,
5546 pub walking_speed: f32,
5548}
5549impl crate::packet::Packet for Abilities {
5550 const ID: i32 = id::ABILITIES;
5551 const NAME: &'static str = "abilities";
5552 const STATE: State = State::Play;
5553 const DIRECTION: Direction = Direction::Clientbound;
5554}
5555impl Decode for Abilities {
5556 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5557 Ok({
5558 let v740 = r.read_i8()?;
5559 let v741 = r.read_f32()?;
5560 let v742 = r.read_f32()?;
5561 Abilities {
5562 flags: v740,
5563 flying_speed: v741,
5564 walking_speed: v742,
5565 }
5566 })
5567 }
5568}
5569impl Encode for Abilities {
5570 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5571 w.put_i8((*self).flags);
5572 w.put_f32((*self).flying_speed);
5573 w.put_f32((*self).walking_speed);
5574 Ok(())
5575 }
5576}
5577#[cfg(feature = "testgen")]
5578impl Generate for Abilities {
5579 fn generate(g: &mut Gen) -> Self {
5580 {
5581 let v743 = (g.int_in(-128, 127, &[]) as i8);
5582 let v744 = g.f32();
5583 let v745 = g.f32();
5584 Abilities {
5585 flags: v743,
5586 flying_speed: v744,
5587 walking_speed: v745,
5588 }
5589 }
5590 }
5591}
5592impl From<Abilities> for ClientboundPlayPacket {
5593 fn from(p: Abilities) -> Self {
5594 Self::Abilities(p)
5595 }
5596}
5597
5598#[derive(Debug, Clone, PartialEq)]
5600pub struct TabComplete {
5601 pub matches: Vec<ByteString>,
5603}
5604impl crate::packet::Packet for TabComplete {
5605 const ID: i32 = id::TAB_COMPLETE;
5606 const NAME: &'static str = "tab_complete";
5607 const STATE: State = State::Play;
5608 const DIRECTION: Direction = Direction::Clientbound;
5609}
5610impl Decode for TabComplete {
5611 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5612 Ok({
5613 let v746 = {
5614 let v747 = {
5615 let c = r.read_varint()?;
5616 r.check_count(i64::from(c), 1)?
5617 };
5618 let mut v748 = Vec::with_capacity(v747.min(crate::codec::PREALLOC_LIMIT));
5619 for _ in 0..v747 {
5620 v748.push(r.read_string()?);
5621 }
5622 v748
5623 };
5624 TabComplete { matches: v746 }
5625 })
5626 }
5627}
5628impl Encode for TabComplete {
5629 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5630 w.put_len_varint((*self).matches.len())?;
5631 for v749 in (*self).matches.iter() {
5632 w.put_string(&(*v749))?;
5633 }
5634 Ok(())
5635 }
5636}
5637#[cfg(feature = "testgen")]
5638impl Generate for TabComplete {
5639 fn generate(g: &mut Gen) -> Self {
5640 {
5641 let v750 = {
5642 let v751 = g.count();
5643 let mut v752 = Vec::with_capacity(v751.min(crate::codec::PREALLOC_LIMIT));
5644 for _ in 0..v751 {
5645 v752.push(g.string());
5646 }
5647 v752
5648 };
5649 TabComplete { matches: v750 }
5650 }
5651 }
5652}
5653impl From<TabComplete> for ClientboundPlayPacket {
5654 fn from(p: TabComplete) -> Self {
5655 Self::TabComplete(p)
5656 }
5657}
5658
5659#[derive(Debug, Clone, PartialEq)]
5661pub struct ScoreboardObjective {
5662 pub name: ByteString,
5664 pub action: i8,
5666 pub display_text: Option<ByteString>,
5668 pub r#type: Option<ByteString>,
5670}
5671impl crate::packet::Packet for ScoreboardObjective {
5672 const ID: i32 = id::SCOREBOARD_OBJECTIVE;
5673 const NAME: &'static str = "scoreboard_objective";
5674 const STATE: State = State::Play;
5675 const DIRECTION: Direction = Direction::Clientbound;
5676}
5677impl Decode for ScoreboardObjective {
5678 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5679 Ok({
5680 let v753 = r.read_string()?;
5681 let v754 = r.read_i8()?;
5682 let v755 = if (v754 == 0) || (v754 == 2) {
5683 Some(r.read_string()?)
5684 } else {
5685 None
5686 };
5687 let v756 = if (v754 == 0) || (v754 == 2) {
5688 Some(r.read_string()?)
5689 } else {
5690 None
5691 };
5692 ScoreboardObjective {
5693 name: v753,
5694 action: v754,
5695 display_text: v755,
5696 r#type: v756,
5697 }
5698 })
5699 }
5700}
5701impl Encode for ScoreboardObjective {
5702 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5703 w.put_string(&(*self).name)?;
5704 w.put_i8((*self).action);
5705 match (
5706 &(*self).display_text,
5707 ((*self).action == 0) || ((*self).action == 2),
5708 ) {
5709 (Some(v757), true) => {
5710 w.put_string(&(*v757))?;
5711 }
5712 (None, false) => {}
5713 _ => {
5714 return Err(EncodeError::SwitchMismatch(
5715 "play.clientbound.scoreboard_objective.displayText",
5716 ));
5717 }
5718 }
5719 match (
5720 &(*self).r#type,
5721 ((*self).action == 0) || ((*self).action == 2),
5722 ) {
5723 (Some(v758), true) => {
5724 w.put_string(&(*v758))?;
5725 }
5726 (None, false) => {}
5727 _ => {
5728 return Err(EncodeError::SwitchMismatch(
5729 "play.clientbound.scoreboard_objective.type",
5730 ));
5731 }
5732 }
5733 Ok(())
5734 }
5735}
5736#[cfg(feature = "testgen")]
5737impl Generate for ScoreboardObjective {
5738 fn generate(g: &mut Gen) -> Self {
5739 {
5740 let v759 = g.string();
5741 let v760 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
5742 let v761 = if (v760 == 0) || (v760 == 2) {
5743 Some(g.string())
5744 } else {
5745 None
5746 };
5747 let v762 = if (v760 == 0) || (v760 == 2) {
5748 Some(g.string())
5749 } else {
5750 None
5751 };
5752 ScoreboardObjective {
5753 name: v759,
5754 action: v760,
5755 display_text: v761,
5756 r#type: v762,
5757 }
5758 }
5759 }
5760}
5761impl From<ScoreboardObjective> for ClientboundPlayPacket {
5762 fn from(p: ScoreboardObjective) -> Self {
5763 Self::ScoreboardObjective(p)
5764 }
5765}
5766
5767#[derive(Debug, Clone, PartialEq)]
5769pub struct ScoreboardScore {
5770 pub item_name: ByteString,
5772 pub action: i32,
5774 pub score_name: ByteString,
5776 pub value: Option<i32>,
5778}
5779impl crate::packet::Packet for ScoreboardScore {
5780 const ID: i32 = id::SCOREBOARD_SCORE;
5781 const NAME: &'static str = "scoreboard_score";
5782 const STATE: State = State::Play;
5783 const DIRECTION: Direction = Direction::Clientbound;
5784}
5785impl Decode for ScoreboardScore {
5786 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5787 Ok({
5788 let v763 = r.read_string()?;
5789 let v764 = r.read_varint()?;
5790 let v765 = r.read_string()?;
5791 let v766 = if !(v764 == 1) {
5792 Some(r.read_varint()?)
5793 } else {
5794 None
5795 };
5796 ScoreboardScore {
5797 item_name: v763,
5798 action: v764,
5799 score_name: v765,
5800 value: v766,
5801 }
5802 })
5803 }
5804}
5805impl Encode for ScoreboardScore {
5806 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5807 w.put_string(&(*self).item_name)?;
5808 w.put_varint((*self).action);
5809 w.put_string(&(*self).score_name)?;
5810 match (&(*self).value, !((*self).action == 1)) {
5811 (Some(v767), true) => {
5812 w.put_varint((*v767));
5813 }
5814 (None, false) => {}
5815 _ => {
5816 return Err(EncodeError::SwitchMismatch(
5817 "play.clientbound.scoreboard_score.value",
5818 ));
5819 }
5820 }
5821 Ok(())
5822 }
5823}
5824#[cfg(feature = "testgen")]
5825impl Generate for ScoreboardScore {
5826 fn generate(g: &mut Gen) -> Self {
5827 {
5828 let v768 = g.string();
5829 let v769 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
5830 let v770 = g.string();
5831 let v771 = if !(v769 == 1) {
5832 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5833 } else {
5834 None
5835 };
5836 ScoreboardScore {
5837 item_name: v768,
5838 action: v769,
5839 score_name: v770,
5840 value: v771,
5841 }
5842 }
5843 }
5844}
5845impl From<ScoreboardScore> for ClientboundPlayPacket {
5846 fn from(p: ScoreboardScore) -> Self {
5847 Self::ScoreboardScore(p)
5848 }
5849}
5850
5851#[derive(Debug, Clone, PartialEq)]
5853pub struct ScoreboardDisplayObjective {
5854 pub position: i8,
5856 pub name: ByteString,
5858}
5859impl crate::packet::Packet for ScoreboardDisplayObjective {
5860 const ID: i32 = id::SCOREBOARD_DISPLAY_OBJECTIVE;
5861 const NAME: &'static str = "scoreboard_display_objective";
5862 const STATE: State = State::Play;
5863 const DIRECTION: Direction = Direction::Clientbound;
5864}
5865impl Decode for ScoreboardDisplayObjective {
5866 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5867 Ok({
5868 let v772 = r.read_i8()?;
5869 let v773 = r.read_string()?;
5870 ScoreboardDisplayObjective {
5871 position: v772,
5872 name: v773,
5873 }
5874 })
5875 }
5876}
5877impl Encode for ScoreboardDisplayObjective {
5878 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5879 w.put_i8((*self).position);
5880 w.put_string(&(*self).name)?;
5881 Ok(())
5882 }
5883}
5884#[cfg(feature = "testgen")]
5885impl Generate for ScoreboardDisplayObjective {
5886 fn generate(g: &mut Gen) -> Self {
5887 {
5888 let v774 = (g.int_in(-128, 127, &[]) as i8);
5889 let v775 = g.string();
5890 ScoreboardDisplayObjective {
5891 position: v774,
5892 name: v775,
5893 }
5894 }
5895 }
5896}
5897impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
5898 fn from(p: ScoreboardDisplayObjective) -> Self {
5899 Self::ScoreboardDisplayObjective(p)
5900 }
5901}
5902
5903#[derive(Debug, Clone, PartialEq)]
5905pub struct ScoreboardTeam {
5906 pub team: ByteString,
5908 pub mode: i8,
5910 pub name: Option<ByteString>,
5912 pub prefix: Option<ByteString>,
5914 pub suffix: Option<ByteString>,
5916 pub friendly_fire: Option<i8>,
5918 pub name_tag_visibility: Option<ByteString>,
5920 pub color: Option<i8>,
5922 pub players: Option<Vec<ByteString>>,
5924}
5925impl crate::packet::Packet for ScoreboardTeam {
5926 const ID: i32 = id::SCOREBOARD_TEAM;
5927 const NAME: &'static str = "scoreboard_team";
5928 const STATE: State = State::Play;
5929 const DIRECTION: Direction = Direction::Clientbound;
5930}
5931impl Decode for ScoreboardTeam {
5932 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5933 Ok({
5934 let v776 = r.read_string()?;
5935 let v777 = r.read_i8()?;
5936 let v778 = if (v777 == 0) || (v777 == 2) {
5937 Some(r.read_string()?)
5938 } else {
5939 None
5940 };
5941 let v779 = if (v777 == 0) || (v777 == 2) {
5942 Some(r.read_string()?)
5943 } else {
5944 None
5945 };
5946 let v780 = if (v777 == 0) || (v777 == 2) {
5947 Some(r.read_string()?)
5948 } else {
5949 None
5950 };
5951 let v781 = if (v777 == 0) || (v777 == 2) {
5952 Some(r.read_i8()?)
5953 } else {
5954 None
5955 };
5956 let v782 = if (v777 == 0) || (v777 == 2) {
5957 Some(r.read_string()?)
5958 } else {
5959 None
5960 };
5961 let v783 = if (v777 == 0) || (v777 == 2) {
5962 Some(r.read_i8()?)
5963 } else {
5964 None
5965 };
5966 let v784 = if (v777 == 0) || (v777 == 3) || (v777 == 4) {
5967 Some({
5968 let v785 = {
5969 let c = r.read_varint()?;
5970 r.check_count(i64::from(c), 1)?
5971 };
5972 let mut v786 = Vec::with_capacity(v785.min(crate::codec::PREALLOC_LIMIT));
5973 for _ in 0..v785 {
5974 v786.push(r.read_string()?);
5975 }
5976 v786
5977 })
5978 } else {
5979 None
5980 };
5981 ScoreboardTeam {
5982 team: v776,
5983 mode: v777,
5984 name: v778,
5985 prefix: v779,
5986 suffix: v780,
5987 friendly_fire: v781,
5988 name_tag_visibility: v782,
5989 color: v783,
5990 players: v784,
5991 }
5992 })
5993 }
5994}
5995impl Encode for ScoreboardTeam {
5996 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5997 w.put_string(&(*self).team)?;
5998 w.put_i8((*self).mode);
5999 match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
6000 (Some(v787), true) => {
6001 w.put_string(&(*v787))?;
6002 }
6003 (None, false) => {}
6004 _ => {
6005 return Err(EncodeError::SwitchMismatch(
6006 "play.clientbound.scoreboard_team.name",
6007 ));
6008 }
6009 }
6010 match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
6011 (Some(v788), true) => {
6012 w.put_string(&(*v788))?;
6013 }
6014 (None, false) => {}
6015 _ => {
6016 return Err(EncodeError::SwitchMismatch(
6017 "play.clientbound.scoreboard_team.prefix",
6018 ));
6019 }
6020 }
6021 match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
6022 (Some(v789), true) => {
6023 w.put_string(&(*v789))?;
6024 }
6025 (None, false) => {}
6026 _ => {
6027 return Err(EncodeError::SwitchMismatch(
6028 "play.clientbound.scoreboard_team.suffix",
6029 ));
6030 }
6031 }
6032 match (
6033 &(*self).friendly_fire,
6034 ((*self).mode == 0) || ((*self).mode == 2),
6035 ) {
6036 (Some(v790), true) => {
6037 w.put_i8((*v790));
6038 }
6039 (None, false) => {}
6040 _ => {
6041 return Err(EncodeError::SwitchMismatch(
6042 "play.clientbound.scoreboard_team.friendlyFire",
6043 ));
6044 }
6045 }
6046 match (
6047 &(*self).name_tag_visibility,
6048 ((*self).mode == 0) || ((*self).mode == 2),
6049 ) {
6050 (Some(v791), true) => {
6051 w.put_string(&(*v791))?;
6052 }
6053 (None, false) => {}
6054 _ => {
6055 return Err(EncodeError::SwitchMismatch(
6056 "play.clientbound.scoreboard_team.nameTagVisibility",
6057 ));
6058 }
6059 }
6060 match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
6061 (Some(v792), true) => {
6062 w.put_i8((*v792));
6063 }
6064 (None, false) => {}
6065 _ => {
6066 return Err(EncodeError::SwitchMismatch(
6067 "play.clientbound.scoreboard_team.color",
6068 ));
6069 }
6070 }
6071 match (
6072 &(*self).players,
6073 ((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
6074 ) {
6075 (Some(v793), true) => {
6076 w.put_len_varint((*v793).len())?;
6077 for v794 in (*v793).iter() {
6078 w.put_string(&(*v794))?;
6079 }
6080 }
6081 (None, false) => {}
6082 _ => {
6083 return Err(EncodeError::SwitchMismatch(
6084 "play.clientbound.scoreboard_team.players",
6085 ));
6086 }
6087 }
6088 Ok(())
6089 }
6090}
6091#[cfg(feature = "testgen")]
6092impl Generate for ScoreboardTeam {
6093 fn generate(g: &mut Gen) -> Self {
6094 {
6095 let v795 = g.string();
6096 let v796 = (g.int_in(-128, 127, &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4]) as i8);
6097 let v797 = if (v796 == 0) || (v796 == 2) {
6098 Some(g.string())
6099 } else {
6100 None
6101 };
6102 let v798 = if (v796 == 0) || (v796 == 2) {
6103 Some(g.string())
6104 } else {
6105 None
6106 };
6107 let v799 = if (v796 == 0) || (v796 == 2) {
6108 Some(g.string())
6109 } else {
6110 None
6111 };
6112 let v800 = if (v796 == 0) || (v796 == 2) {
6113 Some((g.int_in(-128, 127, &[]) as i8))
6114 } else {
6115 None
6116 };
6117 let v801 = if (v796 == 0) || (v796 == 2) {
6118 Some(g.string())
6119 } else {
6120 None
6121 };
6122 let v802 = if (v796 == 0) || (v796 == 2) {
6123 Some((g.int_in(-128, 127, &[]) as i8))
6124 } else {
6125 None
6126 };
6127 let v803 = if (v796 == 0) || (v796 == 3) || (v796 == 4) {
6128 Some({
6129 let v804 = g.count();
6130 let mut v805 = Vec::with_capacity(v804.min(crate::codec::PREALLOC_LIMIT));
6131 for _ in 0..v804 {
6132 v805.push(g.string());
6133 }
6134 v805
6135 })
6136 } else {
6137 None
6138 };
6139 ScoreboardTeam {
6140 team: v795,
6141 mode: v796,
6142 name: v797,
6143 prefix: v798,
6144 suffix: v799,
6145 friendly_fire: v800,
6146 name_tag_visibility: v801,
6147 color: v802,
6148 players: v803,
6149 }
6150 }
6151 }
6152}
6153impl From<ScoreboardTeam> for ClientboundPlayPacket {
6154 fn from(p: ScoreboardTeam) -> Self {
6155 Self::ScoreboardTeam(p)
6156 }
6157}
6158
6159#[derive(Debug, Clone, PartialEq)]
6161pub struct CustomPayload {
6162 pub channel: ByteString,
6164 pub data: Bytes,
6166}
6167impl crate::packet::Packet for CustomPayload {
6168 const ID: i32 = id::CUSTOM_PAYLOAD;
6169 const NAME: &'static str = "custom_payload";
6170 const STATE: State = State::Play;
6171 const DIRECTION: Direction = Direction::Clientbound;
6172}
6173impl Decode for CustomPayload {
6174 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6175 Ok({
6176 let v806 = r.read_string()?;
6177 let v807 = r.read_rest();
6178 CustomPayload {
6179 channel: v806,
6180 data: v807,
6181 }
6182 })
6183 }
6184}
6185impl Encode for CustomPayload {
6186 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6187 w.put_string(&(*self).channel)?;
6188 w.put_slice(&(*self).data);
6189 Ok(())
6190 }
6191}
6192#[cfg(feature = "testgen")]
6193impl Generate for CustomPayload {
6194 fn generate(g: &mut Gen) -> Self {
6195 {
6196 let v808 = g.string();
6197 let v809 = g.bytes();
6198 CustomPayload {
6199 channel: v808,
6200 data: v809,
6201 }
6202 }
6203 }
6204}
6205impl From<CustomPayload> for ClientboundPlayPacket {
6206 fn from(p: CustomPayload) -> Self {
6207 Self::CustomPayload(p)
6208 }
6209}
6210
6211#[derive(Debug, Clone, PartialEq)]
6213pub struct KickDisconnect {
6214 pub reason: ByteString,
6216}
6217impl crate::packet::Packet for KickDisconnect {
6218 const ID: i32 = id::KICK_DISCONNECT;
6219 const NAME: &'static str = "kick_disconnect";
6220 const STATE: State = State::Play;
6221 const DIRECTION: Direction = Direction::Clientbound;
6222}
6223impl Decode for KickDisconnect {
6224 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6225 Ok({
6226 let v810 = r.read_string()?;
6227 KickDisconnect { reason: v810 }
6228 })
6229 }
6230}
6231impl Encode for KickDisconnect {
6232 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6233 w.put_string(&(*self).reason)?;
6234 Ok(())
6235 }
6236}
6237#[cfg(feature = "testgen")]
6238impl Generate for KickDisconnect {
6239 fn generate(g: &mut Gen) -> Self {
6240 {
6241 let v811 = g.string();
6242 KickDisconnect { reason: v811 }
6243 }
6244 }
6245}
6246impl From<KickDisconnect> for ClientboundPlayPacket {
6247 fn from(p: KickDisconnect) -> Self {
6248 Self::KickDisconnect(p)
6249 }
6250}
6251
6252#[derive(Debug, Clone, PartialEq)]
6254pub struct Difficulty {
6255 pub difficulty: DifficultyDifficulty,
6257}
6258impl crate::packet::Packet for Difficulty {
6259 const ID: i32 = id::DIFFICULTY;
6260 const NAME: &'static str = "difficulty";
6261 const STATE: State = State::Play;
6262 const DIRECTION: Direction = Direction::Clientbound;
6263}
6264impl Decode for Difficulty {
6265 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6266 Ok({
6267 let v812 = DifficultyDifficulty(r.read_u8()?);
6268 Difficulty { difficulty: v812 }
6269 })
6270 }
6271}
6272impl Encode for Difficulty {
6273 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6274 w.put_u8((*self).difficulty.0);
6275 Ok(())
6276 }
6277}
6278#[cfg(feature = "testgen")]
6279impl Generate for Difficulty {
6280 fn generate(g: &mut Gen) -> Self {
6281 {
6282 let v813 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
6283 Difficulty { difficulty: v813 }
6284 }
6285 }
6286}
6287impl From<Difficulty> for ClientboundPlayPacket {
6288 fn from(p: Difficulty) -> Self {
6289 Self::Difficulty(p)
6290 }
6291}
6292
6293#[derive(Debug, Clone, PartialEq)]
6295pub struct CombatEvent {
6296 pub event: i32,
6298 pub duration: Option<i32>,
6300 pub player_id: Option<i32>,
6302 pub entity_id: Option<i32>,
6304 pub message: Option<ByteString>,
6306}
6307impl crate::packet::Packet for CombatEvent {
6308 const ID: i32 = id::COMBAT_EVENT;
6309 const NAME: &'static str = "combat_event";
6310 const STATE: State = State::Play;
6311 const DIRECTION: Direction = Direction::Clientbound;
6312}
6313impl Decode for CombatEvent {
6314 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6315 Ok({
6316 let v814 = r.read_varint()?;
6317 let v815 = if (v814 == 1) {
6318 Some(r.read_varint()?)
6319 } else {
6320 None
6321 };
6322 let v816 = if (v814 == 2) {
6323 Some(r.read_varint()?)
6324 } else {
6325 None
6326 };
6327 let v817 = if (v814 == 1) || (v814 == 2) {
6328 Some(r.read_i32()?)
6329 } else {
6330 None
6331 };
6332 let v818 = if (v814 == 2) {
6333 Some(r.read_string()?)
6334 } else {
6335 None
6336 };
6337 CombatEvent {
6338 event: v814,
6339 duration: v815,
6340 player_id: v816,
6341 entity_id: v817,
6342 message: v818,
6343 }
6344 })
6345 }
6346}
6347impl Encode for CombatEvent {
6348 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6349 w.put_varint((*self).event);
6350 match (&(*self).duration, ((*self).event == 1)) {
6351 (Some(v819), true) => {
6352 w.put_varint((*v819));
6353 }
6354 (None, false) => {}
6355 _ => {
6356 return Err(EncodeError::SwitchMismatch(
6357 "play.clientbound.combat_event.duration",
6358 ));
6359 }
6360 }
6361 match (&(*self).player_id, ((*self).event == 2)) {
6362 (Some(v820), true) => {
6363 w.put_varint((*v820));
6364 }
6365 (None, false) => {}
6366 _ => {
6367 return Err(EncodeError::SwitchMismatch(
6368 "play.clientbound.combat_event.playerId",
6369 ));
6370 }
6371 }
6372 match (
6373 &(*self).entity_id,
6374 ((*self).event == 1) || ((*self).event == 2),
6375 ) {
6376 (Some(v821), true) => {
6377 w.put_i32((*v821));
6378 }
6379 (None, false) => {}
6380 _ => {
6381 return Err(EncodeError::SwitchMismatch(
6382 "play.clientbound.combat_event.entityId",
6383 ));
6384 }
6385 }
6386 match (&(*self).message, ((*self).event == 2)) {
6387 (Some(v822), true) => {
6388 w.put_string(&(*v822))?;
6389 }
6390 (None, false) => {}
6391 _ => {
6392 return Err(EncodeError::SwitchMismatch(
6393 "play.clientbound.combat_event.message",
6394 ));
6395 }
6396 }
6397 Ok(())
6398 }
6399}
6400#[cfg(feature = "testgen")]
6401impl Generate for CombatEvent {
6402 fn generate(g: &mut Gen) -> Self {
6403 {
6404 let v823 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
6405 let v824 = if (v823 == 1) {
6406 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6407 } else {
6408 None
6409 };
6410 let v825 = if (v823 == 2) {
6411 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6412 } else {
6413 None
6414 };
6415 let v826 = if (v823 == 1) || (v823 == 2) {
6416 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6417 } else {
6418 None
6419 };
6420 let v827 = if (v823 == 2) { Some(g.string()) } else { None };
6421 CombatEvent {
6422 event: v823,
6423 duration: v824,
6424 player_id: v825,
6425 entity_id: v826,
6426 message: v827,
6427 }
6428 }
6429 }
6430}
6431impl From<CombatEvent> for ClientboundPlayPacket {
6432 fn from(p: CombatEvent) -> Self {
6433 Self::CombatEvent(p)
6434 }
6435}
6436
6437#[derive(Debug, Clone, PartialEq)]
6439pub struct Camera {
6440 pub camera_id: i32,
6442}
6443impl crate::packet::Packet for Camera {
6444 const ID: i32 = id::CAMERA;
6445 const NAME: &'static str = "camera";
6446 const STATE: State = State::Play;
6447 const DIRECTION: Direction = Direction::Clientbound;
6448}
6449impl Decode for Camera {
6450 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6451 Ok({
6452 let v828 = r.read_varint()?;
6453 Camera { camera_id: v828 }
6454 })
6455 }
6456}
6457impl Encode for Camera {
6458 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6459 w.put_varint((*self).camera_id);
6460 Ok(())
6461 }
6462}
6463#[cfg(feature = "testgen")]
6464impl Generate for Camera {
6465 fn generate(g: &mut Gen) -> Self {
6466 {
6467 let v829 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6468 Camera { camera_id: v829 }
6469 }
6470 }
6471}
6472impl From<Camera> for ClientboundPlayPacket {
6473 fn from(p: Camera) -> Self {
6474 Self::Camera(p)
6475 }
6476}
6477
6478#[derive(Debug, Clone, PartialEq)]
6480pub struct WorldBorder {
6481 pub action: i32,
6483 pub radius: Option<f64>,
6485 pub x: Option<f64>,
6487 pub z: Option<f64>,
6489 pub old_radius: Option<f64>,
6491 pub new_radius: Option<f64>,
6493 pub speed: Option<i64>,
6495 pub portal_boundary: Option<i32>,
6497 pub warning_time: Option<i32>,
6499 pub warning_blocks: Option<i32>,
6501}
6502impl crate::packet::Packet for WorldBorder {
6503 const ID: i32 = id::WORLD_BORDER;
6504 const NAME: &'static str = "world_border";
6505 const STATE: State = State::Play;
6506 const DIRECTION: Direction = Direction::Clientbound;
6507}
6508impl Decode for WorldBorder {
6509 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6510 Ok({
6511 let v830 = r.read_varint()?;
6512 let v831 = if (v830 == 0) {
6513 Some(r.read_f64()?)
6514 } else {
6515 None
6516 };
6517 let v832 = if (v830 == 2) || (v830 == 3) {
6518 Some(r.read_f64()?)
6519 } else {
6520 None
6521 };
6522 let v833 = if (v830 == 2) || (v830 == 3) {
6523 Some(r.read_f64()?)
6524 } else {
6525 None
6526 };
6527 let v834 = if (v830 == 1) || (v830 == 3) {
6528 Some(r.read_f64()?)
6529 } else {
6530 None
6531 };
6532 let v835 = if (v830 == 1) || (v830 == 3) {
6533 Some(r.read_f64()?)
6534 } else {
6535 None
6536 };
6537 let v836 = if (v830 == 1) || (v830 == 3) {
6538 Some(r.read_varlong()?)
6539 } else {
6540 None
6541 };
6542 let v837 = if (v830 == 3) {
6543 Some(r.read_varint()?)
6544 } else {
6545 None
6546 };
6547 let v838 = if (v830 == 3) || (v830 == 4) {
6548 Some(r.read_varint()?)
6549 } else {
6550 None
6551 };
6552 let v839 = if (v830 == 3) || (v830 == 5) {
6553 Some(r.read_varint()?)
6554 } else {
6555 None
6556 };
6557 WorldBorder {
6558 action: v830,
6559 radius: v831,
6560 x: v832,
6561 z: v833,
6562 old_radius: v834,
6563 new_radius: v835,
6564 speed: v836,
6565 portal_boundary: v837,
6566 warning_time: v838,
6567 warning_blocks: v839,
6568 }
6569 })
6570 }
6571}
6572impl Encode for WorldBorder {
6573 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6574 w.put_varint((*self).action);
6575 match (&(*self).radius, ((*self).action == 0)) {
6576 (Some(v840), true) => {
6577 w.put_f64((*v840));
6578 }
6579 (None, false) => {}
6580 _ => {
6581 return Err(EncodeError::SwitchMismatch(
6582 "play.clientbound.world_border.radius",
6583 ));
6584 }
6585 }
6586 match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
6587 (Some(v841), true) => {
6588 w.put_f64((*v841));
6589 }
6590 (None, false) => {}
6591 _ => {
6592 return Err(EncodeError::SwitchMismatch(
6593 "play.clientbound.world_border.x",
6594 ));
6595 }
6596 }
6597 match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
6598 (Some(v842), true) => {
6599 w.put_f64((*v842));
6600 }
6601 (None, false) => {}
6602 _ => {
6603 return Err(EncodeError::SwitchMismatch(
6604 "play.clientbound.world_border.z",
6605 ));
6606 }
6607 }
6608 match (
6609 &(*self).old_radius,
6610 ((*self).action == 1) || ((*self).action == 3),
6611 ) {
6612 (Some(v843), true) => {
6613 w.put_f64((*v843));
6614 }
6615 (None, false) => {}
6616 _ => {
6617 return Err(EncodeError::SwitchMismatch(
6618 "play.clientbound.world_border.old_radius",
6619 ));
6620 }
6621 }
6622 match (
6623 &(*self).new_radius,
6624 ((*self).action == 1) || ((*self).action == 3),
6625 ) {
6626 (Some(v844), true) => {
6627 w.put_f64((*v844));
6628 }
6629 (None, false) => {}
6630 _ => {
6631 return Err(EncodeError::SwitchMismatch(
6632 "play.clientbound.world_border.new_radius",
6633 ));
6634 }
6635 }
6636 match (
6637 &(*self).speed,
6638 ((*self).action == 1) || ((*self).action == 3),
6639 ) {
6640 (Some(v845), true) => {
6641 w.put_varlong((*v845));
6642 }
6643 (None, false) => {}
6644 _ => {
6645 return Err(EncodeError::SwitchMismatch(
6646 "play.clientbound.world_border.speed",
6647 ));
6648 }
6649 }
6650 match (&(*self).portal_boundary, ((*self).action == 3)) {
6651 (Some(v846), true) => {
6652 w.put_varint((*v846));
6653 }
6654 (None, false) => {}
6655 _ => {
6656 return Err(EncodeError::SwitchMismatch(
6657 "play.clientbound.world_border.portalBoundary",
6658 ));
6659 }
6660 }
6661 match (
6662 &(*self).warning_time,
6663 ((*self).action == 3) || ((*self).action == 4),
6664 ) {
6665 (Some(v847), true) => {
6666 w.put_varint((*v847));
6667 }
6668 (None, false) => {}
6669 _ => {
6670 return Err(EncodeError::SwitchMismatch(
6671 "play.clientbound.world_border.warning_time",
6672 ));
6673 }
6674 }
6675 match (
6676 &(*self).warning_blocks,
6677 ((*self).action == 3) || ((*self).action == 5),
6678 ) {
6679 (Some(v848), true) => {
6680 w.put_varint((*v848));
6681 }
6682 (None, false) => {}
6683 _ => {
6684 return Err(EncodeError::SwitchMismatch(
6685 "play.clientbound.world_border.warning_blocks",
6686 ));
6687 }
6688 }
6689 Ok(())
6690 }
6691}
6692#[cfg(feature = "testgen")]
6693impl Generate for WorldBorder {
6694 fn generate(g: &mut Gen) -> Self {
6695 {
6696 let v849 = (g.int_in(
6697 -2147483648,
6698 2147483647,
6699 &[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
6700 ) as i32);
6701 let v850 = if (v849 == 0) { Some(g.f64()) } else { None };
6702 let v851 = if (v849 == 2) || (v849 == 3) {
6703 Some(g.f64())
6704 } else {
6705 None
6706 };
6707 let v852 = if (v849 == 2) || (v849 == 3) {
6708 Some(g.f64())
6709 } else {
6710 None
6711 };
6712 let v853 = if (v849 == 1) || (v849 == 3) {
6713 Some(g.f64())
6714 } else {
6715 None
6716 };
6717 let v854 = if (v849 == 1) || (v849 == 3) {
6718 Some(g.f64())
6719 } else {
6720 None
6721 };
6722 let v855 = if (v849 == 1) || (v849 == 3) {
6723 Some(g.varlong())
6724 } else {
6725 None
6726 };
6727 let v856 = if (v849 == 3) {
6728 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6729 } else {
6730 None
6731 };
6732 let v857 = if (v849 == 3) || (v849 == 4) {
6733 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6734 } else {
6735 None
6736 };
6737 let v858 = if (v849 == 3) || (v849 == 5) {
6738 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6739 } else {
6740 None
6741 };
6742 WorldBorder {
6743 action: v849,
6744 radius: v850,
6745 x: v851,
6746 z: v852,
6747 old_radius: v853,
6748 new_radius: v854,
6749 speed: v855,
6750 portal_boundary: v856,
6751 warning_time: v857,
6752 warning_blocks: v858,
6753 }
6754 }
6755 }
6756}
6757impl From<WorldBorder> for ClientboundPlayPacket {
6758 fn from(p: WorldBorder) -> Self {
6759 Self::WorldBorder(p)
6760 }
6761}
6762
6763#[derive(Debug, Clone, PartialEq)]
6765pub struct Title {
6766 pub action: i32,
6768 pub text: Option<ByteString>,
6770 pub fade_in: Option<i32>,
6772 pub stay: Option<i32>,
6774 pub fade_out: Option<i32>,
6776}
6777impl crate::packet::Packet for Title {
6778 const ID: i32 = id::TITLE;
6779 const NAME: &'static str = "title";
6780 const STATE: State = State::Play;
6781 const DIRECTION: Direction = Direction::Clientbound;
6782}
6783impl Decode for Title {
6784 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6785 Ok({
6786 let v859 = r.read_varint()?;
6787 let v860 = if (v859 == 0) || (v859 == 1) {
6788 Some(r.read_string()?)
6789 } else {
6790 None
6791 };
6792 let v861 = if (v859 == 2) {
6793 Some(r.read_i32()?)
6794 } else {
6795 None
6796 };
6797 let v862 = if (v859 == 2) {
6798 Some(r.read_i32()?)
6799 } else {
6800 None
6801 };
6802 let v863 = if (v859 == 2) {
6803 Some(r.read_i32()?)
6804 } else {
6805 None
6806 };
6807 Title {
6808 action: v859,
6809 text: v860,
6810 fade_in: v861,
6811 stay: v862,
6812 fade_out: v863,
6813 }
6814 })
6815 }
6816}
6817impl Encode for Title {
6818 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6819 w.put_varint((*self).action);
6820 match (
6821 &(*self).text,
6822 ((*self).action == 0) || ((*self).action == 1),
6823 ) {
6824 (Some(v864), true) => {
6825 w.put_string(&(*v864))?;
6826 }
6827 (None, false) => {}
6828 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
6829 }
6830 match (&(*self).fade_in, ((*self).action == 2)) {
6831 (Some(v865), true) => {
6832 w.put_i32((*v865));
6833 }
6834 (None, false) => {}
6835 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
6836 }
6837 match (&(*self).stay, ((*self).action == 2)) {
6838 (Some(v866), true) => {
6839 w.put_i32((*v866));
6840 }
6841 (None, false) => {}
6842 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
6843 }
6844 match (&(*self).fade_out, ((*self).action == 2)) {
6845 (Some(v867), true) => {
6846 w.put_i32((*v867));
6847 }
6848 (None, false) => {}
6849 _ => {
6850 return Err(EncodeError::SwitchMismatch(
6851 "play.clientbound.title.fadeOut",
6852 ));
6853 }
6854 }
6855 Ok(())
6856 }
6857}
6858#[cfg(feature = "testgen")]
6859impl Generate for Title {
6860 fn generate(g: &mut Gen) -> Self {
6861 {
6862 let v868 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 2, 2]) as i32);
6863 let v869 = if (v868 == 0) || (v868 == 1) {
6864 Some(g.string())
6865 } else {
6866 None
6867 };
6868 let v870 = if (v868 == 2) {
6869 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6870 } else {
6871 None
6872 };
6873 let v871 = if (v868 == 2) {
6874 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6875 } else {
6876 None
6877 };
6878 let v872 = if (v868 == 2) {
6879 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6880 } else {
6881 None
6882 };
6883 Title {
6884 action: v868,
6885 text: v869,
6886 fade_in: v870,
6887 stay: v871,
6888 fade_out: v872,
6889 }
6890 }
6891 }
6892}
6893impl From<Title> for ClientboundPlayPacket {
6894 fn from(p: Title) -> Self {
6895 Self::Title(p)
6896 }
6897}
6898
6899#[derive(Debug, Clone, PartialEq)]
6901pub struct SetCompression {
6902 pub threshold: i32,
6904}
6905impl crate::packet::Packet for SetCompression {
6906 const ID: i32 = id::SET_COMPRESSION;
6907 const NAME: &'static str = "set_compression";
6908 const STATE: State = State::Play;
6909 const DIRECTION: Direction = Direction::Clientbound;
6910}
6911impl Decode for SetCompression {
6912 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6913 Ok({
6914 let v873 = r.read_varint()?;
6915 SetCompression { threshold: v873 }
6916 })
6917 }
6918}
6919impl Encode for SetCompression {
6920 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6921 w.put_varint((*self).threshold);
6922 Ok(())
6923 }
6924}
6925#[cfg(feature = "testgen")]
6926impl Generate for SetCompression {
6927 fn generate(g: &mut Gen) -> Self {
6928 {
6929 let v874 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6930 SetCompression { threshold: v874 }
6931 }
6932 }
6933}
6934impl From<SetCompression> for ClientboundPlayPacket {
6935 fn from(p: SetCompression) -> Self {
6936 Self::SetCompression(p)
6937 }
6938}
6939
6940#[derive(Debug, Clone, PartialEq)]
6942pub struct PlayerlistHeader {
6943 pub header: ByteString,
6945 pub footer: ByteString,
6947}
6948impl crate::packet::Packet for PlayerlistHeader {
6949 const ID: i32 = id::PLAYERLIST_HEADER;
6950 const NAME: &'static str = "playerlist_header";
6951 const STATE: State = State::Play;
6952 const DIRECTION: Direction = Direction::Clientbound;
6953}
6954impl Decode for PlayerlistHeader {
6955 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6956 Ok({
6957 let v875 = r.read_string()?;
6958 let v876 = r.read_string()?;
6959 PlayerlistHeader {
6960 header: v875,
6961 footer: v876,
6962 }
6963 })
6964 }
6965}
6966impl Encode for PlayerlistHeader {
6967 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6968 w.put_string(&(*self).header)?;
6969 w.put_string(&(*self).footer)?;
6970 Ok(())
6971 }
6972}
6973#[cfg(feature = "testgen")]
6974impl Generate for PlayerlistHeader {
6975 fn generate(g: &mut Gen) -> Self {
6976 {
6977 let v877 = g.string();
6978 let v878 = g.string();
6979 PlayerlistHeader {
6980 header: v877,
6981 footer: v878,
6982 }
6983 }
6984 }
6985}
6986impl From<PlayerlistHeader> for ClientboundPlayPacket {
6987 fn from(p: PlayerlistHeader) -> Self {
6988 Self::PlayerlistHeader(p)
6989 }
6990}
6991
6992#[derive(Debug, Clone, PartialEq)]
6994pub struct ResourcePackSend {
6995 pub url: ByteString,
6997 pub hash: ByteString,
6999}
7000impl crate::packet::Packet for ResourcePackSend {
7001 const ID: i32 = id::RESOURCE_PACK_SEND;
7002 const NAME: &'static str = "resource_pack_send";
7003 const STATE: State = State::Play;
7004 const DIRECTION: Direction = Direction::Clientbound;
7005}
7006impl Decode for ResourcePackSend {
7007 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7008 Ok({
7009 let v879 = r.read_string()?;
7010 let v880 = r.read_string()?;
7011 ResourcePackSend {
7012 url: v879,
7013 hash: v880,
7014 }
7015 })
7016 }
7017}
7018impl Encode for ResourcePackSend {
7019 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7020 w.put_string(&(*self).url)?;
7021 w.put_string(&(*self).hash)?;
7022 Ok(())
7023 }
7024}
7025#[cfg(feature = "testgen")]
7026impl Generate for ResourcePackSend {
7027 fn generate(g: &mut Gen) -> Self {
7028 {
7029 let v881 = g.string();
7030 let v882 = g.string();
7031 ResourcePackSend {
7032 url: v881,
7033 hash: v882,
7034 }
7035 }
7036 }
7037}
7038impl From<ResourcePackSend> for ClientboundPlayPacket {
7039 fn from(p: ResourcePackSend) -> Self {
7040 Self::ResourcePackSend(p)
7041 }
7042}
7043
7044#[derive(Debug, Clone, PartialEq)]
7046pub struct UpdateEntityNbt {
7047 pub entity_id: i32,
7049 pub tag: RawNbt,
7051}
7052impl crate::packet::Packet for UpdateEntityNbt {
7053 const ID: i32 = id::UPDATE_ENTITY_NBT;
7054 const NAME: &'static str = "update_entity_nbt";
7055 const STATE: State = State::Play;
7056 const DIRECTION: Direction = Direction::Clientbound;
7057}
7058impl Decode for UpdateEntityNbt {
7059 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7060 Ok({
7061 let v883 = r.read_varint()?;
7062 let v884 = RawNbt::read(r)?;
7063 UpdateEntityNbt {
7064 entity_id: v883,
7065 tag: v884,
7066 }
7067 })
7068 }
7069}
7070impl Encode for UpdateEntityNbt {
7071 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7072 w.put_varint((*self).entity_id);
7073 (*self).tag.write(w);
7074 Ok(())
7075 }
7076}
7077#[cfg(feature = "testgen")]
7078impl Generate for UpdateEntityNbt {
7079 fn generate(g: &mut Gen) -> Self {
7080 {
7081 let v885 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7082 let v886 = g.nbt();
7083 UpdateEntityNbt {
7084 entity_id: v885,
7085 tag: v886,
7086 }
7087 }
7088 }
7089}
7090impl From<UpdateEntityNbt> for ClientboundPlayPacket {
7091 fn from(p: UpdateEntityNbt) -> Self {
7092 Self::UpdateEntityNbt(p)
7093 }
7094}
7095
7096#[derive(Debug, Clone, PartialEq)]
7098pub enum ClientboundPlayPacket {
7099 KeepAlive(KeepAlive),
7101 Login(Login),
7103 Chat(Chat),
7105 UpdateTime(UpdateTime),
7107 EntityEquipment(EntityEquipment),
7109 SpawnPosition(SpawnPosition),
7111 UpdateHealth(UpdateHealth),
7113 Respawn(Respawn),
7115 Position(Position),
7117 HeldItemSlot(HeldItemSlot),
7119 Bed(Bed),
7121 Animation(Animation),
7123 NamedEntitySpawn(NamedEntitySpawn),
7125 Collect(Collect),
7127 SpawnEntity(SpawnEntity),
7129 SpawnEntityLiving(SpawnEntityLiving),
7131 SpawnEntityPainting(SpawnEntityPainting),
7133 SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
7135 EntityVelocity(EntityVelocity),
7137 EntityDestroy(EntityDestroy),
7139 Entity(Entity),
7141 RelEntityMove(RelEntityMove),
7143 EntityLook(EntityLook),
7145 EntityMoveLook(EntityMoveLook),
7147 EntityTeleport(EntityTeleport),
7149 EntityHeadRotation(EntityHeadRotation),
7151 EntityStatus(EntityStatus),
7153 AttachEntity(AttachEntity),
7155 EntityMetadata(EntityMetadata),
7157 EntityEffect(EntityEffect),
7159 RemoveEntityEffect(RemoveEntityEffect),
7161 Experience(Experience),
7163 UpdateAttributes(UpdateAttributes),
7165 MapChunk(MapChunk),
7167 MultiBlockChange(MultiBlockChange),
7169 BlockChange(BlockChange),
7171 BlockAction(BlockAction),
7173 BlockBreakAnimation(BlockBreakAnimation),
7175 MapChunkBulk(MapChunkBulk),
7177 Explosion(Explosion),
7179 WorldEvent(WorldEvent),
7181 NamedSoundEffect(NamedSoundEffect),
7183 WorldParticles(WorldParticles),
7185 GameStateChange(GameStateChange),
7187 SpawnEntityWeather(SpawnEntityWeather),
7189 OpenWindow(OpenWindow),
7191 CloseWindow(CloseWindow),
7193 SetSlot(SetSlot),
7195 WindowItems(WindowItems),
7197 CraftProgressBar(CraftProgressBar),
7199 Transaction(Transaction),
7201 UpdateSign(UpdateSign),
7203 Map(Map),
7205 TileEntityData(TileEntityData),
7207 OpenSignEntity(OpenSignEntity),
7209 Statistics(Statistics),
7211 PlayerInfo(PlayerInfo),
7213 Abilities(Abilities),
7215 TabComplete(TabComplete),
7217 ScoreboardObjective(ScoreboardObjective),
7219 ScoreboardScore(ScoreboardScore),
7221 ScoreboardDisplayObjective(ScoreboardDisplayObjective),
7223 ScoreboardTeam(ScoreboardTeam),
7225 CustomPayload(CustomPayload),
7227 KickDisconnect(KickDisconnect),
7229 Difficulty(Difficulty),
7231 CombatEvent(CombatEvent),
7233 Camera(Camera),
7235 WorldBorder(WorldBorder),
7237 Title(Title),
7239 SetCompression(SetCompression),
7241 PlayerlistHeader(PlayerlistHeader),
7243 ResourcePackSend(ResourcePackSend),
7245 UpdateEntityNbt(UpdateEntityNbt),
7247}
7248
7249impl PacketSet for ClientboundPlayPacket {
7250 const STATE: State = State::Play;
7251 const DIRECTION: Direction = Direction::Clientbound;
7252 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
7253 match raw.id {
7254 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
7255 id::LOGIN => decode_exact(&raw.body).map(Self::Login),
7256 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
7257 id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
7258 id::ENTITY_EQUIPMENT => decode_exact(&raw.body).map(Self::EntityEquipment),
7259 id::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
7260 id::UPDATE_HEALTH => decode_exact(&raw.body).map(Self::UpdateHealth),
7261 id::RESPAWN => decode_exact(&raw.body).map(Self::Respawn),
7262 id::POSITION => decode_exact(&raw.body).map(Self::Position),
7263 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
7264 id::BED => decode_exact(&raw.body).map(Self::Bed),
7265 id::ANIMATION => decode_exact(&raw.body).map(Self::Animation),
7266 id::NAMED_ENTITY_SPAWN => decode_exact(&raw.body).map(Self::NamedEntitySpawn),
7267 id::COLLECT => decode_exact(&raw.body).map(Self::Collect),
7268 id::SPAWN_ENTITY => decode_exact(&raw.body).map(Self::SpawnEntity),
7269 id::SPAWN_ENTITY_LIVING => decode_exact(&raw.body).map(Self::SpawnEntityLiving),
7270 id::SPAWN_ENTITY_PAINTING => decode_exact(&raw.body).map(Self::SpawnEntityPainting),
7271 id::SPAWN_ENTITY_EXPERIENCE_ORB => {
7272 decode_exact(&raw.body).map(Self::SpawnEntityExperienceOrb)
7273 }
7274 id::ENTITY_VELOCITY => decode_exact(&raw.body).map(Self::EntityVelocity),
7275 id::ENTITY_DESTROY => decode_exact(&raw.body).map(Self::EntityDestroy),
7276 id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
7277 id::REL_ENTITY_MOVE => decode_exact(&raw.body).map(Self::RelEntityMove),
7278 id::ENTITY_LOOK => decode_exact(&raw.body).map(Self::EntityLook),
7279 id::ENTITY_MOVE_LOOK => decode_exact(&raw.body).map(Self::EntityMoveLook),
7280 id::ENTITY_TELEPORT => decode_exact(&raw.body).map(Self::EntityTeleport),
7281 id::ENTITY_HEAD_ROTATION => decode_exact(&raw.body).map(Self::EntityHeadRotation),
7282 id::ENTITY_STATUS => decode_exact(&raw.body).map(Self::EntityStatus),
7283 id::ATTACH_ENTITY => decode_exact(&raw.body).map(Self::AttachEntity),
7284 id::ENTITY_METADATA => decode_exact(&raw.body).map(Self::EntityMetadata),
7285 id::ENTITY_EFFECT => decode_exact(&raw.body).map(Self::EntityEffect),
7286 id::REMOVE_ENTITY_EFFECT => decode_exact(&raw.body).map(Self::RemoveEntityEffect),
7287 id::EXPERIENCE => decode_exact(&raw.body).map(Self::Experience),
7288 id::UPDATE_ATTRIBUTES => decode_exact(&raw.body).map(Self::UpdateAttributes),
7289 id::MAP_CHUNK => decode_exact(&raw.body).map(Self::MapChunk),
7290 id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
7291 id::BLOCK_CHANGE => decode_exact(&raw.body).map(Self::BlockChange),
7292 id::BLOCK_ACTION => decode_exact(&raw.body).map(Self::BlockAction),
7293 id::BLOCK_BREAK_ANIMATION => decode_exact(&raw.body).map(Self::BlockBreakAnimation),
7294 id::MAP_CHUNK_BULK => decode_exact(&raw.body).map(Self::MapChunkBulk),
7295 id::EXPLOSION => decode_exact(&raw.body).map(Self::Explosion),
7296 id::WORLD_EVENT => decode_exact(&raw.body).map(Self::WorldEvent),
7297 id::NAMED_SOUND_EFFECT => decode_exact(&raw.body).map(Self::NamedSoundEffect),
7298 id::WORLD_PARTICLES => decode_exact(&raw.body).map(Self::WorldParticles),
7299 id::GAME_STATE_CHANGE => decode_exact(&raw.body).map(Self::GameStateChange),
7300 id::SPAWN_ENTITY_WEATHER => decode_exact(&raw.body).map(Self::SpawnEntityWeather),
7301 id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
7302 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
7303 id::SET_SLOT => decode_exact(&raw.body).map(Self::SetSlot),
7304 id::WINDOW_ITEMS => decode_exact(&raw.body).map(Self::WindowItems),
7305 id::CRAFT_PROGRESS_BAR => decode_exact(&raw.body).map(Self::CraftProgressBar),
7306 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
7307 id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
7308 id::MAP => decode_exact(&raw.body).map(Self::Map),
7309 id::TILE_ENTITY_DATA => decode_exact(&raw.body).map(Self::TileEntityData),
7310 id::OPEN_SIGN_ENTITY => decode_exact(&raw.body).map(Self::OpenSignEntity),
7311 id::STATISTICS => decode_exact(&raw.body).map(Self::Statistics),
7312 id::PLAYER_INFO => decode_exact(&raw.body).map(Self::PlayerInfo),
7313 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
7314 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
7315 id::SCOREBOARD_OBJECTIVE => decode_exact(&raw.body).map(Self::ScoreboardObjective),
7316 id::SCOREBOARD_SCORE => decode_exact(&raw.body).map(Self::ScoreboardScore),
7317 id::SCOREBOARD_DISPLAY_OBJECTIVE => {
7318 decode_exact(&raw.body).map(Self::ScoreboardDisplayObjective)
7319 }
7320 id::SCOREBOARD_TEAM => decode_exact(&raw.body).map(Self::ScoreboardTeam),
7321 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
7322 id::KICK_DISCONNECT => decode_exact(&raw.body).map(Self::KickDisconnect),
7323 id::DIFFICULTY => decode_exact(&raw.body).map(Self::Difficulty),
7324 id::COMBAT_EVENT => decode_exact(&raw.body).map(Self::CombatEvent),
7325 id::CAMERA => decode_exact(&raw.body).map(Self::Camera),
7326 id::WORLD_BORDER => decode_exact(&raw.body).map(Self::WorldBorder),
7327 id::TITLE => decode_exact(&raw.body).map(Self::Title),
7328 id::SET_COMPRESSION => decode_exact(&raw.body).map(Self::SetCompression),
7329 id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
7330 id::RESOURCE_PACK_SEND => decode_exact(&raw.body).map(Self::ResourcePackSend),
7331 id::UPDATE_ENTITY_NBT => decode_exact(&raw.body).map(Self::UpdateEntityNbt),
7332 other => Err(DecodeError::UnknownPacketId(other)),
7333 }
7334 }
7335 fn id(&self) -> i32 {
7336 match *self {
7337 Self::KeepAlive(_) => id::KEEP_ALIVE,
7338 Self::Login(_) => id::LOGIN,
7339 Self::Chat(_) => id::CHAT,
7340 Self::UpdateTime(_) => id::UPDATE_TIME,
7341 Self::EntityEquipment(_) => id::ENTITY_EQUIPMENT,
7342 Self::SpawnPosition(_) => id::SPAWN_POSITION,
7343 Self::UpdateHealth(_) => id::UPDATE_HEALTH,
7344 Self::Respawn(_) => id::RESPAWN,
7345 Self::Position(_) => id::POSITION,
7346 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
7347 Self::Bed(_) => id::BED,
7348 Self::Animation(_) => id::ANIMATION,
7349 Self::NamedEntitySpawn(_) => id::NAMED_ENTITY_SPAWN,
7350 Self::Collect(_) => id::COLLECT,
7351 Self::SpawnEntity(_) => id::SPAWN_ENTITY,
7352 Self::SpawnEntityLiving(_) => id::SPAWN_ENTITY_LIVING,
7353 Self::SpawnEntityPainting(_) => id::SPAWN_ENTITY_PAINTING,
7354 Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
7355 Self::EntityVelocity(_) => id::ENTITY_VELOCITY,
7356 Self::EntityDestroy(_) => id::ENTITY_DESTROY,
7357 Self::Entity(_) => id::ENTITY,
7358 Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
7359 Self::EntityLook(_) => id::ENTITY_LOOK,
7360 Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
7361 Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
7362 Self::EntityHeadRotation(_) => id::ENTITY_HEAD_ROTATION,
7363 Self::EntityStatus(_) => id::ENTITY_STATUS,
7364 Self::AttachEntity(_) => id::ATTACH_ENTITY,
7365 Self::EntityMetadata(_) => id::ENTITY_METADATA,
7366 Self::EntityEffect(_) => id::ENTITY_EFFECT,
7367 Self::RemoveEntityEffect(_) => id::REMOVE_ENTITY_EFFECT,
7368 Self::Experience(_) => id::EXPERIENCE,
7369 Self::UpdateAttributes(_) => id::UPDATE_ATTRIBUTES,
7370 Self::MapChunk(_) => id::MAP_CHUNK,
7371 Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
7372 Self::BlockChange(_) => id::BLOCK_CHANGE,
7373 Self::BlockAction(_) => id::BLOCK_ACTION,
7374 Self::BlockBreakAnimation(_) => id::BLOCK_BREAK_ANIMATION,
7375 Self::MapChunkBulk(_) => id::MAP_CHUNK_BULK,
7376 Self::Explosion(_) => id::EXPLOSION,
7377 Self::WorldEvent(_) => id::WORLD_EVENT,
7378 Self::NamedSoundEffect(_) => id::NAMED_SOUND_EFFECT,
7379 Self::WorldParticles(_) => id::WORLD_PARTICLES,
7380 Self::GameStateChange(_) => id::GAME_STATE_CHANGE,
7381 Self::SpawnEntityWeather(_) => id::SPAWN_ENTITY_WEATHER,
7382 Self::OpenWindow(_) => id::OPEN_WINDOW,
7383 Self::CloseWindow(_) => id::CLOSE_WINDOW,
7384 Self::SetSlot(_) => id::SET_SLOT,
7385 Self::WindowItems(_) => id::WINDOW_ITEMS,
7386 Self::CraftProgressBar(_) => id::CRAFT_PROGRESS_BAR,
7387 Self::Transaction(_) => id::TRANSACTION,
7388 Self::UpdateSign(_) => id::UPDATE_SIGN,
7389 Self::Map(_) => id::MAP,
7390 Self::TileEntityData(_) => id::TILE_ENTITY_DATA,
7391 Self::OpenSignEntity(_) => id::OPEN_SIGN_ENTITY,
7392 Self::Statistics(_) => id::STATISTICS,
7393 Self::PlayerInfo(_) => id::PLAYER_INFO,
7394 Self::Abilities(_) => id::ABILITIES,
7395 Self::TabComplete(_) => id::TAB_COMPLETE,
7396 Self::ScoreboardObjective(_) => id::SCOREBOARD_OBJECTIVE,
7397 Self::ScoreboardScore(_) => id::SCOREBOARD_SCORE,
7398 Self::ScoreboardDisplayObjective(_) => id::SCOREBOARD_DISPLAY_OBJECTIVE,
7399 Self::ScoreboardTeam(_) => id::SCOREBOARD_TEAM,
7400 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
7401 Self::KickDisconnect(_) => id::KICK_DISCONNECT,
7402 Self::Difficulty(_) => id::DIFFICULTY,
7403 Self::CombatEvent(_) => id::COMBAT_EVENT,
7404 Self::Camera(_) => id::CAMERA,
7405 Self::WorldBorder(_) => id::WORLD_BORDER,
7406 Self::Title(_) => id::TITLE,
7407 Self::SetCompression(_) => id::SET_COMPRESSION,
7408 Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
7409 Self::ResourcePackSend(_) => id::RESOURCE_PACK_SEND,
7410 Self::UpdateEntityNbt(_) => id::UPDATE_ENTITY_NBT,
7411 }
7412 }
7413 fn name(&self) -> &'static str {
7414 match *self {
7415 Self::KeepAlive(_) => "keep_alive",
7416 Self::Login(_) => "login",
7417 Self::Chat(_) => "chat",
7418 Self::UpdateTime(_) => "update_time",
7419 Self::EntityEquipment(_) => "entity_equipment",
7420 Self::SpawnPosition(_) => "spawn_position",
7421 Self::UpdateHealth(_) => "update_health",
7422 Self::Respawn(_) => "respawn",
7423 Self::Position(_) => "position",
7424 Self::HeldItemSlot(_) => "held_item_slot",
7425 Self::Bed(_) => "bed",
7426 Self::Animation(_) => "animation",
7427 Self::NamedEntitySpawn(_) => "named_entity_spawn",
7428 Self::Collect(_) => "collect",
7429 Self::SpawnEntity(_) => "spawn_entity",
7430 Self::SpawnEntityLiving(_) => "spawn_entity_living",
7431 Self::SpawnEntityPainting(_) => "spawn_entity_painting",
7432 Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
7433 Self::EntityVelocity(_) => "entity_velocity",
7434 Self::EntityDestroy(_) => "entity_destroy",
7435 Self::Entity(_) => "entity",
7436 Self::RelEntityMove(_) => "rel_entity_move",
7437 Self::EntityLook(_) => "entity_look",
7438 Self::EntityMoveLook(_) => "entity_move_look",
7439 Self::EntityTeleport(_) => "entity_teleport",
7440 Self::EntityHeadRotation(_) => "entity_head_rotation",
7441 Self::EntityStatus(_) => "entity_status",
7442 Self::AttachEntity(_) => "attach_entity",
7443 Self::EntityMetadata(_) => "entity_metadata",
7444 Self::EntityEffect(_) => "entity_effect",
7445 Self::RemoveEntityEffect(_) => "remove_entity_effect",
7446 Self::Experience(_) => "experience",
7447 Self::UpdateAttributes(_) => "update_attributes",
7448 Self::MapChunk(_) => "map_chunk",
7449 Self::MultiBlockChange(_) => "multi_block_change",
7450 Self::BlockChange(_) => "block_change",
7451 Self::BlockAction(_) => "block_action",
7452 Self::BlockBreakAnimation(_) => "block_break_animation",
7453 Self::MapChunkBulk(_) => "map_chunk_bulk",
7454 Self::Explosion(_) => "explosion",
7455 Self::WorldEvent(_) => "world_event",
7456 Self::NamedSoundEffect(_) => "named_sound_effect",
7457 Self::WorldParticles(_) => "world_particles",
7458 Self::GameStateChange(_) => "game_state_change",
7459 Self::SpawnEntityWeather(_) => "spawn_entity_weather",
7460 Self::OpenWindow(_) => "open_window",
7461 Self::CloseWindow(_) => "close_window",
7462 Self::SetSlot(_) => "set_slot",
7463 Self::WindowItems(_) => "window_items",
7464 Self::CraftProgressBar(_) => "craft_progress_bar",
7465 Self::Transaction(_) => "transaction",
7466 Self::UpdateSign(_) => "update_sign",
7467 Self::Map(_) => "map",
7468 Self::TileEntityData(_) => "tile_entity_data",
7469 Self::OpenSignEntity(_) => "open_sign_entity",
7470 Self::Statistics(_) => "statistics",
7471 Self::PlayerInfo(_) => "player_info",
7472 Self::Abilities(_) => "abilities",
7473 Self::TabComplete(_) => "tab_complete",
7474 Self::ScoreboardObjective(_) => "scoreboard_objective",
7475 Self::ScoreboardScore(_) => "scoreboard_score",
7476 Self::ScoreboardDisplayObjective(_) => "scoreboard_display_objective",
7477 Self::ScoreboardTeam(_) => "scoreboard_team",
7478 Self::CustomPayload(_) => "custom_payload",
7479 Self::KickDisconnect(_) => "kick_disconnect",
7480 Self::Difficulty(_) => "difficulty",
7481 Self::CombatEvent(_) => "combat_event",
7482 Self::Camera(_) => "camera",
7483 Self::WorldBorder(_) => "world_border",
7484 Self::Title(_) => "title",
7485 Self::SetCompression(_) => "set_compression",
7486 Self::PlayerlistHeader(_) => "playerlist_header",
7487 Self::ResourcePackSend(_) => "resource_pack_send",
7488 Self::UpdateEntityNbt(_) => "update_entity_nbt",
7489 }
7490 }
7491 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
7492 match *self {
7493 Self::KeepAlive(ref p) => p.encode(w),
7494 Self::Login(ref p) => p.encode(w),
7495 Self::Chat(ref p) => p.encode(w),
7496 Self::UpdateTime(ref p) => p.encode(w),
7497 Self::EntityEquipment(ref p) => p.encode(w),
7498 Self::SpawnPosition(ref p) => p.encode(w),
7499 Self::UpdateHealth(ref p) => p.encode(w),
7500 Self::Respawn(ref p) => p.encode(w),
7501 Self::Position(ref p) => p.encode(w),
7502 Self::HeldItemSlot(ref p) => p.encode(w),
7503 Self::Bed(ref p) => p.encode(w),
7504 Self::Animation(ref p) => p.encode(w),
7505 Self::NamedEntitySpawn(ref p) => p.encode(w),
7506 Self::Collect(ref p) => p.encode(w),
7507 Self::SpawnEntity(ref p) => p.encode(w),
7508 Self::SpawnEntityLiving(ref p) => p.encode(w),
7509 Self::SpawnEntityPainting(ref p) => p.encode(w),
7510 Self::SpawnEntityExperienceOrb(ref p) => p.encode(w),
7511 Self::EntityVelocity(ref p) => p.encode(w),
7512 Self::EntityDestroy(ref p) => p.encode(w),
7513 Self::Entity(ref p) => p.encode(w),
7514 Self::RelEntityMove(ref p) => p.encode(w),
7515 Self::EntityLook(ref p) => p.encode(w),
7516 Self::EntityMoveLook(ref p) => p.encode(w),
7517 Self::EntityTeleport(ref p) => p.encode(w),
7518 Self::EntityHeadRotation(ref p) => p.encode(w),
7519 Self::EntityStatus(ref p) => p.encode(w),
7520 Self::AttachEntity(ref p) => p.encode(w),
7521 Self::EntityMetadata(ref p) => p.encode(w),
7522 Self::EntityEffect(ref p) => p.encode(w),
7523 Self::RemoveEntityEffect(ref p) => p.encode(w),
7524 Self::Experience(ref p) => p.encode(w),
7525 Self::UpdateAttributes(ref p) => p.encode(w),
7526 Self::MapChunk(ref p) => p.encode(w),
7527 Self::MultiBlockChange(ref p) => p.encode(w),
7528 Self::BlockChange(ref p) => p.encode(w),
7529 Self::BlockAction(ref p) => p.encode(w),
7530 Self::BlockBreakAnimation(ref p) => p.encode(w),
7531 Self::MapChunkBulk(ref p) => p.encode(w),
7532 Self::Explosion(ref p) => p.encode(w),
7533 Self::WorldEvent(ref p) => p.encode(w),
7534 Self::NamedSoundEffect(ref p) => p.encode(w),
7535 Self::WorldParticles(ref p) => p.encode(w),
7536 Self::GameStateChange(ref p) => p.encode(w),
7537 Self::SpawnEntityWeather(ref p) => p.encode(w),
7538 Self::OpenWindow(ref p) => p.encode(w),
7539 Self::CloseWindow(ref p) => p.encode(w),
7540 Self::SetSlot(ref p) => p.encode(w),
7541 Self::WindowItems(ref p) => p.encode(w),
7542 Self::CraftProgressBar(ref p) => p.encode(w),
7543 Self::Transaction(ref p) => p.encode(w),
7544 Self::UpdateSign(ref p) => p.encode(w),
7545 Self::Map(ref p) => p.encode(w),
7546 Self::TileEntityData(ref p) => p.encode(w),
7547 Self::OpenSignEntity(ref p) => p.encode(w),
7548 Self::Statistics(ref p) => p.encode(w),
7549 Self::PlayerInfo(ref p) => p.encode(w),
7550 Self::Abilities(ref p) => p.encode(w),
7551 Self::TabComplete(ref p) => p.encode(w),
7552 Self::ScoreboardObjective(ref p) => p.encode(w),
7553 Self::ScoreboardScore(ref p) => p.encode(w),
7554 Self::ScoreboardDisplayObjective(ref p) => p.encode(w),
7555 Self::ScoreboardTeam(ref p) => p.encode(w),
7556 Self::CustomPayload(ref p) => p.encode(w),
7557 Self::KickDisconnect(ref p) => p.encode(w),
7558 Self::Difficulty(ref p) => p.encode(w),
7559 Self::CombatEvent(ref p) => p.encode(w),
7560 Self::Camera(ref p) => p.encode(w),
7561 Self::WorldBorder(ref p) => p.encode(w),
7562 Self::Title(ref p) => p.encode(w),
7563 Self::SetCompression(ref p) => p.encode(w),
7564 Self::PlayerlistHeader(ref p) => p.encode(w),
7565 Self::ResourcePackSend(ref p) => p.encode(w),
7566 Self::UpdateEntityNbt(ref p) => p.encode(w),
7567 }
7568 }
7569 fn name_of(id: i32) -> Option<&'static str> {
7570 match id {
7571 id::KEEP_ALIVE => Some("keep_alive"),
7572 id::LOGIN => Some("login"),
7573 id::CHAT => Some("chat"),
7574 id::UPDATE_TIME => Some("update_time"),
7575 id::ENTITY_EQUIPMENT => Some("entity_equipment"),
7576 id::SPAWN_POSITION => Some("spawn_position"),
7577 id::UPDATE_HEALTH => Some("update_health"),
7578 id::RESPAWN => Some("respawn"),
7579 id::POSITION => Some("position"),
7580 id::HELD_ITEM_SLOT => Some("held_item_slot"),
7581 id::BED => Some("bed"),
7582 id::ANIMATION => Some("animation"),
7583 id::NAMED_ENTITY_SPAWN => Some("named_entity_spawn"),
7584 id::COLLECT => Some("collect"),
7585 id::SPAWN_ENTITY => Some("spawn_entity"),
7586 id::SPAWN_ENTITY_LIVING => Some("spawn_entity_living"),
7587 id::SPAWN_ENTITY_PAINTING => Some("spawn_entity_painting"),
7588 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some("spawn_entity_experience_orb"),
7589 id::ENTITY_VELOCITY => Some("entity_velocity"),
7590 id::ENTITY_DESTROY => Some("entity_destroy"),
7591 id::ENTITY => Some("entity"),
7592 id::REL_ENTITY_MOVE => Some("rel_entity_move"),
7593 id::ENTITY_LOOK => Some("entity_look"),
7594 id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
7595 id::ENTITY_TELEPORT => Some("entity_teleport"),
7596 id::ENTITY_HEAD_ROTATION => Some("entity_head_rotation"),
7597 id::ENTITY_STATUS => Some("entity_status"),
7598 id::ATTACH_ENTITY => Some("attach_entity"),
7599 id::ENTITY_METADATA => Some("entity_metadata"),
7600 id::ENTITY_EFFECT => Some("entity_effect"),
7601 id::REMOVE_ENTITY_EFFECT => Some("remove_entity_effect"),
7602 id::EXPERIENCE => Some("experience"),
7603 id::UPDATE_ATTRIBUTES => Some("update_attributes"),
7604 id::MAP_CHUNK => Some("map_chunk"),
7605 id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
7606 id::BLOCK_CHANGE => Some("block_change"),
7607 id::BLOCK_ACTION => Some("block_action"),
7608 id::BLOCK_BREAK_ANIMATION => Some("block_break_animation"),
7609 id::MAP_CHUNK_BULK => Some("map_chunk_bulk"),
7610 id::EXPLOSION => Some("explosion"),
7611 id::WORLD_EVENT => Some("world_event"),
7612 id::NAMED_SOUND_EFFECT => Some("named_sound_effect"),
7613 id::WORLD_PARTICLES => Some("world_particles"),
7614 id::GAME_STATE_CHANGE => Some("game_state_change"),
7615 id::SPAWN_ENTITY_WEATHER => Some("spawn_entity_weather"),
7616 id::OPEN_WINDOW => Some("open_window"),
7617 id::CLOSE_WINDOW => Some("close_window"),
7618 id::SET_SLOT => Some("set_slot"),
7619 id::WINDOW_ITEMS => Some("window_items"),
7620 id::CRAFT_PROGRESS_BAR => Some("craft_progress_bar"),
7621 id::TRANSACTION => Some("transaction"),
7622 id::UPDATE_SIGN => Some("update_sign"),
7623 id::MAP => Some("map"),
7624 id::TILE_ENTITY_DATA => Some("tile_entity_data"),
7625 id::OPEN_SIGN_ENTITY => Some("open_sign_entity"),
7626 id::STATISTICS => Some("statistics"),
7627 id::PLAYER_INFO => Some("player_info"),
7628 id::ABILITIES => Some("abilities"),
7629 id::TAB_COMPLETE => Some("tab_complete"),
7630 id::SCOREBOARD_OBJECTIVE => Some("scoreboard_objective"),
7631 id::SCOREBOARD_SCORE => Some("scoreboard_score"),
7632 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some("scoreboard_display_objective"),
7633 id::SCOREBOARD_TEAM => Some("scoreboard_team"),
7634 id::CUSTOM_PAYLOAD => Some("custom_payload"),
7635 id::KICK_DISCONNECT => Some("kick_disconnect"),
7636 id::DIFFICULTY => Some("difficulty"),
7637 id::COMBAT_EVENT => Some("combat_event"),
7638 id::CAMERA => Some("camera"),
7639 id::WORLD_BORDER => Some("world_border"),
7640 id::TITLE => Some("title"),
7641 id::SET_COMPRESSION => Some("set_compression"),
7642 id::PLAYERLIST_HEADER => Some("playerlist_header"),
7643 id::RESOURCE_PACK_SEND => Some("resource_pack_send"),
7644 id::UPDATE_ENTITY_NBT => Some("update_entity_nbt"),
7645 _ => None,
7646 }
7647 }
7648}
7649
7650impl ClientboundPlayPacket {
7651 pub const IDS: &'static [i32] = &[
7653 id::KEEP_ALIVE,
7654 id::LOGIN,
7655 id::CHAT,
7656 id::UPDATE_TIME,
7657 id::ENTITY_EQUIPMENT,
7658 id::SPAWN_POSITION,
7659 id::UPDATE_HEALTH,
7660 id::RESPAWN,
7661 id::POSITION,
7662 id::HELD_ITEM_SLOT,
7663 id::BED,
7664 id::ANIMATION,
7665 id::NAMED_ENTITY_SPAWN,
7666 id::COLLECT,
7667 id::SPAWN_ENTITY,
7668 id::SPAWN_ENTITY_LIVING,
7669 id::SPAWN_ENTITY_PAINTING,
7670 id::SPAWN_ENTITY_EXPERIENCE_ORB,
7671 id::ENTITY_VELOCITY,
7672 id::ENTITY_DESTROY,
7673 id::ENTITY,
7674 id::REL_ENTITY_MOVE,
7675 id::ENTITY_LOOK,
7676 id::ENTITY_MOVE_LOOK,
7677 id::ENTITY_TELEPORT,
7678 id::ENTITY_HEAD_ROTATION,
7679 id::ENTITY_STATUS,
7680 id::ATTACH_ENTITY,
7681 id::ENTITY_METADATA,
7682 id::ENTITY_EFFECT,
7683 id::REMOVE_ENTITY_EFFECT,
7684 id::EXPERIENCE,
7685 id::UPDATE_ATTRIBUTES,
7686 id::MAP_CHUNK,
7687 id::MULTI_BLOCK_CHANGE,
7688 id::BLOCK_CHANGE,
7689 id::BLOCK_ACTION,
7690 id::BLOCK_BREAK_ANIMATION,
7691 id::MAP_CHUNK_BULK,
7692 id::EXPLOSION,
7693 id::WORLD_EVENT,
7694 id::NAMED_SOUND_EFFECT,
7695 id::WORLD_PARTICLES,
7696 id::GAME_STATE_CHANGE,
7697 id::SPAWN_ENTITY_WEATHER,
7698 id::OPEN_WINDOW,
7699 id::CLOSE_WINDOW,
7700 id::SET_SLOT,
7701 id::WINDOW_ITEMS,
7702 id::CRAFT_PROGRESS_BAR,
7703 id::TRANSACTION,
7704 id::UPDATE_SIGN,
7705 id::MAP,
7706 id::TILE_ENTITY_DATA,
7707 id::OPEN_SIGN_ENTITY,
7708 id::STATISTICS,
7709 id::PLAYER_INFO,
7710 id::ABILITIES,
7711 id::TAB_COMPLETE,
7712 id::SCOREBOARD_OBJECTIVE,
7713 id::SCOREBOARD_SCORE,
7714 id::SCOREBOARD_DISPLAY_OBJECTIVE,
7715 id::SCOREBOARD_TEAM,
7716 id::CUSTOM_PAYLOAD,
7717 id::KICK_DISCONNECT,
7718 id::DIFFICULTY,
7719 id::COMBAT_EVENT,
7720 id::CAMERA,
7721 id::WORLD_BORDER,
7722 id::TITLE,
7723 id::SET_COMPRESSION,
7724 id::PLAYERLIST_HEADER,
7725 id::RESOURCE_PACK_SEND,
7726 id::UPDATE_ENTITY_NBT,
7727 ];
7728 #[cfg(feature = "testgen")]
7730 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
7731 match id {
7732 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
7733 id::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
7734 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
7735 id::UPDATE_TIME => Some(Self::UpdateTime(<UpdateTime as Generate>::generate(g))),
7736 id::ENTITY_EQUIPMENT => Some(Self::EntityEquipment(
7737 <EntityEquipment as Generate>::generate(g),
7738 )),
7739 id::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition as Generate>::generate(
7740 g,
7741 ))),
7742 id::UPDATE_HEALTH => Some(Self::UpdateHealth(<UpdateHealth as Generate>::generate(g))),
7743 id::RESPAWN => Some(Self::Respawn(<Respawn as Generate>::generate(g))),
7744 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
7745 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
7746 id::BED => Some(Self::Bed(<Bed as Generate>::generate(g))),
7747 id::ANIMATION => Some(Self::Animation(<Animation as Generate>::generate(g))),
7748 id::NAMED_ENTITY_SPAWN => Some(Self::NamedEntitySpawn(
7749 <NamedEntitySpawn as Generate>::generate(g),
7750 )),
7751 id::COLLECT => Some(Self::Collect(<Collect as Generate>::generate(g))),
7752 id::SPAWN_ENTITY => Some(Self::SpawnEntity(<SpawnEntity as Generate>::generate(g))),
7753 id::SPAWN_ENTITY_LIVING => Some(Self::SpawnEntityLiving(
7754 <SpawnEntityLiving as Generate>::generate(g),
7755 )),
7756 id::SPAWN_ENTITY_PAINTING => Some(Self::SpawnEntityPainting(
7757 <SpawnEntityPainting as Generate>::generate(g),
7758 )),
7759 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some(Self::SpawnEntityExperienceOrb(
7760 <SpawnEntityExperienceOrb as Generate>::generate(g),
7761 )),
7762 id::ENTITY_VELOCITY => Some(Self::EntityVelocity(
7763 <EntityVelocity as Generate>::generate(g),
7764 )),
7765 id::ENTITY_DESTROY => Some(Self::EntityDestroy(<EntityDestroy as Generate>::generate(
7766 g,
7767 ))),
7768 id::ENTITY => Some(Self::Entity(<Entity as Generate>::generate(g))),
7769 id::REL_ENTITY_MOVE => Some(Self::RelEntityMove(
7770 <RelEntityMove as Generate>::generate(g),
7771 )),
7772 id::ENTITY_LOOK => Some(Self::EntityLook(<EntityLook as Generate>::generate(g))),
7773 id::ENTITY_MOVE_LOOK => Some(Self::EntityMoveLook(
7774 <EntityMoveLook as Generate>::generate(g),
7775 )),
7776 id::ENTITY_TELEPORT => Some(Self::EntityTeleport(
7777 <EntityTeleport as Generate>::generate(g),
7778 )),
7779 id::ENTITY_HEAD_ROTATION => Some(Self::EntityHeadRotation(
7780 <EntityHeadRotation as Generate>::generate(g),
7781 )),
7782 id::ENTITY_STATUS => Some(Self::EntityStatus(<EntityStatus as Generate>::generate(g))),
7783 id::ATTACH_ENTITY => Some(Self::AttachEntity(<AttachEntity as Generate>::generate(g))),
7784 id::ENTITY_METADATA => Some(Self::EntityMetadata(
7785 <EntityMetadata as Generate>::generate(g),
7786 )),
7787 id::ENTITY_EFFECT => Some(Self::EntityEffect(<EntityEffect as Generate>::generate(g))),
7788 id::REMOVE_ENTITY_EFFECT => Some(Self::RemoveEntityEffect(
7789 <RemoveEntityEffect as Generate>::generate(g),
7790 )),
7791 id::EXPERIENCE => Some(Self::Experience(<Experience as Generate>::generate(g))),
7792 id::UPDATE_ATTRIBUTES => Some(Self::UpdateAttributes(
7793 <UpdateAttributes as Generate>::generate(g),
7794 )),
7795 id::MAP_CHUNK => Some(Self::MapChunk(<MapChunk as Generate>::generate(g))),
7796 id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
7797 <MultiBlockChange as Generate>::generate(g),
7798 )),
7799 id::BLOCK_CHANGE => Some(Self::BlockChange(<BlockChange as Generate>::generate(g))),
7800 id::BLOCK_ACTION => Some(Self::BlockAction(<BlockAction as Generate>::generate(g))),
7801 id::BLOCK_BREAK_ANIMATION => Some(Self::BlockBreakAnimation(
7802 <BlockBreakAnimation as Generate>::generate(g),
7803 )),
7804 id::MAP_CHUNK_BULK => Some(Self::MapChunkBulk(<MapChunkBulk as Generate>::generate(g))),
7805 id::EXPLOSION => Some(Self::Explosion(<Explosion as Generate>::generate(g))),
7806 id::WORLD_EVENT => Some(Self::WorldEvent(<WorldEvent as Generate>::generate(g))),
7807 id::NAMED_SOUND_EFFECT => Some(Self::NamedSoundEffect(
7808 <NamedSoundEffect as Generate>::generate(g),
7809 )),
7810 id::WORLD_PARTICLES => Some(Self::WorldParticles(
7811 <WorldParticles as Generate>::generate(g),
7812 )),
7813 id::GAME_STATE_CHANGE => Some(Self::GameStateChange(
7814 <GameStateChange as Generate>::generate(g),
7815 )),
7816 id::SPAWN_ENTITY_WEATHER => Some(Self::SpawnEntityWeather(
7817 <SpawnEntityWeather as Generate>::generate(g),
7818 )),
7819 id::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow as Generate>::generate(g))),
7820 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
7821 id::SET_SLOT => Some(Self::SetSlot(<SetSlot as Generate>::generate(g))),
7822 id::WINDOW_ITEMS => Some(Self::WindowItems(<WindowItems as Generate>::generate(g))),
7823 id::CRAFT_PROGRESS_BAR => Some(Self::CraftProgressBar(
7824 <CraftProgressBar as Generate>::generate(g),
7825 )),
7826 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
7827 id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
7828 id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
7829 id::TILE_ENTITY_DATA => Some(Self::TileEntityData(
7830 <TileEntityData as Generate>::generate(g),
7831 )),
7832 id::OPEN_SIGN_ENTITY => Some(Self::OpenSignEntity(
7833 <OpenSignEntity as Generate>::generate(g),
7834 )),
7835 id::STATISTICS => Some(Self::Statistics(<Statistics as Generate>::generate(g))),
7836 id::PLAYER_INFO => Some(Self::PlayerInfo(<PlayerInfo as Generate>::generate(g))),
7837 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
7838 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
7839 id::SCOREBOARD_OBJECTIVE => Some(Self::ScoreboardObjective(
7840 <ScoreboardObjective as Generate>::generate(g),
7841 )),
7842 id::SCOREBOARD_SCORE => Some(Self::ScoreboardScore(
7843 <ScoreboardScore as Generate>::generate(g),
7844 )),
7845 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some(Self::ScoreboardDisplayObjective(
7846 <ScoreboardDisplayObjective as Generate>::generate(g),
7847 )),
7848 id::SCOREBOARD_TEAM => Some(Self::ScoreboardTeam(
7849 <ScoreboardTeam as Generate>::generate(g),
7850 )),
7851 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
7852 g,
7853 ))),
7854 id::KICK_DISCONNECT => Some(Self::KickDisconnect(
7855 <KickDisconnect as Generate>::generate(g),
7856 )),
7857 id::DIFFICULTY => Some(Self::Difficulty(<Difficulty as Generate>::generate(g))),
7858 id::COMBAT_EVENT => Some(Self::CombatEvent(<CombatEvent as Generate>::generate(g))),
7859 id::CAMERA => Some(Self::Camera(<Camera as Generate>::generate(g))),
7860 id::WORLD_BORDER => Some(Self::WorldBorder(<WorldBorder as Generate>::generate(g))),
7861 id::TITLE => Some(Self::Title(<Title as Generate>::generate(g))),
7862 id::SET_COMPRESSION => Some(Self::SetCompression(
7863 <SetCompression as Generate>::generate(g),
7864 )),
7865 id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
7866 <PlayerlistHeader as Generate>::generate(g),
7867 )),
7868 id::RESOURCE_PACK_SEND => Some(Self::ResourcePackSend(
7869 <ResourcePackSend as Generate>::generate(g),
7870 )),
7871 id::UPDATE_ENTITY_NBT => Some(Self::UpdateEntityNbt(
7872 <UpdateEntityNbt as Generate>::generate(g),
7873 )),
7874 _ => None,
7875 }
7876 }
7877}