1#![allow(
8 unused_imports,
9 unused_variables,
10 unused_mut,
11 unused_parens,
12 unused_braces,
13 clippy::all,
14 clippy::pedantic,
15 non_camel_case_types,
16 non_snake_case
17)]
18use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
19use crate::error::{DecodeError, EncodeError};
20use crate::nbt::RawNbt;
21use crate::packet::{Direction, PacketSet, RawPacket, State};
22#[cfg(feature = "testgen")]
23use crate::testgen::{Gen, Generate};
24use crate::types::{BlockPos, ByteString, PositionLayout, Uuid};
25use crate::v1_12_2::types;
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[derive(Debug, Clone, PartialEq)]
30pub struct StatisticsEntries {
31 pub name: ByteString,
33 pub value: i32,
35}
36
37#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
39pub struct DifficultyDifficulty(pub u8);
40impl DifficultyDifficulty {
41 pub const PEACEFUL: Self = Self(0);
43 pub const EASY: Self = Self(1);
45 pub const NORMAL: Self = Self(2);
47 pub const HARD: Self = Self(3);
49 pub const fn name(self) -> Option<&'static str> {
51 match self.0 {
52 0 => Some("peaceful"),
53 1 => Some("easy"),
54 2 => Some("normal"),
55 3 => Some("hard"),
56 _ => None,
57 }
58 }
59}
60impl std::fmt::Debug for DifficultyDifficulty {
61 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
62 match self.name() {
63 Some(n) => write!(f, "DifficultyDifficulty::{n}"),
64 None => write!(f, "DifficultyDifficulty({})", self.0),
65 }
66 }
67}
68
69#[derive(Debug, Clone, PartialEq)]
71pub struct MultiBlockChangeRecords {
72 pub horizontal_pos: u8,
74 pub y: u8,
76 pub block_id: i32,
78}
79
80#[derive(Debug, Clone, PartialEq)]
82pub struct ExplosionAffectedBlockOffsets {
83 pub x: i8,
85 pub y: i8,
87 pub z: i8,
89}
90
91#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
93pub struct GameStateChangeReason(pub u8);
94impl GameStateChangeReason {
95 pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
97 pub const START_RAINING: Self = Self(1);
99 pub const STOP_RAINING: Self = Self(2);
101 pub const CHANGE_GAME_MODE: Self = Self(3);
103 pub const WIN_GAME: Self = Self(4);
105 pub const DEMO_EVENT: Self = Self(5);
107 pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
109 pub const RAIN_LEVEL_CHANGE: Self = Self(7);
111 pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
113 pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
115 pub const fn name(self) -> Option<&'static str> {
117 match self.0 {
118 0 => Some("no_respawn_block_available"),
119 1 => Some("start_raining"),
120 2 => Some("stop_raining"),
121 3 => Some("change_game_mode"),
122 4 => Some("win_game"),
123 5 => Some("demo_event"),
124 6 => Some("play_arrow_hit_sound"),
125 7 => Some("rain_level_change"),
126 8 => Some("thunder_level_change"),
127 10 => Some("guardian_elder_effect"),
128 _ => None,
129 }
130 }
131}
132impl std::fmt::Debug for GameStateChangeReason {
133 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
134 match self.name() {
135 Some(n) => write!(f, "GameStateChangeReason::{n}"),
136 None => write!(f, "GameStateChangeReason({})", self.0),
137 }
138 }
139}
140
141#[derive(Debug, Clone, PartialEq)]
143pub enum WorldParticlesData {
144 Case36(Vec<i32>),
146 Case37(Vec<i32>),
148 Case38(Vec<i32>),
150 Other,
152}
153
154#[derive(Debug, Clone, PartialEq)]
156pub struct MapIcons {
157 pub direction_and_type: i8,
159 pub x: i8,
161 pub z: i8,
163}
164
165#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
167pub struct PlayerInfoAction(pub i32);
168impl PlayerInfoAction {
169 pub const ADD_PLAYER: Self = Self(0);
171 pub const UPDATE_GAME_MODE: Self = Self(1);
173 pub const UPDATE_LATENCY: Self = Self(2);
175 pub const UPDATE_DISPLAY_NAME: Self = Self(3);
177 pub const REMOVE_PLAYER: Self = Self(4);
179 pub const fn name(self) -> Option<&'static str> {
181 match self.0 {
182 0 => Some("add_player"),
183 1 => Some("update_game_mode"),
184 2 => Some("update_latency"),
185 3 => Some("update_display_name"),
186 4 => Some("remove_player"),
187 _ => None,
188 }
189 }
190}
191impl std::fmt::Debug for PlayerInfoAction {
192 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
193 match self.name() {
194 Some(n) => write!(f, "PlayerInfoAction::{n}"),
195 None => write!(f, "PlayerInfoAction({})", self.0),
196 }
197 }
198}
199
200#[derive(Debug, Clone, PartialEq)]
202pub struct PlayerInfoDataBodyAddPlayerProperties {
203 pub name: ByteString,
205 pub value: ByteString,
207 pub signature: Option<ByteString>,
209}
210
211#[derive(Debug, Clone, PartialEq)]
213pub struct PlayerInfoDataBodyAddPlayer {
214 pub name: ByteString,
216 pub properties: Vec<PlayerInfoDataBodyAddPlayerProperties>,
218 pub gamemode: i32,
220 pub ping: i32,
222 pub display_name: Option<ByteString>,
224}
225
226#[derive(Debug, Clone, PartialEq)]
228pub struct PlayerInfoDataBodyUpdateGameMode {
229 pub gamemode: i32,
231}
232
233#[derive(Debug, Clone, PartialEq)]
235pub struct PlayerInfoDataBodyUpdateLatency {
236 pub ping: i32,
238}
239
240#[derive(Debug, Clone, PartialEq)]
242pub struct PlayerInfoDataBodyUpdateDisplayName {
243 pub display_name: Option<ByteString>,
245}
246
247#[derive(Debug, Clone, PartialEq)]
249pub enum PlayerInfoDataBody {
250 AddPlayer(PlayerInfoDataBodyAddPlayer),
252 UpdateGameMode(PlayerInfoDataBodyUpdateGameMode),
254 UpdateLatency(PlayerInfoDataBodyUpdateLatency),
256 UpdateDisplayName(PlayerInfoDataBodyUpdateDisplayName),
258 RemovePlayer,
260 Other,
262}
263
264#[derive(Debug, Clone, PartialEq)]
266pub struct PlayerInfoData {
267 pub uuid: Uuid,
269 pub body: PlayerInfoDataBody,
271}
272
273#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
275pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
276 pub _unused: u32,
278 pub hidden: u8,
280 pub show_toast: u8,
282 pub has_background_texture: u8,
284}
285
286#[derive(Debug, Clone, PartialEq)]
288pub struct AdvancementsAdvancementMappingValueDisplayData {
289 pub title: ByteString,
291 pub description: ByteString,
293 pub icon: types::Slot,
295 pub frame_type: i32,
297 pub flags: AdvancementsAdvancementMappingValueDisplayDataFlags,
299 pub background_texture: Option<ByteString>,
301 pub x_cord: f32,
303 pub y_cord: f32,
305}
306
307#[derive(Debug, Clone, PartialEq)]
309pub struct AdvancementsAdvancementMappingValueCriteria {
310 pub key: ByteString,
312}
313
314#[derive(Debug, Clone, PartialEq)]
316pub struct AdvancementsAdvancementMappingValue {
317 pub parent_id: Option<ByteString>,
319 pub display_data: Option<AdvancementsAdvancementMappingValueDisplayData>,
321 pub criteria: Vec<AdvancementsAdvancementMappingValueCriteria>,
323 pub requirements: Vec<Vec<ByteString>>,
325}
326
327#[derive(Debug, Clone, PartialEq)]
329pub struct AdvancementsAdvancementMapping {
330 pub key: ByteString,
332 pub value: AdvancementsAdvancementMappingValue,
334}
335
336#[derive(Debug, Clone, PartialEq)]
338pub struct AdvancementsProgressMappingValue {
339 pub criterion_identifier: ByteString,
341 pub criterion_progress: Option<i64>,
343}
344
345#[derive(Debug, Clone, PartialEq)]
347pub struct AdvancementsProgressMapping {
348 pub key: ByteString,
350 pub value: Vec<AdvancementsProgressMappingValue>,
352}
353
354#[derive(Debug, Clone, PartialEq)]
356pub struct EntityUpdateAttributesPropertiesModifiers {
357 pub uuid: Uuid,
359 pub amount: f64,
361 pub operation: i8,
363}
364
365#[derive(Debug, Clone, PartialEq)]
367pub struct EntityUpdateAttributesProperties {
368 pub key: ByteString,
370 pub value: f64,
372 pub modifiers: Vec<EntityUpdateAttributesPropertiesModifiers>,
374}
375
376pub mod id {
378 pub const SPAWN_ENTITY: i32 = 0x00;
380 pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x01;
382 pub const SPAWN_ENTITY_WEATHER: i32 = 0x02;
384 pub const SPAWN_ENTITY_LIVING: i32 = 0x03;
386 pub const SPAWN_ENTITY_PAINTING: i32 = 0x04;
388 pub const NAMED_ENTITY_SPAWN: i32 = 0x05;
390 pub const ANIMATION: i32 = 0x06;
392 pub const STATISTICS: i32 = 0x07;
394 pub const BLOCK_BREAK_ANIMATION: i32 = 0x08;
396 pub const TILE_ENTITY_DATA: i32 = 0x09;
398 pub const BLOCK_ACTION: i32 = 0x0a;
400 pub const BLOCK_CHANGE: i32 = 0x0b;
402 pub const BOSS_BAR: i32 = 0x0c;
404 pub const DIFFICULTY: i32 = 0x0d;
406 pub const TAB_COMPLETE: i32 = 0x0e;
408 pub const CHAT: i32 = 0x0f;
410 pub const MULTI_BLOCK_CHANGE: i32 = 0x10;
412 pub const TRANSACTION: i32 = 0x11;
414 pub const CLOSE_WINDOW: i32 = 0x12;
416 pub const OPEN_WINDOW: i32 = 0x13;
418 pub const WINDOW_ITEMS: i32 = 0x14;
420 pub const CRAFT_PROGRESS_BAR: i32 = 0x15;
422 pub const SET_SLOT: i32 = 0x16;
424 pub const SET_COOLDOWN: i32 = 0x17;
426 pub const CUSTOM_PAYLOAD: i32 = 0x18;
428 pub const NAMED_SOUND_EFFECT: i32 = 0x19;
430 pub const KICK_DISCONNECT: i32 = 0x1a;
432 pub const ENTITY_STATUS: i32 = 0x1b;
434 pub const EXPLOSION: i32 = 0x1c;
436 pub const UNLOAD_CHUNK: i32 = 0x1d;
438 pub const GAME_STATE_CHANGE: i32 = 0x1e;
440 pub const KEEP_ALIVE: i32 = 0x1f;
442 pub const MAP_CHUNK: i32 = 0x20;
444 pub const WORLD_EVENT: i32 = 0x21;
446 pub const WORLD_PARTICLES: i32 = 0x22;
448 pub const LOGIN: i32 = 0x23;
450 pub const MAP: i32 = 0x24;
452 pub const ENTITY: i32 = 0x25;
454 pub const REL_ENTITY_MOVE: i32 = 0x26;
456 pub const ENTITY_MOVE_LOOK: i32 = 0x27;
458 pub const ENTITY_LOOK: i32 = 0x28;
460 pub const VEHICLE_MOVE: i32 = 0x29;
462 pub const OPEN_SIGN_ENTITY: i32 = 0x2a;
464 pub const CRAFT_RECIPE_RESPONSE: i32 = 0x2b;
466 pub const ABILITIES: i32 = 0x2c;
468 pub const COMBAT_EVENT: i32 = 0x2d;
470 pub const PLAYER_INFO: i32 = 0x2e;
472 pub const POSITION: i32 = 0x2f;
474 pub const BED: i32 = 0x30;
476 pub const UNLOCK_RECIPES: i32 = 0x31;
478 pub const ENTITY_DESTROY: i32 = 0x32;
480 pub const REMOVE_ENTITY_EFFECT: i32 = 0x33;
482 pub const RESOURCE_PACK_SEND: i32 = 0x34;
484 pub const RESPAWN: i32 = 0x35;
486 pub const ENTITY_HEAD_ROTATION: i32 = 0x36;
488 pub const SELECT_ADVANCEMENT_TAB: i32 = 0x37;
490 pub const WORLD_BORDER: i32 = 0x38;
492 pub const CAMERA: i32 = 0x39;
494 pub const HELD_ITEM_SLOT: i32 = 0x3a;
496 pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x3b;
498 pub const ENTITY_METADATA: i32 = 0x3c;
500 pub const ATTACH_ENTITY: i32 = 0x3d;
502 pub const ENTITY_VELOCITY: i32 = 0x3e;
504 pub const ENTITY_EQUIPMENT: i32 = 0x3f;
506 pub const EXPERIENCE: i32 = 0x40;
508 pub const UPDATE_HEALTH: i32 = 0x41;
510 pub const SCOREBOARD_OBJECTIVE: i32 = 0x42;
512 pub const SET_PASSENGERS: i32 = 0x43;
514 pub const TEAMS: i32 = 0x44;
516 pub const SCOREBOARD_SCORE: i32 = 0x45;
518 pub const SPAWN_POSITION: i32 = 0x46;
520 pub const UPDATE_TIME: i32 = 0x47;
522 pub const TITLE: i32 = 0x48;
524 pub const SOUND_EFFECT: i32 = 0x49;
526 pub const PLAYERLIST_HEADER: i32 = 0x4a;
528 pub const COLLECT: i32 = 0x4b;
530 pub const ENTITY_TELEPORT: i32 = 0x4c;
532 pub const ADVANCEMENTS: i32 = 0x4d;
534 pub const ENTITY_UPDATE_ATTRIBUTES: i32 = 0x4e;
536 pub const ENTITY_EFFECT: i32 = 0x4f;
538}
539
540#[derive(Debug, Clone, PartialEq)]
542pub struct SpawnEntity {
543 pub entity_id: i32,
545 pub object_uuid: Uuid,
547 pub r#type: i8,
549 pub x: f64,
551 pub y: f64,
553 pub z: f64,
555 pub pitch: i8,
557 pub yaw: i8,
559 pub object_data: i32,
561 pub velocity: types::Vec3i16,
563}
564impl crate::packet::Packet for SpawnEntity {
565 const ID: i32 = id::SPAWN_ENTITY;
566 const NAME: &'static str = "spawn_entity";
567 const STATE: State = State::Play;
568 const DIRECTION: Direction = Direction::Clientbound;
569}
570impl Decode for SpawnEntity {
571 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
572 Ok({
573 let v37 = r.read_varint()?;
574 let v38 = r.read_uuid()?;
575 let v39 = r.read_i8()?;
576 let v40 = r.read_f64()?;
577 let v41 = r.read_f64()?;
578 let v42 = r.read_f64()?;
579 let v43 = r.read_i8()?;
580 let v44 = r.read_i8()?;
581 let v45 = r.read_i32()?;
582 let v46 = <types::Vec3i16 as Decode>::decode(r)?;
583 SpawnEntity {
584 entity_id: v37,
585 object_uuid: v38,
586 r#type: v39,
587 x: v40,
588 y: v41,
589 z: v42,
590 pitch: v43,
591 yaw: v44,
592 object_data: v45,
593 velocity: v46,
594 }
595 })
596 }
597}
598impl Encode for SpawnEntity {
599 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
600 w.put_varint((*self).entity_id);
601 w.put_uuid(&(*self).object_uuid);
602 w.put_i8((*self).r#type);
603 w.put_f64((*self).x);
604 w.put_f64((*self).y);
605 w.put_f64((*self).z);
606 w.put_i8((*self).pitch);
607 w.put_i8((*self).yaw);
608 w.put_i32((*self).object_data);
609 (*self).velocity.encode(w)?;
610 Ok(())
611 }
612}
613#[cfg(feature = "testgen")]
614impl Generate for SpawnEntity {
615 fn generate(g: &mut Gen) -> Self {
616 {
617 let v47 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
618 let v48 = g.uuid();
619 let v49 = (g.int_in(-128, 127, &[]) as i8);
620 let v50 = g.f64();
621 let v51 = g.f64();
622 let v52 = g.f64();
623 let v53 = (g.int_in(-128, 127, &[]) as i8);
624 let v54 = (g.int_in(-128, 127, &[]) as i8);
625 let v55 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
626 let v56 = <types::Vec3i16 as Generate>::generate(g);
627 SpawnEntity {
628 entity_id: v47,
629 object_uuid: v48,
630 r#type: v49,
631 x: v50,
632 y: v51,
633 z: v52,
634 pitch: v53,
635 yaw: v54,
636 object_data: v55,
637 velocity: v56,
638 }
639 }
640 }
641}
642impl From<SpawnEntity> for ClientboundPlayPacket {
643 fn from(p: SpawnEntity) -> Self {
644 Self::SpawnEntity(p)
645 }
646}
647
648#[derive(Debug, Clone, PartialEq)]
650pub struct SpawnEntityExperienceOrb {
651 pub entity_id: i32,
653 pub x: f64,
655 pub y: f64,
657 pub z: f64,
659 pub count: i16,
661}
662impl crate::packet::Packet for SpawnEntityExperienceOrb {
663 const ID: i32 = id::SPAWN_ENTITY_EXPERIENCE_ORB;
664 const NAME: &'static str = "spawn_entity_experience_orb";
665 const STATE: State = State::Play;
666 const DIRECTION: Direction = Direction::Clientbound;
667}
668impl Decode for SpawnEntityExperienceOrb {
669 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
670 Ok({
671 let v57 = r.read_varint()?;
672 let v58 = r.read_f64()?;
673 let v59 = r.read_f64()?;
674 let v60 = r.read_f64()?;
675 let v61 = r.read_i16()?;
676 SpawnEntityExperienceOrb {
677 entity_id: v57,
678 x: v58,
679 y: v59,
680 z: v60,
681 count: v61,
682 }
683 })
684 }
685}
686impl Encode for SpawnEntityExperienceOrb {
687 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
688 w.put_varint((*self).entity_id);
689 w.put_f64((*self).x);
690 w.put_f64((*self).y);
691 w.put_f64((*self).z);
692 w.put_i16((*self).count);
693 Ok(())
694 }
695}
696#[cfg(feature = "testgen")]
697impl Generate for SpawnEntityExperienceOrb {
698 fn generate(g: &mut Gen) -> Self {
699 {
700 let v62 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
701 let v63 = g.f64();
702 let v64 = g.f64();
703 let v65 = g.f64();
704 let v66 = (g.int_in(-32768, 32767, &[]) as i16);
705 SpawnEntityExperienceOrb {
706 entity_id: v62,
707 x: v63,
708 y: v64,
709 z: v65,
710 count: v66,
711 }
712 }
713 }
714}
715impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
716 fn from(p: SpawnEntityExperienceOrb) -> Self {
717 Self::SpawnEntityExperienceOrb(p)
718 }
719}
720
721#[derive(Debug, Clone, PartialEq)]
723pub struct SpawnEntityWeather {
724 pub entity_id: i32,
726 pub r#type: i8,
728 pub x: f64,
730 pub y: f64,
732 pub z: f64,
734}
735impl crate::packet::Packet for SpawnEntityWeather {
736 const ID: i32 = id::SPAWN_ENTITY_WEATHER;
737 const NAME: &'static str = "spawn_entity_weather";
738 const STATE: State = State::Play;
739 const DIRECTION: Direction = Direction::Clientbound;
740}
741impl Decode for SpawnEntityWeather {
742 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
743 Ok({
744 let v67 = r.read_varint()?;
745 let v68 = r.read_i8()?;
746 let v69 = r.read_f64()?;
747 let v70 = r.read_f64()?;
748 let v71 = r.read_f64()?;
749 SpawnEntityWeather {
750 entity_id: v67,
751 r#type: v68,
752 x: v69,
753 y: v70,
754 z: v71,
755 }
756 })
757 }
758}
759impl Encode for SpawnEntityWeather {
760 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
761 w.put_varint((*self).entity_id);
762 w.put_i8((*self).r#type);
763 w.put_f64((*self).x);
764 w.put_f64((*self).y);
765 w.put_f64((*self).z);
766 Ok(())
767 }
768}
769#[cfg(feature = "testgen")]
770impl Generate for SpawnEntityWeather {
771 fn generate(g: &mut Gen) -> Self {
772 {
773 let v72 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
774 let v73 = (g.int_in(-128, 127, &[]) as i8);
775 let v74 = g.f64();
776 let v75 = g.f64();
777 let v76 = g.f64();
778 SpawnEntityWeather {
779 entity_id: v72,
780 r#type: v73,
781 x: v74,
782 y: v75,
783 z: v76,
784 }
785 }
786 }
787}
788impl From<SpawnEntityWeather> for ClientboundPlayPacket {
789 fn from(p: SpawnEntityWeather) -> Self {
790 Self::SpawnEntityWeather(p)
791 }
792}
793
794#[derive(Debug, Clone, PartialEq)]
796pub struct SpawnEntityLiving {
797 pub entity_id: i32,
799 pub entity_uuid: Uuid,
801 pub r#type: i32,
803 pub x: f64,
805 pub y: f64,
807 pub z: f64,
809 pub yaw: i8,
811 pub pitch: i8,
813 pub head_pitch: i8,
815 pub velocity: types::Vec3i16,
817 pub metadata: Vec<types::EntityMetadataEntry>,
819}
820impl crate::packet::Packet for SpawnEntityLiving {
821 const ID: i32 = id::SPAWN_ENTITY_LIVING;
822 const NAME: &'static str = "spawn_entity_living";
823 const STATE: State = State::Play;
824 const DIRECTION: Direction = Direction::Clientbound;
825}
826impl Decode for SpawnEntityLiving {
827 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
828 Ok({
829 let v77 = r.read_varint()?;
830 let v78 = r.read_uuid()?;
831 let v79 = r.read_varint()?;
832 let v80 = r.read_f64()?;
833 let v81 = r.read_f64()?;
834 let v82 = r.read_f64()?;
835 let v83 = r.read_i8()?;
836 let v84 = r.read_i8()?;
837 let v85 = r.read_i8()?;
838 let v86 = <types::Vec3i16 as Decode>::decode(r)?;
839 let v87 = {
840 let mut v88 = Vec::new();
841 loop {
842 if r.peek_u8()? == 255 {
843 r.skip(1)?;
844 break;
845 }
846 v88.push({
847 let v89 = r.read_u8()?;
848 let v90 = r.read_i8()?;
849 let v91 = (if (v90 == 0) {
850 types::EntityMetadataValue::Byte(r.read_i8()?)
851 } else if (v90 == 1) {
852 types::EntityMetadataValue::VarInt(r.read_varint()?)
853 } else if (v90 == 2) {
854 types::EntityMetadataValue::Float(r.read_f32()?)
855 } else if (v90 == 3) {
856 types::EntityMetadataValue::String(r.read_string()?)
857 } else if (v90 == 4) {
858 types::EntityMetadataValue::Chat(r.read_string()?)
859 } else if (v90 == 5) {
860 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
861 } else if (v90 == 6) {
862 types::EntityMetadataValue::Boolean(r.read_bool()?)
863 } else if (v90 == 7) {
864 types::EntityMetadataValue::Rotation({
865 let v92 = r.read_f32()?;
866 let v93 = r.read_f32()?;
867 let v94 = r.read_f32()?;
868 types::EntityMetadataValueRotation {
869 pitch: v92,
870 yaw: v93,
871 roll: v94,
872 }
873 })
874 } else if (v90 == 8) {
875 types::EntityMetadataValue::Position(BlockPos::read(
876 r,
877 PositionLayout::Xyz,
878 )?)
879 } else if (v90 == 9) {
880 types::EntityMetadataValue::OptPosition(if r.read_bool()? {
881 Some(BlockPos::read(r, PositionLayout::Xyz)?)
882 } else {
883 None
884 })
885 } else if (v90 == 10) {
886 types::EntityMetadataValue::Direction(r.read_varint()?)
887 } else if (v90 == 11) {
888 types::EntityMetadataValue::OptUuid(if r.read_bool()? {
889 Some(r.read_uuid()?)
890 } else {
891 None
892 })
893 } else if (v90 == 12) {
894 types::EntityMetadataValue::BlockState(r.read_varint()?)
895 } else if (v90 == 13) {
896 types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
897 } else {
898 types::EntityMetadataValue::Other
899 });
900 types::EntityMetadataEntry {
901 key: v89,
902 r#type: v90,
903 value: v91,
904 }
905 });
906 }
907 v88
908 };
909 SpawnEntityLiving {
910 entity_id: v77,
911 entity_uuid: v78,
912 r#type: v79,
913 x: v80,
914 y: v81,
915 z: v82,
916 yaw: v83,
917 pitch: v84,
918 head_pitch: v85,
919 velocity: v86,
920 metadata: v87,
921 }
922 })
923 }
924}
925impl Encode for SpawnEntityLiving {
926 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
927 w.put_varint((*self).entity_id);
928 w.put_uuid(&(*self).entity_uuid);
929 w.put_varint((*self).r#type);
930 w.put_f64((*self).x);
931 w.put_f64((*self).y);
932 w.put_f64((*self).z);
933 w.put_i8((*self).yaw);
934 w.put_i8((*self).pitch);
935 w.put_i8((*self).head_pitch);
936 (*self).velocity.encode(w)?;
937 for v95 in (*self).metadata.iter() {
938 let v96 = w.len();
939 w.put_u8((*v95).key);
940 w.put_i8((*v95).r#type);
941 match &(*v95).value {
942 types::EntityMetadataValue::Byte(v97) => {
943 if !((*v95).r#type == 0) {
944 return Err(EncodeError::SwitchMismatch(
945 "play.clientbound.spawn_entity_living.metadata.value",
946 ));
947 }
948 w.put_i8((*v97));
949 }
950 types::EntityMetadataValue::VarInt(v98) => {
951 if !((*v95).r#type == 1) {
952 return Err(EncodeError::SwitchMismatch(
953 "play.clientbound.spawn_entity_living.metadata.value",
954 ));
955 }
956 w.put_varint((*v98));
957 }
958 types::EntityMetadataValue::Float(v99) => {
959 if !((*v95).r#type == 2) {
960 return Err(EncodeError::SwitchMismatch(
961 "play.clientbound.spawn_entity_living.metadata.value",
962 ));
963 }
964 w.put_f32((*v99));
965 }
966 types::EntityMetadataValue::String(v100) => {
967 if !((*v95).r#type == 3) {
968 return Err(EncodeError::SwitchMismatch(
969 "play.clientbound.spawn_entity_living.metadata.value",
970 ));
971 }
972 w.put_string(&(*v100))?;
973 }
974 types::EntityMetadataValue::Chat(v101) => {
975 if !((*v95).r#type == 4) {
976 return Err(EncodeError::SwitchMismatch(
977 "play.clientbound.spawn_entity_living.metadata.value",
978 ));
979 }
980 w.put_string(&(*v101))?;
981 }
982 types::EntityMetadataValue::Slot(v102) => {
983 if !((*v95).r#type == 5) {
984 return Err(EncodeError::SwitchMismatch(
985 "play.clientbound.spawn_entity_living.metadata.value",
986 ));
987 }
988 (*v102).encode(w)?;
989 }
990 types::EntityMetadataValue::Boolean(v103) => {
991 if !((*v95).r#type == 6) {
992 return Err(EncodeError::SwitchMismatch(
993 "play.clientbound.spawn_entity_living.metadata.value",
994 ));
995 }
996 w.put_bool((*v103));
997 }
998 types::EntityMetadataValue::Rotation(v104) => {
999 if !((*v95).r#type == 7) {
1000 return Err(EncodeError::SwitchMismatch(
1001 "play.clientbound.spawn_entity_living.metadata.value",
1002 ));
1003 }
1004 w.put_f32((*v104).pitch);
1005 w.put_f32((*v104).yaw);
1006 w.put_f32((*v104).roll);
1007 }
1008 types::EntityMetadataValue::Position(v105) => {
1009 if !((*v95).r#type == 8) {
1010 return Err(EncodeError::SwitchMismatch(
1011 "play.clientbound.spawn_entity_living.metadata.value",
1012 ));
1013 }
1014 (*v105).write(w, PositionLayout::Xyz)?;
1015 }
1016 types::EntityMetadataValue::OptPosition(v106) => {
1017 if !((*v95).r#type == 9) {
1018 return Err(EncodeError::SwitchMismatch(
1019 "play.clientbound.spawn_entity_living.metadata.value",
1020 ));
1021 }
1022 match &(*v106) {
1023 Some(v107) => {
1024 w.put_u8(1);
1025 (*v107).write(w, PositionLayout::Xyz)?;
1026 }
1027 None => w.put_u8(0),
1028 }
1029 }
1030 types::EntityMetadataValue::Direction(v108) => {
1031 if !((*v95).r#type == 10) {
1032 return Err(EncodeError::SwitchMismatch(
1033 "play.clientbound.spawn_entity_living.metadata.value",
1034 ));
1035 }
1036 w.put_varint((*v108));
1037 }
1038 types::EntityMetadataValue::OptUuid(v109) => {
1039 if !((*v95).r#type == 11) {
1040 return Err(EncodeError::SwitchMismatch(
1041 "play.clientbound.spawn_entity_living.metadata.value",
1042 ));
1043 }
1044 match &(*v109) {
1045 Some(v110) => {
1046 w.put_u8(1);
1047 w.put_uuid(&(*v110));
1048 }
1049 None => w.put_u8(0),
1050 }
1051 }
1052 types::EntityMetadataValue::BlockState(v111) => {
1053 if !((*v95).r#type == 12) {
1054 return Err(EncodeError::SwitchMismatch(
1055 "play.clientbound.spawn_entity_living.metadata.value",
1056 ));
1057 }
1058 w.put_varint((*v111));
1059 }
1060 types::EntityMetadataValue::Nbt(v112) => {
1061 if !((*v95).r#type == 13) {
1062 return Err(EncodeError::SwitchMismatch(
1063 "play.clientbound.spawn_entity_living.metadata.value",
1064 ));
1065 }
1066 (*v112).write(w);
1067 }
1068 types::EntityMetadataValue::Other => {
1069 if !(!(((*v95).r#type == 0)
1070 || ((*v95).r#type == 1)
1071 || ((*v95).r#type == 2)
1072 || ((*v95).r#type == 3)
1073 || ((*v95).r#type == 4)
1074 || ((*v95).r#type == 5)
1075 || ((*v95).r#type == 6)
1076 || ((*v95).r#type == 7)
1077 || ((*v95).r#type == 8)
1078 || ((*v95).r#type == 9)
1079 || ((*v95).r#type == 10)
1080 || ((*v95).r#type == 11)
1081 || ((*v95).r#type == 12)
1082 || ((*v95).r#type == 13)))
1083 {
1084 return Err(EncodeError::SwitchMismatch(
1085 "play.clientbound.spawn_entity_living.metadata.value",
1086 ));
1087 }
1088 }
1089 }
1090 if w.get(v96) == Some(&255) {
1091 return Err(EncodeError::OutOfRange(
1092 "play.clientbound.spawn_entity_living.metadata",
1093 ));
1094 }
1095 }
1096 w.put_u8(255);
1097 Ok(())
1098 }
1099}
1100#[cfg(feature = "testgen")]
1101impl Generate for SpawnEntityLiving {
1102 fn generate(g: &mut Gen) -> Self {
1103 {
1104 let v113 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1105 let v114 = g.uuid();
1106 let v115 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1107 let v116 = g.f64();
1108 let v117 = g.f64();
1109 let v118 = g.f64();
1110 let v119 = (g.int_in(-128, 127, &[]) as i8);
1111 let v120 = (g.int_in(-128, 127, &[]) as i8);
1112 let v121 = (g.int_in(-128, 127, &[]) as i8);
1113 let v122 = <types::Vec3i16 as Generate>::generate(g);
1114 let v123 = {
1115 let n = g.count();
1116 let mut v124 = Vec::with_capacity(n);
1117 for _ in 0..n {
1118 v124.push(loop { let v125 = { let v126 = (g.int_in(0, 255, &[]) as u8);let v127 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v128 = (if (v127 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v127 == 1) { types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 2) { types::EntityMetadataValue::Float(g.f32()) } else if (v127 == 3) { types::EntityMetadataValue::String(g.string()) } else if (v127 == 4) { types::EntityMetadataValue::Chat(g.string()) } else if (v127 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v127 == 6) { types::EntityMetadataValue::Boolean(g.bool()) } else if (v127 == 7) { types::EntityMetadataValue::Rotation({ let v129 = g.f32();let v130 = g.f32();let v131 = g.f32(); types::EntityMetadataValueRotation { pitch: v129, yaw: v130, roll: v131 } }) } else if (v127 == 8) { types::EntityMetadataValue::Position(g.position()) } else if (v127 == 9) { types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v127 == 10) { types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 11) { types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v127 == 12) { types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 13) { types::EntityMetadataValue::Nbt(g.nbt()) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { key: v126, r#type: v127, value: v128 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v125.key);w.put_i8(v125.r#type);match &v125.value { types::EntityMetadataValue::Byte(v132) => { if !((v125.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v132)); }types::EntityMetadataValue::VarInt(v133) => { if !((v125.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v133)); }types::EntityMetadataValue::Float(v134) => { if !((v125.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v134)); }types::EntityMetadataValue::String(v135) => { if !((v125.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v135))?; }types::EntityMetadataValue::Chat(v136) => { if !((v125.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v136))?; }types::EntityMetadataValue::Slot(v137) => { if !((v125.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v137).encode(w)?; }types::EntityMetadataValue::Boolean(v138) => { if !((v125.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_bool((*v138)); }types::EntityMetadataValue::Rotation(v139) => { if !((v125.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v139).pitch);w.put_f32((*v139).yaw);w.put_f32((*v139).roll); }types::EntityMetadataValue::Position(v140) => { if !((v125.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v140).write(w, PositionLayout::Xyz)?; }types::EntityMetadataValue::OptPosition(v141) => { if !((v125.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v141) { Some(v142) => { w.put_u8(1); (*v142).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }types::EntityMetadataValue::Direction(v143) => { if !((v125.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v143)); }types::EntityMetadataValue::OptUuid(v144) => { if !((v125.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v144) { Some(v145) => { w.put_u8(1); w.put_uuid(&(*v145)); } None => w.put_u8(0), } }types::EntityMetadataValue::BlockState(v146) => { if !((v125.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v146)); }types::EntityMetadataValue::Nbt(v147) => { if !((v125.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v147).write(w); }types::EntityMetadataValue::Other => { if !(!((v125.r#type == 0) || (v125.r#type == 1) || (v125.r#type == 2) || (v125.r#type == 3) || (v125.r#type == 4) || (v125.r#type == 5) || (v125.r#type == 6) || (v125.r#type == 7) || (v125.r#type == 8) || (v125.r#type == 9) || (v125.r#type == 10) || (v125.r#type == 11) || (v125.r#type == 12) || (v125.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v125; } });
1119 }
1120 v124
1121 };
1122 SpawnEntityLiving {
1123 entity_id: v113,
1124 entity_uuid: v114,
1125 r#type: v115,
1126 x: v116,
1127 y: v117,
1128 z: v118,
1129 yaw: v119,
1130 pitch: v120,
1131 head_pitch: v121,
1132 velocity: v122,
1133 metadata: v123,
1134 }
1135 }
1136 }
1137}
1138impl From<SpawnEntityLiving> for ClientboundPlayPacket {
1139 fn from(p: SpawnEntityLiving) -> Self {
1140 Self::SpawnEntityLiving(p)
1141 }
1142}
1143
1144#[derive(Debug, Clone, PartialEq)]
1146pub struct SpawnEntityPainting {
1147 pub entity_id: i32,
1149 pub entity_uuid: Uuid,
1151 pub title: ByteString,
1153 pub location: BlockPos,
1155 pub direction: u8,
1157}
1158impl crate::packet::Packet for SpawnEntityPainting {
1159 const ID: i32 = id::SPAWN_ENTITY_PAINTING;
1160 const NAME: &'static str = "spawn_entity_painting";
1161 const STATE: State = State::Play;
1162 const DIRECTION: Direction = Direction::Clientbound;
1163}
1164impl Decode for SpawnEntityPainting {
1165 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1166 Ok({
1167 let v148 = r.read_varint()?;
1168 let v149 = r.read_uuid()?;
1169 let v150 = r.read_string()?;
1170 let v151 = BlockPos::read(r, PositionLayout::Xyz)?;
1171 let v152 = r.read_u8()?;
1172 SpawnEntityPainting {
1173 entity_id: v148,
1174 entity_uuid: v149,
1175 title: v150,
1176 location: v151,
1177 direction: v152,
1178 }
1179 })
1180 }
1181}
1182impl Encode for SpawnEntityPainting {
1183 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1184 w.put_varint((*self).entity_id);
1185 w.put_uuid(&(*self).entity_uuid);
1186 w.put_string(&(*self).title)?;
1187 (*self).location.write(w, PositionLayout::Xyz)?;
1188 w.put_u8((*self).direction);
1189 Ok(())
1190 }
1191}
1192#[cfg(feature = "testgen")]
1193impl Generate for SpawnEntityPainting {
1194 fn generate(g: &mut Gen) -> Self {
1195 {
1196 let v153 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1197 let v154 = g.uuid();
1198 let v155 = g.string();
1199 let v156 = g.position();
1200 let v157 = (g.int_in(0, 255, &[]) as u8);
1201 SpawnEntityPainting {
1202 entity_id: v153,
1203 entity_uuid: v154,
1204 title: v155,
1205 location: v156,
1206 direction: v157,
1207 }
1208 }
1209 }
1210}
1211impl From<SpawnEntityPainting> for ClientboundPlayPacket {
1212 fn from(p: SpawnEntityPainting) -> Self {
1213 Self::SpawnEntityPainting(p)
1214 }
1215}
1216
1217#[derive(Debug, Clone, PartialEq)]
1219pub struct NamedEntitySpawn {
1220 pub entity_id: i32,
1222 pub player_uuid: Uuid,
1224 pub x: f64,
1226 pub y: f64,
1228 pub z: f64,
1230 pub yaw: i8,
1232 pub pitch: i8,
1234 pub metadata: Vec<types::EntityMetadataEntry>,
1236}
1237impl crate::packet::Packet for NamedEntitySpawn {
1238 const ID: i32 = id::NAMED_ENTITY_SPAWN;
1239 const NAME: &'static str = "named_entity_spawn";
1240 const STATE: State = State::Play;
1241 const DIRECTION: Direction = Direction::Clientbound;
1242}
1243impl Decode for NamedEntitySpawn {
1244 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1245 Ok({
1246 let v158 = r.read_varint()?;
1247 let v159 = r.read_uuid()?;
1248 let v160 = r.read_f64()?;
1249 let v161 = r.read_f64()?;
1250 let v162 = r.read_f64()?;
1251 let v163 = r.read_i8()?;
1252 let v164 = r.read_i8()?;
1253 let v165 = {
1254 let mut v166 = Vec::new();
1255 loop {
1256 if r.peek_u8()? == 255 {
1257 r.skip(1)?;
1258 break;
1259 }
1260 v166.push({
1261 let v167 = r.read_u8()?;
1262 let v168 = r.read_i8()?;
1263 let v169 = (if (v168 == 0) {
1264 types::EntityMetadataValue::Byte(r.read_i8()?)
1265 } else if (v168 == 1) {
1266 types::EntityMetadataValue::VarInt(r.read_varint()?)
1267 } else if (v168 == 2) {
1268 types::EntityMetadataValue::Float(r.read_f32()?)
1269 } else if (v168 == 3) {
1270 types::EntityMetadataValue::String(r.read_string()?)
1271 } else if (v168 == 4) {
1272 types::EntityMetadataValue::Chat(r.read_string()?)
1273 } else if (v168 == 5) {
1274 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
1275 } else if (v168 == 6) {
1276 types::EntityMetadataValue::Boolean(r.read_bool()?)
1277 } else if (v168 == 7) {
1278 types::EntityMetadataValue::Rotation({
1279 let v170 = r.read_f32()?;
1280 let v171 = r.read_f32()?;
1281 let v172 = r.read_f32()?;
1282 types::EntityMetadataValueRotation {
1283 pitch: v170,
1284 yaw: v171,
1285 roll: v172,
1286 }
1287 })
1288 } else if (v168 == 8) {
1289 types::EntityMetadataValue::Position(BlockPos::read(
1290 r,
1291 PositionLayout::Xyz,
1292 )?)
1293 } else if (v168 == 9) {
1294 types::EntityMetadataValue::OptPosition(if r.read_bool()? {
1295 Some(BlockPos::read(r, PositionLayout::Xyz)?)
1296 } else {
1297 None
1298 })
1299 } else if (v168 == 10) {
1300 types::EntityMetadataValue::Direction(r.read_varint()?)
1301 } else if (v168 == 11) {
1302 types::EntityMetadataValue::OptUuid(if r.read_bool()? {
1303 Some(r.read_uuid()?)
1304 } else {
1305 None
1306 })
1307 } else if (v168 == 12) {
1308 types::EntityMetadataValue::BlockState(r.read_varint()?)
1309 } else if (v168 == 13) {
1310 types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
1311 } else {
1312 types::EntityMetadataValue::Other
1313 });
1314 types::EntityMetadataEntry {
1315 key: v167,
1316 r#type: v168,
1317 value: v169,
1318 }
1319 });
1320 }
1321 v166
1322 };
1323 NamedEntitySpawn {
1324 entity_id: v158,
1325 player_uuid: v159,
1326 x: v160,
1327 y: v161,
1328 z: v162,
1329 yaw: v163,
1330 pitch: v164,
1331 metadata: v165,
1332 }
1333 })
1334 }
1335}
1336impl Encode for NamedEntitySpawn {
1337 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1338 w.put_varint((*self).entity_id);
1339 w.put_uuid(&(*self).player_uuid);
1340 w.put_f64((*self).x);
1341 w.put_f64((*self).y);
1342 w.put_f64((*self).z);
1343 w.put_i8((*self).yaw);
1344 w.put_i8((*self).pitch);
1345 for v173 in (*self).metadata.iter() {
1346 let v174 = w.len();
1347 w.put_u8((*v173).key);
1348 w.put_i8((*v173).r#type);
1349 match &(*v173).value {
1350 types::EntityMetadataValue::Byte(v175) => {
1351 if !((*v173).r#type == 0) {
1352 return Err(EncodeError::SwitchMismatch(
1353 "play.clientbound.named_entity_spawn.metadata.value",
1354 ));
1355 }
1356 w.put_i8((*v175));
1357 }
1358 types::EntityMetadataValue::VarInt(v176) => {
1359 if !((*v173).r#type == 1) {
1360 return Err(EncodeError::SwitchMismatch(
1361 "play.clientbound.named_entity_spawn.metadata.value",
1362 ));
1363 }
1364 w.put_varint((*v176));
1365 }
1366 types::EntityMetadataValue::Float(v177) => {
1367 if !((*v173).r#type == 2) {
1368 return Err(EncodeError::SwitchMismatch(
1369 "play.clientbound.named_entity_spawn.metadata.value",
1370 ));
1371 }
1372 w.put_f32((*v177));
1373 }
1374 types::EntityMetadataValue::String(v178) => {
1375 if !((*v173).r#type == 3) {
1376 return Err(EncodeError::SwitchMismatch(
1377 "play.clientbound.named_entity_spawn.metadata.value",
1378 ));
1379 }
1380 w.put_string(&(*v178))?;
1381 }
1382 types::EntityMetadataValue::Chat(v179) => {
1383 if !((*v173).r#type == 4) {
1384 return Err(EncodeError::SwitchMismatch(
1385 "play.clientbound.named_entity_spawn.metadata.value",
1386 ));
1387 }
1388 w.put_string(&(*v179))?;
1389 }
1390 types::EntityMetadataValue::Slot(v180) => {
1391 if !((*v173).r#type == 5) {
1392 return Err(EncodeError::SwitchMismatch(
1393 "play.clientbound.named_entity_spawn.metadata.value",
1394 ));
1395 }
1396 (*v180).encode(w)?;
1397 }
1398 types::EntityMetadataValue::Boolean(v181) => {
1399 if !((*v173).r#type == 6) {
1400 return Err(EncodeError::SwitchMismatch(
1401 "play.clientbound.named_entity_spawn.metadata.value",
1402 ));
1403 }
1404 w.put_bool((*v181));
1405 }
1406 types::EntityMetadataValue::Rotation(v182) => {
1407 if !((*v173).r#type == 7) {
1408 return Err(EncodeError::SwitchMismatch(
1409 "play.clientbound.named_entity_spawn.metadata.value",
1410 ));
1411 }
1412 w.put_f32((*v182).pitch);
1413 w.put_f32((*v182).yaw);
1414 w.put_f32((*v182).roll);
1415 }
1416 types::EntityMetadataValue::Position(v183) => {
1417 if !((*v173).r#type == 8) {
1418 return Err(EncodeError::SwitchMismatch(
1419 "play.clientbound.named_entity_spawn.metadata.value",
1420 ));
1421 }
1422 (*v183).write(w, PositionLayout::Xyz)?;
1423 }
1424 types::EntityMetadataValue::OptPosition(v184) => {
1425 if !((*v173).r#type == 9) {
1426 return Err(EncodeError::SwitchMismatch(
1427 "play.clientbound.named_entity_spawn.metadata.value",
1428 ));
1429 }
1430 match &(*v184) {
1431 Some(v185) => {
1432 w.put_u8(1);
1433 (*v185).write(w, PositionLayout::Xyz)?;
1434 }
1435 None => w.put_u8(0),
1436 }
1437 }
1438 types::EntityMetadataValue::Direction(v186) => {
1439 if !((*v173).r#type == 10) {
1440 return Err(EncodeError::SwitchMismatch(
1441 "play.clientbound.named_entity_spawn.metadata.value",
1442 ));
1443 }
1444 w.put_varint((*v186));
1445 }
1446 types::EntityMetadataValue::OptUuid(v187) => {
1447 if !((*v173).r#type == 11) {
1448 return Err(EncodeError::SwitchMismatch(
1449 "play.clientbound.named_entity_spawn.metadata.value",
1450 ));
1451 }
1452 match &(*v187) {
1453 Some(v188) => {
1454 w.put_u8(1);
1455 w.put_uuid(&(*v188));
1456 }
1457 None => w.put_u8(0),
1458 }
1459 }
1460 types::EntityMetadataValue::BlockState(v189) => {
1461 if !((*v173).r#type == 12) {
1462 return Err(EncodeError::SwitchMismatch(
1463 "play.clientbound.named_entity_spawn.metadata.value",
1464 ));
1465 }
1466 w.put_varint((*v189));
1467 }
1468 types::EntityMetadataValue::Nbt(v190) => {
1469 if !((*v173).r#type == 13) {
1470 return Err(EncodeError::SwitchMismatch(
1471 "play.clientbound.named_entity_spawn.metadata.value",
1472 ));
1473 }
1474 (*v190).write(w);
1475 }
1476 types::EntityMetadataValue::Other => {
1477 if !(!(((*v173).r#type == 0)
1478 || ((*v173).r#type == 1)
1479 || ((*v173).r#type == 2)
1480 || ((*v173).r#type == 3)
1481 || ((*v173).r#type == 4)
1482 || ((*v173).r#type == 5)
1483 || ((*v173).r#type == 6)
1484 || ((*v173).r#type == 7)
1485 || ((*v173).r#type == 8)
1486 || ((*v173).r#type == 9)
1487 || ((*v173).r#type == 10)
1488 || ((*v173).r#type == 11)
1489 || ((*v173).r#type == 12)
1490 || ((*v173).r#type == 13)))
1491 {
1492 return Err(EncodeError::SwitchMismatch(
1493 "play.clientbound.named_entity_spawn.metadata.value",
1494 ));
1495 }
1496 }
1497 }
1498 if w.get(v174) == Some(&255) {
1499 return Err(EncodeError::OutOfRange(
1500 "play.clientbound.named_entity_spawn.metadata",
1501 ));
1502 }
1503 }
1504 w.put_u8(255);
1505 Ok(())
1506 }
1507}
1508#[cfg(feature = "testgen")]
1509impl Generate for NamedEntitySpawn {
1510 fn generate(g: &mut Gen) -> Self {
1511 {
1512 let v191 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1513 let v192 = g.uuid();
1514 let v193 = g.f64();
1515 let v194 = g.f64();
1516 let v195 = g.f64();
1517 let v196 = (g.int_in(-128, 127, &[]) as i8);
1518 let v197 = (g.int_in(-128, 127, &[]) as i8);
1519 let v198 = {
1520 let n = g.count();
1521 let mut v199 = Vec::with_capacity(n);
1522 for _ in 0..n {
1523 v199.push(loop { let v200 = { let v201 = (g.int_in(0, 255, &[]) as u8);let v202 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v203 = (if (v202 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v202 == 1) { types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 2) { types::EntityMetadataValue::Float(g.f32()) } else if (v202 == 3) { types::EntityMetadataValue::String(g.string()) } else if (v202 == 4) { types::EntityMetadataValue::Chat(g.string()) } else if (v202 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v202 == 6) { types::EntityMetadataValue::Boolean(g.bool()) } else if (v202 == 7) { types::EntityMetadataValue::Rotation({ let v204 = g.f32();let v205 = g.f32();let v206 = g.f32(); types::EntityMetadataValueRotation { pitch: v204, yaw: v205, roll: v206 } }) } else if (v202 == 8) { types::EntityMetadataValue::Position(g.position()) } else if (v202 == 9) { types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v202 == 10) { types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 11) { types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v202 == 12) { types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 13) { types::EntityMetadataValue::Nbt(g.nbt()) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { key: v201, r#type: v202, value: v203 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v200.key);w.put_i8(v200.r#type);match &v200.value { types::EntityMetadataValue::Byte(v207) => { if !((v200.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v207)); }types::EntityMetadataValue::VarInt(v208) => { if !((v200.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v208)); }types::EntityMetadataValue::Float(v209) => { if !((v200.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v209)); }types::EntityMetadataValue::String(v210) => { if !((v200.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v210))?; }types::EntityMetadataValue::Chat(v211) => { if !((v200.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v211))?; }types::EntityMetadataValue::Slot(v212) => { if !((v200.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v212).encode(w)?; }types::EntityMetadataValue::Boolean(v213) => { if !((v200.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_bool((*v213)); }types::EntityMetadataValue::Rotation(v214) => { if !((v200.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v214).pitch);w.put_f32((*v214).yaw);w.put_f32((*v214).roll); }types::EntityMetadataValue::Position(v215) => { if !((v200.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v215).write(w, PositionLayout::Xyz)?; }types::EntityMetadataValue::OptPosition(v216) => { if !((v200.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v216) { Some(v217) => { w.put_u8(1); (*v217).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }types::EntityMetadataValue::Direction(v218) => { if !((v200.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v218)); }types::EntityMetadataValue::OptUuid(v219) => { if !((v200.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v219) { Some(v220) => { w.put_u8(1); w.put_uuid(&(*v220)); } None => w.put_u8(0), } }types::EntityMetadataValue::BlockState(v221) => { if !((v200.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v221)); }types::EntityMetadataValue::Nbt(v222) => { if !((v200.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v222).write(w); }types::EntityMetadataValue::Other => { if !(!((v200.r#type == 0) || (v200.r#type == 1) || (v200.r#type == 2) || (v200.r#type == 3) || (v200.r#type == 4) || (v200.r#type == 5) || (v200.r#type == 6) || (v200.r#type == 7) || (v200.r#type == 8) || (v200.r#type == 9) || (v200.r#type == 10) || (v200.r#type == 11) || (v200.r#type == 12) || (v200.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v200; } });
1524 }
1525 v199
1526 };
1527 NamedEntitySpawn {
1528 entity_id: v191,
1529 player_uuid: v192,
1530 x: v193,
1531 y: v194,
1532 z: v195,
1533 yaw: v196,
1534 pitch: v197,
1535 metadata: v198,
1536 }
1537 }
1538 }
1539}
1540impl From<NamedEntitySpawn> for ClientboundPlayPacket {
1541 fn from(p: NamedEntitySpawn) -> Self {
1542 Self::NamedEntitySpawn(p)
1543 }
1544}
1545
1546#[derive(Debug, Clone, PartialEq)]
1548pub struct Animation {
1549 pub entity_id: i32,
1551 pub animation: u8,
1553}
1554impl crate::packet::Packet for Animation {
1555 const ID: i32 = id::ANIMATION;
1556 const NAME: &'static str = "animation";
1557 const STATE: State = State::Play;
1558 const DIRECTION: Direction = Direction::Clientbound;
1559}
1560impl Decode for Animation {
1561 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1562 Ok({
1563 let v223 = r.read_varint()?;
1564 let v224 = r.read_u8()?;
1565 Animation {
1566 entity_id: v223,
1567 animation: v224,
1568 }
1569 })
1570 }
1571}
1572impl Encode for Animation {
1573 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1574 w.put_varint((*self).entity_id);
1575 w.put_u8((*self).animation);
1576 Ok(())
1577 }
1578}
1579#[cfg(feature = "testgen")]
1580impl Generate for Animation {
1581 fn generate(g: &mut Gen) -> Self {
1582 {
1583 let v225 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1584 let v226 = (g.int_in(0, 255, &[]) as u8);
1585 Animation {
1586 entity_id: v225,
1587 animation: v226,
1588 }
1589 }
1590 }
1591}
1592impl From<Animation> for ClientboundPlayPacket {
1593 fn from(p: Animation) -> Self {
1594 Self::Animation(p)
1595 }
1596}
1597
1598#[derive(Debug, Clone, PartialEq)]
1600pub struct Statistics {
1601 pub entries: Vec<StatisticsEntries>,
1603}
1604impl crate::packet::Packet for Statistics {
1605 const ID: i32 = id::STATISTICS;
1606 const NAME: &'static str = "statistics";
1607 const STATE: State = State::Play;
1608 const DIRECTION: Direction = Direction::Clientbound;
1609}
1610impl Decode for Statistics {
1611 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1612 Ok({
1613 let v227 = {
1614 let v228 = {
1615 let c = r.read_varint()?;
1616 r.check_count(i64::from(c), 2)?
1617 };
1618 let mut v229 = Vec::with_capacity(v228.min(crate::codec::PREALLOC_LIMIT));
1619 for _ in 0..v228 {
1620 v229.push({
1621 let v230 = r.read_string()?;
1622 let v231 = r.read_varint()?;
1623 StatisticsEntries {
1624 name: v230,
1625 value: v231,
1626 }
1627 });
1628 }
1629 v229
1630 };
1631 Statistics { entries: v227 }
1632 })
1633 }
1634}
1635impl Encode for Statistics {
1636 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1637 w.put_len_varint((*self).entries.len())?;
1638 for v232 in (*self).entries.iter() {
1639 w.put_string(&(*v232).name)?;
1640 w.put_varint((*v232).value);
1641 }
1642 Ok(())
1643 }
1644}
1645#[cfg(feature = "testgen")]
1646impl Generate for Statistics {
1647 fn generate(g: &mut Gen) -> Self {
1648 {
1649 let v233 = {
1650 let v234 = g.count();
1651 let mut v235 = Vec::with_capacity(v234.min(crate::codec::PREALLOC_LIMIT));
1652 for _ in 0..v234 {
1653 v235.push({
1654 let v236 = g.string();
1655 let v237 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1656 StatisticsEntries {
1657 name: v236,
1658 value: v237,
1659 }
1660 });
1661 }
1662 v235
1663 };
1664 Statistics { entries: v233 }
1665 }
1666 }
1667}
1668impl From<Statistics> for ClientboundPlayPacket {
1669 fn from(p: Statistics) -> Self {
1670 Self::Statistics(p)
1671 }
1672}
1673
1674#[derive(Debug, Clone, PartialEq)]
1676pub struct BlockBreakAnimation {
1677 pub entity_id: i32,
1679 pub location: BlockPos,
1681 pub destroy_stage: i8,
1683}
1684impl crate::packet::Packet for BlockBreakAnimation {
1685 const ID: i32 = id::BLOCK_BREAK_ANIMATION;
1686 const NAME: &'static str = "block_break_animation";
1687 const STATE: State = State::Play;
1688 const DIRECTION: Direction = Direction::Clientbound;
1689}
1690impl Decode for BlockBreakAnimation {
1691 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1692 Ok({
1693 let v238 = r.read_varint()?;
1694 let v239 = BlockPos::read(r, PositionLayout::Xyz)?;
1695 let v240 = r.read_i8()?;
1696 BlockBreakAnimation {
1697 entity_id: v238,
1698 location: v239,
1699 destroy_stage: v240,
1700 }
1701 })
1702 }
1703}
1704impl Encode for BlockBreakAnimation {
1705 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1706 w.put_varint((*self).entity_id);
1707 (*self).location.write(w, PositionLayout::Xyz)?;
1708 w.put_i8((*self).destroy_stage);
1709 Ok(())
1710 }
1711}
1712#[cfg(feature = "testgen")]
1713impl Generate for BlockBreakAnimation {
1714 fn generate(g: &mut Gen) -> Self {
1715 {
1716 let v241 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1717 let v242 = g.position();
1718 let v243 = (g.int_in(-128, 127, &[]) as i8);
1719 BlockBreakAnimation {
1720 entity_id: v241,
1721 location: v242,
1722 destroy_stage: v243,
1723 }
1724 }
1725 }
1726}
1727impl From<BlockBreakAnimation> for ClientboundPlayPacket {
1728 fn from(p: BlockBreakAnimation) -> Self {
1729 Self::BlockBreakAnimation(p)
1730 }
1731}
1732
1733#[derive(Debug, Clone, PartialEq)]
1735pub struct TileEntityData {
1736 pub location: BlockPos,
1738 pub action: u8,
1740 pub nbt_data: Option<RawNbt>,
1742}
1743impl crate::packet::Packet for TileEntityData {
1744 const ID: i32 = id::TILE_ENTITY_DATA;
1745 const NAME: &'static str = "tile_entity_data";
1746 const STATE: State = State::Play;
1747 const DIRECTION: Direction = Direction::Clientbound;
1748}
1749impl Decode for TileEntityData {
1750 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1751 Ok({
1752 let v244 = BlockPos::read(r, PositionLayout::Xyz)?;
1753 let v245 = r.read_u8()?;
1754 let v246 = RawNbt::read_optional(r)?;
1755 TileEntityData {
1756 location: v244,
1757 action: v245,
1758 nbt_data: v246,
1759 }
1760 })
1761 }
1762}
1763impl Encode for TileEntityData {
1764 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1765 (*self).location.write(w, PositionLayout::Xyz)?;
1766 w.put_u8((*self).action);
1767 RawNbt::write_optional(&(*self).nbt_data, w);
1768 Ok(())
1769 }
1770}
1771#[cfg(feature = "testgen")]
1772impl Generate for TileEntityData {
1773 fn generate(g: &mut Gen) -> Self {
1774 {
1775 let v247 = g.position();
1776 let v248 = (g.int_in(0, 255, &[]) as u8);
1777 let v249 = g.opt_nbt();
1778 TileEntityData {
1779 location: v247,
1780 action: v248,
1781 nbt_data: v249,
1782 }
1783 }
1784 }
1785}
1786impl From<TileEntityData> for ClientboundPlayPacket {
1787 fn from(p: TileEntityData) -> Self {
1788 Self::TileEntityData(p)
1789 }
1790}
1791
1792#[derive(Debug, Clone, PartialEq)]
1794pub struct BlockAction {
1795 pub location: BlockPos,
1797 pub byte1: u8,
1799 pub byte2: u8,
1801 pub block_id: i32,
1803}
1804impl crate::packet::Packet for BlockAction {
1805 const ID: i32 = id::BLOCK_ACTION;
1806 const NAME: &'static str = "block_action";
1807 const STATE: State = State::Play;
1808 const DIRECTION: Direction = Direction::Clientbound;
1809}
1810impl Decode for BlockAction {
1811 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1812 Ok({
1813 let v250 = BlockPos::read(r, PositionLayout::Xyz)?;
1814 let v251 = r.read_u8()?;
1815 let v252 = r.read_u8()?;
1816 let v253 = r.read_varint()?;
1817 BlockAction {
1818 location: v250,
1819 byte1: v251,
1820 byte2: v252,
1821 block_id: v253,
1822 }
1823 })
1824 }
1825}
1826impl Encode for BlockAction {
1827 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1828 (*self).location.write(w, PositionLayout::Xyz)?;
1829 w.put_u8((*self).byte1);
1830 w.put_u8((*self).byte2);
1831 w.put_varint((*self).block_id);
1832 Ok(())
1833 }
1834}
1835#[cfg(feature = "testgen")]
1836impl Generate for BlockAction {
1837 fn generate(g: &mut Gen) -> Self {
1838 {
1839 let v254 = g.position();
1840 let v255 = (g.int_in(0, 255, &[]) as u8);
1841 let v256 = (g.int_in(0, 255, &[]) as u8);
1842 let v257 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1843 BlockAction {
1844 location: v254,
1845 byte1: v255,
1846 byte2: v256,
1847 block_id: v257,
1848 }
1849 }
1850 }
1851}
1852impl From<BlockAction> for ClientboundPlayPacket {
1853 fn from(p: BlockAction) -> Self {
1854 Self::BlockAction(p)
1855 }
1856}
1857
1858#[derive(Debug, Clone, PartialEq)]
1860pub struct BlockChange {
1861 pub location: BlockPos,
1863 pub r#type: i32,
1865}
1866impl crate::packet::Packet for BlockChange {
1867 const ID: i32 = id::BLOCK_CHANGE;
1868 const NAME: &'static str = "block_change";
1869 const STATE: State = State::Play;
1870 const DIRECTION: Direction = Direction::Clientbound;
1871}
1872impl Decode for BlockChange {
1873 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1874 Ok({
1875 let v258 = BlockPos::read(r, PositionLayout::Xyz)?;
1876 let v259 = r.read_varint()?;
1877 BlockChange {
1878 location: v258,
1879 r#type: v259,
1880 }
1881 })
1882 }
1883}
1884impl Encode for BlockChange {
1885 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1886 (*self).location.write(w, PositionLayout::Xyz)?;
1887 w.put_varint((*self).r#type);
1888 Ok(())
1889 }
1890}
1891#[cfg(feature = "testgen")]
1892impl Generate for BlockChange {
1893 fn generate(g: &mut Gen) -> Self {
1894 {
1895 let v260 = g.position();
1896 let v261 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1897 BlockChange {
1898 location: v260,
1899 r#type: v261,
1900 }
1901 }
1902 }
1903}
1904impl From<BlockChange> for ClientboundPlayPacket {
1905 fn from(p: BlockChange) -> Self {
1906 Self::BlockChange(p)
1907 }
1908}
1909
1910#[derive(Debug, Clone, PartialEq)]
1912pub struct BossBar {
1913 pub entity_uuid: Uuid,
1915 pub action: i32,
1917 pub title: Option<ByteString>,
1919 pub health: Option<f32>,
1921 pub color: Option<i32>,
1923 pub dividers: Option<i32>,
1925 pub flags: Option<u8>,
1927}
1928impl crate::packet::Packet for BossBar {
1929 const ID: i32 = id::BOSS_BAR;
1930 const NAME: &'static str = "boss_bar";
1931 const STATE: State = State::Play;
1932 const DIRECTION: Direction = Direction::Clientbound;
1933}
1934impl Decode for BossBar {
1935 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1936 Ok({
1937 let v262 = r.read_uuid()?;
1938 let v263 = r.read_varint()?;
1939 let v264 = if (v263 == 0) || (v263 == 3) {
1940 Some(r.read_string()?)
1941 } else {
1942 None
1943 };
1944 let v265 = if (v263 == 0) || (v263 == 2) {
1945 Some(r.read_f32()?)
1946 } else {
1947 None
1948 };
1949 let v266 = if (v263 == 0) || (v263 == 4) {
1950 Some(r.read_varint()?)
1951 } else {
1952 None
1953 };
1954 let v267 = if (v263 == 0) || (v263 == 4) {
1955 Some(r.read_varint()?)
1956 } else {
1957 None
1958 };
1959 let v268 = if (v263 == 0) || (v263 == 5) {
1960 Some(r.read_u8()?)
1961 } else {
1962 None
1963 };
1964 BossBar {
1965 entity_uuid: v262,
1966 action: v263,
1967 title: v264,
1968 health: v265,
1969 color: v266,
1970 dividers: v267,
1971 flags: v268,
1972 }
1973 })
1974 }
1975}
1976impl Encode for BossBar {
1977 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1978 w.put_uuid(&(*self).entity_uuid);
1979 w.put_varint((*self).action);
1980 match (
1981 &(*self).title,
1982 ((*self).action == 0) || ((*self).action == 3),
1983 ) {
1984 (Some(v269), true) => {
1985 w.put_string(&(*v269))?;
1986 }
1987 (None, false) => {}
1988 _ => {
1989 return Err(EncodeError::SwitchMismatch(
1990 "play.clientbound.boss_bar.title",
1991 ));
1992 }
1993 }
1994 match (
1995 &(*self).health,
1996 ((*self).action == 0) || ((*self).action == 2),
1997 ) {
1998 (Some(v270), true) => {
1999 w.put_f32((*v270));
2000 }
2001 (None, false) => {}
2002 _ => {
2003 return Err(EncodeError::SwitchMismatch(
2004 "play.clientbound.boss_bar.health",
2005 ));
2006 }
2007 }
2008 match (
2009 &(*self).color,
2010 ((*self).action == 0) || ((*self).action == 4),
2011 ) {
2012 (Some(v271), true) => {
2013 w.put_varint((*v271));
2014 }
2015 (None, false) => {}
2016 _ => {
2017 return Err(EncodeError::SwitchMismatch(
2018 "play.clientbound.boss_bar.color",
2019 ));
2020 }
2021 }
2022 match (
2023 &(*self).dividers,
2024 ((*self).action == 0) || ((*self).action == 4),
2025 ) {
2026 (Some(v272), true) => {
2027 w.put_varint((*v272));
2028 }
2029 (None, false) => {}
2030 _ => {
2031 return Err(EncodeError::SwitchMismatch(
2032 "play.clientbound.boss_bar.dividers",
2033 ));
2034 }
2035 }
2036 match (
2037 &(*self).flags,
2038 ((*self).action == 0) || ((*self).action == 5),
2039 ) {
2040 (Some(v273), true) => {
2041 w.put_u8((*v273));
2042 }
2043 (None, false) => {}
2044 _ => {
2045 return Err(EncodeError::SwitchMismatch(
2046 "play.clientbound.boss_bar.flags",
2047 ));
2048 }
2049 }
2050 Ok(())
2051 }
2052}
2053#[cfg(feature = "testgen")]
2054impl Generate for BossBar {
2055 fn generate(g: &mut Gen) -> Self {
2056 {
2057 let v274 = g.uuid();
2058 let v275 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
2059 let v276 = if (v275 == 0) || (v275 == 3) {
2060 Some(g.string())
2061 } else {
2062 None
2063 };
2064 let v277 = if (v275 == 0) || (v275 == 2) {
2065 Some(g.f32())
2066 } else {
2067 None
2068 };
2069 let v278 = if (v275 == 0) || (v275 == 4) {
2070 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2071 } else {
2072 None
2073 };
2074 let v279 = if (v275 == 0) || (v275 == 4) {
2075 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2076 } else {
2077 None
2078 };
2079 let v280 = if (v275 == 0) || (v275 == 5) {
2080 Some((g.int_in(0, 255, &[]) as u8))
2081 } else {
2082 None
2083 };
2084 BossBar {
2085 entity_uuid: v274,
2086 action: v275,
2087 title: v276,
2088 health: v277,
2089 color: v278,
2090 dividers: v279,
2091 flags: v280,
2092 }
2093 }
2094 }
2095}
2096impl From<BossBar> for ClientboundPlayPacket {
2097 fn from(p: BossBar) -> Self {
2098 Self::BossBar(p)
2099 }
2100}
2101
2102#[derive(Debug, Clone, PartialEq)]
2104pub struct Difficulty {
2105 pub difficulty: DifficultyDifficulty,
2107}
2108impl crate::packet::Packet for Difficulty {
2109 const ID: i32 = id::DIFFICULTY;
2110 const NAME: &'static str = "difficulty";
2111 const STATE: State = State::Play;
2112 const DIRECTION: Direction = Direction::Clientbound;
2113}
2114impl Decode for Difficulty {
2115 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2116 Ok({
2117 let v281 = DifficultyDifficulty(r.read_u8()?);
2118 Difficulty { difficulty: v281 }
2119 })
2120 }
2121}
2122impl Encode for Difficulty {
2123 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2124 w.put_u8((*self).difficulty.0);
2125 Ok(())
2126 }
2127}
2128#[cfg(feature = "testgen")]
2129impl Generate for Difficulty {
2130 fn generate(g: &mut Gen) -> Self {
2131 {
2132 let v282 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
2133 Difficulty { difficulty: v282 }
2134 }
2135 }
2136}
2137impl From<Difficulty> for ClientboundPlayPacket {
2138 fn from(p: Difficulty) -> Self {
2139 Self::Difficulty(p)
2140 }
2141}
2142
2143#[derive(Debug, Clone, PartialEq)]
2145pub struct TabComplete {
2146 pub matches: Vec<ByteString>,
2148}
2149impl crate::packet::Packet for TabComplete {
2150 const ID: i32 = id::TAB_COMPLETE;
2151 const NAME: &'static str = "tab_complete";
2152 const STATE: State = State::Play;
2153 const DIRECTION: Direction = Direction::Clientbound;
2154}
2155impl Decode for TabComplete {
2156 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2157 Ok({
2158 let v283 = {
2159 let v284 = {
2160 let c = r.read_varint()?;
2161 r.check_count(i64::from(c), 1)?
2162 };
2163 let mut v285 = Vec::with_capacity(v284.min(crate::codec::PREALLOC_LIMIT));
2164 for _ in 0..v284 {
2165 v285.push(r.read_string()?);
2166 }
2167 v285
2168 };
2169 TabComplete { matches: v283 }
2170 })
2171 }
2172}
2173impl Encode for TabComplete {
2174 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2175 w.put_len_varint((*self).matches.len())?;
2176 for v286 in (*self).matches.iter() {
2177 w.put_string(&(*v286))?;
2178 }
2179 Ok(())
2180 }
2181}
2182#[cfg(feature = "testgen")]
2183impl Generate for TabComplete {
2184 fn generate(g: &mut Gen) -> Self {
2185 {
2186 let v287 = {
2187 let v288 = g.count();
2188 let mut v289 = Vec::with_capacity(v288.min(crate::codec::PREALLOC_LIMIT));
2189 for _ in 0..v288 {
2190 v289.push(g.string());
2191 }
2192 v289
2193 };
2194 TabComplete { matches: v287 }
2195 }
2196 }
2197}
2198impl From<TabComplete> for ClientboundPlayPacket {
2199 fn from(p: TabComplete) -> Self {
2200 Self::TabComplete(p)
2201 }
2202}
2203
2204#[derive(Debug, Clone, PartialEq)]
2206pub struct Chat {
2207 pub message: ByteString,
2209 pub position: i8,
2211}
2212impl crate::packet::Packet for Chat {
2213 const ID: i32 = id::CHAT;
2214 const NAME: &'static str = "chat";
2215 const STATE: State = State::Play;
2216 const DIRECTION: Direction = Direction::Clientbound;
2217}
2218impl Decode for Chat {
2219 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2220 Ok({
2221 let v290 = r.read_string()?;
2222 let v291 = r.read_i8()?;
2223 Chat {
2224 message: v290,
2225 position: v291,
2226 }
2227 })
2228 }
2229}
2230impl Encode for Chat {
2231 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2232 w.put_string(&(*self).message)?;
2233 w.put_i8((*self).position);
2234 Ok(())
2235 }
2236}
2237#[cfg(feature = "testgen")]
2238impl Generate for Chat {
2239 fn generate(g: &mut Gen) -> Self {
2240 {
2241 let v292 = g.string();
2242 let v293 = (g.int_in(-128, 127, &[]) as i8);
2243 Chat {
2244 message: v292,
2245 position: v293,
2246 }
2247 }
2248 }
2249}
2250impl From<Chat> for ClientboundPlayPacket {
2251 fn from(p: Chat) -> Self {
2252 Self::Chat(p)
2253 }
2254}
2255
2256#[derive(Debug, Clone, PartialEq)]
2258pub struct MultiBlockChange {
2259 pub chunk_x: i32,
2261 pub chunk_z: i32,
2263 pub records: Vec<MultiBlockChangeRecords>,
2265}
2266impl crate::packet::Packet for MultiBlockChange {
2267 const ID: i32 = id::MULTI_BLOCK_CHANGE;
2268 const NAME: &'static str = "multi_block_change";
2269 const STATE: State = State::Play;
2270 const DIRECTION: Direction = Direction::Clientbound;
2271}
2272impl Decode for MultiBlockChange {
2273 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2274 Ok({
2275 let v294 = r.read_i32()?;
2276 let v295 = r.read_i32()?;
2277 let v296 = {
2278 let v297 = {
2279 let c = r.read_varint()?;
2280 r.check_count(i64::from(c), 3)?
2281 };
2282 let mut v298 = Vec::with_capacity(v297.min(crate::codec::PREALLOC_LIMIT));
2283 for _ in 0..v297 {
2284 v298.push({
2285 let v299 = r.read_u8()?;
2286 let v300 = r.read_u8()?;
2287 let v301 = r.read_varint()?;
2288 MultiBlockChangeRecords {
2289 horizontal_pos: v299,
2290 y: v300,
2291 block_id: v301,
2292 }
2293 });
2294 }
2295 v298
2296 };
2297 MultiBlockChange {
2298 chunk_x: v294,
2299 chunk_z: v295,
2300 records: v296,
2301 }
2302 })
2303 }
2304}
2305impl Encode for MultiBlockChange {
2306 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2307 w.put_i32((*self).chunk_x);
2308 w.put_i32((*self).chunk_z);
2309 w.put_len_varint((*self).records.len())?;
2310 for v302 in (*self).records.iter() {
2311 w.put_u8((*v302).horizontal_pos);
2312 w.put_u8((*v302).y);
2313 w.put_varint((*v302).block_id);
2314 }
2315 Ok(())
2316 }
2317}
2318#[cfg(feature = "testgen")]
2319impl Generate for MultiBlockChange {
2320 fn generate(g: &mut Gen) -> Self {
2321 {
2322 let v303 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2323 let v304 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2324 let v305 = {
2325 let v306 = g.count();
2326 let mut v307 = Vec::with_capacity(v306.min(crate::codec::PREALLOC_LIMIT));
2327 for _ in 0..v306 {
2328 v307.push({
2329 let v308 = (g.int_in(0, 255, &[]) as u8);
2330 let v309 = (g.int_in(0, 255, &[]) as u8);
2331 let v310 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2332 MultiBlockChangeRecords {
2333 horizontal_pos: v308,
2334 y: v309,
2335 block_id: v310,
2336 }
2337 });
2338 }
2339 v307
2340 };
2341 MultiBlockChange {
2342 chunk_x: v303,
2343 chunk_z: v304,
2344 records: v305,
2345 }
2346 }
2347 }
2348}
2349impl From<MultiBlockChange> for ClientboundPlayPacket {
2350 fn from(p: MultiBlockChange) -> Self {
2351 Self::MultiBlockChange(p)
2352 }
2353}
2354
2355#[derive(Debug, Clone, PartialEq)]
2357pub struct Transaction {
2358 pub window_id: i8,
2360 pub action: i16,
2362 pub accepted: bool,
2364}
2365impl crate::packet::Packet for Transaction {
2366 const ID: i32 = id::TRANSACTION;
2367 const NAME: &'static str = "transaction";
2368 const STATE: State = State::Play;
2369 const DIRECTION: Direction = Direction::Clientbound;
2370}
2371impl Decode for Transaction {
2372 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2373 Ok({
2374 let v311 = r.read_i8()?;
2375 let v312 = r.read_i16()?;
2376 let v313 = r.read_bool()?;
2377 Transaction {
2378 window_id: v311,
2379 action: v312,
2380 accepted: v313,
2381 }
2382 })
2383 }
2384}
2385impl Encode for Transaction {
2386 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2387 w.put_i8((*self).window_id);
2388 w.put_i16((*self).action);
2389 w.put_bool((*self).accepted);
2390 Ok(())
2391 }
2392}
2393#[cfg(feature = "testgen")]
2394impl Generate for Transaction {
2395 fn generate(g: &mut Gen) -> Self {
2396 {
2397 let v314 = (g.int_in(-128, 127, &[]) as i8);
2398 let v315 = (g.int_in(-32768, 32767, &[]) as i16);
2399 let v316 = g.bool();
2400 Transaction {
2401 window_id: v314,
2402 action: v315,
2403 accepted: v316,
2404 }
2405 }
2406 }
2407}
2408impl From<Transaction> for ClientboundPlayPacket {
2409 fn from(p: Transaction) -> Self {
2410 Self::Transaction(p)
2411 }
2412}
2413
2414#[derive(Debug, Clone, PartialEq)]
2416pub struct CloseWindow {
2417 pub window_id: u8,
2419}
2420impl crate::packet::Packet for CloseWindow {
2421 const ID: i32 = id::CLOSE_WINDOW;
2422 const NAME: &'static str = "close_window";
2423 const STATE: State = State::Play;
2424 const DIRECTION: Direction = Direction::Clientbound;
2425}
2426impl Decode for CloseWindow {
2427 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2428 Ok({
2429 let v317 = r.read_u8()?;
2430 CloseWindow { window_id: v317 }
2431 })
2432 }
2433}
2434impl Encode for CloseWindow {
2435 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2436 w.put_u8((*self).window_id);
2437 Ok(())
2438 }
2439}
2440#[cfg(feature = "testgen")]
2441impl Generate for CloseWindow {
2442 fn generate(g: &mut Gen) -> Self {
2443 {
2444 let v318 = (g.int_in(0, 255, &[]) as u8);
2445 CloseWindow { window_id: v318 }
2446 }
2447 }
2448}
2449impl From<CloseWindow> for ClientboundPlayPacket {
2450 fn from(p: CloseWindow) -> Self {
2451 Self::CloseWindow(p)
2452 }
2453}
2454
2455#[derive(Debug, Clone, PartialEq)]
2457pub struct OpenWindow {
2458 pub window_id: u8,
2460 pub inventory_type: ByteString,
2462 pub window_title: ByteString,
2464 pub slot_count: u8,
2466 pub entity_id: Option<i32>,
2468}
2469impl crate::packet::Packet for OpenWindow {
2470 const ID: i32 = id::OPEN_WINDOW;
2471 const NAME: &'static str = "open_window";
2472 const STATE: State = State::Play;
2473 const DIRECTION: Direction = Direction::Clientbound;
2474}
2475impl Decode for OpenWindow {
2476 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2477 Ok({
2478 let v319 = r.read_u8()?;
2479 let v320 = r.read_string()?;
2480 let v321 = r.read_string()?;
2481 let v322 = r.read_u8()?;
2482 let v323 = if (&*v320 == "EntityHorse") {
2483 Some(r.read_i32()?)
2484 } else {
2485 None
2486 };
2487 OpenWindow {
2488 window_id: v319,
2489 inventory_type: v320,
2490 window_title: v321,
2491 slot_count: v322,
2492 entity_id: v323,
2493 }
2494 })
2495 }
2496}
2497impl Encode for OpenWindow {
2498 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2499 w.put_u8((*self).window_id);
2500 w.put_string(&(*self).inventory_type)?;
2501 w.put_string(&(*self).window_title)?;
2502 w.put_u8((*self).slot_count);
2503 match (
2504 &(*self).entity_id,
2505 (&*(*self).inventory_type == "EntityHorse"),
2506 ) {
2507 (Some(v324), true) => {
2508 w.put_i32((*v324));
2509 }
2510 (None, false) => {}
2511 _ => {
2512 return Err(EncodeError::SwitchMismatch(
2513 "play.clientbound.open_window.entityId",
2514 ));
2515 }
2516 }
2517 Ok(())
2518 }
2519}
2520#[cfg(feature = "testgen")]
2521impl Generate for OpenWindow {
2522 fn generate(g: &mut Gen) -> Self {
2523 {
2524 let v325 = (g.int_in(0, 255, &[]) as u8);
2525 let v326 = g.string_in(&["EntityHorse"]);
2526 let v327 = g.string();
2527 let v328 = (g.int_in(0, 255, &[]) as u8);
2528 let v329 = if (&*v326 == "EntityHorse") {
2529 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
2530 } else {
2531 None
2532 };
2533 OpenWindow {
2534 window_id: v325,
2535 inventory_type: v326,
2536 window_title: v327,
2537 slot_count: v328,
2538 entity_id: v329,
2539 }
2540 }
2541 }
2542}
2543impl From<OpenWindow> for ClientboundPlayPacket {
2544 fn from(p: OpenWindow) -> Self {
2545 Self::OpenWindow(p)
2546 }
2547}
2548
2549#[derive(Debug, Clone, PartialEq)]
2551pub struct WindowItems {
2552 pub window_id: u8,
2554 pub items: Vec<types::Slot>,
2556}
2557impl crate::packet::Packet for WindowItems {
2558 const ID: i32 = id::WINDOW_ITEMS;
2559 const NAME: &'static str = "window_items";
2560 const STATE: State = State::Play;
2561 const DIRECTION: Direction = Direction::Clientbound;
2562}
2563impl Decode for WindowItems {
2564 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2565 Ok({
2566 let v330 = r.read_u8()?;
2567 let v331 = {
2568 let v332 = {
2569 let c = r.read_i16()?;
2570 r.check_count(i64::from(c), 1)?
2571 };
2572 let mut v333 = Vec::with_capacity(v332.min(crate::codec::PREALLOC_LIMIT));
2573 for _ in 0..v332 {
2574 v333.push(<types::Slot as Decode>::decode(r)?);
2575 }
2576 v333
2577 };
2578 WindowItems {
2579 window_id: v330,
2580 items: v331,
2581 }
2582 })
2583 }
2584}
2585impl Encode for WindowItems {
2586 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2587 w.put_u8((*self).window_id);
2588 w.put_i16(crate::codec::count_i16((*self).items.len())?);
2589 for v334 in (*self).items.iter() {
2590 (*v334).encode(w)?;
2591 }
2592 Ok(())
2593 }
2594}
2595#[cfg(feature = "testgen")]
2596impl Generate for WindowItems {
2597 fn generate(g: &mut Gen) -> Self {
2598 {
2599 let v335 = (g.int_in(0, 255, &[]) as u8);
2600 let v336 = {
2601 let v337 = g.count();
2602 let mut v338 = Vec::with_capacity(v337.min(crate::codec::PREALLOC_LIMIT));
2603 for _ in 0..v337 {
2604 v338.push(<types::Slot as Generate>::generate(g));
2605 }
2606 v338
2607 };
2608 WindowItems {
2609 window_id: v335,
2610 items: v336,
2611 }
2612 }
2613 }
2614}
2615impl From<WindowItems> for ClientboundPlayPacket {
2616 fn from(p: WindowItems) -> Self {
2617 Self::WindowItems(p)
2618 }
2619}
2620
2621#[derive(Debug, Clone, PartialEq)]
2623pub struct CraftProgressBar {
2624 pub window_id: u8,
2626 pub property: i16,
2628 pub value: i16,
2630}
2631impl crate::packet::Packet for CraftProgressBar {
2632 const ID: i32 = id::CRAFT_PROGRESS_BAR;
2633 const NAME: &'static str = "craft_progress_bar";
2634 const STATE: State = State::Play;
2635 const DIRECTION: Direction = Direction::Clientbound;
2636}
2637impl Decode for CraftProgressBar {
2638 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2639 Ok({
2640 let v339 = r.read_u8()?;
2641 let v340 = r.read_i16()?;
2642 let v341 = r.read_i16()?;
2643 CraftProgressBar {
2644 window_id: v339,
2645 property: v340,
2646 value: v341,
2647 }
2648 })
2649 }
2650}
2651impl Encode for CraftProgressBar {
2652 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2653 w.put_u8((*self).window_id);
2654 w.put_i16((*self).property);
2655 w.put_i16((*self).value);
2656 Ok(())
2657 }
2658}
2659#[cfg(feature = "testgen")]
2660impl Generate for CraftProgressBar {
2661 fn generate(g: &mut Gen) -> Self {
2662 {
2663 let v342 = (g.int_in(0, 255, &[]) as u8);
2664 let v343 = (g.int_in(-32768, 32767, &[]) as i16);
2665 let v344 = (g.int_in(-32768, 32767, &[]) as i16);
2666 CraftProgressBar {
2667 window_id: v342,
2668 property: v343,
2669 value: v344,
2670 }
2671 }
2672 }
2673}
2674impl From<CraftProgressBar> for ClientboundPlayPacket {
2675 fn from(p: CraftProgressBar) -> Self {
2676 Self::CraftProgressBar(p)
2677 }
2678}
2679
2680#[derive(Debug, Clone, PartialEq)]
2682pub struct SetSlot {
2683 pub window_id: i8,
2685 pub slot: i16,
2687 pub item: types::Slot,
2689}
2690impl crate::packet::Packet for SetSlot {
2691 const ID: i32 = id::SET_SLOT;
2692 const NAME: &'static str = "set_slot";
2693 const STATE: State = State::Play;
2694 const DIRECTION: Direction = Direction::Clientbound;
2695}
2696impl Decode for SetSlot {
2697 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2698 Ok({
2699 let v345 = r.read_i8()?;
2700 let v346 = r.read_i16()?;
2701 let v347 = <types::Slot as Decode>::decode(r)?;
2702 SetSlot {
2703 window_id: v345,
2704 slot: v346,
2705 item: v347,
2706 }
2707 })
2708 }
2709}
2710impl Encode for SetSlot {
2711 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2712 w.put_i8((*self).window_id);
2713 w.put_i16((*self).slot);
2714 (*self).item.encode(w)?;
2715 Ok(())
2716 }
2717}
2718#[cfg(feature = "testgen")]
2719impl Generate for SetSlot {
2720 fn generate(g: &mut Gen) -> Self {
2721 {
2722 let v348 = (g.int_in(-128, 127, &[]) as i8);
2723 let v349 = (g.int_in(-32768, 32767, &[]) as i16);
2724 let v350 = <types::Slot as Generate>::generate(g);
2725 SetSlot {
2726 window_id: v348,
2727 slot: v349,
2728 item: v350,
2729 }
2730 }
2731 }
2732}
2733impl From<SetSlot> for ClientboundPlayPacket {
2734 fn from(p: SetSlot) -> Self {
2735 Self::SetSlot(p)
2736 }
2737}
2738
2739#[derive(Debug, Clone, PartialEq)]
2741pub struct SetCooldown {
2742 pub item_id: i32,
2744 pub cooldown_ticks: i32,
2746}
2747impl crate::packet::Packet for SetCooldown {
2748 const ID: i32 = id::SET_COOLDOWN;
2749 const NAME: &'static str = "set_cooldown";
2750 const STATE: State = State::Play;
2751 const DIRECTION: Direction = Direction::Clientbound;
2752}
2753impl Decode for SetCooldown {
2754 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2755 Ok({
2756 let v351 = r.read_varint()?;
2757 let v352 = r.read_varint()?;
2758 SetCooldown {
2759 item_id: v351,
2760 cooldown_ticks: v352,
2761 }
2762 })
2763 }
2764}
2765impl Encode for SetCooldown {
2766 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2767 w.put_varint((*self).item_id);
2768 w.put_varint((*self).cooldown_ticks);
2769 Ok(())
2770 }
2771}
2772#[cfg(feature = "testgen")]
2773impl Generate for SetCooldown {
2774 fn generate(g: &mut Gen) -> Self {
2775 {
2776 let v353 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2777 let v354 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2778 SetCooldown {
2779 item_id: v353,
2780 cooldown_ticks: v354,
2781 }
2782 }
2783 }
2784}
2785impl From<SetCooldown> for ClientboundPlayPacket {
2786 fn from(p: SetCooldown) -> Self {
2787 Self::SetCooldown(p)
2788 }
2789}
2790
2791#[derive(Debug, Clone, PartialEq)]
2793pub struct CustomPayload {
2794 pub channel: ByteString,
2796 pub data: Bytes,
2798}
2799impl crate::packet::Packet for CustomPayload {
2800 const ID: i32 = id::CUSTOM_PAYLOAD;
2801 const NAME: &'static str = "custom_payload";
2802 const STATE: State = State::Play;
2803 const DIRECTION: Direction = Direction::Clientbound;
2804}
2805impl Decode for CustomPayload {
2806 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2807 Ok({
2808 let v355 = r.read_string()?;
2809 let v356 = r.read_rest();
2810 CustomPayload {
2811 channel: v355,
2812 data: v356,
2813 }
2814 })
2815 }
2816}
2817impl Encode for CustomPayload {
2818 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2819 w.put_string(&(*self).channel)?;
2820 w.put_slice(&(*self).data);
2821 Ok(())
2822 }
2823}
2824#[cfg(feature = "testgen")]
2825impl Generate for CustomPayload {
2826 fn generate(g: &mut Gen) -> Self {
2827 {
2828 let v357 = g.string();
2829 let v358 = g.bytes();
2830 CustomPayload {
2831 channel: v357,
2832 data: v358,
2833 }
2834 }
2835 }
2836}
2837impl From<CustomPayload> for ClientboundPlayPacket {
2838 fn from(p: CustomPayload) -> Self {
2839 Self::CustomPayload(p)
2840 }
2841}
2842
2843#[derive(Debug, Clone, PartialEq)]
2845pub struct NamedSoundEffect {
2846 pub sound_name: ByteString,
2848 pub sound_category: i32,
2850 pub x: i32,
2852 pub y: i32,
2854 pub z: i32,
2856 pub volume: f32,
2858 pub pitch: f32,
2860}
2861impl crate::packet::Packet for NamedSoundEffect {
2862 const ID: i32 = id::NAMED_SOUND_EFFECT;
2863 const NAME: &'static str = "named_sound_effect";
2864 const STATE: State = State::Play;
2865 const DIRECTION: Direction = Direction::Clientbound;
2866}
2867impl Decode for NamedSoundEffect {
2868 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2869 Ok({
2870 let v359 = r.read_string()?;
2871 let v360 = r.read_varint()?;
2872 let v361 = r.read_i32()?;
2873 let v362 = r.read_i32()?;
2874 let v363 = r.read_i32()?;
2875 let v364 = r.read_f32()?;
2876 let v365 = r.read_f32()?;
2877 NamedSoundEffect {
2878 sound_name: v359,
2879 sound_category: v360,
2880 x: v361,
2881 y: v362,
2882 z: v363,
2883 volume: v364,
2884 pitch: v365,
2885 }
2886 })
2887 }
2888}
2889impl Encode for NamedSoundEffect {
2890 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2891 w.put_string(&(*self).sound_name)?;
2892 w.put_varint((*self).sound_category);
2893 w.put_i32((*self).x);
2894 w.put_i32((*self).y);
2895 w.put_i32((*self).z);
2896 w.put_f32((*self).volume);
2897 w.put_f32((*self).pitch);
2898 Ok(())
2899 }
2900}
2901#[cfg(feature = "testgen")]
2902impl Generate for NamedSoundEffect {
2903 fn generate(g: &mut Gen) -> Self {
2904 {
2905 let v366 = g.string();
2906 let v367 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2907 let v368 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2908 let v369 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2909 let v370 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2910 let v371 = g.f32();
2911 let v372 = g.f32();
2912 NamedSoundEffect {
2913 sound_name: v366,
2914 sound_category: v367,
2915 x: v368,
2916 y: v369,
2917 z: v370,
2918 volume: v371,
2919 pitch: v372,
2920 }
2921 }
2922 }
2923}
2924impl From<NamedSoundEffect> for ClientboundPlayPacket {
2925 fn from(p: NamedSoundEffect) -> Self {
2926 Self::NamedSoundEffect(p)
2927 }
2928}
2929
2930#[derive(Debug, Clone, PartialEq)]
2932pub struct KickDisconnect {
2933 pub reason: ByteString,
2935}
2936impl crate::packet::Packet for KickDisconnect {
2937 const ID: i32 = id::KICK_DISCONNECT;
2938 const NAME: &'static str = "kick_disconnect";
2939 const STATE: State = State::Play;
2940 const DIRECTION: Direction = Direction::Clientbound;
2941}
2942impl Decode for KickDisconnect {
2943 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2944 Ok({
2945 let v373 = r.read_string()?;
2946 KickDisconnect { reason: v373 }
2947 })
2948 }
2949}
2950impl Encode for KickDisconnect {
2951 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2952 w.put_string(&(*self).reason)?;
2953 Ok(())
2954 }
2955}
2956#[cfg(feature = "testgen")]
2957impl Generate for KickDisconnect {
2958 fn generate(g: &mut Gen) -> Self {
2959 {
2960 let v374 = g.string();
2961 KickDisconnect { reason: v374 }
2962 }
2963 }
2964}
2965impl From<KickDisconnect> for ClientboundPlayPacket {
2966 fn from(p: KickDisconnect) -> Self {
2967 Self::KickDisconnect(p)
2968 }
2969}
2970
2971#[derive(Debug, Clone, PartialEq)]
2973pub struct EntityStatus {
2974 pub entity_id: i32,
2976 pub entity_status: i8,
2978}
2979impl crate::packet::Packet for EntityStatus {
2980 const ID: i32 = id::ENTITY_STATUS;
2981 const NAME: &'static str = "entity_status";
2982 const STATE: State = State::Play;
2983 const DIRECTION: Direction = Direction::Clientbound;
2984}
2985impl Decode for EntityStatus {
2986 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2987 Ok({
2988 let v375 = r.read_i32()?;
2989 let v376 = r.read_i8()?;
2990 EntityStatus {
2991 entity_id: v375,
2992 entity_status: v376,
2993 }
2994 })
2995 }
2996}
2997impl Encode for EntityStatus {
2998 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2999 w.put_i32((*self).entity_id);
3000 w.put_i8((*self).entity_status);
3001 Ok(())
3002 }
3003}
3004#[cfg(feature = "testgen")]
3005impl Generate for EntityStatus {
3006 fn generate(g: &mut Gen) -> Self {
3007 {
3008 let v377 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3009 let v378 = (g.int_in(-128, 127, &[]) as i8);
3010 EntityStatus {
3011 entity_id: v377,
3012 entity_status: v378,
3013 }
3014 }
3015 }
3016}
3017impl From<EntityStatus> for ClientboundPlayPacket {
3018 fn from(p: EntityStatus) -> Self {
3019 Self::EntityStatus(p)
3020 }
3021}
3022
3023#[derive(Debug, Clone, PartialEq)]
3025pub struct Explosion {
3026 pub x: f32,
3028 pub y: f32,
3030 pub z: f32,
3032 pub radius: f32,
3034 pub affected_block_offsets: Vec<ExplosionAffectedBlockOffsets>,
3036 pub player_motion_x: f32,
3038 pub player_motion_y: f32,
3040 pub player_motion_z: f32,
3042}
3043impl crate::packet::Packet for Explosion {
3044 const ID: i32 = id::EXPLOSION;
3045 const NAME: &'static str = "explosion";
3046 const STATE: State = State::Play;
3047 const DIRECTION: Direction = Direction::Clientbound;
3048}
3049impl Decode for Explosion {
3050 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3051 Ok({
3052 let v379 = r.read_f32()?;
3053 let v380 = r.read_f32()?;
3054 let v381 = r.read_f32()?;
3055 let v382 = r.read_f32()?;
3056 let v383 = {
3057 let v384 = {
3058 let c = r.read_i32()?;
3059 r.check_count(i64::from(c), 3)?
3060 };
3061 let mut v385 = Vec::with_capacity(v384.min(crate::codec::PREALLOC_LIMIT));
3062 for _ in 0..v384 {
3063 v385.push({
3064 let v386 = r.read_i8()?;
3065 let v387 = r.read_i8()?;
3066 let v388 = r.read_i8()?;
3067 ExplosionAffectedBlockOffsets {
3068 x: v386,
3069 y: v387,
3070 z: v388,
3071 }
3072 });
3073 }
3074 v385
3075 };
3076 let v389 = r.read_f32()?;
3077 let v390 = r.read_f32()?;
3078 let v391 = r.read_f32()?;
3079 Explosion {
3080 x: v379,
3081 y: v380,
3082 z: v381,
3083 radius: v382,
3084 affected_block_offsets: v383,
3085 player_motion_x: v389,
3086 player_motion_y: v390,
3087 player_motion_z: v391,
3088 }
3089 })
3090 }
3091}
3092impl Encode for Explosion {
3093 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3094 w.put_f32((*self).x);
3095 w.put_f32((*self).y);
3096 w.put_f32((*self).z);
3097 w.put_f32((*self).radius);
3098 w.put_i32(crate::codec::count_i32(
3099 (*self).affected_block_offsets.len(),
3100 )?);
3101 for v392 in (*self).affected_block_offsets.iter() {
3102 w.put_i8((*v392).x);
3103 w.put_i8((*v392).y);
3104 w.put_i8((*v392).z);
3105 }
3106 w.put_f32((*self).player_motion_x);
3107 w.put_f32((*self).player_motion_y);
3108 w.put_f32((*self).player_motion_z);
3109 Ok(())
3110 }
3111}
3112#[cfg(feature = "testgen")]
3113impl Generate for Explosion {
3114 fn generate(g: &mut Gen) -> Self {
3115 {
3116 let v393 = g.f32();
3117 let v394 = g.f32();
3118 let v395 = g.f32();
3119 let v396 = g.f32();
3120 let v397 = {
3121 let v398 = g.count();
3122 let mut v399 = Vec::with_capacity(v398.min(crate::codec::PREALLOC_LIMIT));
3123 for _ in 0..v398 {
3124 v399.push({
3125 let v400 = (g.int_in(-128, 127, &[]) as i8);
3126 let v401 = (g.int_in(-128, 127, &[]) as i8);
3127 let v402 = (g.int_in(-128, 127, &[]) as i8);
3128 ExplosionAffectedBlockOffsets {
3129 x: v400,
3130 y: v401,
3131 z: v402,
3132 }
3133 });
3134 }
3135 v399
3136 };
3137 let v403 = g.f32();
3138 let v404 = g.f32();
3139 let v405 = g.f32();
3140 Explosion {
3141 x: v393,
3142 y: v394,
3143 z: v395,
3144 radius: v396,
3145 affected_block_offsets: v397,
3146 player_motion_x: v403,
3147 player_motion_y: v404,
3148 player_motion_z: v405,
3149 }
3150 }
3151 }
3152}
3153impl From<Explosion> for ClientboundPlayPacket {
3154 fn from(p: Explosion) -> Self {
3155 Self::Explosion(p)
3156 }
3157}
3158
3159#[derive(Debug, Clone, PartialEq)]
3161pub struct UnloadChunk {
3162 pub chunk_x: i32,
3164 pub chunk_z: i32,
3166}
3167impl crate::packet::Packet for UnloadChunk {
3168 const ID: i32 = id::UNLOAD_CHUNK;
3169 const NAME: &'static str = "unload_chunk";
3170 const STATE: State = State::Play;
3171 const DIRECTION: Direction = Direction::Clientbound;
3172}
3173impl Decode for UnloadChunk {
3174 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3175 Ok({
3176 let v406 = r.read_i32()?;
3177 let v407 = r.read_i32()?;
3178 UnloadChunk {
3179 chunk_x: v406,
3180 chunk_z: v407,
3181 }
3182 })
3183 }
3184}
3185impl Encode for UnloadChunk {
3186 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3187 w.put_i32((*self).chunk_x);
3188 w.put_i32((*self).chunk_z);
3189 Ok(())
3190 }
3191}
3192#[cfg(feature = "testgen")]
3193impl Generate for UnloadChunk {
3194 fn generate(g: &mut Gen) -> Self {
3195 {
3196 let v408 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3197 let v409 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3198 UnloadChunk {
3199 chunk_x: v408,
3200 chunk_z: v409,
3201 }
3202 }
3203 }
3204}
3205impl From<UnloadChunk> for ClientboundPlayPacket {
3206 fn from(p: UnloadChunk) -> Self {
3207 Self::UnloadChunk(p)
3208 }
3209}
3210
3211#[derive(Debug, Clone, PartialEq)]
3213pub struct GameStateChange {
3214 pub reason: GameStateChangeReason,
3216 pub game_mode: f32,
3218}
3219impl crate::packet::Packet for GameStateChange {
3220 const ID: i32 = id::GAME_STATE_CHANGE;
3221 const NAME: &'static str = "game_state_change";
3222 const STATE: State = State::Play;
3223 const DIRECTION: Direction = Direction::Clientbound;
3224}
3225impl Decode for GameStateChange {
3226 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3227 Ok({
3228 let v410 = GameStateChangeReason(r.read_u8()?);
3229 let v411 = r.read_f32()?;
3230 GameStateChange {
3231 reason: v410,
3232 game_mode: v411,
3233 }
3234 })
3235 }
3236}
3237impl Encode for GameStateChange {
3238 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3239 w.put_u8((*self).reason.0);
3240 w.put_f32((*self).game_mode);
3241 Ok(())
3242 }
3243}
3244#[cfg(feature = "testgen")]
3245impl Generate for GameStateChange {
3246 fn generate(g: &mut Gen) -> Self {
3247 {
3248 let v412 =
3249 GameStateChangeReason(g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) as u8);
3250 let v413 = g.f32();
3251 GameStateChange {
3252 reason: v412,
3253 game_mode: v413,
3254 }
3255 }
3256 }
3257}
3258impl From<GameStateChange> for ClientboundPlayPacket {
3259 fn from(p: GameStateChange) -> Self {
3260 Self::GameStateChange(p)
3261 }
3262}
3263
3264#[derive(Debug, Clone, PartialEq)]
3266pub struct KeepAlive {
3267 pub keep_alive_id: i64,
3269}
3270impl crate::packet::Packet for KeepAlive {
3271 const ID: i32 = id::KEEP_ALIVE;
3272 const NAME: &'static str = "keep_alive";
3273 const STATE: State = State::Play;
3274 const DIRECTION: Direction = Direction::Clientbound;
3275}
3276impl Decode for KeepAlive {
3277 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3278 Ok({
3279 let v414 = r.read_i64()?;
3280 KeepAlive {
3281 keep_alive_id: v414,
3282 }
3283 })
3284 }
3285}
3286impl Encode for KeepAlive {
3287 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3288 w.put_i64((*self).keep_alive_id);
3289 Ok(())
3290 }
3291}
3292#[cfg(feature = "testgen")]
3293impl Generate for KeepAlive {
3294 fn generate(g: &mut Gen) -> Self {
3295 {
3296 let v415 = g.i64();
3297 KeepAlive {
3298 keep_alive_id: v415,
3299 }
3300 }
3301 }
3302}
3303impl From<KeepAlive> for ClientboundPlayPacket {
3304 fn from(p: KeepAlive) -> Self {
3305 Self::KeepAlive(p)
3306 }
3307}
3308
3309#[derive(Debug, Clone, PartialEq)]
3311pub struct MapChunk {
3312 pub x: i32,
3314 pub z: i32,
3316 pub ground_up: bool,
3318 pub bit_map: i32,
3320 pub chunk_data: Bytes,
3322 pub block_entities: Vec<RawNbt>,
3324}
3325impl crate::packet::Packet for MapChunk {
3326 const ID: i32 = id::MAP_CHUNK;
3327 const NAME: &'static str = "map_chunk";
3328 const STATE: State = State::Play;
3329 const DIRECTION: Direction = Direction::Clientbound;
3330}
3331impl Decode for MapChunk {
3332 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3333 Ok({
3334 let v416 = r.read_i32()?;
3335 let v417 = r.read_i32()?;
3336 let v418 = r.read_bool()?;
3337 let v419 = r.read_varint()?;
3338 let v420 = r.read_byte_array()?;
3339 let v421 = {
3340 let v422 = {
3341 let c = r.read_varint()?;
3342 r.check_count(i64::from(c), 1)?
3343 };
3344 let mut v423 = Vec::with_capacity(v422.min(crate::codec::PREALLOC_LIMIT));
3345 for _ in 0..v422 {
3346 v423.push(RawNbt::read(r)?);
3347 }
3348 v423
3349 };
3350 MapChunk {
3351 x: v416,
3352 z: v417,
3353 ground_up: v418,
3354 bit_map: v419,
3355 chunk_data: v420,
3356 block_entities: v421,
3357 }
3358 })
3359 }
3360}
3361impl Encode for MapChunk {
3362 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3363 w.put_i32((*self).x);
3364 w.put_i32((*self).z);
3365 w.put_bool((*self).ground_up);
3366 w.put_varint((*self).bit_map);
3367 w.put_byte_array(&(*self).chunk_data)?;
3368 w.put_len_varint((*self).block_entities.len())?;
3369 for v424 in (*self).block_entities.iter() {
3370 (*v424).write(w);
3371 }
3372 Ok(())
3373 }
3374}
3375#[cfg(feature = "testgen")]
3376impl Generate for MapChunk {
3377 fn generate(g: &mut Gen) -> Self {
3378 {
3379 let v425 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3380 let v426 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3381 let v427 = g.bool();
3382 let v428 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3383 let v429 = g.bytes();
3384 let v430 = {
3385 let v431 = g.count();
3386 let mut v432 = Vec::with_capacity(v431.min(crate::codec::PREALLOC_LIMIT));
3387 for _ in 0..v431 {
3388 v432.push(g.nbt());
3389 }
3390 v432
3391 };
3392 MapChunk {
3393 x: v425,
3394 z: v426,
3395 ground_up: v427,
3396 bit_map: v428,
3397 chunk_data: v429,
3398 block_entities: v430,
3399 }
3400 }
3401 }
3402}
3403impl From<MapChunk> for ClientboundPlayPacket {
3404 fn from(p: MapChunk) -> Self {
3405 Self::MapChunk(p)
3406 }
3407}
3408
3409#[derive(Debug, Clone, PartialEq)]
3411pub struct WorldEvent {
3412 pub effect_id: i32,
3414 pub location: BlockPos,
3416 pub data: i32,
3418 pub global: bool,
3420}
3421impl crate::packet::Packet for WorldEvent {
3422 const ID: i32 = id::WORLD_EVENT;
3423 const NAME: &'static str = "world_event";
3424 const STATE: State = State::Play;
3425 const DIRECTION: Direction = Direction::Clientbound;
3426}
3427impl Decode for WorldEvent {
3428 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3429 Ok({
3430 let v433 = r.read_i32()?;
3431 let v434 = BlockPos::read(r, PositionLayout::Xyz)?;
3432 let v435 = r.read_i32()?;
3433 let v436 = r.read_bool()?;
3434 WorldEvent {
3435 effect_id: v433,
3436 location: v434,
3437 data: v435,
3438 global: v436,
3439 }
3440 })
3441 }
3442}
3443impl Encode for WorldEvent {
3444 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3445 w.put_i32((*self).effect_id);
3446 (*self).location.write(w, PositionLayout::Xyz)?;
3447 w.put_i32((*self).data);
3448 w.put_bool((*self).global);
3449 Ok(())
3450 }
3451}
3452#[cfg(feature = "testgen")]
3453impl Generate for WorldEvent {
3454 fn generate(g: &mut Gen) -> Self {
3455 {
3456 let v437 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3457 let v438 = g.position();
3458 let v439 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3459 let v440 = g.bool();
3460 WorldEvent {
3461 effect_id: v437,
3462 location: v438,
3463 data: v439,
3464 global: v440,
3465 }
3466 }
3467 }
3468}
3469impl From<WorldEvent> for ClientboundPlayPacket {
3470 fn from(p: WorldEvent) -> Self {
3471 Self::WorldEvent(p)
3472 }
3473}
3474
3475#[derive(Debug, Clone, PartialEq)]
3477pub struct WorldParticles {
3478 pub particle_id: i32,
3480 pub long_distance: bool,
3482 pub x: f32,
3484 pub y: f32,
3486 pub z: f32,
3488 pub offset_x: f32,
3490 pub offset_y: f32,
3492 pub offset_z: f32,
3494 pub particle_data: f32,
3496 pub particles: i32,
3498 pub data: WorldParticlesData,
3500}
3501impl crate::packet::Packet for WorldParticles {
3502 const ID: i32 = id::WORLD_PARTICLES;
3503 const NAME: &'static str = "world_particles";
3504 const STATE: State = State::Play;
3505 const DIRECTION: Direction = Direction::Clientbound;
3506}
3507impl Decode for WorldParticles {
3508 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3509 Ok({
3510 let v441 = r.read_i32()?;
3511 let v442 = r.read_bool()?;
3512 let v443 = r.read_f32()?;
3513 let v444 = r.read_f32()?;
3514 let v445 = r.read_f32()?;
3515 let v446 = r.read_f32()?;
3516 let v447 = r.read_f32()?;
3517 let v448 = r.read_f32()?;
3518 let v449 = r.read_f32()?;
3519 let v450 = r.read_i32()?;
3520 let v451 = (if (v441 == 36) {
3521 WorldParticlesData::Case36({
3522 let v452 = 2;
3523 let mut v453 = Vec::with_capacity(v452.min(crate::codec::PREALLOC_LIMIT));
3524 for _ in 0..v452 {
3525 v453.push(r.read_varint()?);
3526 }
3527 v453
3528 })
3529 } else if (v441 == 37) {
3530 WorldParticlesData::Case37({
3531 let v454 = 1;
3532 let mut v455 = Vec::with_capacity(v454.min(crate::codec::PREALLOC_LIMIT));
3533 for _ in 0..v454 {
3534 v455.push(r.read_varint()?);
3535 }
3536 v455
3537 })
3538 } else if (v441 == 38) {
3539 WorldParticlesData::Case38({
3540 let v456 = 1;
3541 let mut v457 = Vec::with_capacity(v456.min(crate::codec::PREALLOC_LIMIT));
3542 for _ in 0..v456 {
3543 v457.push(r.read_varint()?);
3544 }
3545 v457
3546 })
3547 } else {
3548 WorldParticlesData::Other
3549 });
3550 WorldParticles {
3551 particle_id: v441,
3552 long_distance: v442,
3553 x: v443,
3554 y: v444,
3555 z: v445,
3556 offset_x: v446,
3557 offset_y: v447,
3558 offset_z: v448,
3559 particle_data: v449,
3560 particles: v450,
3561 data: v451,
3562 }
3563 })
3564 }
3565}
3566impl Encode for WorldParticles {
3567 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3568 w.put_i32((*self).particle_id);
3569 w.put_bool((*self).long_distance);
3570 w.put_f32((*self).x);
3571 w.put_f32((*self).y);
3572 w.put_f32((*self).z);
3573 w.put_f32((*self).offset_x);
3574 w.put_f32((*self).offset_y);
3575 w.put_f32((*self).offset_z);
3576 w.put_f32((*self).particle_data);
3577 w.put_i32((*self).particles);
3578 match &(*self).data {
3579 WorldParticlesData::Case36(v458) => {
3580 if !((*self).particle_id == 36) {
3581 return Err(EncodeError::SwitchMismatch(
3582 "play.clientbound.world_particles.data",
3583 ));
3584 }
3585 if (*v458).len() != 2 {
3586 return Err(EncodeError::CountMismatch {
3587 field: "play.clientbound.world_particles.data",
3588 expected: 2,
3589 actual: (*v458).len(),
3590 });
3591 }
3592 for v459 in (*v458).iter() {
3593 w.put_varint((*v459));
3594 }
3595 }
3596 WorldParticlesData::Case37(v460) => {
3597 if !((*self).particle_id == 37) {
3598 return Err(EncodeError::SwitchMismatch(
3599 "play.clientbound.world_particles.data",
3600 ));
3601 }
3602 if (*v460).len() != 1 {
3603 return Err(EncodeError::CountMismatch {
3604 field: "play.clientbound.world_particles.data",
3605 expected: 1,
3606 actual: (*v460).len(),
3607 });
3608 }
3609 for v461 in (*v460).iter() {
3610 w.put_varint((*v461));
3611 }
3612 }
3613 WorldParticlesData::Case38(v462) => {
3614 if !((*self).particle_id == 38) {
3615 return Err(EncodeError::SwitchMismatch(
3616 "play.clientbound.world_particles.data",
3617 ));
3618 }
3619 if (*v462).len() != 1 {
3620 return Err(EncodeError::CountMismatch {
3621 field: "play.clientbound.world_particles.data",
3622 expected: 1,
3623 actual: (*v462).len(),
3624 });
3625 }
3626 for v463 in (*v462).iter() {
3627 w.put_varint((*v463));
3628 }
3629 }
3630 WorldParticlesData::Other => {
3631 if !(!(((*self).particle_id == 36)
3632 || ((*self).particle_id == 37)
3633 || ((*self).particle_id == 38)))
3634 {
3635 return Err(EncodeError::SwitchMismatch(
3636 "play.clientbound.world_particles.data",
3637 ));
3638 }
3639 }
3640 }
3641 Ok(())
3642 }
3643}
3644#[cfg(feature = "testgen")]
3645impl Generate for WorldParticles {
3646 fn generate(g: &mut Gen) -> Self {
3647 {
3648 let v464 = (g.int_in(-2147483648, 2147483647, &[36, 37, 38]) as i32);
3649 let v465 = g.bool();
3650 let v466 = g.f32();
3651 let v467 = g.f32();
3652 let v468 = g.f32();
3653 let v469 = g.f32();
3654 let v470 = g.f32();
3655 let v471 = g.f32();
3656 let v472 = g.f32();
3657 let v473 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3658 let v474 = (if (v464 == 36) {
3659 WorldParticlesData::Case36({
3660 let v475 = 2;
3661 let mut v476 = Vec::with_capacity(v475.min(crate::codec::PREALLOC_LIMIT));
3662 for _ in 0..v475 {
3663 v476.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3664 }
3665 v476
3666 })
3667 } else if (v464 == 37) {
3668 WorldParticlesData::Case37({
3669 let v477 = 1;
3670 let mut v478 = Vec::with_capacity(v477.min(crate::codec::PREALLOC_LIMIT));
3671 for _ in 0..v477 {
3672 v478.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3673 }
3674 v478
3675 })
3676 } else if (v464 == 38) {
3677 WorldParticlesData::Case38({
3678 let v479 = 1;
3679 let mut v480 = Vec::with_capacity(v479.min(crate::codec::PREALLOC_LIMIT));
3680 for _ in 0..v479 {
3681 v480.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3682 }
3683 v480
3684 })
3685 } else {
3686 WorldParticlesData::Other
3687 });
3688 WorldParticles {
3689 particle_id: v464,
3690 long_distance: v465,
3691 x: v466,
3692 y: v467,
3693 z: v468,
3694 offset_x: v469,
3695 offset_y: v470,
3696 offset_z: v471,
3697 particle_data: v472,
3698 particles: v473,
3699 data: v474,
3700 }
3701 }
3702 }
3703}
3704impl From<WorldParticles> for ClientboundPlayPacket {
3705 fn from(p: WorldParticles) -> Self {
3706 Self::WorldParticles(p)
3707 }
3708}
3709
3710#[derive(Debug, Clone, PartialEq)]
3712pub struct Login {
3713 pub entity_id: i32,
3715 pub game_mode: u8,
3717 pub dimension: i32,
3719 pub difficulty: u8,
3721 pub max_players: u8,
3723 pub level_type: ByteString,
3725 pub reduced_debug_info: bool,
3727}
3728impl crate::packet::Packet for Login {
3729 const ID: i32 = id::LOGIN;
3730 const NAME: &'static str = "login";
3731 const STATE: State = State::Play;
3732 const DIRECTION: Direction = Direction::Clientbound;
3733}
3734impl Decode for Login {
3735 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3736 Ok({
3737 let v481 = r.read_i32()?;
3738 let v482 = r.read_u8()?;
3739 let v483 = r.read_i32()?;
3740 let v484 = r.read_u8()?;
3741 let v485 = r.read_u8()?;
3742 let v486 = r.read_string()?;
3743 let v487 = r.read_bool()?;
3744 Login {
3745 entity_id: v481,
3746 game_mode: v482,
3747 dimension: v483,
3748 difficulty: v484,
3749 max_players: v485,
3750 level_type: v486,
3751 reduced_debug_info: v487,
3752 }
3753 })
3754 }
3755}
3756impl Encode for Login {
3757 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3758 w.put_i32((*self).entity_id);
3759 w.put_u8((*self).game_mode);
3760 w.put_i32((*self).dimension);
3761 w.put_u8((*self).difficulty);
3762 w.put_u8((*self).max_players);
3763 w.put_string(&(*self).level_type)?;
3764 w.put_bool((*self).reduced_debug_info);
3765 Ok(())
3766 }
3767}
3768#[cfg(feature = "testgen")]
3769impl Generate for Login {
3770 fn generate(g: &mut Gen) -> Self {
3771 {
3772 let v488 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3773 let v489 = (g.int_in(0, 255, &[]) as u8);
3774 let v490 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3775 let v491 = (g.int_in(0, 255, &[]) as u8);
3776 let v492 = (g.int_in(0, 255, &[]) as u8);
3777 let v493 = g.string();
3778 let v494 = g.bool();
3779 Login {
3780 entity_id: v488,
3781 game_mode: v489,
3782 dimension: v490,
3783 difficulty: v491,
3784 max_players: v492,
3785 level_type: v493,
3786 reduced_debug_info: v494,
3787 }
3788 }
3789 }
3790}
3791impl From<Login> for ClientboundPlayPacket {
3792 fn from(p: Login) -> Self {
3793 Self::Login(p)
3794 }
3795}
3796
3797#[derive(Debug, Clone, PartialEq)]
3799pub struct Map {
3800 pub item_damage: i32,
3802 pub scale: i8,
3804 pub tracking_position: bool,
3806 pub icons: Vec<MapIcons>,
3808 pub columns: i8,
3810 pub rows: Option<i8>,
3812 pub x: Option<i8>,
3814 pub y: Option<i8>,
3816 pub data: Option<Bytes>,
3818}
3819impl crate::packet::Packet for Map {
3820 const ID: i32 = id::MAP;
3821 const NAME: &'static str = "map";
3822 const STATE: State = State::Play;
3823 const DIRECTION: Direction = Direction::Clientbound;
3824}
3825impl Decode for Map {
3826 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3827 Ok({
3828 let v495 = r.read_varint()?;
3829 let v496 = r.read_i8()?;
3830 let v497 = r.read_bool()?;
3831 let v498 = {
3832 let v499 = {
3833 let c = r.read_varint()?;
3834 r.check_count(i64::from(c), 3)?
3835 };
3836 let mut v500 = Vec::with_capacity(v499.min(crate::codec::PREALLOC_LIMIT));
3837 for _ in 0..v499 {
3838 v500.push({
3839 let v501 = r.read_i8()?;
3840 let v502 = r.read_i8()?;
3841 let v503 = r.read_i8()?;
3842 MapIcons {
3843 direction_and_type: v501,
3844 x: v502,
3845 z: v503,
3846 }
3847 });
3848 }
3849 v500
3850 };
3851 let v504 = r.read_i8()?;
3852 let v505 = if !(v504 == 0) {
3853 Some(r.read_i8()?)
3854 } else {
3855 None
3856 };
3857 let v506 = if !(v504 == 0) {
3858 Some(r.read_i8()?)
3859 } else {
3860 None
3861 };
3862 let v507 = if !(v504 == 0) {
3863 Some(r.read_i8()?)
3864 } else {
3865 None
3866 };
3867 let v508 = if !(v504 == 0) {
3868 Some(r.read_byte_array()?)
3869 } else {
3870 None
3871 };
3872 Map {
3873 item_damage: v495,
3874 scale: v496,
3875 tracking_position: v497,
3876 icons: v498,
3877 columns: v504,
3878 rows: v505,
3879 x: v506,
3880 y: v507,
3881 data: v508,
3882 }
3883 })
3884 }
3885}
3886impl Encode for Map {
3887 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3888 w.put_varint((*self).item_damage);
3889 w.put_i8((*self).scale);
3890 w.put_bool((*self).tracking_position);
3891 w.put_len_varint((*self).icons.len())?;
3892 for v509 in (*self).icons.iter() {
3893 w.put_i8((*v509).direction_and_type);
3894 w.put_i8((*v509).x);
3895 w.put_i8((*v509).z);
3896 }
3897 w.put_i8((*self).columns);
3898 match (&(*self).rows, !((*self).columns == 0)) {
3899 (Some(v510), true) => {
3900 w.put_i8((*v510));
3901 }
3902 (None, false) => {}
3903 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
3904 }
3905 match (&(*self).x, !((*self).columns == 0)) {
3906 (Some(v511), true) => {
3907 w.put_i8((*v511));
3908 }
3909 (None, false) => {}
3910 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
3911 }
3912 match (&(*self).y, !((*self).columns == 0)) {
3913 (Some(v512), true) => {
3914 w.put_i8((*v512));
3915 }
3916 (None, false) => {}
3917 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
3918 }
3919 match (&(*self).data, !((*self).columns == 0)) {
3920 (Some(v513), true) => {
3921 w.put_byte_array(&(*v513))?;
3922 }
3923 (None, false) => {}
3924 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
3925 }
3926 Ok(())
3927 }
3928}
3929#[cfg(feature = "testgen")]
3930impl Generate for Map {
3931 fn generate(g: &mut Gen) -> Self {
3932 {
3933 let v514 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3934 let v515 = (g.int_in(-128, 127, &[]) as i8);
3935 let v516 = g.bool();
3936 let v517 = {
3937 let v518 = g.count();
3938 let mut v519 = Vec::with_capacity(v518.min(crate::codec::PREALLOC_LIMIT));
3939 for _ in 0..v518 {
3940 v519.push({
3941 let v520 = (g.int_in(-128, 127, &[]) as i8);
3942 let v521 = (g.int_in(-128, 127, &[]) as i8);
3943 let v522 = (g.int_in(-128, 127, &[]) as i8);
3944 MapIcons {
3945 direction_and_type: v520,
3946 x: v521,
3947 z: v522,
3948 }
3949 });
3950 }
3951 v519
3952 };
3953 let v523 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
3954 let v524 = if !(v523 == 0) {
3955 Some((g.int_in(-128, 127, &[]) as i8))
3956 } else {
3957 None
3958 };
3959 let v525 = if !(v523 == 0) {
3960 Some((g.int_in(-128, 127, &[]) as i8))
3961 } else {
3962 None
3963 };
3964 let v526 = if !(v523 == 0) {
3965 Some((g.int_in(-128, 127, &[]) as i8))
3966 } else {
3967 None
3968 };
3969 let v527 = if !(v523 == 0) { Some(g.bytes()) } else { None };
3970 Map {
3971 item_damage: v514,
3972 scale: v515,
3973 tracking_position: v516,
3974 icons: v517,
3975 columns: v523,
3976 rows: v524,
3977 x: v525,
3978 y: v526,
3979 data: v527,
3980 }
3981 }
3982 }
3983}
3984impl From<Map> for ClientboundPlayPacket {
3985 fn from(p: Map) -> Self {
3986 Self::Map(p)
3987 }
3988}
3989
3990#[derive(Debug, Clone, PartialEq)]
3992pub struct Entity {
3993 pub entity_id: i32,
3995}
3996impl crate::packet::Packet for Entity {
3997 const ID: i32 = id::ENTITY;
3998 const NAME: &'static str = "entity";
3999 const STATE: State = State::Play;
4000 const DIRECTION: Direction = Direction::Clientbound;
4001}
4002impl Decode for Entity {
4003 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4004 Ok({
4005 let v528 = r.read_varint()?;
4006 Entity { entity_id: v528 }
4007 })
4008 }
4009}
4010impl Encode for Entity {
4011 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4012 w.put_varint((*self).entity_id);
4013 Ok(())
4014 }
4015}
4016#[cfg(feature = "testgen")]
4017impl Generate for Entity {
4018 fn generate(g: &mut Gen) -> Self {
4019 {
4020 let v529 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4021 Entity { entity_id: v529 }
4022 }
4023 }
4024}
4025impl From<Entity> for ClientboundPlayPacket {
4026 fn from(p: Entity) -> Self {
4027 Self::Entity(p)
4028 }
4029}
4030
4031#[derive(Debug, Clone, PartialEq)]
4033pub struct RelEntityMove {
4034 pub entity_id: i32,
4036 pub d_x: i16,
4038 pub d_y: i16,
4040 pub d_z: i16,
4042 pub on_ground: bool,
4044}
4045impl crate::packet::Packet for RelEntityMove {
4046 const ID: i32 = id::REL_ENTITY_MOVE;
4047 const NAME: &'static str = "rel_entity_move";
4048 const STATE: State = State::Play;
4049 const DIRECTION: Direction = Direction::Clientbound;
4050}
4051impl Decode for RelEntityMove {
4052 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4053 Ok({
4054 let v530 = r.read_varint()?;
4055 let v531 = r.read_i16()?;
4056 let v532 = r.read_i16()?;
4057 let v533 = r.read_i16()?;
4058 let v534 = r.read_bool()?;
4059 RelEntityMove {
4060 entity_id: v530,
4061 d_x: v531,
4062 d_y: v532,
4063 d_z: v533,
4064 on_ground: v534,
4065 }
4066 })
4067 }
4068}
4069impl Encode for RelEntityMove {
4070 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4071 w.put_varint((*self).entity_id);
4072 w.put_i16((*self).d_x);
4073 w.put_i16((*self).d_y);
4074 w.put_i16((*self).d_z);
4075 w.put_bool((*self).on_ground);
4076 Ok(())
4077 }
4078}
4079#[cfg(feature = "testgen")]
4080impl Generate for RelEntityMove {
4081 fn generate(g: &mut Gen) -> Self {
4082 {
4083 let v535 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4084 let v536 = (g.int_in(-32768, 32767, &[]) as i16);
4085 let v537 = (g.int_in(-32768, 32767, &[]) as i16);
4086 let v538 = (g.int_in(-32768, 32767, &[]) as i16);
4087 let v539 = g.bool();
4088 RelEntityMove {
4089 entity_id: v535,
4090 d_x: v536,
4091 d_y: v537,
4092 d_z: v538,
4093 on_ground: v539,
4094 }
4095 }
4096 }
4097}
4098impl From<RelEntityMove> for ClientboundPlayPacket {
4099 fn from(p: RelEntityMove) -> Self {
4100 Self::RelEntityMove(p)
4101 }
4102}
4103
4104#[derive(Debug, Clone, PartialEq)]
4106pub struct EntityMoveLook {
4107 pub entity_id: i32,
4109 pub d_x: i16,
4111 pub d_y: i16,
4113 pub d_z: i16,
4115 pub yaw: i8,
4117 pub pitch: i8,
4119 pub on_ground: bool,
4121}
4122impl crate::packet::Packet for EntityMoveLook {
4123 const ID: i32 = id::ENTITY_MOVE_LOOK;
4124 const NAME: &'static str = "entity_move_look";
4125 const STATE: State = State::Play;
4126 const DIRECTION: Direction = Direction::Clientbound;
4127}
4128impl Decode for EntityMoveLook {
4129 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4130 Ok({
4131 let v540 = r.read_varint()?;
4132 let v541 = r.read_i16()?;
4133 let v542 = r.read_i16()?;
4134 let v543 = r.read_i16()?;
4135 let v544 = r.read_i8()?;
4136 let v545 = r.read_i8()?;
4137 let v546 = r.read_bool()?;
4138 EntityMoveLook {
4139 entity_id: v540,
4140 d_x: v541,
4141 d_y: v542,
4142 d_z: v543,
4143 yaw: v544,
4144 pitch: v545,
4145 on_ground: v546,
4146 }
4147 })
4148 }
4149}
4150impl Encode for EntityMoveLook {
4151 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4152 w.put_varint((*self).entity_id);
4153 w.put_i16((*self).d_x);
4154 w.put_i16((*self).d_y);
4155 w.put_i16((*self).d_z);
4156 w.put_i8((*self).yaw);
4157 w.put_i8((*self).pitch);
4158 w.put_bool((*self).on_ground);
4159 Ok(())
4160 }
4161}
4162#[cfg(feature = "testgen")]
4163impl Generate for EntityMoveLook {
4164 fn generate(g: &mut Gen) -> Self {
4165 {
4166 let v547 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4167 let v548 = (g.int_in(-32768, 32767, &[]) as i16);
4168 let v549 = (g.int_in(-32768, 32767, &[]) as i16);
4169 let v550 = (g.int_in(-32768, 32767, &[]) as i16);
4170 let v551 = (g.int_in(-128, 127, &[]) as i8);
4171 let v552 = (g.int_in(-128, 127, &[]) as i8);
4172 let v553 = g.bool();
4173 EntityMoveLook {
4174 entity_id: v547,
4175 d_x: v548,
4176 d_y: v549,
4177 d_z: v550,
4178 yaw: v551,
4179 pitch: v552,
4180 on_ground: v553,
4181 }
4182 }
4183 }
4184}
4185impl From<EntityMoveLook> for ClientboundPlayPacket {
4186 fn from(p: EntityMoveLook) -> Self {
4187 Self::EntityMoveLook(p)
4188 }
4189}
4190
4191#[derive(Debug, Clone, PartialEq)]
4193pub struct EntityLook {
4194 pub entity_id: i32,
4196 pub yaw: i8,
4198 pub pitch: i8,
4200 pub on_ground: bool,
4202}
4203impl crate::packet::Packet for EntityLook {
4204 const ID: i32 = id::ENTITY_LOOK;
4205 const NAME: &'static str = "entity_look";
4206 const STATE: State = State::Play;
4207 const DIRECTION: Direction = Direction::Clientbound;
4208}
4209impl Decode for EntityLook {
4210 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4211 Ok({
4212 let v554 = r.read_varint()?;
4213 let v555 = r.read_i8()?;
4214 let v556 = r.read_i8()?;
4215 let v557 = r.read_bool()?;
4216 EntityLook {
4217 entity_id: v554,
4218 yaw: v555,
4219 pitch: v556,
4220 on_ground: v557,
4221 }
4222 })
4223 }
4224}
4225impl Encode for EntityLook {
4226 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4227 w.put_varint((*self).entity_id);
4228 w.put_i8((*self).yaw);
4229 w.put_i8((*self).pitch);
4230 w.put_bool((*self).on_ground);
4231 Ok(())
4232 }
4233}
4234#[cfg(feature = "testgen")]
4235impl Generate for EntityLook {
4236 fn generate(g: &mut Gen) -> Self {
4237 {
4238 let v558 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4239 let v559 = (g.int_in(-128, 127, &[]) as i8);
4240 let v560 = (g.int_in(-128, 127, &[]) as i8);
4241 let v561 = g.bool();
4242 EntityLook {
4243 entity_id: v558,
4244 yaw: v559,
4245 pitch: v560,
4246 on_ground: v561,
4247 }
4248 }
4249 }
4250}
4251impl From<EntityLook> for ClientboundPlayPacket {
4252 fn from(p: EntityLook) -> Self {
4253 Self::EntityLook(p)
4254 }
4255}
4256
4257#[derive(Debug, Clone, PartialEq)]
4259pub struct VehicleMove {
4260 pub x: f64,
4262 pub y: f64,
4264 pub z: f64,
4266 pub yaw: f32,
4268 pub pitch: f32,
4270}
4271impl crate::packet::Packet for VehicleMove {
4272 const ID: i32 = id::VEHICLE_MOVE;
4273 const NAME: &'static str = "vehicle_move";
4274 const STATE: State = State::Play;
4275 const DIRECTION: Direction = Direction::Clientbound;
4276}
4277impl Decode for VehicleMove {
4278 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4279 Ok({
4280 let v562 = r.read_f64()?;
4281 let v563 = r.read_f64()?;
4282 let v564 = r.read_f64()?;
4283 let v565 = r.read_f32()?;
4284 let v566 = r.read_f32()?;
4285 VehicleMove {
4286 x: v562,
4287 y: v563,
4288 z: v564,
4289 yaw: v565,
4290 pitch: v566,
4291 }
4292 })
4293 }
4294}
4295impl Encode for VehicleMove {
4296 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4297 w.put_f64((*self).x);
4298 w.put_f64((*self).y);
4299 w.put_f64((*self).z);
4300 w.put_f32((*self).yaw);
4301 w.put_f32((*self).pitch);
4302 Ok(())
4303 }
4304}
4305#[cfg(feature = "testgen")]
4306impl Generate for VehicleMove {
4307 fn generate(g: &mut Gen) -> Self {
4308 {
4309 let v567 = g.f64();
4310 let v568 = g.f64();
4311 let v569 = g.f64();
4312 let v570 = g.f32();
4313 let v571 = g.f32();
4314 VehicleMove {
4315 x: v567,
4316 y: v568,
4317 z: v569,
4318 yaw: v570,
4319 pitch: v571,
4320 }
4321 }
4322 }
4323}
4324impl From<VehicleMove> for ClientboundPlayPacket {
4325 fn from(p: VehicleMove) -> Self {
4326 Self::VehicleMove(p)
4327 }
4328}
4329
4330#[derive(Debug, Clone, PartialEq)]
4332pub struct OpenSignEntity {
4333 pub location: BlockPos,
4335}
4336impl crate::packet::Packet for OpenSignEntity {
4337 const ID: i32 = id::OPEN_SIGN_ENTITY;
4338 const NAME: &'static str = "open_sign_entity";
4339 const STATE: State = State::Play;
4340 const DIRECTION: Direction = Direction::Clientbound;
4341}
4342impl Decode for OpenSignEntity {
4343 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4344 Ok({
4345 let v572 = BlockPos::read(r, PositionLayout::Xyz)?;
4346 OpenSignEntity { location: v572 }
4347 })
4348 }
4349}
4350impl Encode for OpenSignEntity {
4351 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4352 (*self).location.write(w, PositionLayout::Xyz)?;
4353 Ok(())
4354 }
4355}
4356#[cfg(feature = "testgen")]
4357impl Generate for OpenSignEntity {
4358 fn generate(g: &mut Gen) -> Self {
4359 {
4360 let v573 = g.position();
4361 OpenSignEntity { location: v573 }
4362 }
4363 }
4364}
4365impl From<OpenSignEntity> for ClientboundPlayPacket {
4366 fn from(p: OpenSignEntity) -> Self {
4367 Self::OpenSignEntity(p)
4368 }
4369}
4370
4371#[derive(Debug, Clone, PartialEq)]
4373pub struct CraftRecipeResponse {
4374 pub window_id: i8,
4376 pub recipe: i32,
4378}
4379impl crate::packet::Packet for CraftRecipeResponse {
4380 const ID: i32 = id::CRAFT_RECIPE_RESPONSE;
4381 const NAME: &'static str = "craft_recipe_response";
4382 const STATE: State = State::Play;
4383 const DIRECTION: Direction = Direction::Clientbound;
4384}
4385impl Decode for CraftRecipeResponse {
4386 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4387 Ok({
4388 let v574 = r.read_i8()?;
4389 let v575 = r.read_varint()?;
4390 CraftRecipeResponse {
4391 window_id: v574,
4392 recipe: v575,
4393 }
4394 })
4395 }
4396}
4397impl Encode for CraftRecipeResponse {
4398 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4399 w.put_i8((*self).window_id);
4400 w.put_varint((*self).recipe);
4401 Ok(())
4402 }
4403}
4404#[cfg(feature = "testgen")]
4405impl Generate for CraftRecipeResponse {
4406 fn generate(g: &mut Gen) -> Self {
4407 {
4408 let v576 = (g.int_in(-128, 127, &[]) as i8);
4409 let v577 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4410 CraftRecipeResponse {
4411 window_id: v576,
4412 recipe: v577,
4413 }
4414 }
4415 }
4416}
4417impl From<CraftRecipeResponse> for ClientboundPlayPacket {
4418 fn from(p: CraftRecipeResponse) -> Self {
4419 Self::CraftRecipeResponse(p)
4420 }
4421}
4422
4423#[derive(Debug, Clone, PartialEq)]
4425pub struct Abilities {
4426 pub flags: i8,
4428 pub flying_speed: f32,
4430 pub walking_speed: f32,
4432}
4433impl crate::packet::Packet for Abilities {
4434 const ID: i32 = id::ABILITIES;
4435 const NAME: &'static str = "abilities";
4436 const STATE: State = State::Play;
4437 const DIRECTION: Direction = Direction::Clientbound;
4438}
4439impl Decode for Abilities {
4440 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4441 Ok({
4442 let v578 = r.read_i8()?;
4443 let v579 = r.read_f32()?;
4444 let v580 = r.read_f32()?;
4445 Abilities {
4446 flags: v578,
4447 flying_speed: v579,
4448 walking_speed: v580,
4449 }
4450 })
4451 }
4452}
4453impl Encode for Abilities {
4454 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4455 w.put_i8((*self).flags);
4456 w.put_f32((*self).flying_speed);
4457 w.put_f32((*self).walking_speed);
4458 Ok(())
4459 }
4460}
4461#[cfg(feature = "testgen")]
4462impl Generate for Abilities {
4463 fn generate(g: &mut Gen) -> Self {
4464 {
4465 let v581 = (g.int_in(-128, 127, &[]) as i8);
4466 let v582 = g.f32();
4467 let v583 = g.f32();
4468 Abilities {
4469 flags: v581,
4470 flying_speed: v582,
4471 walking_speed: v583,
4472 }
4473 }
4474 }
4475}
4476impl From<Abilities> for ClientboundPlayPacket {
4477 fn from(p: Abilities) -> Self {
4478 Self::Abilities(p)
4479 }
4480}
4481
4482#[derive(Debug, Clone, PartialEq)]
4484pub struct CombatEvent {
4485 pub event: i32,
4487 pub duration: Option<i32>,
4489 pub player_id: Option<i32>,
4491 pub entity_id: Option<i32>,
4493 pub message: Option<ByteString>,
4495}
4496impl crate::packet::Packet for CombatEvent {
4497 const ID: i32 = id::COMBAT_EVENT;
4498 const NAME: &'static str = "combat_event";
4499 const STATE: State = State::Play;
4500 const DIRECTION: Direction = Direction::Clientbound;
4501}
4502impl Decode for CombatEvent {
4503 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4504 Ok({
4505 let v584 = r.read_varint()?;
4506 let v585 = if (v584 == 1) {
4507 Some(r.read_varint()?)
4508 } else {
4509 None
4510 };
4511 let v586 = if (v584 == 2) {
4512 Some(r.read_varint()?)
4513 } else {
4514 None
4515 };
4516 let v587 = if (v584 == 1) || (v584 == 2) {
4517 Some(r.read_i32()?)
4518 } else {
4519 None
4520 };
4521 let v588 = if (v584 == 2) {
4522 Some(r.read_string()?)
4523 } else {
4524 None
4525 };
4526 CombatEvent {
4527 event: v584,
4528 duration: v585,
4529 player_id: v586,
4530 entity_id: v587,
4531 message: v588,
4532 }
4533 })
4534 }
4535}
4536impl Encode for CombatEvent {
4537 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4538 w.put_varint((*self).event);
4539 match (&(*self).duration, ((*self).event == 1)) {
4540 (Some(v589), true) => {
4541 w.put_varint((*v589));
4542 }
4543 (None, false) => {}
4544 _ => {
4545 return Err(EncodeError::SwitchMismatch(
4546 "play.clientbound.combat_event.duration",
4547 ));
4548 }
4549 }
4550 match (&(*self).player_id, ((*self).event == 2)) {
4551 (Some(v590), true) => {
4552 w.put_varint((*v590));
4553 }
4554 (None, false) => {}
4555 _ => {
4556 return Err(EncodeError::SwitchMismatch(
4557 "play.clientbound.combat_event.playerId",
4558 ));
4559 }
4560 }
4561 match (
4562 &(*self).entity_id,
4563 ((*self).event == 1) || ((*self).event == 2),
4564 ) {
4565 (Some(v591), true) => {
4566 w.put_i32((*v591));
4567 }
4568 (None, false) => {}
4569 _ => {
4570 return Err(EncodeError::SwitchMismatch(
4571 "play.clientbound.combat_event.entityId",
4572 ));
4573 }
4574 }
4575 match (&(*self).message, ((*self).event == 2)) {
4576 (Some(v592), true) => {
4577 w.put_string(&(*v592))?;
4578 }
4579 (None, false) => {}
4580 _ => {
4581 return Err(EncodeError::SwitchMismatch(
4582 "play.clientbound.combat_event.message",
4583 ));
4584 }
4585 }
4586 Ok(())
4587 }
4588}
4589#[cfg(feature = "testgen")]
4590impl Generate for CombatEvent {
4591 fn generate(g: &mut Gen) -> Self {
4592 {
4593 let v593 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
4594 let v594 = if (v593 == 1) {
4595 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4596 } else {
4597 None
4598 };
4599 let v595 = if (v593 == 2) {
4600 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4601 } else {
4602 None
4603 };
4604 let v596 = if (v593 == 1) || (v593 == 2) {
4605 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4606 } else {
4607 None
4608 };
4609 let v597 = if (v593 == 2) { Some(g.string()) } else { None };
4610 CombatEvent {
4611 event: v593,
4612 duration: v594,
4613 player_id: v595,
4614 entity_id: v596,
4615 message: v597,
4616 }
4617 }
4618 }
4619}
4620impl From<CombatEvent> for ClientboundPlayPacket {
4621 fn from(p: CombatEvent) -> Self {
4622 Self::CombatEvent(p)
4623 }
4624}
4625
4626#[derive(Debug, Clone, PartialEq)]
4628pub struct PlayerInfo {
4629 pub action: PlayerInfoAction,
4631 pub data: Vec<PlayerInfoData>,
4633}
4634impl crate::packet::Packet for PlayerInfo {
4635 const ID: i32 = id::PLAYER_INFO;
4636 const NAME: &'static str = "player_info";
4637 const STATE: State = State::Play;
4638 const DIRECTION: Direction = Direction::Clientbound;
4639}
4640impl Decode for PlayerInfo {
4641 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4642 Ok({
4643 let v598 = PlayerInfoAction(r.read_varint()?);
4644 let v599 = {
4645 let v600 = {
4646 let c = r.read_varint()?;
4647 r.check_count(i64::from(c), 16)?
4648 };
4649 let mut v601 = Vec::with_capacity(v600.min(crate::codec::PREALLOC_LIMIT));
4650 for _ in 0..v600 {
4651 v601.push({
4652 let v602 = r.read_uuid()?;
4653 let v603 = (if (v598.0 == 0) {
4654 PlayerInfoDataBody::AddPlayer({
4655 let v604 = r.read_string()?;
4656 let v605 = {
4657 let v606 = {
4658 let c = r.read_varint()?;
4659 r.check_count(i64::from(c), 3)?
4660 };
4661 let mut v607 =
4662 Vec::with_capacity(v606.min(crate::codec::PREALLOC_LIMIT));
4663 for _ in 0..v606 {
4664 v607.push({
4665 let v608 = r.read_string()?;
4666 let v609 = r.read_string()?;
4667 let v610 = if r.read_bool()? {
4668 Some(r.read_string()?)
4669 } else {
4670 None
4671 };
4672 PlayerInfoDataBodyAddPlayerProperties {
4673 name: v608,
4674 value: v609,
4675 signature: v610,
4676 }
4677 });
4678 }
4679 v607
4680 };
4681 let v611 = r.read_varint()?;
4682 let v612 = r.read_varint()?;
4683 let v613 = if r.read_bool()? {
4684 Some(r.read_string()?)
4685 } else {
4686 None
4687 };
4688 PlayerInfoDataBodyAddPlayer {
4689 name: v604,
4690 properties: v605,
4691 gamemode: v611,
4692 ping: v612,
4693 display_name: v613,
4694 }
4695 })
4696 } else if (v598.0 == 1) {
4697 PlayerInfoDataBody::UpdateGameMode({
4698 let v614 = r.read_varint()?;
4699 PlayerInfoDataBodyUpdateGameMode { gamemode: v614 }
4700 })
4701 } else if (v598.0 == 2) {
4702 PlayerInfoDataBody::UpdateLatency({
4703 let v615 = r.read_varint()?;
4704 PlayerInfoDataBodyUpdateLatency { ping: v615 }
4705 })
4706 } else if (v598.0 == 3) {
4707 PlayerInfoDataBody::UpdateDisplayName({
4708 let v616 = if r.read_bool()? {
4709 Some(r.read_string()?)
4710 } else {
4711 None
4712 };
4713 PlayerInfoDataBodyUpdateDisplayName { display_name: v616 }
4714 })
4715 } else if (v598.0 == 4) {
4716 PlayerInfoDataBody::RemovePlayer
4717 } else {
4718 PlayerInfoDataBody::Other
4719 });
4720 PlayerInfoData {
4721 uuid: v602,
4722 body: v603,
4723 }
4724 });
4725 }
4726 v601
4727 };
4728 PlayerInfo {
4729 action: v598,
4730 data: v599,
4731 }
4732 })
4733 }
4734}
4735impl Encode for PlayerInfo {
4736 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4737 w.put_varint((*self).action.0);
4738 w.put_len_varint((*self).data.len())?;
4739 for v617 in (*self).data.iter() {
4740 w.put_uuid(&(*v617).uuid);
4741 match &(*v617).body {
4742 PlayerInfoDataBody::AddPlayer(v618) => {
4743 if !((*self).action.0 == 0) {
4744 return Err(EncodeError::SwitchMismatch(
4745 "play.clientbound.player_info.data.body",
4746 ));
4747 }
4748 w.put_string(&(*v618).name)?;
4749 w.put_len_varint((*v618).properties.len())?;
4750 for v619 in (*v618).properties.iter() {
4751 w.put_string(&(*v619).name)?;
4752 w.put_string(&(*v619).value)?;
4753 match &(*v619).signature {
4754 Some(v620) => {
4755 w.put_u8(1);
4756 w.put_string(&(*v620))?;
4757 }
4758 None => w.put_u8(0),
4759 }
4760 }
4761 w.put_varint((*v618).gamemode);
4762 w.put_varint((*v618).ping);
4763 match &(*v618).display_name {
4764 Some(v621) => {
4765 w.put_u8(1);
4766 w.put_string(&(*v621))?;
4767 }
4768 None => w.put_u8(0),
4769 }
4770 }
4771 PlayerInfoDataBody::UpdateGameMode(v622) => {
4772 if !((*self).action.0 == 1) {
4773 return Err(EncodeError::SwitchMismatch(
4774 "play.clientbound.player_info.data.body",
4775 ));
4776 }
4777 w.put_varint((*v622).gamemode);
4778 }
4779 PlayerInfoDataBody::UpdateLatency(v623) => {
4780 if !((*self).action.0 == 2) {
4781 return Err(EncodeError::SwitchMismatch(
4782 "play.clientbound.player_info.data.body",
4783 ));
4784 }
4785 w.put_varint((*v623).ping);
4786 }
4787 PlayerInfoDataBody::UpdateDisplayName(v624) => {
4788 if !((*self).action.0 == 3) {
4789 return Err(EncodeError::SwitchMismatch(
4790 "play.clientbound.player_info.data.body",
4791 ));
4792 }
4793 match &(*v624).display_name {
4794 Some(v625) => {
4795 w.put_u8(1);
4796 w.put_string(&(*v625))?;
4797 }
4798 None => w.put_u8(0),
4799 }
4800 }
4801 PlayerInfoDataBody::RemovePlayer => {
4802 if !((*self).action.0 == 4) {
4803 return Err(EncodeError::SwitchMismatch(
4804 "play.clientbound.player_info.data.body",
4805 ));
4806 }
4807 }
4808 PlayerInfoDataBody::Other => {
4809 if !(!(((*self).action.0 == 0)
4810 || ((*self).action.0 == 1)
4811 || ((*self).action.0 == 2)
4812 || ((*self).action.0 == 3)
4813 || ((*self).action.0 == 4)))
4814 {
4815 return Err(EncodeError::SwitchMismatch(
4816 "play.clientbound.player_info.data.body",
4817 ));
4818 }
4819 }
4820 }
4821 }
4822 Ok(())
4823 }
4824}
4825#[cfg(feature = "testgen")]
4826impl Generate for PlayerInfo {
4827 fn generate(g: &mut Gen) -> Self {
4828 {
4829 let v626 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
4830 let v627 = {
4831 let v628 = g.count();
4832 let mut v629 = Vec::with_capacity(v628.min(crate::codec::PREALLOC_LIMIT));
4833 for _ in 0..v628 {
4834 v629.push({
4835 let v630 = g.uuid();
4836 let v631 = (if (v626.0 == 0) {
4837 PlayerInfoDataBody::AddPlayer({
4838 let v632 = g.string();
4839 let v633 = {
4840 let v634 = g.count();
4841 let mut v635 =
4842 Vec::with_capacity(v634.min(crate::codec::PREALLOC_LIMIT));
4843 for _ in 0..v634 {
4844 v635.push({
4845 let v636 = g.string();
4846 let v637 = g.string();
4847 let v638 =
4848 if g.bool() { Some(g.string()) } else { None };
4849 PlayerInfoDataBodyAddPlayerProperties {
4850 name: v636,
4851 value: v637,
4852 signature: v638,
4853 }
4854 });
4855 }
4856 v635
4857 };
4858 let v639 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4859 let v640 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4860 let v641 = if g.bool() { Some(g.string()) } else { None };
4861 PlayerInfoDataBodyAddPlayer {
4862 name: v632,
4863 properties: v633,
4864 gamemode: v639,
4865 ping: v640,
4866 display_name: v641,
4867 }
4868 })
4869 } else if (v626.0 == 1) {
4870 PlayerInfoDataBody::UpdateGameMode({
4871 let v642 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4872 PlayerInfoDataBodyUpdateGameMode { gamemode: v642 }
4873 })
4874 } else if (v626.0 == 2) {
4875 PlayerInfoDataBody::UpdateLatency({
4876 let v643 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4877 PlayerInfoDataBodyUpdateLatency { ping: v643 }
4878 })
4879 } else if (v626.0 == 3) {
4880 PlayerInfoDataBody::UpdateDisplayName({
4881 let v644 = if g.bool() { Some(g.string()) } else { None };
4882 PlayerInfoDataBodyUpdateDisplayName { display_name: v644 }
4883 })
4884 } else if (v626.0 == 4) {
4885 PlayerInfoDataBody::RemovePlayer
4886 } else {
4887 PlayerInfoDataBody::Other
4888 });
4889 PlayerInfoData {
4890 uuid: v630,
4891 body: v631,
4892 }
4893 });
4894 }
4895 v629
4896 };
4897 PlayerInfo {
4898 action: v626,
4899 data: v627,
4900 }
4901 }
4902 }
4903}
4904impl From<PlayerInfo> for ClientboundPlayPacket {
4905 fn from(p: PlayerInfo) -> Self {
4906 Self::PlayerInfo(p)
4907 }
4908}
4909
4910#[derive(Debug, Clone, PartialEq)]
4912pub struct Position {
4913 pub x: f64,
4915 pub y: f64,
4917 pub z: f64,
4919 pub yaw: f32,
4921 pub pitch: f32,
4923 pub flags: i8,
4925 pub teleport_id: i32,
4927}
4928impl crate::packet::Packet for Position {
4929 const ID: i32 = id::POSITION;
4930 const NAME: &'static str = "position";
4931 const STATE: State = State::Play;
4932 const DIRECTION: Direction = Direction::Clientbound;
4933}
4934impl Decode for Position {
4935 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4936 Ok({
4937 let v645 = r.read_f64()?;
4938 let v646 = r.read_f64()?;
4939 let v647 = r.read_f64()?;
4940 let v648 = r.read_f32()?;
4941 let v649 = r.read_f32()?;
4942 let v650 = r.read_i8()?;
4943 let v651 = r.read_varint()?;
4944 Position {
4945 x: v645,
4946 y: v646,
4947 z: v647,
4948 yaw: v648,
4949 pitch: v649,
4950 flags: v650,
4951 teleport_id: v651,
4952 }
4953 })
4954 }
4955}
4956impl Encode for Position {
4957 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4958 w.put_f64((*self).x);
4959 w.put_f64((*self).y);
4960 w.put_f64((*self).z);
4961 w.put_f32((*self).yaw);
4962 w.put_f32((*self).pitch);
4963 w.put_i8((*self).flags);
4964 w.put_varint((*self).teleport_id);
4965 Ok(())
4966 }
4967}
4968#[cfg(feature = "testgen")]
4969impl Generate for Position {
4970 fn generate(g: &mut Gen) -> Self {
4971 {
4972 let v652 = g.f64();
4973 let v653 = g.f64();
4974 let v654 = g.f64();
4975 let v655 = g.f32();
4976 let v656 = g.f32();
4977 let v657 = (g.int_in(-128, 127, &[]) as i8);
4978 let v658 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4979 Position {
4980 x: v652,
4981 y: v653,
4982 z: v654,
4983 yaw: v655,
4984 pitch: v656,
4985 flags: v657,
4986 teleport_id: v658,
4987 }
4988 }
4989 }
4990}
4991impl From<Position> for ClientboundPlayPacket {
4992 fn from(p: Position) -> Self {
4993 Self::Position(p)
4994 }
4995}
4996
4997#[derive(Debug, Clone, PartialEq)]
4999pub struct Bed {
5000 pub entity_id: i32,
5002 pub location: BlockPos,
5004}
5005impl crate::packet::Packet for Bed {
5006 const ID: i32 = id::BED;
5007 const NAME: &'static str = "bed";
5008 const STATE: State = State::Play;
5009 const DIRECTION: Direction = Direction::Clientbound;
5010}
5011impl Decode for Bed {
5012 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5013 Ok({
5014 let v659 = r.read_varint()?;
5015 let v660 = BlockPos::read(r, PositionLayout::Xyz)?;
5016 Bed {
5017 entity_id: v659,
5018 location: v660,
5019 }
5020 })
5021 }
5022}
5023impl Encode for Bed {
5024 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5025 w.put_varint((*self).entity_id);
5026 (*self).location.write(w, PositionLayout::Xyz)?;
5027 Ok(())
5028 }
5029}
5030#[cfg(feature = "testgen")]
5031impl Generate for Bed {
5032 fn generate(g: &mut Gen) -> Self {
5033 {
5034 let v661 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5035 let v662 = g.position();
5036 Bed {
5037 entity_id: v661,
5038 location: v662,
5039 }
5040 }
5041 }
5042}
5043impl From<Bed> for ClientboundPlayPacket {
5044 fn from(p: Bed) -> Self {
5045 Self::Bed(p)
5046 }
5047}
5048
5049#[derive(Debug, Clone, PartialEq)]
5051pub struct UnlockRecipes {
5052 pub action: i32,
5054 pub crafting_book_open: bool,
5056 pub filtering_craftable: bool,
5058 pub recipes1: Vec<i32>,
5060 pub recipes2: Option<Vec<i32>>,
5062}
5063impl crate::packet::Packet for UnlockRecipes {
5064 const ID: i32 = id::UNLOCK_RECIPES;
5065 const NAME: &'static str = "unlock_recipes";
5066 const STATE: State = State::Play;
5067 const DIRECTION: Direction = Direction::Clientbound;
5068}
5069impl Decode for UnlockRecipes {
5070 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5071 Ok({
5072 let v663 = r.read_varint()?;
5073 let v664 = r.read_bool()?;
5074 let v665 = r.read_bool()?;
5075 let v666 = {
5076 let v667 = {
5077 let c = r.read_varint()?;
5078 r.check_count(i64::from(c), 1)?
5079 };
5080 let mut v668 = Vec::with_capacity(v667.min(crate::codec::PREALLOC_LIMIT));
5081 for _ in 0..v667 {
5082 v668.push(r.read_varint()?);
5083 }
5084 v668
5085 };
5086 let v669 = if (v663 == 0) {
5087 Some({
5088 let v670 = {
5089 let c = r.read_varint()?;
5090 r.check_count(i64::from(c), 1)?
5091 };
5092 let mut v671 = Vec::with_capacity(v670.min(crate::codec::PREALLOC_LIMIT));
5093 for _ in 0..v670 {
5094 v671.push(r.read_varint()?);
5095 }
5096 v671
5097 })
5098 } else {
5099 None
5100 };
5101 UnlockRecipes {
5102 action: v663,
5103 crafting_book_open: v664,
5104 filtering_craftable: v665,
5105 recipes1: v666,
5106 recipes2: v669,
5107 }
5108 })
5109 }
5110}
5111impl Encode for UnlockRecipes {
5112 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5113 w.put_varint((*self).action);
5114 w.put_bool((*self).crafting_book_open);
5115 w.put_bool((*self).filtering_craftable);
5116 w.put_len_varint((*self).recipes1.len())?;
5117 for v672 in (*self).recipes1.iter() {
5118 w.put_varint((*v672));
5119 }
5120 match (&(*self).recipes2, ((*self).action == 0)) {
5121 (Some(v673), true) => {
5122 w.put_len_varint((*v673).len())?;
5123 for v674 in (*v673).iter() {
5124 w.put_varint((*v674));
5125 }
5126 }
5127 (None, false) => {}
5128 _ => {
5129 return Err(EncodeError::SwitchMismatch(
5130 "play.clientbound.unlock_recipes.recipes2",
5131 ));
5132 }
5133 }
5134 Ok(())
5135 }
5136}
5137#[cfg(feature = "testgen")]
5138impl Generate for UnlockRecipes {
5139 fn generate(g: &mut Gen) -> Self {
5140 {
5141 let v675 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
5142 let v676 = g.bool();
5143 let v677 = g.bool();
5144 let v678 = {
5145 let v679 = g.count();
5146 let mut v680 = Vec::with_capacity(v679.min(crate::codec::PREALLOC_LIMIT));
5147 for _ in 0..v679 {
5148 v680.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5149 }
5150 v680
5151 };
5152 let v681 = if (v675 == 0) {
5153 Some({
5154 let v682 = g.count();
5155 let mut v683 = Vec::with_capacity(v682.min(crate::codec::PREALLOC_LIMIT));
5156 for _ in 0..v682 {
5157 v683.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5158 }
5159 v683
5160 })
5161 } else {
5162 None
5163 };
5164 UnlockRecipes {
5165 action: v675,
5166 crafting_book_open: v676,
5167 filtering_craftable: v677,
5168 recipes1: v678,
5169 recipes2: v681,
5170 }
5171 }
5172 }
5173}
5174impl From<UnlockRecipes> for ClientboundPlayPacket {
5175 fn from(p: UnlockRecipes) -> Self {
5176 Self::UnlockRecipes(p)
5177 }
5178}
5179
5180#[derive(Debug, Clone, PartialEq)]
5182pub struct EntityDestroy {
5183 pub entity_ids: Vec<i32>,
5185}
5186impl crate::packet::Packet for EntityDestroy {
5187 const ID: i32 = id::ENTITY_DESTROY;
5188 const NAME: &'static str = "entity_destroy";
5189 const STATE: State = State::Play;
5190 const DIRECTION: Direction = Direction::Clientbound;
5191}
5192impl Decode for EntityDestroy {
5193 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5194 Ok({
5195 let v684 = {
5196 let v685 = {
5197 let c = r.read_varint()?;
5198 r.check_count(i64::from(c), 1)?
5199 };
5200 let mut v686 = Vec::with_capacity(v685.min(crate::codec::PREALLOC_LIMIT));
5201 for _ in 0..v685 {
5202 v686.push(r.read_varint()?);
5203 }
5204 v686
5205 };
5206 EntityDestroy { entity_ids: v684 }
5207 })
5208 }
5209}
5210impl Encode for EntityDestroy {
5211 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5212 w.put_len_varint((*self).entity_ids.len())?;
5213 for v687 in (*self).entity_ids.iter() {
5214 w.put_varint((*v687));
5215 }
5216 Ok(())
5217 }
5218}
5219#[cfg(feature = "testgen")]
5220impl Generate for EntityDestroy {
5221 fn generate(g: &mut Gen) -> Self {
5222 {
5223 let v688 = {
5224 let v689 = g.count();
5225 let mut v690 = Vec::with_capacity(v689.min(crate::codec::PREALLOC_LIMIT));
5226 for _ in 0..v689 {
5227 v690.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5228 }
5229 v690
5230 };
5231 EntityDestroy { entity_ids: v688 }
5232 }
5233 }
5234}
5235impl From<EntityDestroy> for ClientboundPlayPacket {
5236 fn from(p: EntityDestroy) -> Self {
5237 Self::EntityDestroy(p)
5238 }
5239}
5240
5241#[derive(Debug, Clone, PartialEq)]
5243pub struct RemoveEntityEffect {
5244 pub entity_id: i32,
5246 pub effect_id: i8,
5248}
5249impl crate::packet::Packet for RemoveEntityEffect {
5250 const ID: i32 = id::REMOVE_ENTITY_EFFECT;
5251 const NAME: &'static str = "remove_entity_effect";
5252 const STATE: State = State::Play;
5253 const DIRECTION: Direction = Direction::Clientbound;
5254}
5255impl Decode for RemoveEntityEffect {
5256 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5257 Ok({
5258 let v691 = r.read_varint()?;
5259 let v692 = r.read_i8()?;
5260 RemoveEntityEffect {
5261 entity_id: v691,
5262 effect_id: v692,
5263 }
5264 })
5265 }
5266}
5267impl Encode for RemoveEntityEffect {
5268 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5269 w.put_varint((*self).entity_id);
5270 w.put_i8((*self).effect_id);
5271 Ok(())
5272 }
5273}
5274#[cfg(feature = "testgen")]
5275impl Generate for RemoveEntityEffect {
5276 fn generate(g: &mut Gen) -> Self {
5277 {
5278 let v693 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5279 let v694 = (g.int_in(-128, 127, &[]) as i8);
5280 RemoveEntityEffect {
5281 entity_id: v693,
5282 effect_id: v694,
5283 }
5284 }
5285 }
5286}
5287impl From<RemoveEntityEffect> for ClientboundPlayPacket {
5288 fn from(p: RemoveEntityEffect) -> Self {
5289 Self::RemoveEntityEffect(p)
5290 }
5291}
5292
5293#[derive(Debug, Clone, PartialEq)]
5295pub struct ResourcePackSend {
5296 pub url: ByteString,
5298 pub hash: ByteString,
5300}
5301impl crate::packet::Packet for ResourcePackSend {
5302 const ID: i32 = id::RESOURCE_PACK_SEND;
5303 const NAME: &'static str = "resource_pack_send";
5304 const STATE: State = State::Play;
5305 const DIRECTION: Direction = Direction::Clientbound;
5306}
5307impl Decode for ResourcePackSend {
5308 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5309 Ok({
5310 let v695 = r.read_string()?;
5311 let v696 = r.read_string()?;
5312 ResourcePackSend {
5313 url: v695,
5314 hash: v696,
5315 }
5316 })
5317 }
5318}
5319impl Encode for ResourcePackSend {
5320 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5321 w.put_string(&(*self).url)?;
5322 w.put_string(&(*self).hash)?;
5323 Ok(())
5324 }
5325}
5326#[cfg(feature = "testgen")]
5327impl Generate for ResourcePackSend {
5328 fn generate(g: &mut Gen) -> Self {
5329 {
5330 let v697 = g.string();
5331 let v698 = g.string();
5332 ResourcePackSend {
5333 url: v697,
5334 hash: v698,
5335 }
5336 }
5337 }
5338}
5339impl From<ResourcePackSend> for ClientboundPlayPacket {
5340 fn from(p: ResourcePackSend) -> Self {
5341 Self::ResourcePackSend(p)
5342 }
5343}
5344
5345#[derive(Debug, Clone, PartialEq)]
5347pub struct Respawn {
5348 pub dimension: i32,
5350 pub difficulty: u8,
5352 pub gamemode: u8,
5354 pub level_type: ByteString,
5356}
5357impl crate::packet::Packet for Respawn {
5358 const ID: i32 = id::RESPAWN;
5359 const NAME: &'static str = "respawn";
5360 const STATE: State = State::Play;
5361 const DIRECTION: Direction = Direction::Clientbound;
5362}
5363impl Decode for Respawn {
5364 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5365 Ok({
5366 let v699 = r.read_i32()?;
5367 let v700 = r.read_u8()?;
5368 let v701 = r.read_u8()?;
5369 let v702 = r.read_string()?;
5370 Respawn {
5371 dimension: v699,
5372 difficulty: v700,
5373 gamemode: v701,
5374 level_type: v702,
5375 }
5376 })
5377 }
5378}
5379impl Encode for Respawn {
5380 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5381 w.put_i32((*self).dimension);
5382 w.put_u8((*self).difficulty);
5383 w.put_u8((*self).gamemode);
5384 w.put_string(&(*self).level_type)?;
5385 Ok(())
5386 }
5387}
5388#[cfg(feature = "testgen")]
5389impl Generate for Respawn {
5390 fn generate(g: &mut Gen) -> Self {
5391 {
5392 let v703 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5393 let v704 = (g.int_in(0, 255, &[]) as u8);
5394 let v705 = (g.int_in(0, 255, &[]) as u8);
5395 let v706 = g.string();
5396 Respawn {
5397 dimension: v703,
5398 difficulty: v704,
5399 gamemode: v705,
5400 level_type: v706,
5401 }
5402 }
5403 }
5404}
5405impl From<Respawn> for ClientboundPlayPacket {
5406 fn from(p: Respawn) -> Self {
5407 Self::Respawn(p)
5408 }
5409}
5410
5411#[derive(Debug, Clone, PartialEq)]
5413pub struct EntityHeadRotation {
5414 pub entity_id: i32,
5416 pub head_yaw: i8,
5418}
5419impl crate::packet::Packet for EntityHeadRotation {
5420 const ID: i32 = id::ENTITY_HEAD_ROTATION;
5421 const NAME: &'static str = "entity_head_rotation";
5422 const STATE: State = State::Play;
5423 const DIRECTION: Direction = Direction::Clientbound;
5424}
5425impl Decode for EntityHeadRotation {
5426 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5427 Ok({
5428 let v707 = r.read_varint()?;
5429 let v708 = r.read_i8()?;
5430 EntityHeadRotation {
5431 entity_id: v707,
5432 head_yaw: v708,
5433 }
5434 })
5435 }
5436}
5437impl Encode for EntityHeadRotation {
5438 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5439 w.put_varint((*self).entity_id);
5440 w.put_i8((*self).head_yaw);
5441 Ok(())
5442 }
5443}
5444#[cfg(feature = "testgen")]
5445impl Generate for EntityHeadRotation {
5446 fn generate(g: &mut Gen) -> Self {
5447 {
5448 let v709 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5449 let v710 = (g.int_in(-128, 127, &[]) as i8);
5450 EntityHeadRotation {
5451 entity_id: v709,
5452 head_yaw: v710,
5453 }
5454 }
5455 }
5456}
5457impl From<EntityHeadRotation> for ClientboundPlayPacket {
5458 fn from(p: EntityHeadRotation) -> Self {
5459 Self::EntityHeadRotation(p)
5460 }
5461}
5462
5463#[derive(Debug, Clone, PartialEq)]
5465pub struct SelectAdvancementTab {
5466 pub id: Option<ByteString>,
5468}
5469impl crate::packet::Packet for SelectAdvancementTab {
5470 const ID: i32 = id::SELECT_ADVANCEMENT_TAB;
5471 const NAME: &'static str = "select_advancement_tab";
5472 const STATE: State = State::Play;
5473 const DIRECTION: Direction = Direction::Clientbound;
5474}
5475impl Decode for SelectAdvancementTab {
5476 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5477 Ok({
5478 let v711 = if r.read_bool()? {
5479 Some(r.read_string()?)
5480 } else {
5481 None
5482 };
5483 SelectAdvancementTab { id: v711 }
5484 })
5485 }
5486}
5487impl Encode for SelectAdvancementTab {
5488 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5489 match &(*self).id {
5490 Some(v712) => {
5491 w.put_u8(1);
5492 w.put_string(&(*v712))?;
5493 }
5494 None => w.put_u8(0),
5495 }
5496 Ok(())
5497 }
5498}
5499#[cfg(feature = "testgen")]
5500impl Generate for SelectAdvancementTab {
5501 fn generate(g: &mut Gen) -> Self {
5502 {
5503 let v713 = if g.bool() { Some(g.string()) } else { None };
5504 SelectAdvancementTab { id: v713 }
5505 }
5506 }
5507}
5508impl From<SelectAdvancementTab> for ClientboundPlayPacket {
5509 fn from(p: SelectAdvancementTab) -> Self {
5510 Self::SelectAdvancementTab(p)
5511 }
5512}
5513
5514#[derive(Debug, Clone, PartialEq)]
5516pub struct WorldBorder {
5517 pub action: i32,
5519 pub radius: Option<f64>,
5521 pub x: Option<f64>,
5523 pub z: Option<f64>,
5525 pub old_radius: Option<f64>,
5527 pub new_radius: Option<f64>,
5529 pub speed: Option<i64>,
5531 pub portal_boundary: Option<i32>,
5533 pub warning_time: Option<i32>,
5535 pub warning_blocks: Option<i32>,
5537}
5538impl crate::packet::Packet for WorldBorder {
5539 const ID: i32 = id::WORLD_BORDER;
5540 const NAME: &'static str = "world_border";
5541 const STATE: State = State::Play;
5542 const DIRECTION: Direction = Direction::Clientbound;
5543}
5544impl Decode for WorldBorder {
5545 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5546 Ok({
5547 let v714 = r.read_varint()?;
5548 let v715 = if (v714 == 0) {
5549 Some(r.read_f64()?)
5550 } else {
5551 None
5552 };
5553 let v716 = if (v714 == 2) || (v714 == 3) {
5554 Some(r.read_f64()?)
5555 } else {
5556 None
5557 };
5558 let v717 = if (v714 == 2) || (v714 == 3) {
5559 Some(r.read_f64()?)
5560 } else {
5561 None
5562 };
5563 let v718 = if (v714 == 1) || (v714 == 3) {
5564 Some(r.read_f64()?)
5565 } else {
5566 None
5567 };
5568 let v719 = if (v714 == 1) || (v714 == 3) {
5569 Some(r.read_f64()?)
5570 } else {
5571 None
5572 };
5573 let v720 = if (v714 == 1) || (v714 == 3) {
5574 Some(r.read_varlong()?)
5575 } else {
5576 None
5577 };
5578 let v721 = if (v714 == 3) {
5579 Some(r.read_varint()?)
5580 } else {
5581 None
5582 };
5583 let v722 = if (v714 == 3) || (v714 == 4) {
5584 Some(r.read_varint()?)
5585 } else {
5586 None
5587 };
5588 let v723 = if (v714 == 3) || (v714 == 5) {
5589 Some(r.read_varint()?)
5590 } else {
5591 None
5592 };
5593 WorldBorder {
5594 action: v714,
5595 radius: v715,
5596 x: v716,
5597 z: v717,
5598 old_radius: v718,
5599 new_radius: v719,
5600 speed: v720,
5601 portal_boundary: v721,
5602 warning_time: v722,
5603 warning_blocks: v723,
5604 }
5605 })
5606 }
5607}
5608impl Encode for WorldBorder {
5609 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5610 w.put_varint((*self).action);
5611 match (&(*self).radius, ((*self).action == 0)) {
5612 (Some(v724), true) => {
5613 w.put_f64((*v724));
5614 }
5615 (None, false) => {}
5616 _ => {
5617 return Err(EncodeError::SwitchMismatch(
5618 "play.clientbound.world_border.radius",
5619 ));
5620 }
5621 }
5622 match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
5623 (Some(v725), true) => {
5624 w.put_f64((*v725));
5625 }
5626 (None, false) => {}
5627 _ => {
5628 return Err(EncodeError::SwitchMismatch(
5629 "play.clientbound.world_border.x",
5630 ));
5631 }
5632 }
5633 match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
5634 (Some(v726), true) => {
5635 w.put_f64((*v726));
5636 }
5637 (None, false) => {}
5638 _ => {
5639 return Err(EncodeError::SwitchMismatch(
5640 "play.clientbound.world_border.z",
5641 ));
5642 }
5643 }
5644 match (
5645 &(*self).old_radius,
5646 ((*self).action == 1) || ((*self).action == 3),
5647 ) {
5648 (Some(v727), true) => {
5649 w.put_f64((*v727));
5650 }
5651 (None, false) => {}
5652 _ => {
5653 return Err(EncodeError::SwitchMismatch(
5654 "play.clientbound.world_border.old_radius",
5655 ));
5656 }
5657 }
5658 match (
5659 &(*self).new_radius,
5660 ((*self).action == 1) || ((*self).action == 3),
5661 ) {
5662 (Some(v728), true) => {
5663 w.put_f64((*v728));
5664 }
5665 (None, false) => {}
5666 _ => {
5667 return Err(EncodeError::SwitchMismatch(
5668 "play.clientbound.world_border.new_radius",
5669 ));
5670 }
5671 }
5672 match (
5673 &(*self).speed,
5674 ((*self).action == 1) || ((*self).action == 3),
5675 ) {
5676 (Some(v729), true) => {
5677 w.put_varlong((*v729));
5678 }
5679 (None, false) => {}
5680 _ => {
5681 return Err(EncodeError::SwitchMismatch(
5682 "play.clientbound.world_border.speed",
5683 ));
5684 }
5685 }
5686 match (&(*self).portal_boundary, ((*self).action == 3)) {
5687 (Some(v730), true) => {
5688 w.put_varint((*v730));
5689 }
5690 (None, false) => {}
5691 _ => {
5692 return Err(EncodeError::SwitchMismatch(
5693 "play.clientbound.world_border.portalBoundary",
5694 ));
5695 }
5696 }
5697 match (
5698 &(*self).warning_time,
5699 ((*self).action == 3) || ((*self).action == 4),
5700 ) {
5701 (Some(v731), true) => {
5702 w.put_varint((*v731));
5703 }
5704 (None, false) => {}
5705 _ => {
5706 return Err(EncodeError::SwitchMismatch(
5707 "play.clientbound.world_border.warning_time",
5708 ));
5709 }
5710 }
5711 match (
5712 &(*self).warning_blocks,
5713 ((*self).action == 3) || ((*self).action == 5),
5714 ) {
5715 (Some(v732), true) => {
5716 w.put_varint((*v732));
5717 }
5718 (None, false) => {}
5719 _ => {
5720 return Err(EncodeError::SwitchMismatch(
5721 "play.clientbound.world_border.warning_blocks",
5722 ));
5723 }
5724 }
5725 Ok(())
5726 }
5727}
5728#[cfg(feature = "testgen")]
5729impl Generate for WorldBorder {
5730 fn generate(g: &mut Gen) -> Self {
5731 {
5732 let v733 = (g.int_in(
5733 -2147483648,
5734 2147483647,
5735 &[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
5736 ) as i32);
5737 let v734 = if (v733 == 0) { Some(g.f64()) } else { None };
5738 let v735 = if (v733 == 2) || (v733 == 3) {
5739 Some(g.f64())
5740 } else {
5741 None
5742 };
5743 let v736 = if (v733 == 2) || (v733 == 3) {
5744 Some(g.f64())
5745 } else {
5746 None
5747 };
5748 let v737 = if (v733 == 1) || (v733 == 3) {
5749 Some(g.f64())
5750 } else {
5751 None
5752 };
5753 let v738 = if (v733 == 1) || (v733 == 3) {
5754 Some(g.f64())
5755 } else {
5756 None
5757 };
5758 let v739 = if (v733 == 1) || (v733 == 3) {
5759 Some(g.varlong())
5760 } else {
5761 None
5762 };
5763 let v740 = if (v733 == 3) {
5764 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5765 } else {
5766 None
5767 };
5768 let v741 = if (v733 == 3) || (v733 == 4) {
5769 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5770 } else {
5771 None
5772 };
5773 let v742 = if (v733 == 3) || (v733 == 5) {
5774 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5775 } else {
5776 None
5777 };
5778 WorldBorder {
5779 action: v733,
5780 radius: v734,
5781 x: v735,
5782 z: v736,
5783 old_radius: v737,
5784 new_radius: v738,
5785 speed: v739,
5786 portal_boundary: v740,
5787 warning_time: v741,
5788 warning_blocks: v742,
5789 }
5790 }
5791 }
5792}
5793impl From<WorldBorder> for ClientboundPlayPacket {
5794 fn from(p: WorldBorder) -> Self {
5795 Self::WorldBorder(p)
5796 }
5797}
5798
5799#[derive(Debug, Clone, PartialEq)]
5801pub struct Camera {
5802 pub camera_id: i32,
5804}
5805impl crate::packet::Packet for Camera {
5806 const ID: i32 = id::CAMERA;
5807 const NAME: &'static str = "camera";
5808 const STATE: State = State::Play;
5809 const DIRECTION: Direction = Direction::Clientbound;
5810}
5811impl Decode for Camera {
5812 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5813 Ok({
5814 let v743 = r.read_varint()?;
5815 Camera { camera_id: v743 }
5816 })
5817 }
5818}
5819impl Encode for Camera {
5820 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5821 w.put_varint((*self).camera_id);
5822 Ok(())
5823 }
5824}
5825#[cfg(feature = "testgen")]
5826impl Generate for Camera {
5827 fn generate(g: &mut Gen) -> Self {
5828 {
5829 let v744 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5830 Camera { camera_id: v744 }
5831 }
5832 }
5833}
5834impl From<Camera> for ClientboundPlayPacket {
5835 fn from(p: Camera) -> Self {
5836 Self::Camera(p)
5837 }
5838}
5839
5840#[derive(Debug, Clone, PartialEq)]
5842pub struct HeldItemSlot {
5843 pub slot: i8,
5845}
5846impl crate::packet::Packet for HeldItemSlot {
5847 const ID: i32 = id::HELD_ITEM_SLOT;
5848 const NAME: &'static str = "held_item_slot";
5849 const STATE: State = State::Play;
5850 const DIRECTION: Direction = Direction::Clientbound;
5851}
5852impl Decode for HeldItemSlot {
5853 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5854 Ok({
5855 let v745 = r.read_i8()?;
5856 HeldItemSlot { slot: v745 }
5857 })
5858 }
5859}
5860impl Encode for HeldItemSlot {
5861 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5862 w.put_i8((*self).slot);
5863 Ok(())
5864 }
5865}
5866#[cfg(feature = "testgen")]
5867impl Generate for HeldItemSlot {
5868 fn generate(g: &mut Gen) -> Self {
5869 {
5870 let v746 = (g.int_in(-128, 127, &[]) as i8);
5871 HeldItemSlot { slot: v746 }
5872 }
5873 }
5874}
5875impl From<HeldItemSlot> for ClientboundPlayPacket {
5876 fn from(p: HeldItemSlot) -> Self {
5877 Self::HeldItemSlot(p)
5878 }
5879}
5880
5881#[derive(Debug, Clone, PartialEq)]
5883pub struct ScoreboardDisplayObjective {
5884 pub position: i8,
5886 pub name: ByteString,
5888}
5889impl crate::packet::Packet for ScoreboardDisplayObjective {
5890 const ID: i32 = id::SCOREBOARD_DISPLAY_OBJECTIVE;
5891 const NAME: &'static str = "scoreboard_display_objective";
5892 const STATE: State = State::Play;
5893 const DIRECTION: Direction = Direction::Clientbound;
5894}
5895impl Decode for ScoreboardDisplayObjective {
5896 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5897 Ok({
5898 let v747 = r.read_i8()?;
5899 let v748 = r.read_string()?;
5900 ScoreboardDisplayObjective {
5901 position: v747,
5902 name: v748,
5903 }
5904 })
5905 }
5906}
5907impl Encode for ScoreboardDisplayObjective {
5908 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5909 w.put_i8((*self).position);
5910 w.put_string(&(*self).name)?;
5911 Ok(())
5912 }
5913}
5914#[cfg(feature = "testgen")]
5915impl Generate for ScoreboardDisplayObjective {
5916 fn generate(g: &mut Gen) -> Self {
5917 {
5918 let v749 = (g.int_in(-128, 127, &[]) as i8);
5919 let v750 = g.string();
5920 ScoreboardDisplayObjective {
5921 position: v749,
5922 name: v750,
5923 }
5924 }
5925 }
5926}
5927impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
5928 fn from(p: ScoreboardDisplayObjective) -> Self {
5929 Self::ScoreboardDisplayObjective(p)
5930 }
5931}
5932
5933#[derive(Debug, Clone, PartialEq)]
5935pub struct EntityMetadata {
5936 pub entity_id: i32,
5938 pub metadata: Vec<types::EntityMetadataEntry>,
5940}
5941impl crate::packet::Packet for EntityMetadata {
5942 const ID: i32 = id::ENTITY_METADATA;
5943 const NAME: &'static str = "entity_metadata";
5944 const STATE: State = State::Play;
5945 const DIRECTION: Direction = Direction::Clientbound;
5946}
5947impl Decode for EntityMetadata {
5948 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5949 Ok({
5950 let v751 = r.read_varint()?;
5951 let v752 = {
5952 let mut v753 = Vec::new();
5953 loop {
5954 if r.peek_u8()? == 255 {
5955 r.skip(1)?;
5956 break;
5957 }
5958 v753.push({
5959 let v754 = r.read_u8()?;
5960 let v755 = r.read_i8()?;
5961 let v756 = (if (v755 == 0) {
5962 types::EntityMetadataValue::Byte(r.read_i8()?)
5963 } else if (v755 == 1) {
5964 types::EntityMetadataValue::VarInt(r.read_varint()?)
5965 } else if (v755 == 2) {
5966 types::EntityMetadataValue::Float(r.read_f32()?)
5967 } else if (v755 == 3) {
5968 types::EntityMetadataValue::String(r.read_string()?)
5969 } else if (v755 == 4) {
5970 types::EntityMetadataValue::Chat(r.read_string()?)
5971 } else if (v755 == 5) {
5972 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
5973 } else if (v755 == 6) {
5974 types::EntityMetadataValue::Boolean(r.read_bool()?)
5975 } else if (v755 == 7) {
5976 types::EntityMetadataValue::Rotation({
5977 let v757 = r.read_f32()?;
5978 let v758 = r.read_f32()?;
5979 let v759 = r.read_f32()?;
5980 types::EntityMetadataValueRotation {
5981 pitch: v757,
5982 yaw: v758,
5983 roll: v759,
5984 }
5985 })
5986 } else if (v755 == 8) {
5987 types::EntityMetadataValue::Position(BlockPos::read(
5988 r,
5989 PositionLayout::Xyz,
5990 )?)
5991 } else if (v755 == 9) {
5992 types::EntityMetadataValue::OptPosition(if r.read_bool()? {
5993 Some(BlockPos::read(r, PositionLayout::Xyz)?)
5994 } else {
5995 None
5996 })
5997 } else if (v755 == 10) {
5998 types::EntityMetadataValue::Direction(r.read_varint()?)
5999 } else if (v755 == 11) {
6000 types::EntityMetadataValue::OptUuid(if r.read_bool()? {
6001 Some(r.read_uuid()?)
6002 } else {
6003 None
6004 })
6005 } else if (v755 == 12) {
6006 types::EntityMetadataValue::BlockState(r.read_varint()?)
6007 } else if (v755 == 13) {
6008 types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
6009 } else {
6010 types::EntityMetadataValue::Other
6011 });
6012 types::EntityMetadataEntry {
6013 key: v754,
6014 r#type: v755,
6015 value: v756,
6016 }
6017 });
6018 }
6019 v753
6020 };
6021 EntityMetadata {
6022 entity_id: v751,
6023 metadata: v752,
6024 }
6025 })
6026 }
6027}
6028impl Encode for EntityMetadata {
6029 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6030 w.put_varint((*self).entity_id);
6031 for v760 in (*self).metadata.iter() {
6032 let v761 = w.len();
6033 w.put_u8((*v760).key);
6034 w.put_i8((*v760).r#type);
6035 match &(*v760).value {
6036 types::EntityMetadataValue::Byte(v762) => {
6037 if !((*v760).r#type == 0) {
6038 return Err(EncodeError::SwitchMismatch(
6039 "play.clientbound.entity_metadata.metadata.value",
6040 ));
6041 }
6042 w.put_i8((*v762));
6043 }
6044 types::EntityMetadataValue::VarInt(v763) => {
6045 if !((*v760).r#type == 1) {
6046 return Err(EncodeError::SwitchMismatch(
6047 "play.clientbound.entity_metadata.metadata.value",
6048 ));
6049 }
6050 w.put_varint((*v763));
6051 }
6052 types::EntityMetadataValue::Float(v764) => {
6053 if !((*v760).r#type == 2) {
6054 return Err(EncodeError::SwitchMismatch(
6055 "play.clientbound.entity_metadata.metadata.value",
6056 ));
6057 }
6058 w.put_f32((*v764));
6059 }
6060 types::EntityMetadataValue::String(v765) => {
6061 if !((*v760).r#type == 3) {
6062 return Err(EncodeError::SwitchMismatch(
6063 "play.clientbound.entity_metadata.metadata.value",
6064 ));
6065 }
6066 w.put_string(&(*v765))?;
6067 }
6068 types::EntityMetadataValue::Chat(v766) => {
6069 if !((*v760).r#type == 4) {
6070 return Err(EncodeError::SwitchMismatch(
6071 "play.clientbound.entity_metadata.metadata.value",
6072 ));
6073 }
6074 w.put_string(&(*v766))?;
6075 }
6076 types::EntityMetadataValue::Slot(v767) => {
6077 if !((*v760).r#type == 5) {
6078 return Err(EncodeError::SwitchMismatch(
6079 "play.clientbound.entity_metadata.metadata.value",
6080 ));
6081 }
6082 (*v767).encode(w)?;
6083 }
6084 types::EntityMetadataValue::Boolean(v768) => {
6085 if !((*v760).r#type == 6) {
6086 return Err(EncodeError::SwitchMismatch(
6087 "play.clientbound.entity_metadata.metadata.value",
6088 ));
6089 }
6090 w.put_bool((*v768));
6091 }
6092 types::EntityMetadataValue::Rotation(v769) => {
6093 if !((*v760).r#type == 7) {
6094 return Err(EncodeError::SwitchMismatch(
6095 "play.clientbound.entity_metadata.metadata.value",
6096 ));
6097 }
6098 w.put_f32((*v769).pitch);
6099 w.put_f32((*v769).yaw);
6100 w.put_f32((*v769).roll);
6101 }
6102 types::EntityMetadataValue::Position(v770) => {
6103 if !((*v760).r#type == 8) {
6104 return Err(EncodeError::SwitchMismatch(
6105 "play.clientbound.entity_metadata.metadata.value",
6106 ));
6107 }
6108 (*v770).write(w, PositionLayout::Xyz)?;
6109 }
6110 types::EntityMetadataValue::OptPosition(v771) => {
6111 if !((*v760).r#type == 9) {
6112 return Err(EncodeError::SwitchMismatch(
6113 "play.clientbound.entity_metadata.metadata.value",
6114 ));
6115 }
6116 match &(*v771) {
6117 Some(v772) => {
6118 w.put_u8(1);
6119 (*v772).write(w, PositionLayout::Xyz)?;
6120 }
6121 None => w.put_u8(0),
6122 }
6123 }
6124 types::EntityMetadataValue::Direction(v773) => {
6125 if !((*v760).r#type == 10) {
6126 return Err(EncodeError::SwitchMismatch(
6127 "play.clientbound.entity_metadata.metadata.value",
6128 ));
6129 }
6130 w.put_varint((*v773));
6131 }
6132 types::EntityMetadataValue::OptUuid(v774) => {
6133 if !((*v760).r#type == 11) {
6134 return Err(EncodeError::SwitchMismatch(
6135 "play.clientbound.entity_metadata.metadata.value",
6136 ));
6137 }
6138 match &(*v774) {
6139 Some(v775) => {
6140 w.put_u8(1);
6141 w.put_uuid(&(*v775));
6142 }
6143 None => w.put_u8(0),
6144 }
6145 }
6146 types::EntityMetadataValue::BlockState(v776) => {
6147 if !((*v760).r#type == 12) {
6148 return Err(EncodeError::SwitchMismatch(
6149 "play.clientbound.entity_metadata.metadata.value",
6150 ));
6151 }
6152 w.put_varint((*v776));
6153 }
6154 types::EntityMetadataValue::Nbt(v777) => {
6155 if !((*v760).r#type == 13) {
6156 return Err(EncodeError::SwitchMismatch(
6157 "play.clientbound.entity_metadata.metadata.value",
6158 ));
6159 }
6160 (*v777).write(w);
6161 }
6162 types::EntityMetadataValue::Other => {
6163 if !(!(((*v760).r#type == 0)
6164 || ((*v760).r#type == 1)
6165 || ((*v760).r#type == 2)
6166 || ((*v760).r#type == 3)
6167 || ((*v760).r#type == 4)
6168 || ((*v760).r#type == 5)
6169 || ((*v760).r#type == 6)
6170 || ((*v760).r#type == 7)
6171 || ((*v760).r#type == 8)
6172 || ((*v760).r#type == 9)
6173 || ((*v760).r#type == 10)
6174 || ((*v760).r#type == 11)
6175 || ((*v760).r#type == 12)
6176 || ((*v760).r#type == 13)))
6177 {
6178 return Err(EncodeError::SwitchMismatch(
6179 "play.clientbound.entity_metadata.metadata.value",
6180 ));
6181 }
6182 }
6183 }
6184 if w.get(v761) == Some(&255) {
6185 return Err(EncodeError::OutOfRange(
6186 "play.clientbound.entity_metadata.metadata",
6187 ));
6188 }
6189 }
6190 w.put_u8(255);
6191 Ok(())
6192 }
6193}
6194#[cfg(feature = "testgen")]
6195impl Generate for EntityMetadata {
6196 fn generate(g: &mut Gen) -> Self {
6197 {
6198 let v778 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6199 let v779 = {
6200 let n = g.count();
6201 let mut v780 = Vec::with_capacity(n);
6202 for _ in 0..n {
6203 v780.push(loop {
6204 let v781 = {
6205 let v782 = (g.int_in(0, 255, &[]) as u8);
6206 let v783 = (g.int_in(
6207 -128,
6208 127,
6209 &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
6210 ) as i8);
6211 let v784 = (if (v783 == 0) {
6212 types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
6213 } else if (v783 == 1) {
6214 types::EntityMetadataValue::VarInt(
6215 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6216 )
6217 } else if (v783 == 2) {
6218 types::EntityMetadataValue::Float(g.f32())
6219 } else if (v783 == 3) {
6220 types::EntityMetadataValue::String(g.string())
6221 } else if (v783 == 4) {
6222 types::EntityMetadataValue::Chat(g.string())
6223 } else if (v783 == 5) {
6224 types::EntityMetadataValue::Slot(
6225 <types::Slot as Generate>::generate(g),
6226 )
6227 } else if (v783 == 6) {
6228 types::EntityMetadataValue::Boolean(g.bool())
6229 } else if (v783 == 7) {
6230 types::EntityMetadataValue::Rotation({
6231 let v785 = g.f32();
6232 let v786 = g.f32();
6233 let v787 = g.f32();
6234 types::EntityMetadataValueRotation {
6235 pitch: v785,
6236 yaw: v786,
6237 roll: v787,
6238 }
6239 })
6240 } else if (v783 == 8) {
6241 types::EntityMetadataValue::Position(g.position())
6242 } else if (v783 == 9) {
6243 types::EntityMetadataValue::OptPosition(if g.bool() {
6244 Some(g.position())
6245 } else {
6246 None
6247 })
6248 } else if (v783 == 10) {
6249 types::EntityMetadataValue::Direction(
6250 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6251 )
6252 } else if (v783 == 11) {
6253 types::EntityMetadataValue::OptUuid(if g.bool() {
6254 Some(g.uuid())
6255 } else {
6256 None
6257 })
6258 } else if (v783 == 12) {
6259 types::EntityMetadataValue::BlockState(
6260 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6261 )
6262 } else if (v783 == 13) {
6263 types::EntityMetadataValue::Nbt(g.nbt())
6264 } else {
6265 types::EntityMetadataValue::Other
6266 });
6267 types::EntityMetadataEntry {
6268 key: v782,
6269 r#type: v783,
6270 value: v784,
6271 }
6272 };
6273 if crate::testgen::first_byte_ok(
6274 |w: &mut BytesMut| -> EncodeResult {
6275 w.put_u8(v781.key);
6276 w.put_i8(v781.r#type);
6277 match &v781.value {
6278 types::EntityMetadataValue::Byte(v788) => {
6279 if !(v781.r#type == 0) {
6280 return Err(EncodeError::SwitchMismatch(
6281 "play.clientbound.entity_metadata.metadata.value",
6282 ));
6283 }
6284 w.put_i8((*v788));
6285 }
6286 types::EntityMetadataValue::VarInt(v789) => {
6287 if !(v781.r#type == 1) {
6288 return Err(EncodeError::SwitchMismatch(
6289 "play.clientbound.entity_metadata.metadata.value",
6290 ));
6291 }
6292 w.put_varint((*v789));
6293 }
6294 types::EntityMetadataValue::Float(v790) => {
6295 if !(v781.r#type == 2) {
6296 return Err(EncodeError::SwitchMismatch(
6297 "play.clientbound.entity_metadata.metadata.value",
6298 ));
6299 }
6300 w.put_f32((*v790));
6301 }
6302 types::EntityMetadataValue::String(v791) => {
6303 if !(v781.r#type == 3) {
6304 return Err(EncodeError::SwitchMismatch(
6305 "play.clientbound.entity_metadata.metadata.value",
6306 ));
6307 }
6308 w.put_string(&(*v791))?;
6309 }
6310 types::EntityMetadataValue::Chat(v792) => {
6311 if !(v781.r#type == 4) {
6312 return Err(EncodeError::SwitchMismatch(
6313 "play.clientbound.entity_metadata.metadata.value",
6314 ));
6315 }
6316 w.put_string(&(*v792))?;
6317 }
6318 types::EntityMetadataValue::Slot(v793) => {
6319 if !(v781.r#type == 5) {
6320 return Err(EncodeError::SwitchMismatch(
6321 "play.clientbound.entity_metadata.metadata.value",
6322 ));
6323 }
6324 (*v793).encode(w)?;
6325 }
6326 types::EntityMetadataValue::Boolean(v794) => {
6327 if !(v781.r#type == 6) {
6328 return Err(EncodeError::SwitchMismatch(
6329 "play.clientbound.entity_metadata.metadata.value",
6330 ));
6331 }
6332 w.put_bool((*v794));
6333 }
6334 types::EntityMetadataValue::Rotation(v795) => {
6335 if !(v781.r#type == 7) {
6336 return Err(EncodeError::SwitchMismatch(
6337 "play.clientbound.entity_metadata.metadata.value",
6338 ));
6339 }
6340 w.put_f32((*v795).pitch);
6341 w.put_f32((*v795).yaw);
6342 w.put_f32((*v795).roll);
6343 }
6344 types::EntityMetadataValue::Position(v796) => {
6345 if !(v781.r#type == 8) {
6346 return Err(EncodeError::SwitchMismatch(
6347 "play.clientbound.entity_metadata.metadata.value",
6348 ));
6349 }
6350 (*v796).write(w, PositionLayout::Xyz)?;
6351 }
6352 types::EntityMetadataValue::OptPosition(v797) => {
6353 if !(v781.r#type == 9) {
6354 return Err(EncodeError::SwitchMismatch(
6355 "play.clientbound.entity_metadata.metadata.value",
6356 ));
6357 }
6358 match &(*v797) {
6359 Some(v798) => {
6360 w.put_u8(1);
6361 (*v798).write(w, PositionLayout::Xyz)?;
6362 }
6363 None => w.put_u8(0),
6364 }
6365 }
6366 types::EntityMetadataValue::Direction(v799) => {
6367 if !(v781.r#type == 10) {
6368 return Err(EncodeError::SwitchMismatch(
6369 "play.clientbound.entity_metadata.metadata.value",
6370 ));
6371 }
6372 w.put_varint((*v799));
6373 }
6374 types::EntityMetadataValue::OptUuid(v800) => {
6375 if !(v781.r#type == 11) {
6376 return Err(EncodeError::SwitchMismatch(
6377 "play.clientbound.entity_metadata.metadata.value",
6378 ));
6379 }
6380 match &(*v800) {
6381 Some(v801) => {
6382 w.put_u8(1);
6383 w.put_uuid(&(*v801));
6384 }
6385 None => w.put_u8(0),
6386 }
6387 }
6388 types::EntityMetadataValue::BlockState(v802) => {
6389 if !(v781.r#type == 12) {
6390 return Err(EncodeError::SwitchMismatch(
6391 "play.clientbound.entity_metadata.metadata.value",
6392 ));
6393 }
6394 w.put_varint((*v802));
6395 }
6396 types::EntityMetadataValue::Nbt(v803) => {
6397 if !(v781.r#type == 13) {
6398 return Err(EncodeError::SwitchMismatch(
6399 "play.clientbound.entity_metadata.metadata.value",
6400 ));
6401 }
6402 (*v803).write(w);
6403 }
6404 types::EntityMetadataValue::Other => {
6405 if !(!((v781.r#type == 0)
6406 || (v781.r#type == 1)
6407 || (v781.r#type == 2)
6408 || (v781.r#type == 3)
6409 || (v781.r#type == 4)
6410 || (v781.r#type == 5)
6411 || (v781.r#type == 6)
6412 || (v781.r#type == 7)
6413 || (v781.r#type == 8)
6414 || (v781.r#type == 9)
6415 || (v781.r#type == 10)
6416 || (v781.r#type == 11)
6417 || (v781.r#type == 12)
6418 || (v781.r#type == 13)))
6419 {
6420 return Err(EncodeError::SwitchMismatch(
6421 "play.clientbound.entity_metadata.metadata.value",
6422 ));
6423 }
6424 }
6425 }
6426 Ok(())
6427 },
6428 |b| b != 255,
6429 ) {
6430 break v781;
6431 }
6432 });
6433 }
6434 v780
6435 };
6436 EntityMetadata {
6437 entity_id: v778,
6438 metadata: v779,
6439 }
6440 }
6441 }
6442}
6443impl From<EntityMetadata> for ClientboundPlayPacket {
6444 fn from(p: EntityMetadata) -> Self {
6445 Self::EntityMetadata(p)
6446 }
6447}
6448
6449#[derive(Debug, Clone, PartialEq)]
6451pub struct AttachEntity {
6452 pub entity_id: i32,
6454 pub vehicle_id: i32,
6456}
6457impl crate::packet::Packet for AttachEntity {
6458 const ID: i32 = id::ATTACH_ENTITY;
6459 const NAME: &'static str = "attach_entity";
6460 const STATE: State = State::Play;
6461 const DIRECTION: Direction = Direction::Clientbound;
6462}
6463impl Decode for AttachEntity {
6464 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6465 Ok({
6466 let v804 = r.read_i32()?;
6467 let v805 = r.read_i32()?;
6468 AttachEntity {
6469 entity_id: v804,
6470 vehicle_id: v805,
6471 }
6472 })
6473 }
6474}
6475impl Encode for AttachEntity {
6476 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6477 w.put_i32((*self).entity_id);
6478 w.put_i32((*self).vehicle_id);
6479 Ok(())
6480 }
6481}
6482#[cfg(feature = "testgen")]
6483impl Generate for AttachEntity {
6484 fn generate(g: &mut Gen) -> Self {
6485 {
6486 let v806 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6487 let v807 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6488 AttachEntity {
6489 entity_id: v806,
6490 vehicle_id: v807,
6491 }
6492 }
6493 }
6494}
6495impl From<AttachEntity> for ClientboundPlayPacket {
6496 fn from(p: AttachEntity) -> Self {
6497 Self::AttachEntity(p)
6498 }
6499}
6500
6501#[derive(Debug, Clone, PartialEq)]
6503pub struct EntityVelocity {
6504 pub entity_id: i32,
6506 pub velocity: types::Vec3i16,
6508}
6509impl crate::packet::Packet for EntityVelocity {
6510 const ID: i32 = id::ENTITY_VELOCITY;
6511 const NAME: &'static str = "entity_velocity";
6512 const STATE: State = State::Play;
6513 const DIRECTION: Direction = Direction::Clientbound;
6514}
6515impl Decode for EntityVelocity {
6516 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6517 Ok({
6518 let v808 = r.read_varint()?;
6519 let v809 = <types::Vec3i16 as Decode>::decode(r)?;
6520 EntityVelocity {
6521 entity_id: v808,
6522 velocity: v809,
6523 }
6524 })
6525 }
6526}
6527impl Encode for EntityVelocity {
6528 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6529 w.put_varint((*self).entity_id);
6530 (*self).velocity.encode(w)?;
6531 Ok(())
6532 }
6533}
6534#[cfg(feature = "testgen")]
6535impl Generate for EntityVelocity {
6536 fn generate(g: &mut Gen) -> Self {
6537 {
6538 let v810 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6539 let v811 = <types::Vec3i16 as Generate>::generate(g);
6540 EntityVelocity {
6541 entity_id: v810,
6542 velocity: v811,
6543 }
6544 }
6545 }
6546}
6547impl From<EntityVelocity> for ClientboundPlayPacket {
6548 fn from(p: EntityVelocity) -> Self {
6549 Self::EntityVelocity(p)
6550 }
6551}
6552
6553#[derive(Debug, Clone, PartialEq)]
6555pub struct EntityEquipment {
6556 pub entity_id: i32,
6558 pub slot: i32,
6560 pub item: types::Slot,
6562}
6563impl crate::packet::Packet for EntityEquipment {
6564 const ID: i32 = id::ENTITY_EQUIPMENT;
6565 const NAME: &'static str = "entity_equipment";
6566 const STATE: State = State::Play;
6567 const DIRECTION: Direction = Direction::Clientbound;
6568}
6569impl Decode for EntityEquipment {
6570 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6571 Ok({
6572 let v812 = r.read_varint()?;
6573 let v813 = r.read_varint()?;
6574 let v814 = <types::Slot as Decode>::decode(r)?;
6575 EntityEquipment {
6576 entity_id: v812,
6577 slot: v813,
6578 item: v814,
6579 }
6580 })
6581 }
6582}
6583impl Encode for EntityEquipment {
6584 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6585 w.put_varint((*self).entity_id);
6586 w.put_varint((*self).slot);
6587 (*self).item.encode(w)?;
6588 Ok(())
6589 }
6590}
6591#[cfg(feature = "testgen")]
6592impl Generate for EntityEquipment {
6593 fn generate(g: &mut Gen) -> Self {
6594 {
6595 let v815 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6596 let v816 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6597 let v817 = <types::Slot as Generate>::generate(g);
6598 EntityEquipment {
6599 entity_id: v815,
6600 slot: v816,
6601 item: v817,
6602 }
6603 }
6604 }
6605}
6606impl From<EntityEquipment> for ClientboundPlayPacket {
6607 fn from(p: EntityEquipment) -> Self {
6608 Self::EntityEquipment(p)
6609 }
6610}
6611
6612#[derive(Debug, Clone, PartialEq)]
6614pub struct Experience {
6615 pub experience_bar: f32,
6617 pub level: i32,
6619 pub total_experience: i32,
6621}
6622impl crate::packet::Packet for Experience {
6623 const ID: i32 = id::EXPERIENCE;
6624 const NAME: &'static str = "experience";
6625 const STATE: State = State::Play;
6626 const DIRECTION: Direction = Direction::Clientbound;
6627}
6628impl Decode for Experience {
6629 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6630 Ok({
6631 let v818 = r.read_f32()?;
6632 let v819 = r.read_varint()?;
6633 let v820 = r.read_varint()?;
6634 Experience {
6635 experience_bar: v818,
6636 level: v819,
6637 total_experience: v820,
6638 }
6639 })
6640 }
6641}
6642impl Encode for Experience {
6643 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6644 w.put_f32((*self).experience_bar);
6645 w.put_varint((*self).level);
6646 w.put_varint((*self).total_experience);
6647 Ok(())
6648 }
6649}
6650#[cfg(feature = "testgen")]
6651impl Generate for Experience {
6652 fn generate(g: &mut Gen) -> Self {
6653 {
6654 let v821 = g.f32();
6655 let v822 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6656 let v823 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6657 Experience {
6658 experience_bar: v821,
6659 level: v822,
6660 total_experience: v823,
6661 }
6662 }
6663 }
6664}
6665impl From<Experience> for ClientboundPlayPacket {
6666 fn from(p: Experience) -> Self {
6667 Self::Experience(p)
6668 }
6669}
6670
6671#[derive(Debug, Clone, PartialEq)]
6673pub struct UpdateHealth {
6674 pub health: f32,
6676 pub food: i32,
6678 pub food_saturation: f32,
6680}
6681impl crate::packet::Packet for UpdateHealth {
6682 const ID: i32 = id::UPDATE_HEALTH;
6683 const NAME: &'static str = "update_health";
6684 const STATE: State = State::Play;
6685 const DIRECTION: Direction = Direction::Clientbound;
6686}
6687impl Decode for UpdateHealth {
6688 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6689 Ok({
6690 let v824 = r.read_f32()?;
6691 let v825 = r.read_varint()?;
6692 let v826 = r.read_f32()?;
6693 UpdateHealth {
6694 health: v824,
6695 food: v825,
6696 food_saturation: v826,
6697 }
6698 })
6699 }
6700}
6701impl Encode for UpdateHealth {
6702 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6703 w.put_f32((*self).health);
6704 w.put_varint((*self).food);
6705 w.put_f32((*self).food_saturation);
6706 Ok(())
6707 }
6708}
6709#[cfg(feature = "testgen")]
6710impl Generate for UpdateHealth {
6711 fn generate(g: &mut Gen) -> Self {
6712 {
6713 let v827 = g.f32();
6714 let v828 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6715 let v829 = g.f32();
6716 UpdateHealth {
6717 health: v827,
6718 food: v828,
6719 food_saturation: v829,
6720 }
6721 }
6722 }
6723}
6724impl From<UpdateHealth> for ClientboundPlayPacket {
6725 fn from(p: UpdateHealth) -> Self {
6726 Self::UpdateHealth(p)
6727 }
6728}
6729
6730#[derive(Debug, Clone, PartialEq)]
6732pub struct ScoreboardObjective {
6733 pub name: ByteString,
6735 pub action: i8,
6737 pub display_text: Option<ByteString>,
6739 pub r#type: Option<ByteString>,
6741}
6742impl crate::packet::Packet for ScoreboardObjective {
6743 const ID: i32 = id::SCOREBOARD_OBJECTIVE;
6744 const NAME: &'static str = "scoreboard_objective";
6745 const STATE: State = State::Play;
6746 const DIRECTION: Direction = Direction::Clientbound;
6747}
6748impl Decode for ScoreboardObjective {
6749 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6750 Ok({
6751 let v830 = r.read_string()?;
6752 let v831 = r.read_i8()?;
6753 let v832 = if (v831 == 0) || (v831 == 2) {
6754 Some(r.read_string()?)
6755 } else {
6756 None
6757 };
6758 let v833 = if (v831 == 0) || (v831 == 2) {
6759 Some(r.read_string()?)
6760 } else {
6761 None
6762 };
6763 ScoreboardObjective {
6764 name: v830,
6765 action: v831,
6766 display_text: v832,
6767 r#type: v833,
6768 }
6769 })
6770 }
6771}
6772impl Encode for ScoreboardObjective {
6773 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6774 w.put_string(&(*self).name)?;
6775 w.put_i8((*self).action);
6776 match (
6777 &(*self).display_text,
6778 ((*self).action == 0) || ((*self).action == 2),
6779 ) {
6780 (Some(v834), true) => {
6781 w.put_string(&(*v834))?;
6782 }
6783 (None, false) => {}
6784 _ => {
6785 return Err(EncodeError::SwitchMismatch(
6786 "play.clientbound.scoreboard_objective.displayText",
6787 ));
6788 }
6789 }
6790 match (
6791 &(*self).r#type,
6792 ((*self).action == 0) || ((*self).action == 2),
6793 ) {
6794 (Some(v835), true) => {
6795 w.put_string(&(*v835))?;
6796 }
6797 (None, false) => {}
6798 _ => {
6799 return Err(EncodeError::SwitchMismatch(
6800 "play.clientbound.scoreboard_objective.type",
6801 ));
6802 }
6803 }
6804 Ok(())
6805 }
6806}
6807#[cfg(feature = "testgen")]
6808impl Generate for ScoreboardObjective {
6809 fn generate(g: &mut Gen) -> Self {
6810 {
6811 let v836 = g.string();
6812 let v837 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
6813 let v838 = if (v837 == 0) || (v837 == 2) {
6814 Some(g.string())
6815 } else {
6816 None
6817 };
6818 let v839 = if (v837 == 0) || (v837 == 2) {
6819 Some(g.string())
6820 } else {
6821 None
6822 };
6823 ScoreboardObjective {
6824 name: v836,
6825 action: v837,
6826 display_text: v838,
6827 r#type: v839,
6828 }
6829 }
6830 }
6831}
6832impl From<ScoreboardObjective> for ClientboundPlayPacket {
6833 fn from(p: ScoreboardObjective) -> Self {
6834 Self::ScoreboardObjective(p)
6835 }
6836}
6837
6838#[derive(Debug, Clone, PartialEq)]
6840pub struct SetPassengers {
6841 pub entity_id: i32,
6843 pub passengers: Vec<i32>,
6845}
6846impl crate::packet::Packet for SetPassengers {
6847 const ID: i32 = id::SET_PASSENGERS;
6848 const NAME: &'static str = "set_passengers";
6849 const STATE: State = State::Play;
6850 const DIRECTION: Direction = Direction::Clientbound;
6851}
6852impl Decode for SetPassengers {
6853 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6854 Ok({
6855 let v840 = r.read_varint()?;
6856 let v841 = {
6857 let v842 = {
6858 let c = r.read_varint()?;
6859 r.check_count(i64::from(c), 1)?
6860 };
6861 let mut v843 = Vec::with_capacity(v842.min(crate::codec::PREALLOC_LIMIT));
6862 for _ in 0..v842 {
6863 v843.push(r.read_varint()?);
6864 }
6865 v843
6866 };
6867 SetPassengers {
6868 entity_id: v840,
6869 passengers: v841,
6870 }
6871 })
6872 }
6873}
6874impl Encode for SetPassengers {
6875 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6876 w.put_varint((*self).entity_id);
6877 w.put_len_varint((*self).passengers.len())?;
6878 for v844 in (*self).passengers.iter() {
6879 w.put_varint((*v844));
6880 }
6881 Ok(())
6882 }
6883}
6884#[cfg(feature = "testgen")]
6885impl Generate for SetPassengers {
6886 fn generate(g: &mut Gen) -> Self {
6887 {
6888 let v845 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6889 let v846 = {
6890 let v847 = g.count();
6891 let mut v848 = Vec::with_capacity(v847.min(crate::codec::PREALLOC_LIMIT));
6892 for _ in 0..v847 {
6893 v848.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
6894 }
6895 v848
6896 };
6897 SetPassengers {
6898 entity_id: v845,
6899 passengers: v846,
6900 }
6901 }
6902 }
6903}
6904impl From<SetPassengers> for ClientboundPlayPacket {
6905 fn from(p: SetPassengers) -> Self {
6906 Self::SetPassengers(p)
6907 }
6908}
6909
6910#[derive(Debug, Clone, PartialEq)]
6912pub struct Teams {
6913 pub team: ByteString,
6915 pub mode: i8,
6917 pub name: Option<ByteString>,
6919 pub prefix: Option<ByteString>,
6921 pub suffix: Option<ByteString>,
6923 pub friendly_fire: Option<i8>,
6925 pub name_tag_visibility: Option<ByteString>,
6927 pub collision_rule: Option<ByteString>,
6929 pub color: Option<i8>,
6931 pub players: Option<Vec<ByteString>>,
6933}
6934impl crate::packet::Packet for Teams {
6935 const ID: i32 = id::TEAMS;
6936 const NAME: &'static str = "teams";
6937 const STATE: State = State::Play;
6938 const DIRECTION: Direction = Direction::Clientbound;
6939}
6940impl Decode for Teams {
6941 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6942 Ok({
6943 let v849 = r.read_string()?;
6944 let v850 = r.read_i8()?;
6945 let v851 = if (v850 == 0) || (v850 == 2) {
6946 Some(r.read_string()?)
6947 } else {
6948 None
6949 };
6950 let v852 = if (v850 == 0) || (v850 == 2) {
6951 Some(r.read_string()?)
6952 } else {
6953 None
6954 };
6955 let v853 = if (v850 == 0) || (v850 == 2) {
6956 Some(r.read_string()?)
6957 } else {
6958 None
6959 };
6960 let v854 = if (v850 == 0) || (v850 == 2) {
6961 Some(r.read_i8()?)
6962 } else {
6963 None
6964 };
6965 let v855 = if (v850 == 0) || (v850 == 2) {
6966 Some(r.read_string()?)
6967 } else {
6968 None
6969 };
6970 let v856 = if (v850 == 0) || (v850 == 2) {
6971 Some(r.read_string()?)
6972 } else {
6973 None
6974 };
6975 let v857 = if (v850 == 0) || (v850 == 2) {
6976 Some(r.read_i8()?)
6977 } else {
6978 None
6979 };
6980 let v858 = if (v850 == 0) || (v850 == 3) || (v850 == 4) {
6981 Some({
6982 let v859 = {
6983 let c = r.read_varint()?;
6984 r.check_count(i64::from(c), 1)?
6985 };
6986 let mut v860 = Vec::with_capacity(v859.min(crate::codec::PREALLOC_LIMIT));
6987 for _ in 0..v859 {
6988 v860.push(r.read_string()?);
6989 }
6990 v860
6991 })
6992 } else {
6993 None
6994 };
6995 Teams {
6996 team: v849,
6997 mode: v850,
6998 name: v851,
6999 prefix: v852,
7000 suffix: v853,
7001 friendly_fire: v854,
7002 name_tag_visibility: v855,
7003 collision_rule: v856,
7004 color: v857,
7005 players: v858,
7006 }
7007 })
7008 }
7009}
7010impl Encode for Teams {
7011 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7012 w.put_string(&(*self).team)?;
7013 w.put_i8((*self).mode);
7014 match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
7015 (Some(v861), true) => {
7016 w.put_string(&(*v861))?;
7017 }
7018 (None, false) => {}
7019 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
7020 }
7021 match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
7022 (Some(v862), true) => {
7023 w.put_string(&(*v862))?;
7024 }
7025 (None, false) => {}
7026 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
7027 }
7028 match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
7029 (Some(v863), true) => {
7030 w.put_string(&(*v863))?;
7031 }
7032 (None, false) => {}
7033 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
7034 }
7035 match (
7036 &(*self).friendly_fire,
7037 ((*self).mode == 0) || ((*self).mode == 2),
7038 ) {
7039 (Some(v864), true) => {
7040 w.put_i8((*v864));
7041 }
7042 (None, false) => {}
7043 _ => {
7044 return Err(EncodeError::SwitchMismatch(
7045 "play.clientbound.teams.friendlyFire",
7046 ));
7047 }
7048 }
7049 match (
7050 &(*self).name_tag_visibility,
7051 ((*self).mode == 0) || ((*self).mode == 2),
7052 ) {
7053 (Some(v865), true) => {
7054 w.put_string(&(*v865))?;
7055 }
7056 (None, false) => {}
7057 _ => {
7058 return Err(EncodeError::SwitchMismatch(
7059 "play.clientbound.teams.nameTagVisibility",
7060 ));
7061 }
7062 }
7063 match (
7064 &(*self).collision_rule,
7065 ((*self).mode == 0) || ((*self).mode == 2),
7066 ) {
7067 (Some(v866), true) => {
7068 w.put_string(&(*v866))?;
7069 }
7070 (None, false) => {}
7071 _ => {
7072 return Err(EncodeError::SwitchMismatch(
7073 "play.clientbound.teams.collisionRule",
7074 ));
7075 }
7076 }
7077 match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
7078 (Some(v867), true) => {
7079 w.put_i8((*v867));
7080 }
7081 (None, false) => {}
7082 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.color")),
7083 }
7084 match (
7085 &(*self).players,
7086 ((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
7087 ) {
7088 (Some(v868), true) => {
7089 w.put_len_varint((*v868).len())?;
7090 for v869 in (*v868).iter() {
7091 w.put_string(&(*v869))?;
7092 }
7093 }
7094 (None, false) => {}
7095 _ => {
7096 return Err(EncodeError::SwitchMismatch(
7097 "play.clientbound.teams.players",
7098 ));
7099 }
7100 }
7101 Ok(())
7102 }
7103}
7104#[cfg(feature = "testgen")]
7105impl Generate for Teams {
7106 fn generate(g: &mut Gen) -> Self {
7107 {
7108 let v870 = g.string();
7109 let v871 = (g.int_in(
7110 -128,
7111 127,
7112 &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4],
7113 ) as i8);
7114 let v872 = if (v871 == 0) || (v871 == 2) {
7115 Some(g.string())
7116 } else {
7117 None
7118 };
7119 let v873 = if (v871 == 0) || (v871 == 2) {
7120 Some(g.string())
7121 } else {
7122 None
7123 };
7124 let v874 = if (v871 == 0) || (v871 == 2) {
7125 Some(g.string())
7126 } else {
7127 None
7128 };
7129 let v875 = if (v871 == 0) || (v871 == 2) {
7130 Some((g.int_in(-128, 127, &[]) as i8))
7131 } else {
7132 None
7133 };
7134 let v876 = if (v871 == 0) || (v871 == 2) {
7135 Some(g.string())
7136 } else {
7137 None
7138 };
7139 let v877 = if (v871 == 0) || (v871 == 2) {
7140 Some(g.string())
7141 } else {
7142 None
7143 };
7144 let v878 = if (v871 == 0) || (v871 == 2) {
7145 Some((g.int_in(-128, 127, &[]) as i8))
7146 } else {
7147 None
7148 };
7149 let v879 = if (v871 == 0) || (v871 == 3) || (v871 == 4) {
7150 Some({
7151 let v880 = g.count();
7152 let mut v881 = Vec::with_capacity(v880.min(crate::codec::PREALLOC_LIMIT));
7153 for _ in 0..v880 {
7154 v881.push(g.string());
7155 }
7156 v881
7157 })
7158 } else {
7159 None
7160 };
7161 Teams {
7162 team: v870,
7163 mode: v871,
7164 name: v872,
7165 prefix: v873,
7166 suffix: v874,
7167 friendly_fire: v875,
7168 name_tag_visibility: v876,
7169 collision_rule: v877,
7170 color: v878,
7171 players: v879,
7172 }
7173 }
7174 }
7175}
7176impl From<Teams> for ClientboundPlayPacket {
7177 fn from(p: Teams) -> Self {
7178 Self::Teams(p)
7179 }
7180}
7181
7182#[derive(Debug, Clone, PartialEq)]
7184pub struct ScoreboardScore {
7185 pub item_name: ByteString,
7187 pub action: i32,
7189 pub score_name: ByteString,
7191 pub value: Option<i32>,
7193}
7194impl crate::packet::Packet for ScoreboardScore {
7195 const ID: i32 = id::SCOREBOARD_SCORE;
7196 const NAME: &'static str = "scoreboard_score";
7197 const STATE: State = State::Play;
7198 const DIRECTION: Direction = Direction::Clientbound;
7199}
7200impl Decode for ScoreboardScore {
7201 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7202 Ok({
7203 let v882 = r.read_string()?;
7204 let v883 = r.read_varint()?;
7205 let v884 = r.read_string()?;
7206 let v885 = if !(v883 == 1) {
7207 Some(r.read_varint()?)
7208 } else {
7209 None
7210 };
7211 ScoreboardScore {
7212 item_name: v882,
7213 action: v883,
7214 score_name: v884,
7215 value: v885,
7216 }
7217 })
7218 }
7219}
7220impl Encode for ScoreboardScore {
7221 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7222 w.put_string(&(*self).item_name)?;
7223 w.put_varint((*self).action);
7224 w.put_string(&(*self).score_name)?;
7225 match (&(*self).value, !((*self).action == 1)) {
7226 (Some(v886), true) => {
7227 w.put_varint((*v886));
7228 }
7229 (None, false) => {}
7230 _ => {
7231 return Err(EncodeError::SwitchMismatch(
7232 "play.clientbound.scoreboard_score.value",
7233 ));
7234 }
7235 }
7236 Ok(())
7237 }
7238}
7239#[cfg(feature = "testgen")]
7240impl Generate for ScoreboardScore {
7241 fn generate(g: &mut Gen) -> Self {
7242 {
7243 let v887 = g.string();
7244 let v888 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
7245 let v889 = g.string();
7246 let v890 = if !(v888 == 1) {
7247 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7248 } else {
7249 None
7250 };
7251 ScoreboardScore {
7252 item_name: v887,
7253 action: v888,
7254 score_name: v889,
7255 value: v890,
7256 }
7257 }
7258 }
7259}
7260impl From<ScoreboardScore> for ClientboundPlayPacket {
7261 fn from(p: ScoreboardScore) -> Self {
7262 Self::ScoreboardScore(p)
7263 }
7264}
7265
7266#[derive(Debug, Clone, PartialEq)]
7268pub struct SpawnPosition {
7269 pub location: BlockPos,
7271}
7272impl crate::packet::Packet for SpawnPosition {
7273 const ID: i32 = id::SPAWN_POSITION;
7274 const NAME: &'static str = "spawn_position";
7275 const STATE: State = State::Play;
7276 const DIRECTION: Direction = Direction::Clientbound;
7277}
7278impl Decode for SpawnPosition {
7279 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7280 Ok({
7281 let v891 = BlockPos::read(r, PositionLayout::Xyz)?;
7282 SpawnPosition { location: v891 }
7283 })
7284 }
7285}
7286impl Encode for SpawnPosition {
7287 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7288 (*self).location.write(w, PositionLayout::Xyz)?;
7289 Ok(())
7290 }
7291}
7292#[cfg(feature = "testgen")]
7293impl Generate for SpawnPosition {
7294 fn generate(g: &mut Gen) -> Self {
7295 {
7296 let v892 = g.position();
7297 SpawnPosition { location: v892 }
7298 }
7299 }
7300}
7301impl From<SpawnPosition> for ClientboundPlayPacket {
7302 fn from(p: SpawnPosition) -> Self {
7303 Self::SpawnPosition(p)
7304 }
7305}
7306
7307#[derive(Debug, Clone, PartialEq)]
7309pub struct UpdateTime {
7310 pub age: i64,
7312 pub time: i64,
7314}
7315impl crate::packet::Packet for UpdateTime {
7316 const ID: i32 = id::UPDATE_TIME;
7317 const NAME: &'static str = "update_time";
7318 const STATE: State = State::Play;
7319 const DIRECTION: Direction = Direction::Clientbound;
7320}
7321impl Decode for UpdateTime {
7322 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7323 Ok({
7324 let v893 = r.read_i64()?;
7325 let v894 = r.read_i64()?;
7326 UpdateTime {
7327 age: v893,
7328 time: v894,
7329 }
7330 })
7331 }
7332}
7333impl Encode for UpdateTime {
7334 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7335 w.put_i64((*self).age);
7336 w.put_i64((*self).time);
7337 Ok(())
7338 }
7339}
7340#[cfg(feature = "testgen")]
7341impl Generate for UpdateTime {
7342 fn generate(g: &mut Gen) -> Self {
7343 {
7344 let v895 = g.i64();
7345 let v896 = g.i64();
7346 UpdateTime {
7347 age: v895,
7348 time: v896,
7349 }
7350 }
7351 }
7352}
7353impl From<UpdateTime> for ClientboundPlayPacket {
7354 fn from(p: UpdateTime) -> Self {
7355 Self::UpdateTime(p)
7356 }
7357}
7358
7359#[derive(Debug, Clone, PartialEq)]
7361pub struct Title {
7362 pub action: i32,
7364 pub text: Option<ByteString>,
7366 pub fade_in: Option<i32>,
7368 pub stay: Option<i32>,
7370 pub fade_out: Option<i32>,
7372}
7373impl crate::packet::Packet for Title {
7374 const ID: i32 = id::TITLE;
7375 const NAME: &'static str = "title";
7376 const STATE: State = State::Play;
7377 const DIRECTION: Direction = Direction::Clientbound;
7378}
7379impl Decode for Title {
7380 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7381 Ok({
7382 let v897 = r.read_varint()?;
7383 let v898 = if (v897 == 0) || (v897 == 1) || (v897 == 2) {
7384 Some(r.read_string()?)
7385 } else {
7386 None
7387 };
7388 let v899 = if (v897 == 3) {
7389 Some(r.read_i32()?)
7390 } else {
7391 None
7392 };
7393 let v900 = if (v897 == 3) {
7394 Some(r.read_i32()?)
7395 } else {
7396 None
7397 };
7398 let v901 = if (v897 == 3) {
7399 Some(r.read_i32()?)
7400 } else {
7401 None
7402 };
7403 Title {
7404 action: v897,
7405 text: v898,
7406 fade_in: v899,
7407 stay: v900,
7408 fade_out: v901,
7409 }
7410 })
7411 }
7412}
7413impl Encode for Title {
7414 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7415 w.put_varint((*self).action);
7416 match (
7417 &(*self).text,
7418 ((*self).action == 0) || ((*self).action == 1) || ((*self).action == 2),
7419 ) {
7420 (Some(v902), true) => {
7421 w.put_string(&(*v902))?;
7422 }
7423 (None, false) => {}
7424 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
7425 }
7426 match (&(*self).fade_in, ((*self).action == 3)) {
7427 (Some(v903), true) => {
7428 w.put_i32((*v903));
7429 }
7430 (None, false) => {}
7431 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
7432 }
7433 match (&(*self).stay, ((*self).action == 3)) {
7434 (Some(v904), true) => {
7435 w.put_i32((*v904));
7436 }
7437 (None, false) => {}
7438 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
7439 }
7440 match (&(*self).fade_out, ((*self).action == 3)) {
7441 (Some(v905), true) => {
7442 w.put_i32((*v905));
7443 }
7444 (None, false) => {}
7445 _ => {
7446 return Err(EncodeError::SwitchMismatch(
7447 "play.clientbound.title.fadeOut",
7448 ));
7449 }
7450 }
7451 Ok(())
7452 }
7453}
7454#[cfg(feature = "testgen")]
7455impl Generate for Title {
7456 fn generate(g: &mut Gen) -> Self {
7457 {
7458 let v906 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 3, 3]) as i32);
7459 let v907 = if (v906 == 0) || (v906 == 1) || (v906 == 2) {
7460 Some(g.string())
7461 } else {
7462 None
7463 };
7464 let v908 = if (v906 == 3) {
7465 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7466 } else {
7467 None
7468 };
7469 let v909 = if (v906 == 3) {
7470 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7471 } else {
7472 None
7473 };
7474 let v910 = if (v906 == 3) {
7475 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7476 } else {
7477 None
7478 };
7479 Title {
7480 action: v906,
7481 text: v907,
7482 fade_in: v908,
7483 stay: v909,
7484 fade_out: v910,
7485 }
7486 }
7487 }
7488}
7489impl From<Title> for ClientboundPlayPacket {
7490 fn from(p: Title) -> Self {
7491 Self::Title(p)
7492 }
7493}
7494
7495#[derive(Debug, Clone, PartialEq)]
7497pub struct SoundEffect {
7498 pub sound_id: i32,
7500 pub sound_category: i32,
7502 pub x: i32,
7504 pub y: i32,
7506 pub z: i32,
7508 pub volume: f32,
7510 pub pitch: f32,
7512}
7513impl crate::packet::Packet for SoundEffect {
7514 const ID: i32 = id::SOUND_EFFECT;
7515 const NAME: &'static str = "sound_effect";
7516 const STATE: State = State::Play;
7517 const DIRECTION: Direction = Direction::Clientbound;
7518}
7519impl Decode for SoundEffect {
7520 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7521 Ok({
7522 let v911 = r.read_varint()?;
7523 let v912 = r.read_varint()?;
7524 let v913 = r.read_i32()?;
7525 let v914 = r.read_i32()?;
7526 let v915 = r.read_i32()?;
7527 let v916 = r.read_f32()?;
7528 let v917 = r.read_f32()?;
7529 SoundEffect {
7530 sound_id: v911,
7531 sound_category: v912,
7532 x: v913,
7533 y: v914,
7534 z: v915,
7535 volume: v916,
7536 pitch: v917,
7537 }
7538 })
7539 }
7540}
7541impl Encode for SoundEffect {
7542 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7543 w.put_varint((*self).sound_id);
7544 w.put_varint((*self).sound_category);
7545 w.put_i32((*self).x);
7546 w.put_i32((*self).y);
7547 w.put_i32((*self).z);
7548 w.put_f32((*self).volume);
7549 w.put_f32((*self).pitch);
7550 Ok(())
7551 }
7552}
7553#[cfg(feature = "testgen")]
7554impl Generate for SoundEffect {
7555 fn generate(g: &mut Gen) -> Self {
7556 {
7557 let v918 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7558 let v919 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7559 let v920 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7560 let v921 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7561 let v922 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7562 let v923 = g.f32();
7563 let v924 = g.f32();
7564 SoundEffect {
7565 sound_id: v918,
7566 sound_category: v919,
7567 x: v920,
7568 y: v921,
7569 z: v922,
7570 volume: v923,
7571 pitch: v924,
7572 }
7573 }
7574 }
7575}
7576impl From<SoundEffect> for ClientboundPlayPacket {
7577 fn from(p: SoundEffect) -> Self {
7578 Self::SoundEffect(p)
7579 }
7580}
7581
7582#[derive(Debug, Clone, PartialEq)]
7584pub struct PlayerlistHeader {
7585 pub header: ByteString,
7587 pub footer: ByteString,
7589}
7590impl crate::packet::Packet for PlayerlistHeader {
7591 const ID: i32 = id::PLAYERLIST_HEADER;
7592 const NAME: &'static str = "playerlist_header";
7593 const STATE: State = State::Play;
7594 const DIRECTION: Direction = Direction::Clientbound;
7595}
7596impl Decode for PlayerlistHeader {
7597 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7598 Ok({
7599 let v925 = r.read_string()?;
7600 let v926 = r.read_string()?;
7601 PlayerlistHeader {
7602 header: v925,
7603 footer: v926,
7604 }
7605 })
7606 }
7607}
7608impl Encode for PlayerlistHeader {
7609 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7610 w.put_string(&(*self).header)?;
7611 w.put_string(&(*self).footer)?;
7612 Ok(())
7613 }
7614}
7615#[cfg(feature = "testgen")]
7616impl Generate for PlayerlistHeader {
7617 fn generate(g: &mut Gen) -> Self {
7618 {
7619 let v927 = g.string();
7620 let v928 = g.string();
7621 PlayerlistHeader {
7622 header: v927,
7623 footer: v928,
7624 }
7625 }
7626 }
7627}
7628impl From<PlayerlistHeader> for ClientboundPlayPacket {
7629 fn from(p: PlayerlistHeader) -> Self {
7630 Self::PlayerlistHeader(p)
7631 }
7632}
7633
7634#[derive(Debug, Clone, PartialEq)]
7636pub struct Collect {
7637 pub collected_entity_id: i32,
7639 pub collector_entity_id: i32,
7641 pub pickup_item_count: i32,
7643}
7644impl crate::packet::Packet for Collect {
7645 const ID: i32 = id::COLLECT;
7646 const NAME: &'static str = "collect";
7647 const STATE: State = State::Play;
7648 const DIRECTION: Direction = Direction::Clientbound;
7649}
7650impl Decode for Collect {
7651 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7652 Ok({
7653 let v929 = r.read_varint()?;
7654 let v930 = r.read_varint()?;
7655 let v931 = r.read_varint()?;
7656 Collect {
7657 collected_entity_id: v929,
7658 collector_entity_id: v930,
7659 pickup_item_count: v931,
7660 }
7661 })
7662 }
7663}
7664impl Encode for Collect {
7665 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7666 w.put_varint((*self).collected_entity_id);
7667 w.put_varint((*self).collector_entity_id);
7668 w.put_varint((*self).pickup_item_count);
7669 Ok(())
7670 }
7671}
7672#[cfg(feature = "testgen")]
7673impl Generate for Collect {
7674 fn generate(g: &mut Gen) -> Self {
7675 {
7676 let v932 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7677 let v933 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7678 let v934 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7679 Collect {
7680 collected_entity_id: v932,
7681 collector_entity_id: v933,
7682 pickup_item_count: v934,
7683 }
7684 }
7685 }
7686}
7687impl From<Collect> for ClientboundPlayPacket {
7688 fn from(p: Collect) -> Self {
7689 Self::Collect(p)
7690 }
7691}
7692
7693#[derive(Debug, Clone, PartialEq)]
7695pub struct EntityTeleport {
7696 pub entity_id: i32,
7698 pub x: f64,
7700 pub y: f64,
7702 pub z: f64,
7704 pub yaw: i8,
7706 pub pitch: i8,
7708 pub on_ground: bool,
7710}
7711impl crate::packet::Packet for EntityTeleport {
7712 const ID: i32 = id::ENTITY_TELEPORT;
7713 const NAME: &'static str = "entity_teleport";
7714 const STATE: State = State::Play;
7715 const DIRECTION: Direction = Direction::Clientbound;
7716}
7717impl Decode for EntityTeleport {
7718 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7719 Ok({
7720 let v935 = r.read_varint()?;
7721 let v936 = r.read_f64()?;
7722 let v937 = r.read_f64()?;
7723 let v938 = r.read_f64()?;
7724 let v939 = r.read_i8()?;
7725 let v940 = r.read_i8()?;
7726 let v941 = r.read_bool()?;
7727 EntityTeleport {
7728 entity_id: v935,
7729 x: v936,
7730 y: v937,
7731 z: v938,
7732 yaw: v939,
7733 pitch: v940,
7734 on_ground: v941,
7735 }
7736 })
7737 }
7738}
7739impl Encode for EntityTeleport {
7740 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7741 w.put_varint((*self).entity_id);
7742 w.put_f64((*self).x);
7743 w.put_f64((*self).y);
7744 w.put_f64((*self).z);
7745 w.put_i8((*self).yaw);
7746 w.put_i8((*self).pitch);
7747 w.put_bool((*self).on_ground);
7748 Ok(())
7749 }
7750}
7751#[cfg(feature = "testgen")]
7752impl Generate for EntityTeleport {
7753 fn generate(g: &mut Gen) -> Self {
7754 {
7755 let v942 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7756 let v943 = g.f64();
7757 let v944 = g.f64();
7758 let v945 = g.f64();
7759 let v946 = (g.int_in(-128, 127, &[]) as i8);
7760 let v947 = (g.int_in(-128, 127, &[]) as i8);
7761 let v948 = g.bool();
7762 EntityTeleport {
7763 entity_id: v942,
7764 x: v943,
7765 y: v944,
7766 z: v945,
7767 yaw: v946,
7768 pitch: v947,
7769 on_ground: v948,
7770 }
7771 }
7772 }
7773}
7774impl From<EntityTeleport> for ClientboundPlayPacket {
7775 fn from(p: EntityTeleport) -> Self {
7776 Self::EntityTeleport(p)
7777 }
7778}
7779
7780#[derive(Debug, Clone, PartialEq)]
7782pub struct Advancements {
7783 pub reset: bool,
7785 pub advancement_mapping: Vec<AdvancementsAdvancementMapping>,
7787 pub identifiers: Vec<ByteString>,
7789 pub progress_mapping: Vec<AdvancementsProgressMapping>,
7791}
7792impl crate::packet::Packet for Advancements {
7793 const ID: i32 = id::ADVANCEMENTS;
7794 const NAME: &'static str = "advancements";
7795 const STATE: State = State::Play;
7796 const DIRECTION: Direction = Direction::Clientbound;
7797}
7798impl Decode for Advancements {
7799 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7800 Ok({
7801 let v949 = r.read_bool()?;
7802 let v950 = {
7803 let v951 = {
7804 let c = r.read_varint()?;
7805 r.check_count(i64::from(c), 5)?
7806 };
7807 let mut v952 = Vec::with_capacity(v951.min(crate::codec::PREALLOC_LIMIT));
7808 for _ in 0..v951 {
7809 v952.push({
7810 let v953 = r.read_string()?;
7811 let v954 = {
7812 let v955 = if r.read_bool()? {
7813 Some(r.read_string()?)
7814 } else {
7815 None
7816 };
7817 let v956 = if r.read_bool()? {
7818 Some({
7819 let v957 = r.read_string()?;
7820 let v958 = r.read_string()?;
7821 let v959 = <types::Slot as Decode>::decode(r)?;
7822 let v960 = r.read_varint()?;
7823 let v961 = {
7824 let v962 = u64::from(r.read_i32()? as u32);
7825 AdvancementsAdvancementMappingValueDisplayDataFlags {
7826 _unused: (((v962 >> 3) & 0x1fffffff) as u32),
7827 hidden: (((v962 >> 2) & 0x1) as u8),
7828 show_toast: (((v962 >> 1) & 0x1) as u8),
7829 has_background_texture: (((v962 >> 0) & 0x1) as u8),
7830 }
7831 };
7832 let v963 = if (v961.has_background_texture == 1) {
7833 Some(r.read_string()?)
7834 } else {
7835 None
7836 };
7837 let v964 = r.read_f32()?;
7838 let v965 = r.read_f32()?;
7839 AdvancementsAdvancementMappingValueDisplayData {
7840 title: v957,
7841 description: v958,
7842 icon: v959,
7843 frame_type: v960,
7844 flags: v961,
7845 background_texture: v963,
7846 x_cord: v964,
7847 y_cord: v965,
7848 }
7849 })
7850 } else {
7851 None
7852 };
7853 let v966 = {
7854 let v967 = {
7855 let c = r.read_varint()?;
7856 r.check_count(i64::from(c), 1)?
7857 };
7858 let mut v968 =
7859 Vec::with_capacity(v967.min(crate::codec::PREALLOC_LIMIT));
7860 for _ in 0..v967 {
7861 v968.push({
7862 let v969 = r.read_string()?;
7863 AdvancementsAdvancementMappingValueCriteria { key: v969 }
7864 });
7865 }
7866 v968
7867 };
7868 let v971 = {
7869 let v972 = {
7870 let c = r.read_varint()?;
7871 r.check_count(i64::from(c), 1)?
7872 };
7873 let mut v973 =
7874 Vec::with_capacity(v972.min(crate::codec::PREALLOC_LIMIT));
7875 for _ in 0..v972 {
7876 v973.push({
7877 let v974 = {
7878 let c = r.read_varint()?;
7879 r.check_count(i64::from(c), 1)?
7880 };
7881 let mut v975 = Vec::with_capacity(
7882 v974.min(crate::codec::PREALLOC_LIMIT),
7883 );
7884 for _ in 0..v974 {
7885 v975.push(r.read_string()?);
7886 }
7887 v975
7888 });
7889 }
7890 v973
7891 };
7892 AdvancementsAdvancementMappingValue {
7893 parent_id: v955,
7894 display_data: v956,
7895 criteria: v966,
7896 requirements: v971,
7897 }
7898 };
7899 AdvancementsAdvancementMapping {
7900 key: v953,
7901 value: v954,
7902 }
7903 });
7904 }
7905 v952
7906 };
7907 let v976 = {
7908 let v977 = {
7909 let c = r.read_varint()?;
7910 r.check_count(i64::from(c), 1)?
7911 };
7912 let mut v978 = Vec::with_capacity(v977.min(crate::codec::PREALLOC_LIMIT));
7913 for _ in 0..v977 {
7914 v978.push(r.read_string()?);
7915 }
7916 v978
7917 };
7918 let v979 = {
7919 let v980 = {
7920 let c = r.read_varint()?;
7921 r.check_count(i64::from(c), 2)?
7922 };
7923 let mut v981 = Vec::with_capacity(v980.min(crate::codec::PREALLOC_LIMIT));
7924 for _ in 0..v980 {
7925 v981.push({
7926 let v982 = r.read_string()?;
7927 let v983 = {
7928 let v984 = {
7929 let c = r.read_varint()?;
7930 r.check_count(i64::from(c), 2)?
7931 };
7932 let mut v985 =
7933 Vec::with_capacity(v984.min(crate::codec::PREALLOC_LIMIT));
7934 for _ in 0..v984 {
7935 v985.push({
7936 let v986 = r.read_string()?;
7937 let v987 = if r.read_bool()? {
7938 Some(r.read_i64()?)
7939 } else {
7940 None
7941 };
7942 AdvancementsProgressMappingValue {
7943 criterion_identifier: v986,
7944 criterion_progress: v987,
7945 }
7946 });
7947 }
7948 v985
7949 };
7950 AdvancementsProgressMapping {
7951 key: v982,
7952 value: v983,
7953 }
7954 });
7955 }
7956 v981
7957 };
7958 Advancements {
7959 reset: v949,
7960 advancement_mapping: v950,
7961 identifiers: v976,
7962 progress_mapping: v979,
7963 }
7964 })
7965 }
7966}
7967impl Encode for Advancements {
7968 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7969 w.put_bool((*self).reset);
7970 w.put_len_varint((*self).advancement_mapping.len())?;
7971 for v988 in (*self).advancement_mapping.iter() {
7972 w.put_string(&(*v988).key)?;
7973 match &(*v988).value.parent_id {
7974 Some(v989) => {
7975 w.put_u8(1);
7976 w.put_string(&(*v989))?;
7977 }
7978 None => w.put_u8(0),
7979 }
7980 match &(*v988).value.display_data {
7981 Some(v990) => {
7982 w.put_u8(1);
7983 w.put_string(&(*v990).title)?;
7984 w.put_string(&(*v990).description)?;
7985 (*v990).icon.encode(w)?;
7986 w.put_varint((*v990).frame_type);
7987 {
7988 let mut bits: u64 = 0;
7989 {
7990 let x = i128::from((*v990).flags._unused);
7991 if x < 0 || x > 536870911 {
7992 return Err(EncodeError::OutOfRange("_unused"));
7993 }
7994 bits = (bits << 29) | ((x as u64) & 0x1fffffff);
7995 }
7996 {
7997 let x = i128::from((*v990).flags.hidden);
7998 if x < 0 || x > 1 {
7999 return Err(EncodeError::OutOfRange("hidden"));
8000 }
8001 bits = (bits << 1) | ((x as u64) & 0x1);
8002 }
8003 {
8004 let x = i128::from((*v990).flags.show_toast);
8005 if x < 0 || x > 1 {
8006 return Err(EncodeError::OutOfRange("show_toast"));
8007 }
8008 bits = (bits << 1) | ((x as u64) & 0x1);
8009 }
8010 {
8011 let x = i128::from((*v990).flags.has_background_texture);
8012 if x < 0 || x > 1 {
8013 return Err(EncodeError::OutOfRange("has_background_texture"));
8014 }
8015 bits = (bits << 1) | ((x as u64) & 0x1);
8016 }
8017 w.put_u32(bits as u32);
8018 }
8019 match (
8020 &(*v990).background_texture,
8021 ((*v990).flags.has_background_texture == 1),
8022 ) {
8023 (Some(v991), true) => {
8024 w.put_string(&(*v991))?;
8025 }
8026 (None, false) => {}
8027 _ => {
8028 return Err(EncodeError::SwitchMismatch(
8029 "play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
8030 ));
8031 }
8032 }
8033 w.put_f32((*v990).x_cord);
8034 w.put_f32((*v990).y_cord);
8035 }
8036 None => w.put_u8(0),
8037 }
8038 w.put_len_varint((*v988).value.criteria.len())?;
8039 for v992 in (*v988).value.criteria.iter() {
8040 w.put_string(&(*v992).key)?;
8041 }
8042 w.put_len_varint((*v988).value.requirements.len())?;
8043 for v993 in (*v988).value.requirements.iter() {
8044 w.put_len_varint((*v993).len())?;
8045 for v994 in (*v993).iter() {
8046 w.put_string(&(*v994))?;
8047 }
8048 }
8049 }
8050 w.put_len_varint((*self).identifiers.len())?;
8051 for v995 in (*self).identifiers.iter() {
8052 w.put_string(&(*v995))?;
8053 }
8054 w.put_len_varint((*self).progress_mapping.len())?;
8055 for v996 in (*self).progress_mapping.iter() {
8056 w.put_string(&(*v996).key)?;
8057 w.put_len_varint((*v996).value.len())?;
8058 for v997 in (*v996).value.iter() {
8059 w.put_string(&(*v997).criterion_identifier)?;
8060 match &(*v997).criterion_progress {
8061 Some(v998) => {
8062 w.put_u8(1);
8063 w.put_i64((*v998));
8064 }
8065 None => w.put_u8(0),
8066 }
8067 }
8068 }
8069 Ok(())
8070 }
8071}
8072#[cfg(feature = "testgen")]
8073impl Generate for Advancements {
8074 fn generate(g: &mut Gen) -> Self {
8075 {
8076 let v999 = g.bool();
8077 let v1000 = {
8078 let v1001 = g.count();
8079 let mut v1002 = Vec::with_capacity(v1001.min(crate::codec::PREALLOC_LIMIT));
8080 for _ in 0..v1001 {
8081 v1002.push({
8082 let v1003 = g.string();
8083 let v1004 = {
8084 let v1005 = if g.bool() { Some(g.string()) } else { None };
8085 let v1006 = if g.bool() {
8086 Some({
8087 let v1007 = g.string();
8088 let v1008 = g.string();
8089 let v1009 = <types::Slot as Generate>::generate(g);
8090 let v1010 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8091 let v1011 = {
8092 AdvancementsAdvancementMappingValueDisplayDataFlags {
8093 _unused: (g.int_in(0, 536870911, &[]) as u32),
8094 hidden: (g.int_in(0, 1, &[]) as u8),
8095 show_toast: (g.int_in(0, 1, &[]) as u8),
8096 has_background_texture: (g.int_in(0, 1, &[1]) as u8),
8097 }
8098 };
8099 let v1013 = if (v1011.has_background_texture == 1) {
8100 Some(g.string())
8101 } else {
8102 None
8103 };
8104 let v1014 = g.f32();
8105 let v1015 = g.f32();
8106 AdvancementsAdvancementMappingValueDisplayData {
8107 title: v1007,
8108 description: v1008,
8109 icon: v1009,
8110 frame_type: v1010,
8111 flags: v1011,
8112 background_texture: v1013,
8113 x_cord: v1014,
8114 y_cord: v1015,
8115 }
8116 })
8117 } else {
8118 None
8119 };
8120 let v1016 = {
8121 let v1017 = g.count();
8122 let mut v1018 =
8123 Vec::with_capacity(v1017.min(crate::codec::PREALLOC_LIMIT));
8124 for _ in 0..v1017 {
8125 v1018.push({
8126 let v1019 = g.string();
8127 AdvancementsAdvancementMappingValueCriteria { key: v1019 }
8128 });
8129 }
8130 v1018
8131 };
8132 let v1021 = {
8133 let v1022 = g.count();
8134 let mut v1023 =
8135 Vec::with_capacity(v1022.min(crate::codec::PREALLOC_LIMIT));
8136 for _ in 0..v1022 {
8137 v1023.push({
8138 let v1024 = g.count();
8139 let mut v1025 = Vec::with_capacity(
8140 v1024.min(crate::codec::PREALLOC_LIMIT),
8141 );
8142 for _ in 0..v1024 {
8143 v1025.push(g.string());
8144 }
8145 v1025
8146 });
8147 }
8148 v1023
8149 };
8150 AdvancementsAdvancementMappingValue {
8151 parent_id: v1005,
8152 display_data: v1006,
8153 criteria: v1016,
8154 requirements: v1021,
8155 }
8156 };
8157 AdvancementsAdvancementMapping {
8158 key: v1003,
8159 value: v1004,
8160 }
8161 });
8162 }
8163 v1002
8164 };
8165 let v1026 = {
8166 let v1027 = g.count();
8167 let mut v1028 = Vec::with_capacity(v1027.min(crate::codec::PREALLOC_LIMIT));
8168 for _ in 0..v1027 {
8169 v1028.push(g.string());
8170 }
8171 v1028
8172 };
8173 let v1029 = {
8174 let v1030 = g.count();
8175 let mut v1031 = Vec::with_capacity(v1030.min(crate::codec::PREALLOC_LIMIT));
8176 for _ in 0..v1030 {
8177 v1031.push({
8178 let v1032 = g.string();
8179 let v1033 = {
8180 let v1034 = g.count();
8181 let mut v1035 =
8182 Vec::with_capacity(v1034.min(crate::codec::PREALLOC_LIMIT));
8183 for _ in 0..v1034 {
8184 v1035.push({
8185 let v1036 = g.string();
8186 let v1037 = if g.bool() { Some(g.i64()) } else { None };
8187 AdvancementsProgressMappingValue {
8188 criterion_identifier: v1036,
8189 criterion_progress: v1037,
8190 }
8191 });
8192 }
8193 v1035
8194 };
8195 AdvancementsProgressMapping {
8196 key: v1032,
8197 value: v1033,
8198 }
8199 });
8200 }
8201 v1031
8202 };
8203 Advancements {
8204 reset: v999,
8205 advancement_mapping: v1000,
8206 identifiers: v1026,
8207 progress_mapping: v1029,
8208 }
8209 }
8210 }
8211}
8212impl From<Advancements> for ClientboundPlayPacket {
8213 fn from(p: Advancements) -> Self {
8214 Self::Advancements(p)
8215 }
8216}
8217
8218#[derive(Debug, Clone, PartialEq)]
8220pub struct EntityUpdateAttributes {
8221 pub entity_id: i32,
8223 pub properties: Vec<EntityUpdateAttributesProperties>,
8225}
8226impl crate::packet::Packet for EntityUpdateAttributes {
8227 const ID: i32 = id::ENTITY_UPDATE_ATTRIBUTES;
8228 const NAME: &'static str = "entity_update_attributes";
8229 const STATE: State = State::Play;
8230 const DIRECTION: Direction = Direction::Clientbound;
8231}
8232impl Decode for EntityUpdateAttributes {
8233 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8234 Ok({
8235 let v1038 = r.read_varint()?;
8236 let v1039 = {
8237 let v1040 = {
8238 let c = r.read_i32()?;
8239 r.check_count(i64::from(c), 10)?
8240 };
8241 let mut v1041 = Vec::with_capacity(v1040.min(crate::codec::PREALLOC_LIMIT));
8242 for _ in 0..v1040 {
8243 v1041.push({
8244 let v1042 = r.read_string()?;
8245 let v1043 = r.read_f64()?;
8246 let v1044 = {
8247 let v1045 = {
8248 let c = r.read_varint()?;
8249 r.check_count(i64::from(c), 25)?
8250 };
8251 let mut v1046 =
8252 Vec::with_capacity(v1045.min(crate::codec::PREALLOC_LIMIT));
8253 for _ in 0..v1045 {
8254 v1046.push({
8255 let v1047 = r.read_uuid()?;
8256 let v1048 = r.read_f64()?;
8257 let v1049 = r.read_i8()?;
8258 EntityUpdateAttributesPropertiesModifiers {
8259 uuid: v1047,
8260 amount: v1048,
8261 operation: v1049,
8262 }
8263 });
8264 }
8265 v1046
8266 };
8267 EntityUpdateAttributesProperties {
8268 key: v1042,
8269 value: v1043,
8270 modifiers: v1044,
8271 }
8272 });
8273 }
8274 v1041
8275 };
8276 EntityUpdateAttributes {
8277 entity_id: v1038,
8278 properties: v1039,
8279 }
8280 })
8281 }
8282}
8283impl Encode for EntityUpdateAttributes {
8284 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8285 w.put_varint((*self).entity_id);
8286 w.put_i32(crate::codec::count_i32((*self).properties.len())?);
8287 for v1050 in (*self).properties.iter() {
8288 w.put_string(&(*v1050).key)?;
8289 w.put_f64((*v1050).value);
8290 w.put_len_varint((*v1050).modifiers.len())?;
8291 for v1051 in (*v1050).modifiers.iter() {
8292 w.put_uuid(&(*v1051).uuid);
8293 w.put_f64((*v1051).amount);
8294 w.put_i8((*v1051).operation);
8295 }
8296 }
8297 Ok(())
8298 }
8299}
8300#[cfg(feature = "testgen")]
8301impl Generate for EntityUpdateAttributes {
8302 fn generate(g: &mut Gen) -> Self {
8303 {
8304 let v1052 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8305 let v1053 = {
8306 let v1054 = g.count();
8307 let mut v1055 = Vec::with_capacity(v1054.min(crate::codec::PREALLOC_LIMIT));
8308 for _ in 0..v1054 {
8309 v1055.push({
8310 let v1056 = g.string();
8311 let v1057 = g.f64();
8312 let v1058 = {
8313 let v1059 = g.count();
8314 let mut v1060 =
8315 Vec::with_capacity(v1059.min(crate::codec::PREALLOC_LIMIT));
8316 for _ in 0..v1059 {
8317 v1060.push({
8318 let v1061 = g.uuid();
8319 let v1062 = g.f64();
8320 let v1063 = (g.int_in(-128, 127, &[]) as i8);
8321 EntityUpdateAttributesPropertiesModifiers {
8322 uuid: v1061,
8323 amount: v1062,
8324 operation: v1063,
8325 }
8326 });
8327 }
8328 v1060
8329 };
8330 EntityUpdateAttributesProperties {
8331 key: v1056,
8332 value: v1057,
8333 modifiers: v1058,
8334 }
8335 });
8336 }
8337 v1055
8338 };
8339 EntityUpdateAttributes {
8340 entity_id: v1052,
8341 properties: v1053,
8342 }
8343 }
8344 }
8345}
8346impl From<EntityUpdateAttributes> for ClientboundPlayPacket {
8347 fn from(p: EntityUpdateAttributes) -> Self {
8348 Self::EntityUpdateAttributes(p)
8349 }
8350}
8351
8352#[derive(Debug, Clone, PartialEq)]
8354pub struct EntityEffect {
8355 pub entity_id: i32,
8357 pub effect_id: i8,
8359 pub amplifier: i8,
8361 pub duration: i32,
8363 pub hide_particles: i8,
8365}
8366impl crate::packet::Packet for EntityEffect {
8367 const ID: i32 = id::ENTITY_EFFECT;
8368 const NAME: &'static str = "entity_effect";
8369 const STATE: State = State::Play;
8370 const DIRECTION: Direction = Direction::Clientbound;
8371}
8372impl Decode for EntityEffect {
8373 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8374 Ok({
8375 let v1064 = r.read_varint()?;
8376 let v1065 = r.read_i8()?;
8377 let v1066 = r.read_i8()?;
8378 let v1067 = r.read_varint()?;
8379 let v1068 = r.read_i8()?;
8380 EntityEffect {
8381 entity_id: v1064,
8382 effect_id: v1065,
8383 amplifier: v1066,
8384 duration: v1067,
8385 hide_particles: v1068,
8386 }
8387 })
8388 }
8389}
8390impl Encode for EntityEffect {
8391 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8392 w.put_varint((*self).entity_id);
8393 w.put_i8((*self).effect_id);
8394 w.put_i8((*self).amplifier);
8395 w.put_varint((*self).duration);
8396 w.put_i8((*self).hide_particles);
8397 Ok(())
8398 }
8399}
8400#[cfg(feature = "testgen")]
8401impl Generate for EntityEffect {
8402 fn generate(g: &mut Gen) -> Self {
8403 {
8404 let v1069 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8405 let v1070 = (g.int_in(-128, 127, &[]) as i8);
8406 let v1071 = (g.int_in(-128, 127, &[]) as i8);
8407 let v1072 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8408 let v1073 = (g.int_in(-128, 127, &[]) as i8);
8409 EntityEffect {
8410 entity_id: v1069,
8411 effect_id: v1070,
8412 amplifier: v1071,
8413 duration: v1072,
8414 hide_particles: v1073,
8415 }
8416 }
8417 }
8418}
8419impl From<EntityEffect> for ClientboundPlayPacket {
8420 fn from(p: EntityEffect) -> Self {
8421 Self::EntityEffect(p)
8422 }
8423}
8424
8425#[derive(Debug, Clone, PartialEq)]
8427pub enum ClientboundPlayPacket {
8428 SpawnEntity(SpawnEntity),
8430 SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
8432 SpawnEntityWeather(SpawnEntityWeather),
8434 SpawnEntityLiving(SpawnEntityLiving),
8436 SpawnEntityPainting(SpawnEntityPainting),
8438 NamedEntitySpawn(NamedEntitySpawn),
8440 Animation(Animation),
8442 Statistics(Statistics),
8444 BlockBreakAnimation(BlockBreakAnimation),
8446 TileEntityData(TileEntityData),
8448 BlockAction(BlockAction),
8450 BlockChange(BlockChange),
8452 BossBar(BossBar),
8454 Difficulty(Difficulty),
8456 TabComplete(TabComplete),
8458 Chat(Chat),
8460 MultiBlockChange(MultiBlockChange),
8462 Transaction(Transaction),
8464 CloseWindow(CloseWindow),
8466 OpenWindow(OpenWindow),
8468 WindowItems(WindowItems),
8470 CraftProgressBar(CraftProgressBar),
8472 SetSlot(SetSlot),
8474 SetCooldown(SetCooldown),
8476 CustomPayload(CustomPayload),
8478 NamedSoundEffect(NamedSoundEffect),
8480 KickDisconnect(KickDisconnect),
8482 EntityStatus(EntityStatus),
8484 Explosion(Explosion),
8486 UnloadChunk(UnloadChunk),
8488 GameStateChange(GameStateChange),
8490 KeepAlive(KeepAlive),
8492 MapChunk(MapChunk),
8494 WorldEvent(WorldEvent),
8496 WorldParticles(WorldParticles),
8498 Login(Login),
8500 Map(Map),
8502 Entity(Entity),
8504 RelEntityMove(RelEntityMove),
8506 EntityMoveLook(EntityMoveLook),
8508 EntityLook(EntityLook),
8510 VehicleMove(VehicleMove),
8512 OpenSignEntity(OpenSignEntity),
8514 CraftRecipeResponse(CraftRecipeResponse),
8516 Abilities(Abilities),
8518 CombatEvent(CombatEvent),
8520 PlayerInfo(PlayerInfo),
8522 Position(Position),
8524 Bed(Bed),
8526 UnlockRecipes(UnlockRecipes),
8528 EntityDestroy(EntityDestroy),
8530 RemoveEntityEffect(RemoveEntityEffect),
8532 ResourcePackSend(ResourcePackSend),
8534 Respawn(Respawn),
8536 EntityHeadRotation(EntityHeadRotation),
8538 SelectAdvancementTab(SelectAdvancementTab),
8540 WorldBorder(WorldBorder),
8542 Camera(Camera),
8544 HeldItemSlot(HeldItemSlot),
8546 ScoreboardDisplayObjective(ScoreboardDisplayObjective),
8548 EntityMetadata(EntityMetadata),
8550 AttachEntity(AttachEntity),
8552 EntityVelocity(EntityVelocity),
8554 EntityEquipment(EntityEquipment),
8556 Experience(Experience),
8558 UpdateHealth(UpdateHealth),
8560 ScoreboardObjective(ScoreboardObjective),
8562 SetPassengers(SetPassengers),
8564 Teams(Teams),
8566 ScoreboardScore(ScoreboardScore),
8568 SpawnPosition(SpawnPosition),
8570 UpdateTime(UpdateTime),
8572 Title(Title),
8574 SoundEffect(SoundEffect),
8576 PlayerlistHeader(PlayerlistHeader),
8578 Collect(Collect),
8580 EntityTeleport(EntityTeleport),
8582 Advancements(Advancements),
8584 EntityUpdateAttributes(EntityUpdateAttributes),
8586 EntityEffect(EntityEffect),
8588}
8589
8590impl PacketSet for ClientboundPlayPacket {
8591 const STATE: State = State::Play;
8592 const DIRECTION: Direction = Direction::Clientbound;
8593 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
8594 match raw.id {
8595 id::SPAWN_ENTITY => decode_exact(&raw.body).map(Self::SpawnEntity),
8596 id::SPAWN_ENTITY_EXPERIENCE_ORB => {
8597 decode_exact(&raw.body).map(Self::SpawnEntityExperienceOrb)
8598 }
8599 id::SPAWN_ENTITY_WEATHER => decode_exact(&raw.body).map(Self::SpawnEntityWeather),
8600 id::SPAWN_ENTITY_LIVING => decode_exact(&raw.body).map(Self::SpawnEntityLiving),
8601 id::SPAWN_ENTITY_PAINTING => decode_exact(&raw.body).map(Self::SpawnEntityPainting),
8602 id::NAMED_ENTITY_SPAWN => decode_exact(&raw.body).map(Self::NamedEntitySpawn),
8603 id::ANIMATION => decode_exact(&raw.body).map(Self::Animation),
8604 id::STATISTICS => decode_exact(&raw.body).map(Self::Statistics),
8605 id::BLOCK_BREAK_ANIMATION => decode_exact(&raw.body).map(Self::BlockBreakAnimation),
8606 id::TILE_ENTITY_DATA => decode_exact(&raw.body).map(Self::TileEntityData),
8607 id::BLOCK_ACTION => decode_exact(&raw.body).map(Self::BlockAction),
8608 id::BLOCK_CHANGE => decode_exact(&raw.body).map(Self::BlockChange),
8609 id::BOSS_BAR => decode_exact(&raw.body).map(Self::BossBar),
8610 id::DIFFICULTY => decode_exact(&raw.body).map(Self::Difficulty),
8611 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
8612 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
8613 id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
8614 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
8615 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
8616 id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
8617 id::WINDOW_ITEMS => decode_exact(&raw.body).map(Self::WindowItems),
8618 id::CRAFT_PROGRESS_BAR => decode_exact(&raw.body).map(Self::CraftProgressBar),
8619 id::SET_SLOT => decode_exact(&raw.body).map(Self::SetSlot),
8620 id::SET_COOLDOWN => decode_exact(&raw.body).map(Self::SetCooldown),
8621 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
8622 id::NAMED_SOUND_EFFECT => decode_exact(&raw.body).map(Self::NamedSoundEffect),
8623 id::KICK_DISCONNECT => decode_exact(&raw.body).map(Self::KickDisconnect),
8624 id::ENTITY_STATUS => decode_exact(&raw.body).map(Self::EntityStatus),
8625 id::EXPLOSION => decode_exact(&raw.body).map(Self::Explosion),
8626 id::UNLOAD_CHUNK => decode_exact(&raw.body).map(Self::UnloadChunk),
8627 id::GAME_STATE_CHANGE => decode_exact(&raw.body).map(Self::GameStateChange),
8628 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
8629 id::MAP_CHUNK => decode_exact(&raw.body).map(Self::MapChunk),
8630 id::WORLD_EVENT => decode_exact(&raw.body).map(Self::WorldEvent),
8631 id::WORLD_PARTICLES => decode_exact(&raw.body).map(Self::WorldParticles),
8632 id::LOGIN => decode_exact(&raw.body).map(Self::Login),
8633 id::MAP => decode_exact(&raw.body).map(Self::Map),
8634 id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
8635 id::REL_ENTITY_MOVE => decode_exact(&raw.body).map(Self::RelEntityMove),
8636 id::ENTITY_MOVE_LOOK => decode_exact(&raw.body).map(Self::EntityMoveLook),
8637 id::ENTITY_LOOK => decode_exact(&raw.body).map(Self::EntityLook),
8638 id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
8639 id::OPEN_SIGN_ENTITY => decode_exact(&raw.body).map(Self::OpenSignEntity),
8640 id::CRAFT_RECIPE_RESPONSE => decode_exact(&raw.body).map(Self::CraftRecipeResponse),
8641 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
8642 id::COMBAT_EVENT => decode_exact(&raw.body).map(Self::CombatEvent),
8643 id::PLAYER_INFO => decode_exact(&raw.body).map(Self::PlayerInfo),
8644 id::POSITION => decode_exact(&raw.body).map(Self::Position),
8645 id::BED => decode_exact(&raw.body).map(Self::Bed),
8646 id::UNLOCK_RECIPES => decode_exact(&raw.body).map(Self::UnlockRecipes),
8647 id::ENTITY_DESTROY => decode_exact(&raw.body).map(Self::EntityDestroy),
8648 id::REMOVE_ENTITY_EFFECT => decode_exact(&raw.body).map(Self::RemoveEntityEffect),
8649 id::RESOURCE_PACK_SEND => decode_exact(&raw.body).map(Self::ResourcePackSend),
8650 id::RESPAWN => decode_exact(&raw.body).map(Self::Respawn),
8651 id::ENTITY_HEAD_ROTATION => decode_exact(&raw.body).map(Self::EntityHeadRotation),
8652 id::SELECT_ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::SelectAdvancementTab),
8653 id::WORLD_BORDER => decode_exact(&raw.body).map(Self::WorldBorder),
8654 id::CAMERA => decode_exact(&raw.body).map(Self::Camera),
8655 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
8656 id::SCOREBOARD_DISPLAY_OBJECTIVE => {
8657 decode_exact(&raw.body).map(Self::ScoreboardDisplayObjective)
8658 }
8659 id::ENTITY_METADATA => decode_exact(&raw.body).map(Self::EntityMetadata),
8660 id::ATTACH_ENTITY => decode_exact(&raw.body).map(Self::AttachEntity),
8661 id::ENTITY_VELOCITY => decode_exact(&raw.body).map(Self::EntityVelocity),
8662 id::ENTITY_EQUIPMENT => decode_exact(&raw.body).map(Self::EntityEquipment),
8663 id::EXPERIENCE => decode_exact(&raw.body).map(Self::Experience),
8664 id::UPDATE_HEALTH => decode_exact(&raw.body).map(Self::UpdateHealth),
8665 id::SCOREBOARD_OBJECTIVE => decode_exact(&raw.body).map(Self::ScoreboardObjective),
8666 id::SET_PASSENGERS => decode_exact(&raw.body).map(Self::SetPassengers),
8667 id::TEAMS => decode_exact(&raw.body).map(Self::Teams),
8668 id::SCOREBOARD_SCORE => decode_exact(&raw.body).map(Self::ScoreboardScore),
8669 id::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
8670 id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
8671 id::TITLE => decode_exact(&raw.body).map(Self::Title),
8672 id::SOUND_EFFECT => decode_exact(&raw.body).map(Self::SoundEffect),
8673 id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
8674 id::COLLECT => decode_exact(&raw.body).map(Self::Collect),
8675 id::ENTITY_TELEPORT => decode_exact(&raw.body).map(Self::EntityTeleport),
8676 id::ADVANCEMENTS => decode_exact(&raw.body).map(Self::Advancements),
8677 id::ENTITY_UPDATE_ATTRIBUTES => {
8678 decode_exact(&raw.body).map(Self::EntityUpdateAttributes)
8679 }
8680 id::ENTITY_EFFECT => decode_exact(&raw.body).map(Self::EntityEffect),
8681 other => Err(DecodeError::UnknownPacketId(other)),
8682 }
8683 }
8684 fn id(&self) -> i32 {
8685 match *self {
8686 Self::SpawnEntity(_) => id::SPAWN_ENTITY,
8687 Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
8688 Self::SpawnEntityWeather(_) => id::SPAWN_ENTITY_WEATHER,
8689 Self::SpawnEntityLiving(_) => id::SPAWN_ENTITY_LIVING,
8690 Self::SpawnEntityPainting(_) => id::SPAWN_ENTITY_PAINTING,
8691 Self::NamedEntitySpawn(_) => id::NAMED_ENTITY_SPAWN,
8692 Self::Animation(_) => id::ANIMATION,
8693 Self::Statistics(_) => id::STATISTICS,
8694 Self::BlockBreakAnimation(_) => id::BLOCK_BREAK_ANIMATION,
8695 Self::TileEntityData(_) => id::TILE_ENTITY_DATA,
8696 Self::BlockAction(_) => id::BLOCK_ACTION,
8697 Self::BlockChange(_) => id::BLOCK_CHANGE,
8698 Self::BossBar(_) => id::BOSS_BAR,
8699 Self::Difficulty(_) => id::DIFFICULTY,
8700 Self::TabComplete(_) => id::TAB_COMPLETE,
8701 Self::Chat(_) => id::CHAT,
8702 Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
8703 Self::Transaction(_) => id::TRANSACTION,
8704 Self::CloseWindow(_) => id::CLOSE_WINDOW,
8705 Self::OpenWindow(_) => id::OPEN_WINDOW,
8706 Self::WindowItems(_) => id::WINDOW_ITEMS,
8707 Self::CraftProgressBar(_) => id::CRAFT_PROGRESS_BAR,
8708 Self::SetSlot(_) => id::SET_SLOT,
8709 Self::SetCooldown(_) => id::SET_COOLDOWN,
8710 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
8711 Self::NamedSoundEffect(_) => id::NAMED_SOUND_EFFECT,
8712 Self::KickDisconnect(_) => id::KICK_DISCONNECT,
8713 Self::EntityStatus(_) => id::ENTITY_STATUS,
8714 Self::Explosion(_) => id::EXPLOSION,
8715 Self::UnloadChunk(_) => id::UNLOAD_CHUNK,
8716 Self::GameStateChange(_) => id::GAME_STATE_CHANGE,
8717 Self::KeepAlive(_) => id::KEEP_ALIVE,
8718 Self::MapChunk(_) => id::MAP_CHUNK,
8719 Self::WorldEvent(_) => id::WORLD_EVENT,
8720 Self::WorldParticles(_) => id::WORLD_PARTICLES,
8721 Self::Login(_) => id::LOGIN,
8722 Self::Map(_) => id::MAP,
8723 Self::Entity(_) => id::ENTITY,
8724 Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
8725 Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
8726 Self::EntityLook(_) => id::ENTITY_LOOK,
8727 Self::VehicleMove(_) => id::VEHICLE_MOVE,
8728 Self::OpenSignEntity(_) => id::OPEN_SIGN_ENTITY,
8729 Self::CraftRecipeResponse(_) => id::CRAFT_RECIPE_RESPONSE,
8730 Self::Abilities(_) => id::ABILITIES,
8731 Self::CombatEvent(_) => id::COMBAT_EVENT,
8732 Self::PlayerInfo(_) => id::PLAYER_INFO,
8733 Self::Position(_) => id::POSITION,
8734 Self::Bed(_) => id::BED,
8735 Self::UnlockRecipes(_) => id::UNLOCK_RECIPES,
8736 Self::EntityDestroy(_) => id::ENTITY_DESTROY,
8737 Self::RemoveEntityEffect(_) => id::REMOVE_ENTITY_EFFECT,
8738 Self::ResourcePackSend(_) => id::RESOURCE_PACK_SEND,
8739 Self::Respawn(_) => id::RESPAWN,
8740 Self::EntityHeadRotation(_) => id::ENTITY_HEAD_ROTATION,
8741 Self::SelectAdvancementTab(_) => id::SELECT_ADVANCEMENT_TAB,
8742 Self::WorldBorder(_) => id::WORLD_BORDER,
8743 Self::Camera(_) => id::CAMERA,
8744 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
8745 Self::ScoreboardDisplayObjective(_) => id::SCOREBOARD_DISPLAY_OBJECTIVE,
8746 Self::EntityMetadata(_) => id::ENTITY_METADATA,
8747 Self::AttachEntity(_) => id::ATTACH_ENTITY,
8748 Self::EntityVelocity(_) => id::ENTITY_VELOCITY,
8749 Self::EntityEquipment(_) => id::ENTITY_EQUIPMENT,
8750 Self::Experience(_) => id::EXPERIENCE,
8751 Self::UpdateHealth(_) => id::UPDATE_HEALTH,
8752 Self::ScoreboardObjective(_) => id::SCOREBOARD_OBJECTIVE,
8753 Self::SetPassengers(_) => id::SET_PASSENGERS,
8754 Self::Teams(_) => id::TEAMS,
8755 Self::ScoreboardScore(_) => id::SCOREBOARD_SCORE,
8756 Self::SpawnPosition(_) => id::SPAWN_POSITION,
8757 Self::UpdateTime(_) => id::UPDATE_TIME,
8758 Self::Title(_) => id::TITLE,
8759 Self::SoundEffect(_) => id::SOUND_EFFECT,
8760 Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
8761 Self::Collect(_) => id::COLLECT,
8762 Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
8763 Self::Advancements(_) => id::ADVANCEMENTS,
8764 Self::EntityUpdateAttributes(_) => id::ENTITY_UPDATE_ATTRIBUTES,
8765 Self::EntityEffect(_) => id::ENTITY_EFFECT,
8766 }
8767 }
8768 fn name(&self) -> &'static str {
8769 match *self {
8770 Self::SpawnEntity(_) => "spawn_entity",
8771 Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
8772 Self::SpawnEntityWeather(_) => "spawn_entity_weather",
8773 Self::SpawnEntityLiving(_) => "spawn_entity_living",
8774 Self::SpawnEntityPainting(_) => "spawn_entity_painting",
8775 Self::NamedEntitySpawn(_) => "named_entity_spawn",
8776 Self::Animation(_) => "animation",
8777 Self::Statistics(_) => "statistics",
8778 Self::BlockBreakAnimation(_) => "block_break_animation",
8779 Self::TileEntityData(_) => "tile_entity_data",
8780 Self::BlockAction(_) => "block_action",
8781 Self::BlockChange(_) => "block_change",
8782 Self::BossBar(_) => "boss_bar",
8783 Self::Difficulty(_) => "difficulty",
8784 Self::TabComplete(_) => "tab_complete",
8785 Self::Chat(_) => "chat",
8786 Self::MultiBlockChange(_) => "multi_block_change",
8787 Self::Transaction(_) => "transaction",
8788 Self::CloseWindow(_) => "close_window",
8789 Self::OpenWindow(_) => "open_window",
8790 Self::WindowItems(_) => "window_items",
8791 Self::CraftProgressBar(_) => "craft_progress_bar",
8792 Self::SetSlot(_) => "set_slot",
8793 Self::SetCooldown(_) => "set_cooldown",
8794 Self::CustomPayload(_) => "custom_payload",
8795 Self::NamedSoundEffect(_) => "named_sound_effect",
8796 Self::KickDisconnect(_) => "kick_disconnect",
8797 Self::EntityStatus(_) => "entity_status",
8798 Self::Explosion(_) => "explosion",
8799 Self::UnloadChunk(_) => "unload_chunk",
8800 Self::GameStateChange(_) => "game_state_change",
8801 Self::KeepAlive(_) => "keep_alive",
8802 Self::MapChunk(_) => "map_chunk",
8803 Self::WorldEvent(_) => "world_event",
8804 Self::WorldParticles(_) => "world_particles",
8805 Self::Login(_) => "login",
8806 Self::Map(_) => "map",
8807 Self::Entity(_) => "entity",
8808 Self::RelEntityMove(_) => "rel_entity_move",
8809 Self::EntityMoveLook(_) => "entity_move_look",
8810 Self::EntityLook(_) => "entity_look",
8811 Self::VehicleMove(_) => "vehicle_move",
8812 Self::OpenSignEntity(_) => "open_sign_entity",
8813 Self::CraftRecipeResponse(_) => "craft_recipe_response",
8814 Self::Abilities(_) => "abilities",
8815 Self::CombatEvent(_) => "combat_event",
8816 Self::PlayerInfo(_) => "player_info",
8817 Self::Position(_) => "position",
8818 Self::Bed(_) => "bed",
8819 Self::UnlockRecipes(_) => "unlock_recipes",
8820 Self::EntityDestroy(_) => "entity_destroy",
8821 Self::RemoveEntityEffect(_) => "remove_entity_effect",
8822 Self::ResourcePackSend(_) => "resource_pack_send",
8823 Self::Respawn(_) => "respawn",
8824 Self::EntityHeadRotation(_) => "entity_head_rotation",
8825 Self::SelectAdvancementTab(_) => "select_advancement_tab",
8826 Self::WorldBorder(_) => "world_border",
8827 Self::Camera(_) => "camera",
8828 Self::HeldItemSlot(_) => "held_item_slot",
8829 Self::ScoreboardDisplayObjective(_) => "scoreboard_display_objective",
8830 Self::EntityMetadata(_) => "entity_metadata",
8831 Self::AttachEntity(_) => "attach_entity",
8832 Self::EntityVelocity(_) => "entity_velocity",
8833 Self::EntityEquipment(_) => "entity_equipment",
8834 Self::Experience(_) => "experience",
8835 Self::UpdateHealth(_) => "update_health",
8836 Self::ScoreboardObjective(_) => "scoreboard_objective",
8837 Self::SetPassengers(_) => "set_passengers",
8838 Self::Teams(_) => "teams",
8839 Self::ScoreboardScore(_) => "scoreboard_score",
8840 Self::SpawnPosition(_) => "spawn_position",
8841 Self::UpdateTime(_) => "update_time",
8842 Self::Title(_) => "title",
8843 Self::SoundEffect(_) => "sound_effect",
8844 Self::PlayerlistHeader(_) => "playerlist_header",
8845 Self::Collect(_) => "collect",
8846 Self::EntityTeleport(_) => "entity_teleport",
8847 Self::Advancements(_) => "advancements",
8848 Self::EntityUpdateAttributes(_) => "entity_update_attributes",
8849 Self::EntityEffect(_) => "entity_effect",
8850 }
8851 }
8852 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
8853 match *self {
8854 Self::SpawnEntity(ref p) => p.encode(w),
8855 Self::SpawnEntityExperienceOrb(ref p) => p.encode(w),
8856 Self::SpawnEntityWeather(ref p) => p.encode(w),
8857 Self::SpawnEntityLiving(ref p) => p.encode(w),
8858 Self::SpawnEntityPainting(ref p) => p.encode(w),
8859 Self::NamedEntitySpawn(ref p) => p.encode(w),
8860 Self::Animation(ref p) => p.encode(w),
8861 Self::Statistics(ref p) => p.encode(w),
8862 Self::BlockBreakAnimation(ref p) => p.encode(w),
8863 Self::TileEntityData(ref p) => p.encode(w),
8864 Self::BlockAction(ref p) => p.encode(w),
8865 Self::BlockChange(ref p) => p.encode(w),
8866 Self::BossBar(ref p) => p.encode(w),
8867 Self::Difficulty(ref p) => p.encode(w),
8868 Self::TabComplete(ref p) => p.encode(w),
8869 Self::Chat(ref p) => p.encode(w),
8870 Self::MultiBlockChange(ref p) => p.encode(w),
8871 Self::Transaction(ref p) => p.encode(w),
8872 Self::CloseWindow(ref p) => p.encode(w),
8873 Self::OpenWindow(ref p) => p.encode(w),
8874 Self::WindowItems(ref p) => p.encode(w),
8875 Self::CraftProgressBar(ref p) => p.encode(w),
8876 Self::SetSlot(ref p) => p.encode(w),
8877 Self::SetCooldown(ref p) => p.encode(w),
8878 Self::CustomPayload(ref p) => p.encode(w),
8879 Self::NamedSoundEffect(ref p) => p.encode(w),
8880 Self::KickDisconnect(ref p) => p.encode(w),
8881 Self::EntityStatus(ref p) => p.encode(w),
8882 Self::Explosion(ref p) => p.encode(w),
8883 Self::UnloadChunk(ref p) => p.encode(w),
8884 Self::GameStateChange(ref p) => p.encode(w),
8885 Self::KeepAlive(ref p) => p.encode(w),
8886 Self::MapChunk(ref p) => p.encode(w),
8887 Self::WorldEvent(ref p) => p.encode(w),
8888 Self::WorldParticles(ref p) => p.encode(w),
8889 Self::Login(ref p) => p.encode(w),
8890 Self::Map(ref p) => p.encode(w),
8891 Self::Entity(ref p) => p.encode(w),
8892 Self::RelEntityMove(ref p) => p.encode(w),
8893 Self::EntityMoveLook(ref p) => p.encode(w),
8894 Self::EntityLook(ref p) => p.encode(w),
8895 Self::VehicleMove(ref p) => p.encode(w),
8896 Self::OpenSignEntity(ref p) => p.encode(w),
8897 Self::CraftRecipeResponse(ref p) => p.encode(w),
8898 Self::Abilities(ref p) => p.encode(w),
8899 Self::CombatEvent(ref p) => p.encode(w),
8900 Self::PlayerInfo(ref p) => p.encode(w),
8901 Self::Position(ref p) => p.encode(w),
8902 Self::Bed(ref p) => p.encode(w),
8903 Self::UnlockRecipes(ref p) => p.encode(w),
8904 Self::EntityDestroy(ref p) => p.encode(w),
8905 Self::RemoveEntityEffect(ref p) => p.encode(w),
8906 Self::ResourcePackSend(ref p) => p.encode(w),
8907 Self::Respawn(ref p) => p.encode(w),
8908 Self::EntityHeadRotation(ref p) => p.encode(w),
8909 Self::SelectAdvancementTab(ref p) => p.encode(w),
8910 Self::WorldBorder(ref p) => p.encode(w),
8911 Self::Camera(ref p) => p.encode(w),
8912 Self::HeldItemSlot(ref p) => p.encode(w),
8913 Self::ScoreboardDisplayObjective(ref p) => p.encode(w),
8914 Self::EntityMetadata(ref p) => p.encode(w),
8915 Self::AttachEntity(ref p) => p.encode(w),
8916 Self::EntityVelocity(ref p) => p.encode(w),
8917 Self::EntityEquipment(ref p) => p.encode(w),
8918 Self::Experience(ref p) => p.encode(w),
8919 Self::UpdateHealth(ref p) => p.encode(w),
8920 Self::ScoreboardObjective(ref p) => p.encode(w),
8921 Self::SetPassengers(ref p) => p.encode(w),
8922 Self::Teams(ref p) => p.encode(w),
8923 Self::ScoreboardScore(ref p) => p.encode(w),
8924 Self::SpawnPosition(ref p) => p.encode(w),
8925 Self::UpdateTime(ref p) => p.encode(w),
8926 Self::Title(ref p) => p.encode(w),
8927 Self::SoundEffect(ref p) => p.encode(w),
8928 Self::PlayerlistHeader(ref p) => p.encode(w),
8929 Self::Collect(ref p) => p.encode(w),
8930 Self::EntityTeleport(ref p) => p.encode(w),
8931 Self::Advancements(ref p) => p.encode(w),
8932 Self::EntityUpdateAttributes(ref p) => p.encode(w),
8933 Self::EntityEffect(ref p) => p.encode(w),
8934 }
8935 }
8936 fn name_of(id: i32) -> Option<&'static str> {
8937 match id {
8938 id::SPAWN_ENTITY => Some("spawn_entity"),
8939 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some("spawn_entity_experience_orb"),
8940 id::SPAWN_ENTITY_WEATHER => Some("spawn_entity_weather"),
8941 id::SPAWN_ENTITY_LIVING => Some("spawn_entity_living"),
8942 id::SPAWN_ENTITY_PAINTING => Some("spawn_entity_painting"),
8943 id::NAMED_ENTITY_SPAWN => Some("named_entity_spawn"),
8944 id::ANIMATION => Some("animation"),
8945 id::STATISTICS => Some("statistics"),
8946 id::BLOCK_BREAK_ANIMATION => Some("block_break_animation"),
8947 id::TILE_ENTITY_DATA => Some("tile_entity_data"),
8948 id::BLOCK_ACTION => Some("block_action"),
8949 id::BLOCK_CHANGE => Some("block_change"),
8950 id::BOSS_BAR => Some("boss_bar"),
8951 id::DIFFICULTY => Some("difficulty"),
8952 id::TAB_COMPLETE => Some("tab_complete"),
8953 id::CHAT => Some("chat"),
8954 id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
8955 id::TRANSACTION => Some("transaction"),
8956 id::CLOSE_WINDOW => Some("close_window"),
8957 id::OPEN_WINDOW => Some("open_window"),
8958 id::WINDOW_ITEMS => Some("window_items"),
8959 id::CRAFT_PROGRESS_BAR => Some("craft_progress_bar"),
8960 id::SET_SLOT => Some("set_slot"),
8961 id::SET_COOLDOWN => Some("set_cooldown"),
8962 id::CUSTOM_PAYLOAD => Some("custom_payload"),
8963 id::NAMED_SOUND_EFFECT => Some("named_sound_effect"),
8964 id::KICK_DISCONNECT => Some("kick_disconnect"),
8965 id::ENTITY_STATUS => Some("entity_status"),
8966 id::EXPLOSION => Some("explosion"),
8967 id::UNLOAD_CHUNK => Some("unload_chunk"),
8968 id::GAME_STATE_CHANGE => Some("game_state_change"),
8969 id::KEEP_ALIVE => Some("keep_alive"),
8970 id::MAP_CHUNK => Some("map_chunk"),
8971 id::WORLD_EVENT => Some("world_event"),
8972 id::WORLD_PARTICLES => Some("world_particles"),
8973 id::LOGIN => Some("login"),
8974 id::MAP => Some("map"),
8975 id::ENTITY => Some("entity"),
8976 id::REL_ENTITY_MOVE => Some("rel_entity_move"),
8977 id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
8978 id::ENTITY_LOOK => Some("entity_look"),
8979 id::VEHICLE_MOVE => Some("vehicle_move"),
8980 id::OPEN_SIGN_ENTITY => Some("open_sign_entity"),
8981 id::CRAFT_RECIPE_RESPONSE => Some("craft_recipe_response"),
8982 id::ABILITIES => Some("abilities"),
8983 id::COMBAT_EVENT => Some("combat_event"),
8984 id::PLAYER_INFO => Some("player_info"),
8985 id::POSITION => Some("position"),
8986 id::BED => Some("bed"),
8987 id::UNLOCK_RECIPES => Some("unlock_recipes"),
8988 id::ENTITY_DESTROY => Some("entity_destroy"),
8989 id::REMOVE_ENTITY_EFFECT => Some("remove_entity_effect"),
8990 id::RESOURCE_PACK_SEND => Some("resource_pack_send"),
8991 id::RESPAWN => Some("respawn"),
8992 id::ENTITY_HEAD_ROTATION => Some("entity_head_rotation"),
8993 id::SELECT_ADVANCEMENT_TAB => Some("select_advancement_tab"),
8994 id::WORLD_BORDER => Some("world_border"),
8995 id::CAMERA => Some("camera"),
8996 id::HELD_ITEM_SLOT => Some("held_item_slot"),
8997 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some("scoreboard_display_objective"),
8998 id::ENTITY_METADATA => Some("entity_metadata"),
8999 id::ATTACH_ENTITY => Some("attach_entity"),
9000 id::ENTITY_VELOCITY => Some("entity_velocity"),
9001 id::ENTITY_EQUIPMENT => Some("entity_equipment"),
9002 id::EXPERIENCE => Some("experience"),
9003 id::UPDATE_HEALTH => Some("update_health"),
9004 id::SCOREBOARD_OBJECTIVE => Some("scoreboard_objective"),
9005 id::SET_PASSENGERS => Some("set_passengers"),
9006 id::TEAMS => Some("teams"),
9007 id::SCOREBOARD_SCORE => Some("scoreboard_score"),
9008 id::SPAWN_POSITION => Some("spawn_position"),
9009 id::UPDATE_TIME => Some("update_time"),
9010 id::TITLE => Some("title"),
9011 id::SOUND_EFFECT => Some("sound_effect"),
9012 id::PLAYERLIST_HEADER => Some("playerlist_header"),
9013 id::COLLECT => Some("collect"),
9014 id::ENTITY_TELEPORT => Some("entity_teleport"),
9015 id::ADVANCEMENTS => Some("advancements"),
9016 id::ENTITY_UPDATE_ATTRIBUTES => Some("entity_update_attributes"),
9017 id::ENTITY_EFFECT => Some("entity_effect"),
9018 _ => None,
9019 }
9020 }
9021}
9022
9023impl ClientboundPlayPacket {
9024 pub const IDS: &'static [i32] = &[
9026 id::SPAWN_ENTITY,
9027 id::SPAWN_ENTITY_EXPERIENCE_ORB,
9028 id::SPAWN_ENTITY_WEATHER,
9029 id::SPAWN_ENTITY_LIVING,
9030 id::SPAWN_ENTITY_PAINTING,
9031 id::NAMED_ENTITY_SPAWN,
9032 id::ANIMATION,
9033 id::STATISTICS,
9034 id::BLOCK_BREAK_ANIMATION,
9035 id::TILE_ENTITY_DATA,
9036 id::BLOCK_ACTION,
9037 id::BLOCK_CHANGE,
9038 id::BOSS_BAR,
9039 id::DIFFICULTY,
9040 id::TAB_COMPLETE,
9041 id::CHAT,
9042 id::MULTI_BLOCK_CHANGE,
9043 id::TRANSACTION,
9044 id::CLOSE_WINDOW,
9045 id::OPEN_WINDOW,
9046 id::WINDOW_ITEMS,
9047 id::CRAFT_PROGRESS_BAR,
9048 id::SET_SLOT,
9049 id::SET_COOLDOWN,
9050 id::CUSTOM_PAYLOAD,
9051 id::NAMED_SOUND_EFFECT,
9052 id::KICK_DISCONNECT,
9053 id::ENTITY_STATUS,
9054 id::EXPLOSION,
9055 id::UNLOAD_CHUNK,
9056 id::GAME_STATE_CHANGE,
9057 id::KEEP_ALIVE,
9058 id::MAP_CHUNK,
9059 id::WORLD_EVENT,
9060 id::WORLD_PARTICLES,
9061 id::LOGIN,
9062 id::MAP,
9063 id::ENTITY,
9064 id::REL_ENTITY_MOVE,
9065 id::ENTITY_MOVE_LOOK,
9066 id::ENTITY_LOOK,
9067 id::VEHICLE_MOVE,
9068 id::OPEN_SIGN_ENTITY,
9069 id::CRAFT_RECIPE_RESPONSE,
9070 id::ABILITIES,
9071 id::COMBAT_EVENT,
9072 id::PLAYER_INFO,
9073 id::POSITION,
9074 id::BED,
9075 id::UNLOCK_RECIPES,
9076 id::ENTITY_DESTROY,
9077 id::REMOVE_ENTITY_EFFECT,
9078 id::RESOURCE_PACK_SEND,
9079 id::RESPAWN,
9080 id::ENTITY_HEAD_ROTATION,
9081 id::SELECT_ADVANCEMENT_TAB,
9082 id::WORLD_BORDER,
9083 id::CAMERA,
9084 id::HELD_ITEM_SLOT,
9085 id::SCOREBOARD_DISPLAY_OBJECTIVE,
9086 id::ENTITY_METADATA,
9087 id::ATTACH_ENTITY,
9088 id::ENTITY_VELOCITY,
9089 id::ENTITY_EQUIPMENT,
9090 id::EXPERIENCE,
9091 id::UPDATE_HEALTH,
9092 id::SCOREBOARD_OBJECTIVE,
9093 id::SET_PASSENGERS,
9094 id::TEAMS,
9095 id::SCOREBOARD_SCORE,
9096 id::SPAWN_POSITION,
9097 id::UPDATE_TIME,
9098 id::TITLE,
9099 id::SOUND_EFFECT,
9100 id::PLAYERLIST_HEADER,
9101 id::COLLECT,
9102 id::ENTITY_TELEPORT,
9103 id::ADVANCEMENTS,
9104 id::ENTITY_UPDATE_ATTRIBUTES,
9105 id::ENTITY_EFFECT,
9106 ];
9107 #[cfg(feature = "testgen")]
9109 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
9110 match id {
9111 id::SPAWN_ENTITY => Some(Self::SpawnEntity(<SpawnEntity as Generate>::generate(g))),
9112 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some(Self::SpawnEntityExperienceOrb(
9113 <SpawnEntityExperienceOrb as Generate>::generate(g),
9114 )),
9115 id::SPAWN_ENTITY_WEATHER => Some(Self::SpawnEntityWeather(
9116 <SpawnEntityWeather as Generate>::generate(g),
9117 )),
9118 id::SPAWN_ENTITY_LIVING => Some(Self::SpawnEntityLiving(
9119 <SpawnEntityLiving as Generate>::generate(g),
9120 )),
9121 id::SPAWN_ENTITY_PAINTING => Some(Self::SpawnEntityPainting(
9122 <SpawnEntityPainting as Generate>::generate(g),
9123 )),
9124 id::NAMED_ENTITY_SPAWN => Some(Self::NamedEntitySpawn(
9125 <NamedEntitySpawn as Generate>::generate(g),
9126 )),
9127 id::ANIMATION => Some(Self::Animation(<Animation as Generate>::generate(g))),
9128 id::STATISTICS => Some(Self::Statistics(<Statistics as Generate>::generate(g))),
9129 id::BLOCK_BREAK_ANIMATION => Some(Self::BlockBreakAnimation(
9130 <BlockBreakAnimation as Generate>::generate(g),
9131 )),
9132 id::TILE_ENTITY_DATA => Some(Self::TileEntityData(
9133 <TileEntityData as Generate>::generate(g),
9134 )),
9135 id::BLOCK_ACTION => Some(Self::BlockAction(<BlockAction as Generate>::generate(g))),
9136 id::BLOCK_CHANGE => Some(Self::BlockChange(<BlockChange as Generate>::generate(g))),
9137 id::BOSS_BAR => Some(Self::BossBar(<BossBar as Generate>::generate(g))),
9138 id::DIFFICULTY => Some(Self::Difficulty(<Difficulty as Generate>::generate(g))),
9139 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
9140 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
9141 id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
9142 <MultiBlockChange as Generate>::generate(g),
9143 )),
9144 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
9145 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
9146 id::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow as Generate>::generate(g))),
9147 id::WINDOW_ITEMS => Some(Self::WindowItems(<WindowItems as Generate>::generate(g))),
9148 id::CRAFT_PROGRESS_BAR => Some(Self::CraftProgressBar(
9149 <CraftProgressBar as Generate>::generate(g),
9150 )),
9151 id::SET_SLOT => Some(Self::SetSlot(<SetSlot as Generate>::generate(g))),
9152 id::SET_COOLDOWN => Some(Self::SetCooldown(<SetCooldown as Generate>::generate(g))),
9153 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
9154 g,
9155 ))),
9156 id::NAMED_SOUND_EFFECT => Some(Self::NamedSoundEffect(
9157 <NamedSoundEffect as Generate>::generate(g),
9158 )),
9159 id::KICK_DISCONNECT => Some(Self::KickDisconnect(
9160 <KickDisconnect as Generate>::generate(g),
9161 )),
9162 id::ENTITY_STATUS => Some(Self::EntityStatus(<EntityStatus as Generate>::generate(g))),
9163 id::EXPLOSION => Some(Self::Explosion(<Explosion as Generate>::generate(g))),
9164 id::UNLOAD_CHUNK => Some(Self::UnloadChunk(<UnloadChunk as Generate>::generate(g))),
9165 id::GAME_STATE_CHANGE => Some(Self::GameStateChange(
9166 <GameStateChange as Generate>::generate(g),
9167 )),
9168 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
9169 id::MAP_CHUNK => Some(Self::MapChunk(<MapChunk as Generate>::generate(g))),
9170 id::WORLD_EVENT => Some(Self::WorldEvent(<WorldEvent as Generate>::generate(g))),
9171 id::WORLD_PARTICLES => Some(Self::WorldParticles(
9172 <WorldParticles as Generate>::generate(g),
9173 )),
9174 id::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
9175 id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
9176 id::ENTITY => Some(Self::Entity(<Entity as Generate>::generate(g))),
9177 id::REL_ENTITY_MOVE => Some(Self::RelEntityMove(
9178 <RelEntityMove as Generate>::generate(g),
9179 )),
9180 id::ENTITY_MOVE_LOOK => Some(Self::EntityMoveLook(
9181 <EntityMoveLook as Generate>::generate(g),
9182 )),
9183 id::ENTITY_LOOK => Some(Self::EntityLook(<EntityLook as Generate>::generate(g))),
9184 id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
9185 id::OPEN_SIGN_ENTITY => Some(Self::OpenSignEntity(
9186 <OpenSignEntity as Generate>::generate(g),
9187 )),
9188 id::CRAFT_RECIPE_RESPONSE => Some(Self::CraftRecipeResponse(
9189 <CraftRecipeResponse as Generate>::generate(g),
9190 )),
9191 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
9192 id::COMBAT_EVENT => Some(Self::CombatEvent(<CombatEvent as Generate>::generate(g))),
9193 id::PLAYER_INFO => Some(Self::PlayerInfo(<PlayerInfo as Generate>::generate(g))),
9194 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
9195 id::BED => Some(Self::Bed(<Bed as Generate>::generate(g))),
9196 id::UNLOCK_RECIPES => Some(Self::UnlockRecipes(<UnlockRecipes as Generate>::generate(
9197 g,
9198 ))),
9199 id::ENTITY_DESTROY => Some(Self::EntityDestroy(<EntityDestroy as Generate>::generate(
9200 g,
9201 ))),
9202 id::REMOVE_ENTITY_EFFECT => Some(Self::RemoveEntityEffect(
9203 <RemoveEntityEffect as Generate>::generate(g),
9204 )),
9205 id::RESOURCE_PACK_SEND => Some(Self::ResourcePackSend(
9206 <ResourcePackSend as Generate>::generate(g),
9207 )),
9208 id::RESPAWN => Some(Self::Respawn(<Respawn as Generate>::generate(g))),
9209 id::ENTITY_HEAD_ROTATION => Some(Self::EntityHeadRotation(
9210 <EntityHeadRotation as Generate>::generate(g),
9211 )),
9212 id::SELECT_ADVANCEMENT_TAB => Some(Self::SelectAdvancementTab(
9213 <SelectAdvancementTab as Generate>::generate(g),
9214 )),
9215 id::WORLD_BORDER => Some(Self::WorldBorder(<WorldBorder as Generate>::generate(g))),
9216 id::CAMERA => Some(Self::Camera(<Camera as Generate>::generate(g))),
9217 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
9218 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some(Self::ScoreboardDisplayObjective(
9219 <ScoreboardDisplayObjective as Generate>::generate(g),
9220 )),
9221 id::ENTITY_METADATA => Some(Self::EntityMetadata(
9222 <EntityMetadata as Generate>::generate(g),
9223 )),
9224 id::ATTACH_ENTITY => Some(Self::AttachEntity(<AttachEntity as Generate>::generate(g))),
9225 id::ENTITY_VELOCITY => Some(Self::EntityVelocity(
9226 <EntityVelocity as Generate>::generate(g),
9227 )),
9228 id::ENTITY_EQUIPMENT => Some(Self::EntityEquipment(
9229 <EntityEquipment as Generate>::generate(g),
9230 )),
9231 id::EXPERIENCE => Some(Self::Experience(<Experience as Generate>::generate(g))),
9232 id::UPDATE_HEALTH => Some(Self::UpdateHealth(<UpdateHealth as Generate>::generate(g))),
9233 id::SCOREBOARD_OBJECTIVE => Some(Self::ScoreboardObjective(
9234 <ScoreboardObjective as Generate>::generate(g),
9235 )),
9236 id::SET_PASSENGERS => Some(Self::SetPassengers(<SetPassengers as Generate>::generate(
9237 g,
9238 ))),
9239 id::TEAMS => Some(Self::Teams(<Teams as Generate>::generate(g))),
9240 id::SCOREBOARD_SCORE => Some(Self::ScoreboardScore(
9241 <ScoreboardScore as Generate>::generate(g),
9242 )),
9243 id::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition as Generate>::generate(
9244 g,
9245 ))),
9246 id::UPDATE_TIME => Some(Self::UpdateTime(<UpdateTime as Generate>::generate(g))),
9247 id::TITLE => Some(Self::Title(<Title as Generate>::generate(g))),
9248 id::SOUND_EFFECT => Some(Self::SoundEffect(<SoundEffect as Generate>::generate(g))),
9249 id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
9250 <PlayerlistHeader as Generate>::generate(g),
9251 )),
9252 id::COLLECT => Some(Self::Collect(<Collect as Generate>::generate(g))),
9253 id::ENTITY_TELEPORT => Some(Self::EntityTeleport(
9254 <EntityTeleport as Generate>::generate(g),
9255 )),
9256 id::ADVANCEMENTS => Some(Self::Advancements(<Advancements as Generate>::generate(g))),
9257 id::ENTITY_UPDATE_ATTRIBUTES => Some(Self::EntityUpdateAttributes(
9258 <EntityUpdateAttributes as Generate>::generate(g),
9259 )),
9260 id::ENTITY_EFFECT => Some(Self::EntityEffect(<EntityEffect as Generate>::generate(g))),
9261 _ => None,
9262 }
9263 }
9264}