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_16_5::types;
26use bytes::{BufMut, Bytes, BytesMut};
27
28#[derive(Debug, Clone, PartialEq)]
30pub struct StatisticsEntries {
31 pub category_id: i32,
33 pub statistic_id: i32,
35 pub value: i32,
37}
38
39#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
41pub struct DifficultyDifficulty(pub u8);
42impl DifficultyDifficulty {
43 pub const PEACEFUL: Self = Self(0);
45 pub const EASY: Self = Self(1);
47 pub const NORMAL: Self = Self(2);
49 pub const HARD: Self = Self(3);
51 pub const fn name(self) -> Option<&'static str> {
53 match self.0 {
54 0 => Some("peaceful"),
55 1 => Some("easy"),
56 2 => Some("normal"),
57 3 => Some("hard"),
58 _ => None,
59 }
60 }
61}
62impl std::fmt::Debug for DifficultyDifficulty {
63 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
64 match self.name() {
65 Some(n) => write!(f, "DifficultyDifficulty::{n}"),
66 None => write!(f, "DifficultyDifficulty({})", self.0),
67 }
68 }
69}
70
71#[derive(Debug, Clone, PartialEq)]
73pub struct TabCompleteMatches {
74 pub r#match: ByteString,
76 pub tooltip: Option<ByteString>,
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 PUFFER_FISH_STING: Self = Self(9);
115 pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
117 pub const IMMEDIATE_RESPAWN: Self = Self(11);
119 pub const fn name(self) -> Option<&'static str> {
121 match self.0 {
122 0 => Some("no_respawn_block_available"),
123 1 => Some("start_raining"),
124 2 => Some("stop_raining"),
125 3 => Some("change_game_mode"),
126 4 => Some("win_game"),
127 5 => Some("demo_event"),
128 6 => Some("play_arrow_hit_sound"),
129 7 => Some("rain_level_change"),
130 8 => Some("thunder_level_change"),
131 9 => Some("puffer_fish_sting"),
132 10 => Some("guardian_elder_effect"),
133 11 => Some("immediate_respawn"),
134 _ => None,
135 }
136 }
137}
138impl std::fmt::Debug for GameStateChangeReason {
139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
140 match self.name() {
141 Some(n) => write!(f, "GameStateChangeReason::{n}"),
142 None => write!(f, "GameStateChangeReason({})", self.0),
143 }
144 }
145}
146
147#[derive(Debug, Clone, PartialEq)]
149pub struct MapIcons {
150 pub r#type: i32,
152 pub x: i8,
154 pub z: i8,
156 pub direction: u8,
158 pub display_name: Option<ByteString>,
160}
161
162#[derive(Debug, Clone, PartialEq)]
164pub struct TradeListTrades {
165 pub input_item1: types::Slot,
167 pub output_item: types::Slot,
169 pub input_item2: Option<types::Slot>,
171 pub trade_disabled: bool,
173 pub nb_trade_uses: i32,
175 pub maximum_nb_trade_uses: i32,
177 pub xp: i32,
179 pub special_price: i32,
181 pub price_multiplier: f32,
183 pub demand: i32,
185}
186
187#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
189pub struct PlayerInfoAction(pub i32);
190impl PlayerInfoAction {
191 pub const ADD_PLAYER: Self = Self(0);
193 pub const UPDATE_GAME_MODE: Self = Self(1);
195 pub const UPDATE_LATENCY: Self = Self(2);
197 pub const UPDATE_DISPLAY_NAME: Self = Self(3);
199 pub const REMOVE_PLAYER: Self = Self(4);
201 pub const fn name(self) -> Option<&'static str> {
203 match self.0 {
204 0 => Some("add_player"),
205 1 => Some("update_game_mode"),
206 2 => Some("update_latency"),
207 3 => Some("update_display_name"),
208 4 => Some("remove_player"),
209 _ => None,
210 }
211 }
212}
213impl std::fmt::Debug for PlayerInfoAction {
214 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
215 match self.name() {
216 Some(n) => write!(f, "PlayerInfoAction::{n}"),
217 None => write!(f, "PlayerInfoAction({})", self.0),
218 }
219 }
220}
221
222#[derive(Debug, Clone, PartialEq)]
224pub struct PlayerInfoDataBodyAddPlayerProperties {
225 pub name: ByteString,
227 pub value: ByteString,
229 pub signature: Option<ByteString>,
231}
232
233#[derive(Debug, Clone, PartialEq)]
235pub struct PlayerInfoDataBodyAddPlayer {
236 pub name: ByteString,
238 pub properties: Vec<PlayerInfoDataBodyAddPlayerProperties>,
240 pub gamemode: i32,
242 pub ping: i32,
244 pub display_name: Option<ByteString>,
246}
247
248#[derive(Debug, Clone, PartialEq)]
250pub struct PlayerInfoDataBodyUpdateGameMode {
251 pub gamemode: i32,
253}
254
255#[derive(Debug, Clone, PartialEq)]
257pub struct PlayerInfoDataBodyUpdateLatency {
258 pub ping: i32,
260}
261
262#[derive(Debug, Clone, PartialEq)]
264pub struct PlayerInfoDataBodyUpdateDisplayName {
265 pub display_name: Option<ByteString>,
267}
268
269#[derive(Debug, Clone, PartialEq)]
271pub enum PlayerInfoDataBody {
272 AddPlayer(PlayerInfoDataBodyAddPlayer),
274 UpdateGameMode(PlayerInfoDataBodyUpdateGameMode),
276 UpdateLatency(PlayerInfoDataBodyUpdateLatency),
278 UpdateDisplayName(PlayerInfoDataBodyUpdateDisplayName),
280 RemovePlayer,
282 Other,
284}
285
286#[derive(Debug, Clone, PartialEq)]
288pub struct PlayerInfoData {
289 pub uuid: Uuid,
291 pub body: PlayerInfoDataBody,
293}
294
295#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
297pub struct MultiBlockChangeChunkCoordinates {
298 pub x: i32,
300 pub z: i32,
302 pub y: u32,
304}
305
306#[derive(Debug, Clone, PartialEq)]
308pub struct EntityEquipmentEquipments {
309 pub slot: i8,
311 pub item: types::Slot,
313}
314
315#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
317pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
318 pub _unused: u32,
320 pub hidden: u8,
322 pub show_toast: u8,
324 pub has_background_texture: u8,
326}
327
328#[derive(Debug, Clone, PartialEq)]
330pub struct AdvancementsAdvancementMappingValueDisplayData {
331 pub title: ByteString,
333 pub description: ByteString,
335 pub icon: types::Slot,
337 pub frame_type: i32,
339 pub flags: AdvancementsAdvancementMappingValueDisplayDataFlags,
341 pub background_texture: Option<ByteString>,
343 pub x_cord: f32,
345 pub y_cord: f32,
347}
348
349#[derive(Debug, Clone, PartialEq)]
351pub struct AdvancementsAdvancementMappingValueCriteria {
352 pub key: ByteString,
354}
355
356#[derive(Debug, Clone, PartialEq)]
358pub struct AdvancementsAdvancementMappingValue {
359 pub parent_id: Option<ByteString>,
361 pub display_data: Option<AdvancementsAdvancementMappingValueDisplayData>,
363 pub criteria: Vec<AdvancementsAdvancementMappingValueCriteria>,
365 pub requirements: Vec<Vec<ByteString>>,
367}
368
369#[derive(Debug, Clone, PartialEq)]
371pub struct AdvancementsAdvancementMapping {
372 pub key: ByteString,
374 pub value: AdvancementsAdvancementMappingValue,
376}
377
378#[derive(Debug, Clone, PartialEq)]
380pub struct AdvancementsProgressMappingValue {
381 pub criterion_identifier: ByteString,
383 pub criterion_progress: Option<i64>,
385}
386
387#[derive(Debug, Clone, PartialEq)]
389pub struct AdvancementsProgressMapping {
390 pub key: ByteString,
392 pub value: Vec<AdvancementsProgressMappingValue>,
394}
395
396#[derive(Debug, Clone, PartialEq)]
398pub struct EntityUpdateAttributesPropertiesModifiers {
399 pub uuid: Uuid,
401 pub amount: f64,
403 pub operation: i8,
405}
406
407#[derive(Debug, Clone, PartialEq)]
409pub struct EntityUpdateAttributesProperties {
410 pub key: ByteString,
412 pub value: f64,
414 pub modifiers: Vec<EntityUpdateAttributesPropertiesModifiers>,
416}
417
418#[derive(Debug, Clone, PartialEq)]
420pub struct DeclareRecipesRecipesDataCraftingShapeless {
421 pub group: ByteString,
423 pub ingredients: Vec<Vec<types::Slot>>,
425 pub result: types::Slot,
427}
428
429#[derive(Debug, Clone, PartialEq)]
431pub struct DeclareRecipesRecipesDataCraftingShaped {
432 pub width: i32,
434 pub height: i32,
436 pub group: ByteString,
438 pub ingredients: Vec<Vec<Vec<types::Slot>>>,
440 pub result: types::Slot,
442}
443
444#[derive(Debug, Clone, PartialEq)]
446pub struct DeclareRecipesRecipesDataStonecutting {
447 pub group: ByteString,
449 pub ingredient: Vec<types::Slot>,
451 pub result: types::Slot,
453}
454
455#[derive(Debug, Clone, PartialEq)]
457pub struct DeclareRecipesRecipesDataSmithing {
458 pub base: Vec<types::Slot>,
460 pub addition: Vec<types::Slot>,
462 pub result: types::Slot,
464}
465
466#[derive(Debug, Clone, PartialEq)]
468pub enum DeclareRecipesRecipesData {
469 CraftingShapeless(DeclareRecipesRecipesDataCraftingShapeless),
471 CraftingShaped(DeclareRecipesRecipesDataCraftingShaped),
473 CraftingSpecialArmordye,
475 CraftingSpecialBookcloning,
477 CraftingSpecialMapcloning,
479 CraftingSpecialMapextending,
481 CraftingSpecialFireworkRocket,
483 CraftingSpecialFireworkStar,
485 CraftingSpecialFireworkStarFade,
487 CraftingSpecialRepairitem,
489 CraftingSpecialTippedarrow,
491 CraftingSpecialBannerduplicate,
493 CraftingSpecialBanneraddpattern,
495 CraftingSpecialShielddecoration,
497 CraftingSpecialShulkerboxcoloring,
499 CraftingSpecialSuspiciousstew,
501 Smelting(types::MinecraftSmeltingFormat),
503 Blasting(types::MinecraftSmeltingFormat),
505 Smoking(types::MinecraftSmeltingFormat),
507 CampfireCooking(types::MinecraftSmeltingFormat),
509 Stonecutting(DeclareRecipesRecipesDataStonecutting),
511 Smithing(DeclareRecipesRecipesDataSmithing),
513 Other,
515}
516
517#[derive(Debug, Clone, PartialEq)]
519pub struct DeclareRecipesRecipes {
520 pub r#type: ByteString,
522 pub recipe_id: ByteString,
524 pub data: DeclareRecipesRecipesData,
526}
527
528pub mod id {
530 pub const SPAWN_ENTITY: i32 = 0x00;
532 pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x01;
534 pub const SPAWN_ENTITY_LIVING: i32 = 0x02;
536 pub const SPAWN_ENTITY_PAINTING: i32 = 0x03;
538 pub const NAMED_ENTITY_SPAWN: i32 = 0x04;
540 pub const ANIMATION: i32 = 0x05;
542 pub const STATISTICS: i32 = 0x06;
544 pub const ACKNOWLEDGE_PLAYER_DIGGING: i32 = 0x07;
546 pub const BLOCK_BREAK_ANIMATION: i32 = 0x08;
548 pub const TILE_ENTITY_DATA: i32 = 0x09;
550 pub const BLOCK_ACTION: i32 = 0x0a;
552 pub const BLOCK_CHANGE: i32 = 0x0b;
554 pub const BOSS_BAR: i32 = 0x0c;
556 pub const DIFFICULTY: i32 = 0x0d;
558 pub const CHAT: i32 = 0x0e;
560 pub const TAB_COMPLETE: i32 = 0x0f;
562 pub const DECLARE_COMMANDS: i32 = 0x10;
564 pub const TRANSACTION: i32 = 0x11;
566 pub const CLOSE_WINDOW: i32 = 0x12;
568 pub const WINDOW_ITEMS: i32 = 0x13;
570 pub const CRAFT_PROGRESS_BAR: i32 = 0x14;
572 pub const SET_SLOT: i32 = 0x15;
574 pub const SET_COOLDOWN: i32 = 0x16;
576 pub const CUSTOM_PAYLOAD: i32 = 0x17;
578 pub const NAMED_SOUND_EFFECT: i32 = 0x18;
580 pub const KICK_DISCONNECT: i32 = 0x19;
582 pub const ENTITY_STATUS: i32 = 0x1a;
584 pub const EXPLOSION: i32 = 0x1b;
586 pub const UNLOAD_CHUNK: i32 = 0x1c;
588 pub const GAME_STATE_CHANGE: i32 = 0x1d;
590 pub const OPEN_HORSE_WINDOW: i32 = 0x1e;
592 pub const KEEP_ALIVE: i32 = 0x1f;
594 pub const MAP_CHUNK: i32 = 0x20;
596 pub const WORLD_EVENT: i32 = 0x21;
598 pub const WORLD_PARTICLES: i32 = 0x22;
600 pub const UPDATE_LIGHT: i32 = 0x23;
602 pub const LOGIN: i32 = 0x24;
604 pub const MAP: i32 = 0x25;
606 pub const TRADE_LIST: i32 = 0x26;
608 pub const REL_ENTITY_MOVE: i32 = 0x27;
610 pub const ENTITY_MOVE_LOOK: i32 = 0x28;
612 pub const ENTITY_LOOK: i32 = 0x29;
614 pub const ENTITY: i32 = 0x2a;
616 pub const VEHICLE_MOVE: i32 = 0x2b;
618 pub const OPEN_BOOK: i32 = 0x2c;
620 pub const OPEN_WINDOW: i32 = 0x2d;
622 pub const OPEN_SIGN_ENTITY: i32 = 0x2e;
624 pub const CRAFT_RECIPE_RESPONSE: i32 = 0x2f;
626 pub const ABILITIES: i32 = 0x30;
628 pub const COMBAT_EVENT: i32 = 0x31;
630 pub const PLAYER_INFO: i32 = 0x32;
632 pub const FACE_PLAYER: i32 = 0x33;
634 pub const POSITION: i32 = 0x34;
636 pub const UNLOCK_RECIPES: i32 = 0x35;
638 pub const ENTITY_DESTROY: i32 = 0x36;
640 pub const REMOVE_ENTITY_EFFECT: i32 = 0x37;
642 pub const RESOURCE_PACK_SEND: i32 = 0x38;
644 pub const RESPAWN: i32 = 0x39;
646 pub const ENTITY_HEAD_ROTATION: i32 = 0x3a;
648 pub const MULTI_BLOCK_CHANGE: i32 = 0x3b;
650 pub const SELECT_ADVANCEMENT_TAB: i32 = 0x3c;
652 pub const WORLD_BORDER: i32 = 0x3d;
654 pub const CAMERA: i32 = 0x3e;
656 pub const HELD_ITEM_SLOT: i32 = 0x3f;
658 pub const UPDATE_VIEW_POSITION: i32 = 0x40;
660 pub const UPDATE_VIEW_DISTANCE: i32 = 0x41;
662 pub const SPAWN_POSITION: i32 = 0x42;
664 pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x43;
666 pub const ENTITY_METADATA: i32 = 0x44;
668 pub const ATTACH_ENTITY: i32 = 0x45;
670 pub const ENTITY_VELOCITY: i32 = 0x46;
672 pub const ENTITY_EQUIPMENT: i32 = 0x47;
674 pub const EXPERIENCE: i32 = 0x48;
676 pub const UPDATE_HEALTH: i32 = 0x49;
678 pub const SCOREBOARD_OBJECTIVE: i32 = 0x4a;
680 pub const SET_PASSENGERS: i32 = 0x4b;
682 pub const TEAMS: i32 = 0x4c;
684 pub const SCOREBOARD_SCORE: i32 = 0x4d;
686 pub const UPDATE_TIME: i32 = 0x4e;
688 pub const TITLE: i32 = 0x4f;
690 pub const ENTITY_SOUND_EFFECT: i32 = 0x50;
692 pub const SOUND_EFFECT: i32 = 0x51;
694 pub const STOP_SOUND: i32 = 0x52;
696 pub const PLAYERLIST_HEADER: i32 = 0x53;
698 pub const NBT_QUERY_RESPONSE: i32 = 0x54;
700 pub const COLLECT: i32 = 0x55;
702 pub const ENTITY_TELEPORT: i32 = 0x56;
704 pub const ADVANCEMENTS: i32 = 0x57;
706 pub const ENTITY_UPDATE_ATTRIBUTES: i32 = 0x58;
708 pub const ENTITY_EFFECT: i32 = 0x59;
710 pub const DECLARE_RECIPES: i32 = 0x5a;
712 pub const TAGS: i32 = 0x5b;
714}
715
716#[derive(Debug, Clone, PartialEq)]
718pub struct SpawnEntity {
719 pub entity_id: i32,
721 pub object_uuid: Uuid,
723 pub r#type: i32,
725 pub x: f64,
727 pub y: f64,
729 pub z: f64,
731 pub pitch: i8,
733 pub yaw: i8,
735 pub object_data: i32,
737 pub velocity: types::Vec3i16,
739}
740impl crate::packet::Packet for SpawnEntity {
741 const ID: i32 = id::SPAWN_ENTITY;
742 const NAME: &'static str = "spawn_entity";
743 const STATE: State = State::Play;
744 const DIRECTION: Direction = Direction::Clientbound;
745}
746impl Decode for SpawnEntity {
747 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
748 Ok({
749 let v48 = r.read_varint()?;
750 let v49 = r.read_uuid()?;
751 let v50 = r.read_varint()?;
752 let v51 = r.read_f64()?;
753 let v52 = r.read_f64()?;
754 let v53 = r.read_f64()?;
755 let v54 = r.read_i8()?;
756 let v55 = r.read_i8()?;
757 let v56 = r.read_i32()?;
758 let v57 = <types::Vec3i16 as Decode>::decode(r)?;
759 SpawnEntity {
760 entity_id: v48,
761 object_uuid: v49,
762 r#type: v50,
763 x: v51,
764 y: v52,
765 z: v53,
766 pitch: v54,
767 yaw: v55,
768 object_data: v56,
769 velocity: v57,
770 }
771 })
772 }
773}
774impl Encode for SpawnEntity {
775 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
776 w.put_varint((*self).entity_id);
777 w.put_uuid(&(*self).object_uuid);
778 w.put_varint((*self).r#type);
779 w.put_f64((*self).x);
780 w.put_f64((*self).y);
781 w.put_f64((*self).z);
782 w.put_i8((*self).pitch);
783 w.put_i8((*self).yaw);
784 w.put_i32((*self).object_data);
785 (*self).velocity.encode(w)?;
786 Ok(())
787 }
788}
789#[cfg(feature = "testgen")]
790impl Generate for SpawnEntity {
791 fn generate(g: &mut Gen) -> Self {
792 {
793 let v58 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
794 let v59 = g.uuid();
795 let v60 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
796 let v61 = g.f64();
797 let v62 = g.f64();
798 let v63 = g.f64();
799 let v64 = (g.int_in(-128, 127, &[]) as i8);
800 let v65 = (g.int_in(-128, 127, &[]) as i8);
801 let v66 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
802 let v67 = <types::Vec3i16 as Generate>::generate(g);
803 SpawnEntity {
804 entity_id: v58,
805 object_uuid: v59,
806 r#type: v60,
807 x: v61,
808 y: v62,
809 z: v63,
810 pitch: v64,
811 yaw: v65,
812 object_data: v66,
813 velocity: v67,
814 }
815 }
816 }
817}
818impl From<SpawnEntity> for ClientboundPlayPacket {
819 fn from(p: SpawnEntity) -> Self {
820 Self::SpawnEntity(p)
821 }
822}
823
824#[derive(Debug, Clone, PartialEq)]
826pub struct SpawnEntityExperienceOrb {
827 pub entity_id: i32,
829 pub x: f64,
831 pub y: f64,
833 pub z: f64,
835 pub count: i16,
837}
838impl crate::packet::Packet for SpawnEntityExperienceOrb {
839 const ID: i32 = id::SPAWN_ENTITY_EXPERIENCE_ORB;
840 const NAME: &'static str = "spawn_entity_experience_orb";
841 const STATE: State = State::Play;
842 const DIRECTION: Direction = Direction::Clientbound;
843}
844impl Decode for SpawnEntityExperienceOrb {
845 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
846 Ok({
847 let v68 = r.read_varint()?;
848 let v69 = r.read_f64()?;
849 let v70 = r.read_f64()?;
850 let v71 = r.read_f64()?;
851 let v72 = r.read_i16()?;
852 SpawnEntityExperienceOrb {
853 entity_id: v68,
854 x: v69,
855 y: v70,
856 z: v71,
857 count: v72,
858 }
859 })
860 }
861}
862impl Encode for SpawnEntityExperienceOrb {
863 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
864 w.put_varint((*self).entity_id);
865 w.put_f64((*self).x);
866 w.put_f64((*self).y);
867 w.put_f64((*self).z);
868 w.put_i16((*self).count);
869 Ok(())
870 }
871}
872#[cfg(feature = "testgen")]
873impl Generate for SpawnEntityExperienceOrb {
874 fn generate(g: &mut Gen) -> Self {
875 {
876 let v73 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
877 let v74 = g.f64();
878 let v75 = g.f64();
879 let v76 = g.f64();
880 let v77 = (g.int_in(-32768, 32767, &[]) as i16);
881 SpawnEntityExperienceOrb {
882 entity_id: v73,
883 x: v74,
884 y: v75,
885 z: v76,
886 count: v77,
887 }
888 }
889 }
890}
891impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
892 fn from(p: SpawnEntityExperienceOrb) -> Self {
893 Self::SpawnEntityExperienceOrb(p)
894 }
895}
896
897#[derive(Debug, Clone, PartialEq)]
899pub struct SpawnEntityLiving {
900 pub entity_id: i32,
902 pub entity_uuid: Uuid,
904 pub r#type: i32,
906 pub x: f64,
908 pub y: f64,
910 pub z: f64,
912 pub yaw: i8,
914 pub pitch: i8,
916 pub head_pitch: i8,
918 pub velocity: types::Vec3i16,
920}
921impl crate::packet::Packet for SpawnEntityLiving {
922 const ID: i32 = id::SPAWN_ENTITY_LIVING;
923 const NAME: &'static str = "spawn_entity_living";
924 const STATE: State = State::Play;
925 const DIRECTION: Direction = Direction::Clientbound;
926}
927impl Decode for SpawnEntityLiving {
928 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
929 Ok({
930 let v78 = r.read_varint()?;
931 let v79 = r.read_uuid()?;
932 let v80 = r.read_varint()?;
933 let v81 = r.read_f64()?;
934 let v82 = r.read_f64()?;
935 let v83 = r.read_f64()?;
936 let v84 = r.read_i8()?;
937 let v85 = r.read_i8()?;
938 let v86 = r.read_i8()?;
939 let v87 = <types::Vec3i16 as Decode>::decode(r)?;
940 SpawnEntityLiving {
941 entity_id: v78,
942 entity_uuid: v79,
943 r#type: v80,
944 x: v81,
945 y: v82,
946 z: v83,
947 yaw: v84,
948 pitch: v85,
949 head_pitch: v86,
950 velocity: v87,
951 }
952 })
953 }
954}
955impl Encode for SpawnEntityLiving {
956 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
957 w.put_varint((*self).entity_id);
958 w.put_uuid(&(*self).entity_uuid);
959 w.put_varint((*self).r#type);
960 w.put_f64((*self).x);
961 w.put_f64((*self).y);
962 w.put_f64((*self).z);
963 w.put_i8((*self).yaw);
964 w.put_i8((*self).pitch);
965 w.put_i8((*self).head_pitch);
966 (*self).velocity.encode(w)?;
967 Ok(())
968 }
969}
970#[cfg(feature = "testgen")]
971impl Generate for SpawnEntityLiving {
972 fn generate(g: &mut Gen) -> Self {
973 {
974 let v88 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
975 let v89 = g.uuid();
976 let v90 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
977 let v91 = g.f64();
978 let v92 = g.f64();
979 let v93 = g.f64();
980 let v94 = (g.int_in(-128, 127, &[]) as i8);
981 let v95 = (g.int_in(-128, 127, &[]) as i8);
982 let v96 = (g.int_in(-128, 127, &[]) as i8);
983 let v97 = <types::Vec3i16 as Generate>::generate(g);
984 SpawnEntityLiving {
985 entity_id: v88,
986 entity_uuid: v89,
987 r#type: v90,
988 x: v91,
989 y: v92,
990 z: v93,
991 yaw: v94,
992 pitch: v95,
993 head_pitch: v96,
994 velocity: v97,
995 }
996 }
997 }
998}
999impl From<SpawnEntityLiving> for ClientboundPlayPacket {
1000 fn from(p: SpawnEntityLiving) -> Self {
1001 Self::SpawnEntityLiving(p)
1002 }
1003}
1004
1005#[derive(Debug, Clone, PartialEq)]
1007pub struct SpawnEntityPainting {
1008 pub entity_id: i32,
1010 pub entity_uuid: Uuid,
1012 pub title: i32,
1014 pub location: BlockPos,
1016 pub direction: u8,
1018}
1019impl crate::packet::Packet for SpawnEntityPainting {
1020 const ID: i32 = id::SPAWN_ENTITY_PAINTING;
1021 const NAME: &'static str = "spawn_entity_painting";
1022 const STATE: State = State::Play;
1023 const DIRECTION: Direction = Direction::Clientbound;
1024}
1025impl Decode for SpawnEntityPainting {
1026 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1027 Ok({
1028 let v98 = r.read_varint()?;
1029 let v99 = r.read_uuid()?;
1030 let v100 = r.read_varint()?;
1031 let v101 = BlockPos::read(r, PositionLayout::Xzy)?;
1032 let v102 = r.read_u8()?;
1033 SpawnEntityPainting {
1034 entity_id: v98,
1035 entity_uuid: v99,
1036 title: v100,
1037 location: v101,
1038 direction: v102,
1039 }
1040 })
1041 }
1042}
1043impl Encode for SpawnEntityPainting {
1044 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1045 w.put_varint((*self).entity_id);
1046 w.put_uuid(&(*self).entity_uuid);
1047 w.put_varint((*self).title);
1048 (*self).location.write(w, PositionLayout::Xzy)?;
1049 w.put_u8((*self).direction);
1050 Ok(())
1051 }
1052}
1053#[cfg(feature = "testgen")]
1054impl Generate for SpawnEntityPainting {
1055 fn generate(g: &mut Gen) -> Self {
1056 {
1057 let v103 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1058 let v104 = g.uuid();
1059 let v105 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1060 let v106 = g.position();
1061 let v107 = (g.int_in(0, 255, &[]) as u8);
1062 SpawnEntityPainting {
1063 entity_id: v103,
1064 entity_uuid: v104,
1065 title: v105,
1066 location: v106,
1067 direction: v107,
1068 }
1069 }
1070 }
1071}
1072impl From<SpawnEntityPainting> for ClientboundPlayPacket {
1073 fn from(p: SpawnEntityPainting) -> Self {
1074 Self::SpawnEntityPainting(p)
1075 }
1076}
1077
1078#[derive(Debug, Clone, PartialEq)]
1080pub struct NamedEntitySpawn {
1081 pub entity_id: i32,
1083 pub player_uuid: Uuid,
1085 pub x: f64,
1087 pub y: f64,
1089 pub z: f64,
1091 pub yaw: i8,
1093 pub pitch: i8,
1095}
1096impl crate::packet::Packet for NamedEntitySpawn {
1097 const ID: i32 = id::NAMED_ENTITY_SPAWN;
1098 const NAME: &'static str = "named_entity_spawn";
1099 const STATE: State = State::Play;
1100 const DIRECTION: Direction = Direction::Clientbound;
1101}
1102impl Decode for NamedEntitySpawn {
1103 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1104 Ok({
1105 let v108 = r.read_varint()?;
1106 let v109 = r.read_uuid()?;
1107 let v110 = r.read_f64()?;
1108 let v111 = r.read_f64()?;
1109 let v112 = r.read_f64()?;
1110 let v113 = r.read_i8()?;
1111 let v114 = r.read_i8()?;
1112 NamedEntitySpawn {
1113 entity_id: v108,
1114 player_uuid: v109,
1115 x: v110,
1116 y: v111,
1117 z: v112,
1118 yaw: v113,
1119 pitch: v114,
1120 }
1121 })
1122 }
1123}
1124impl Encode for NamedEntitySpawn {
1125 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1126 w.put_varint((*self).entity_id);
1127 w.put_uuid(&(*self).player_uuid);
1128 w.put_f64((*self).x);
1129 w.put_f64((*self).y);
1130 w.put_f64((*self).z);
1131 w.put_i8((*self).yaw);
1132 w.put_i8((*self).pitch);
1133 Ok(())
1134 }
1135}
1136#[cfg(feature = "testgen")]
1137impl Generate for NamedEntitySpawn {
1138 fn generate(g: &mut Gen) -> Self {
1139 {
1140 let v115 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1141 let v116 = g.uuid();
1142 let v117 = g.f64();
1143 let v118 = g.f64();
1144 let v119 = g.f64();
1145 let v120 = (g.int_in(-128, 127, &[]) as i8);
1146 let v121 = (g.int_in(-128, 127, &[]) as i8);
1147 NamedEntitySpawn {
1148 entity_id: v115,
1149 player_uuid: v116,
1150 x: v117,
1151 y: v118,
1152 z: v119,
1153 yaw: v120,
1154 pitch: v121,
1155 }
1156 }
1157 }
1158}
1159impl From<NamedEntitySpawn> for ClientboundPlayPacket {
1160 fn from(p: NamedEntitySpawn) -> Self {
1161 Self::NamedEntitySpawn(p)
1162 }
1163}
1164
1165#[derive(Debug, Clone, PartialEq)]
1167pub struct Animation {
1168 pub entity_id: i32,
1170 pub animation: u8,
1172}
1173impl crate::packet::Packet for Animation {
1174 const ID: i32 = id::ANIMATION;
1175 const NAME: &'static str = "animation";
1176 const STATE: State = State::Play;
1177 const DIRECTION: Direction = Direction::Clientbound;
1178}
1179impl Decode for Animation {
1180 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1181 Ok({
1182 let v122 = r.read_varint()?;
1183 let v123 = r.read_u8()?;
1184 Animation {
1185 entity_id: v122,
1186 animation: v123,
1187 }
1188 })
1189 }
1190}
1191impl Encode for Animation {
1192 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1193 w.put_varint((*self).entity_id);
1194 w.put_u8((*self).animation);
1195 Ok(())
1196 }
1197}
1198#[cfg(feature = "testgen")]
1199impl Generate for Animation {
1200 fn generate(g: &mut Gen) -> Self {
1201 {
1202 let v124 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1203 let v125 = (g.int_in(0, 255, &[]) as u8);
1204 Animation {
1205 entity_id: v124,
1206 animation: v125,
1207 }
1208 }
1209 }
1210}
1211impl From<Animation> for ClientboundPlayPacket {
1212 fn from(p: Animation) -> Self {
1213 Self::Animation(p)
1214 }
1215}
1216
1217#[derive(Debug, Clone, PartialEq)]
1219pub struct Statistics {
1220 pub entries: Vec<StatisticsEntries>,
1222}
1223impl crate::packet::Packet for Statistics {
1224 const ID: i32 = id::STATISTICS;
1225 const NAME: &'static str = "statistics";
1226 const STATE: State = State::Play;
1227 const DIRECTION: Direction = Direction::Clientbound;
1228}
1229impl Decode for Statistics {
1230 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1231 Ok({
1232 let v126 = {
1233 let v127 = {
1234 let c = r.read_varint()?;
1235 r.check_count(i64::from(c), 3)?
1236 };
1237 let mut v128 = Vec::with_capacity(v127.min(crate::codec::PREALLOC_LIMIT));
1238 for _ in 0..v127 {
1239 v128.push({
1240 let v129 = r.read_varint()?;
1241 let v130 = r.read_varint()?;
1242 let v131 = r.read_varint()?;
1243 StatisticsEntries {
1244 category_id: v129,
1245 statistic_id: v130,
1246 value: v131,
1247 }
1248 });
1249 }
1250 v128
1251 };
1252 Statistics { entries: v126 }
1253 })
1254 }
1255}
1256impl Encode for Statistics {
1257 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1258 w.put_len_varint((*self).entries.len())?;
1259 for v132 in (*self).entries.iter() {
1260 w.put_varint((*v132).category_id);
1261 w.put_varint((*v132).statistic_id);
1262 w.put_varint((*v132).value);
1263 }
1264 Ok(())
1265 }
1266}
1267#[cfg(feature = "testgen")]
1268impl Generate for Statistics {
1269 fn generate(g: &mut Gen) -> Self {
1270 {
1271 let v133 = {
1272 let v134 = g.count();
1273 let mut v135 = Vec::with_capacity(v134.min(crate::codec::PREALLOC_LIMIT));
1274 for _ in 0..v134 {
1275 v135.push({
1276 let v136 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1277 let v137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1278 let v138 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1279 StatisticsEntries {
1280 category_id: v136,
1281 statistic_id: v137,
1282 value: v138,
1283 }
1284 });
1285 }
1286 v135
1287 };
1288 Statistics { entries: v133 }
1289 }
1290 }
1291}
1292impl From<Statistics> for ClientboundPlayPacket {
1293 fn from(p: Statistics) -> Self {
1294 Self::Statistics(p)
1295 }
1296}
1297
1298#[derive(Debug, Clone, PartialEq)]
1300pub struct AcknowledgePlayerDigging {
1301 pub location: BlockPos,
1303 pub block: i32,
1305 pub status: i32,
1307 pub successful: bool,
1309}
1310impl crate::packet::Packet for AcknowledgePlayerDigging {
1311 const ID: i32 = id::ACKNOWLEDGE_PLAYER_DIGGING;
1312 const NAME: &'static str = "acknowledge_player_digging";
1313 const STATE: State = State::Play;
1314 const DIRECTION: Direction = Direction::Clientbound;
1315}
1316impl Decode for AcknowledgePlayerDigging {
1317 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1318 Ok({
1319 let v139 = BlockPos::read(r, PositionLayout::Xzy)?;
1320 let v140 = r.read_varint()?;
1321 let v141 = r.read_varint()?;
1322 let v142 = r.read_bool()?;
1323 AcknowledgePlayerDigging {
1324 location: v139,
1325 block: v140,
1326 status: v141,
1327 successful: v142,
1328 }
1329 })
1330 }
1331}
1332impl Encode for AcknowledgePlayerDigging {
1333 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1334 (*self).location.write(w, PositionLayout::Xzy)?;
1335 w.put_varint((*self).block);
1336 w.put_varint((*self).status);
1337 w.put_bool((*self).successful);
1338 Ok(())
1339 }
1340}
1341#[cfg(feature = "testgen")]
1342impl Generate for AcknowledgePlayerDigging {
1343 fn generate(g: &mut Gen) -> Self {
1344 {
1345 let v143 = g.position();
1346 let v144 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1347 let v145 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1348 let v146 = g.bool();
1349 AcknowledgePlayerDigging {
1350 location: v143,
1351 block: v144,
1352 status: v145,
1353 successful: v146,
1354 }
1355 }
1356 }
1357}
1358impl From<AcknowledgePlayerDigging> for ClientboundPlayPacket {
1359 fn from(p: AcknowledgePlayerDigging) -> Self {
1360 Self::AcknowledgePlayerDigging(p)
1361 }
1362}
1363
1364#[derive(Debug, Clone, PartialEq)]
1366pub struct BlockBreakAnimation {
1367 pub entity_id: i32,
1369 pub location: BlockPos,
1371 pub destroy_stage: i8,
1373}
1374impl crate::packet::Packet for BlockBreakAnimation {
1375 const ID: i32 = id::BLOCK_BREAK_ANIMATION;
1376 const NAME: &'static str = "block_break_animation";
1377 const STATE: State = State::Play;
1378 const DIRECTION: Direction = Direction::Clientbound;
1379}
1380impl Decode for BlockBreakAnimation {
1381 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1382 Ok({
1383 let v147 = r.read_varint()?;
1384 let v148 = BlockPos::read(r, PositionLayout::Xzy)?;
1385 let v149 = r.read_i8()?;
1386 BlockBreakAnimation {
1387 entity_id: v147,
1388 location: v148,
1389 destroy_stage: v149,
1390 }
1391 })
1392 }
1393}
1394impl Encode for BlockBreakAnimation {
1395 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1396 w.put_varint((*self).entity_id);
1397 (*self).location.write(w, PositionLayout::Xzy)?;
1398 w.put_i8((*self).destroy_stage);
1399 Ok(())
1400 }
1401}
1402#[cfg(feature = "testgen")]
1403impl Generate for BlockBreakAnimation {
1404 fn generate(g: &mut Gen) -> Self {
1405 {
1406 let v150 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1407 let v151 = g.position();
1408 let v152 = (g.int_in(-128, 127, &[]) as i8);
1409 BlockBreakAnimation {
1410 entity_id: v150,
1411 location: v151,
1412 destroy_stage: v152,
1413 }
1414 }
1415 }
1416}
1417impl From<BlockBreakAnimation> for ClientboundPlayPacket {
1418 fn from(p: BlockBreakAnimation) -> Self {
1419 Self::BlockBreakAnimation(p)
1420 }
1421}
1422
1423#[derive(Debug, Clone, PartialEq)]
1425pub struct TileEntityData {
1426 pub location: BlockPos,
1428 pub action: u8,
1430 pub nbt_data: Option<RawNbt>,
1432}
1433impl crate::packet::Packet for TileEntityData {
1434 const ID: i32 = id::TILE_ENTITY_DATA;
1435 const NAME: &'static str = "tile_entity_data";
1436 const STATE: State = State::Play;
1437 const DIRECTION: Direction = Direction::Clientbound;
1438}
1439impl Decode for TileEntityData {
1440 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1441 Ok({
1442 let v153 = BlockPos::read(r, PositionLayout::Xzy)?;
1443 let v154 = r.read_u8()?;
1444 let v155 = RawNbt::read_optional(r)?;
1445 TileEntityData {
1446 location: v153,
1447 action: v154,
1448 nbt_data: v155,
1449 }
1450 })
1451 }
1452}
1453impl Encode for TileEntityData {
1454 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1455 (*self).location.write(w, PositionLayout::Xzy)?;
1456 w.put_u8((*self).action);
1457 RawNbt::write_optional(&(*self).nbt_data, w);
1458 Ok(())
1459 }
1460}
1461#[cfg(feature = "testgen")]
1462impl Generate for TileEntityData {
1463 fn generate(g: &mut Gen) -> Self {
1464 {
1465 let v156 = g.position();
1466 let v157 = (g.int_in(0, 255, &[]) as u8);
1467 let v158 = g.opt_nbt();
1468 TileEntityData {
1469 location: v156,
1470 action: v157,
1471 nbt_data: v158,
1472 }
1473 }
1474 }
1475}
1476impl From<TileEntityData> for ClientboundPlayPacket {
1477 fn from(p: TileEntityData) -> Self {
1478 Self::TileEntityData(p)
1479 }
1480}
1481
1482#[derive(Debug, Clone, PartialEq)]
1484pub struct BlockAction {
1485 pub location: BlockPos,
1487 pub byte1: u8,
1489 pub byte2: u8,
1491 pub block_id: i32,
1493}
1494impl crate::packet::Packet for BlockAction {
1495 const ID: i32 = id::BLOCK_ACTION;
1496 const NAME: &'static str = "block_action";
1497 const STATE: State = State::Play;
1498 const DIRECTION: Direction = Direction::Clientbound;
1499}
1500impl Decode for BlockAction {
1501 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1502 Ok({
1503 let v159 = BlockPos::read(r, PositionLayout::Xzy)?;
1504 let v160 = r.read_u8()?;
1505 let v161 = r.read_u8()?;
1506 let v162 = r.read_varint()?;
1507 BlockAction {
1508 location: v159,
1509 byte1: v160,
1510 byte2: v161,
1511 block_id: v162,
1512 }
1513 })
1514 }
1515}
1516impl Encode for BlockAction {
1517 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1518 (*self).location.write(w, PositionLayout::Xzy)?;
1519 w.put_u8((*self).byte1);
1520 w.put_u8((*self).byte2);
1521 w.put_varint((*self).block_id);
1522 Ok(())
1523 }
1524}
1525#[cfg(feature = "testgen")]
1526impl Generate for BlockAction {
1527 fn generate(g: &mut Gen) -> Self {
1528 {
1529 let v163 = g.position();
1530 let v164 = (g.int_in(0, 255, &[]) as u8);
1531 let v165 = (g.int_in(0, 255, &[]) as u8);
1532 let v166 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1533 BlockAction {
1534 location: v163,
1535 byte1: v164,
1536 byte2: v165,
1537 block_id: v166,
1538 }
1539 }
1540 }
1541}
1542impl From<BlockAction> for ClientboundPlayPacket {
1543 fn from(p: BlockAction) -> Self {
1544 Self::BlockAction(p)
1545 }
1546}
1547
1548#[derive(Debug, Clone, PartialEq)]
1550pub struct BlockChange {
1551 pub location: BlockPos,
1553 pub r#type: i32,
1555}
1556impl crate::packet::Packet for BlockChange {
1557 const ID: i32 = id::BLOCK_CHANGE;
1558 const NAME: &'static str = "block_change";
1559 const STATE: State = State::Play;
1560 const DIRECTION: Direction = Direction::Clientbound;
1561}
1562impl Decode for BlockChange {
1563 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1564 Ok({
1565 let v167 = BlockPos::read(r, PositionLayout::Xzy)?;
1566 let v168 = r.read_varint()?;
1567 BlockChange {
1568 location: v167,
1569 r#type: v168,
1570 }
1571 })
1572 }
1573}
1574impl Encode for BlockChange {
1575 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1576 (*self).location.write(w, PositionLayout::Xzy)?;
1577 w.put_varint((*self).r#type);
1578 Ok(())
1579 }
1580}
1581#[cfg(feature = "testgen")]
1582impl Generate for BlockChange {
1583 fn generate(g: &mut Gen) -> Self {
1584 {
1585 let v169 = g.position();
1586 let v170 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1587 BlockChange {
1588 location: v169,
1589 r#type: v170,
1590 }
1591 }
1592 }
1593}
1594impl From<BlockChange> for ClientboundPlayPacket {
1595 fn from(p: BlockChange) -> Self {
1596 Self::BlockChange(p)
1597 }
1598}
1599
1600#[derive(Debug, Clone, PartialEq)]
1602pub struct BossBar {
1603 pub entity_uuid: Uuid,
1605 pub action: i32,
1607 pub title: Option<ByteString>,
1609 pub health: Option<f32>,
1611 pub color: Option<i32>,
1613 pub dividers: Option<i32>,
1615 pub flags: Option<u8>,
1617}
1618impl crate::packet::Packet for BossBar {
1619 const ID: i32 = id::BOSS_BAR;
1620 const NAME: &'static str = "boss_bar";
1621 const STATE: State = State::Play;
1622 const DIRECTION: Direction = Direction::Clientbound;
1623}
1624impl Decode for BossBar {
1625 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1626 Ok({
1627 let v171 = r.read_uuid()?;
1628 let v172 = r.read_varint()?;
1629 let v173 = if (v172 == 0) || (v172 == 3) {
1630 Some(r.read_string()?)
1631 } else {
1632 None
1633 };
1634 let v174 = if (v172 == 0) || (v172 == 2) {
1635 Some(r.read_f32()?)
1636 } else {
1637 None
1638 };
1639 let v175 = if (v172 == 0) || (v172 == 4) {
1640 Some(r.read_varint()?)
1641 } else {
1642 None
1643 };
1644 let v176 = if (v172 == 0) || (v172 == 4) {
1645 Some(r.read_varint()?)
1646 } else {
1647 None
1648 };
1649 let v177 = if (v172 == 0) || (v172 == 5) {
1650 Some(r.read_u8()?)
1651 } else {
1652 None
1653 };
1654 BossBar {
1655 entity_uuid: v171,
1656 action: v172,
1657 title: v173,
1658 health: v174,
1659 color: v175,
1660 dividers: v176,
1661 flags: v177,
1662 }
1663 })
1664 }
1665}
1666impl Encode for BossBar {
1667 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1668 w.put_uuid(&(*self).entity_uuid);
1669 w.put_varint((*self).action);
1670 match (
1671 &(*self).title,
1672 ((*self).action == 0) || ((*self).action == 3),
1673 ) {
1674 (Some(v178), true) => {
1675 w.put_string(&(*v178))?;
1676 }
1677 (None, false) => {}
1678 _ => {
1679 return Err(EncodeError::SwitchMismatch(
1680 "play.clientbound.boss_bar.title",
1681 ));
1682 }
1683 }
1684 match (
1685 &(*self).health,
1686 ((*self).action == 0) || ((*self).action == 2),
1687 ) {
1688 (Some(v179), true) => {
1689 w.put_f32((*v179));
1690 }
1691 (None, false) => {}
1692 _ => {
1693 return Err(EncodeError::SwitchMismatch(
1694 "play.clientbound.boss_bar.health",
1695 ));
1696 }
1697 }
1698 match (
1699 &(*self).color,
1700 ((*self).action == 0) || ((*self).action == 4),
1701 ) {
1702 (Some(v180), true) => {
1703 w.put_varint((*v180));
1704 }
1705 (None, false) => {}
1706 _ => {
1707 return Err(EncodeError::SwitchMismatch(
1708 "play.clientbound.boss_bar.color",
1709 ));
1710 }
1711 }
1712 match (
1713 &(*self).dividers,
1714 ((*self).action == 0) || ((*self).action == 4),
1715 ) {
1716 (Some(v181), true) => {
1717 w.put_varint((*v181));
1718 }
1719 (None, false) => {}
1720 _ => {
1721 return Err(EncodeError::SwitchMismatch(
1722 "play.clientbound.boss_bar.dividers",
1723 ));
1724 }
1725 }
1726 match (
1727 &(*self).flags,
1728 ((*self).action == 0) || ((*self).action == 5),
1729 ) {
1730 (Some(v182), true) => {
1731 w.put_u8((*v182));
1732 }
1733 (None, false) => {}
1734 _ => {
1735 return Err(EncodeError::SwitchMismatch(
1736 "play.clientbound.boss_bar.flags",
1737 ));
1738 }
1739 }
1740 Ok(())
1741 }
1742}
1743#[cfg(feature = "testgen")]
1744impl Generate for BossBar {
1745 fn generate(g: &mut Gen) -> Self {
1746 {
1747 let v183 = g.uuid();
1748 let v184 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
1749 let v185 = if (v184 == 0) || (v184 == 3) {
1750 Some(g.string())
1751 } else {
1752 None
1753 };
1754 let v186 = if (v184 == 0) || (v184 == 2) {
1755 Some(g.f32())
1756 } else {
1757 None
1758 };
1759 let v187 = if (v184 == 0) || (v184 == 4) {
1760 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
1761 } else {
1762 None
1763 };
1764 let v188 = if (v184 == 0) || (v184 == 4) {
1765 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
1766 } else {
1767 None
1768 };
1769 let v189 = if (v184 == 0) || (v184 == 5) {
1770 Some((g.int_in(0, 255, &[]) as u8))
1771 } else {
1772 None
1773 };
1774 BossBar {
1775 entity_uuid: v183,
1776 action: v184,
1777 title: v185,
1778 health: v186,
1779 color: v187,
1780 dividers: v188,
1781 flags: v189,
1782 }
1783 }
1784 }
1785}
1786impl From<BossBar> for ClientboundPlayPacket {
1787 fn from(p: BossBar) -> Self {
1788 Self::BossBar(p)
1789 }
1790}
1791
1792#[derive(Debug, Clone, PartialEq)]
1794pub struct Difficulty {
1795 pub difficulty: DifficultyDifficulty,
1797 pub difficulty_locked: bool,
1799}
1800impl crate::packet::Packet for Difficulty {
1801 const ID: i32 = id::DIFFICULTY;
1802 const NAME: &'static str = "difficulty";
1803 const STATE: State = State::Play;
1804 const DIRECTION: Direction = Direction::Clientbound;
1805}
1806impl Decode for Difficulty {
1807 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1808 Ok({
1809 let v190 = DifficultyDifficulty(r.read_u8()?);
1810 let v191 = r.read_bool()?;
1811 Difficulty {
1812 difficulty: v190,
1813 difficulty_locked: v191,
1814 }
1815 })
1816 }
1817}
1818impl Encode for Difficulty {
1819 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1820 w.put_u8((*self).difficulty.0);
1821 w.put_bool((*self).difficulty_locked);
1822 Ok(())
1823 }
1824}
1825#[cfg(feature = "testgen")]
1826impl Generate for Difficulty {
1827 fn generate(g: &mut Gen) -> Self {
1828 {
1829 let v192 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
1830 let v193 = g.bool();
1831 Difficulty {
1832 difficulty: v192,
1833 difficulty_locked: v193,
1834 }
1835 }
1836 }
1837}
1838impl From<Difficulty> for ClientboundPlayPacket {
1839 fn from(p: Difficulty) -> Self {
1840 Self::Difficulty(p)
1841 }
1842}
1843
1844#[derive(Debug, Clone, PartialEq)]
1846pub struct Chat {
1847 pub message: ByteString,
1849 pub position: i8,
1851 pub sender: Uuid,
1853}
1854impl crate::packet::Packet for Chat {
1855 const ID: i32 = id::CHAT;
1856 const NAME: &'static str = "chat";
1857 const STATE: State = State::Play;
1858 const DIRECTION: Direction = Direction::Clientbound;
1859}
1860impl Decode for Chat {
1861 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1862 Ok({
1863 let v194 = r.read_string()?;
1864 let v195 = r.read_i8()?;
1865 let v196 = r.read_uuid()?;
1866 Chat {
1867 message: v194,
1868 position: v195,
1869 sender: v196,
1870 }
1871 })
1872 }
1873}
1874impl Encode for Chat {
1875 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1876 w.put_string(&(*self).message)?;
1877 w.put_i8((*self).position);
1878 w.put_uuid(&(*self).sender);
1879 Ok(())
1880 }
1881}
1882#[cfg(feature = "testgen")]
1883impl Generate for Chat {
1884 fn generate(g: &mut Gen) -> Self {
1885 {
1886 let v197 = g.string();
1887 let v198 = (g.int_in(-128, 127, &[]) as i8);
1888 let v199 = g.uuid();
1889 Chat {
1890 message: v197,
1891 position: v198,
1892 sender: v199,
1893 }
1894 }
1895 }
1896}
1897impl From<Chat> for ClientboundPlayPacket {
1898 fn from(p: Chat) -> Self {
1899 Self::Chat(p)
1900 }
1901}
1902
1903#[derive(Debug, Clone, PartialEq)]
1905pub struct TabComplete {
1906 pub transaction_id: i32,
1908 pub start: i32,
1910 pub length: i32,
1912 pub matches: Vec<TabCompleteMatches>,
1914}
1915impl crate::packet::Packet for TabComplete {
1916 const ID: i32 = id::TAB_COMPLETE;
1917 const NAME: &'static str = "tab_complete";
1918 const STATE: State = State::Play;
1919 const DIRECTION: Direction = Direction::Clientbound;
1920}
1921impl Decode for TabComplete {
1922 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
1923 Ok({
1924 let v200 = r.read_varint()?;
1925 let v201 = r.read_varint()?;
1926 let v202 = r.read_varint()?;
1927 let v203 = {
1928 let v204 = {
1929 let c = r.read_varint()?;
1930 r.check_count(i64::from(c), 2)?
1931 };
1932 let mut v205 = Vec::with_capacity(v204.min(crate::codec::PREALLOC_LIMIT));
1933 for _ in 0..v204 {
1934 v205.push({
1935 let v206 = r.read_string()?;
1936 let v207 = if r.read_bool()? {
1937 Some(r.read_string()?)
1938 } else {
1939 None
1940 };
1941 TabCompleteMatches {
1942 r#match: v206,
1943 tooltip: v207,
1944 }
1945 });
1946 }
1947 v205
1948 };
1949 TabComplete {
1950 transaction_id: v200,
1951 start: v201,
1952 length: v202,
1953 matches: v203,
1954 }
1955 })
1956 }
1957}
1958impl Encode for TabComplete {
1959 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
1960 w.put_varint((*self).transaction_id);
1961 w.put_varint((*self).start);
1962 w.put_varint((*self).length);
1963 w.put_len_varint((*self).matches.len())?;
1964 for v208 in (*self).matches.iter() {
1965 w.put_string(&(*v208).r#match)?;
1966 match &(*v208).tooltip {
1967 Some(v209) => {
1968 w.put_u8(1);
1969 w.put_string(&(*v209))?;
1970 }
1971 None => w.put_u8(0),
1972 }
1973 }
1974 Ok(())
1975 }
1976}
1977#[cfg(feature = "testgen")]
1978impl Generate for TabComplete {
1979 fn generate(g: &mut Gen) -> Self {
1980 {
1981 let v210 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1982 let v211 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1983 let v212 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
1984 let v213 = {
1985 let v214 = g.count();
1986 let mut v215 = Vec::with_capacity(v214.min(crate::codec::PREALLOC_LIMIT));
1987 for _ in 0..v214 {
1988 v215.push({
1989 let v216 = g.string();
1990 let v217 = if g.bool() { Some(g.string()) } else { None };
1991 TabCompleteMatches {
1992 r#match: v216,
1993 tooltip: v217,
1994 }
1995 });
1996 }
1997 v215
1998 };
1999 TabComplete {
2000 transaction_id: v210,
2001 start: v211,
2002 length: v212,
2003 matches: v213,
2004 }
2005 }
2006 }
2007}
2008impl From<TabComplete> for ClientboundPlayPacket {
2009 fn from(p: TabComplete) -> Self {
2010 Self::TabComplete(p)
2011 }
2012}
2013
2014#[derive(Debug, Clone, PartialEq)]
2016pub struct DeclareCommands {
2017 pub nodes: Vec<types::CommandNode>,
2019 pub root_index: i32,
2021}
2022impl crate::packet::Packet for DeclareCommands {
2023 const ID: i32 = id::DECLARE_COMMANDS;
2024 const NAME: &'static str = "declare_commands";
2025 const STATE: State = State::Play;
2026 const DIRECTION: Direction = Direction::Clientbound;
2027}
2028impl Decode for DeclareCommands {
2029 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2030 Ok({
2031 let v218 = {
2032 let v219 = {
2033 let c = r.read_varint()?;
2034 r.check_count(i64::from(c), 2)?
2035 };
2036 let mut v220 = Vec::with_capacity(v219.min(crate::codec::PREALLOC_LIMIT));
2037 for _ in 0..v219 {
2038 v220.push(<types::CommandNode as Decode>::decode(r)?);
2039 }
2040 v220
2041 };
2042 let v221 = r.read_varint()?;
2043 DeclareCommands {
2044 nodes: v218,
2045 root_index: v221,
2046 }
2047 })
2048 }
2049}
2050impl Encode for DeclareCommands {
2051 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2052 w.put_len_varint((*self).nodes.len())?;
2053 for v222 in (*self).nodes.iter() {
2054 (*v222).encode(w)?;
2055 }
2056 w.put_varint((*self).root_index);
2057 Ok(())
2058 }
2059}
2060#[cfg(feature = "testgen")]
2061impl Generate for DeclareCommands {
2062 fn generate(g: &mut Gen) -> Self {
2063 {
2064 let v223 = {
2065 let v224 = g.count();
2066 let mut v225 = Vec::with_capacity(v224.min(crate::codec::PREALLOC_LIMIT));
2067 for _ in 0..v224 {
2068 v225.push(<types::CommandNode as Generate>::generate(g));
2069 }
2070 v225
2071 };
2072 let v226 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2073 DeclareCommands {
2074 nodes: v223,
2075 root_index: v226,
2076 }
2077 }
2078 }
2079}
2080impl From<DeclareCommands> for ClientboundPlayPacket {
2081 fn from(p: DeclareCommands) -> Self {
2082 Self::DeclareCommands(p)
2083 }
2084}
2085
2086#[derive(Debug, Clone, PartialEq)]
2088pub struct Transaction {
2089 pub window_id: i8,
2091 pub action: i16,
2093 pub accepted: bool,
2095}
2096impl crate::packet::Packet for Transaction {
2097 const ID: i32 = id::TRANSACTION;
2098 const NAME: &'static str = "transaction";
2099 const STATE: State = State::Play;
2100 const DIRECTION: Direction = Direction::Clientbound;
2101}
2102impl Decode for Transaction {
2103 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2104 Ok({
2105 let v227 = r.read_i8()?;
2106 let v228 = r.read_i16()?;
2107 let v229 = r.read_bool()?;
2108 Transaction {
2109 window_id: v227,
2110 action: v228,
2111 accepted: v229,
2112 }
2113 })
2114 }
2115}
2116impl Encode for Transaction {
2117 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2118 w.put_i8((*self).window_id);
2119 w.put_i16((*self).action);
2120 w.put_bool((*self).accepted);
2121 Ok(())
2122 }
2123}
2124#[cfg(feature = "testgen")]
2125impl Generate for Transaction {
2126 fn generate(g: &mut Gen) -> Self {
2127 {
2128 let v230 = (g.int_in(-128, 127, &[]) as i8);
2129 let v231 = (g.int_in(-32768, 32767, &[]) as i16);
2130 let v232 = g.bool();
2131 Transaction {
2132 window_id: v230,
2133 action: v231,
2134 accepted: v232,
2135 }
2136 }
2137 }
2138}
2139impl From<Transaction> for ClientboundPlayPacket {
2140 fn from(p: Transaction) -> Self {
2141 Self::Transaction(p)
2142 }
2143}
2144
2145#[derive(Debug, Clone, PartialEq)]
2147pub struct CloseWindow {
2148 pub window_id: u8,
2150}
2151impl crate::packet::Packet for CloseWindow {
2152 const ID: i32 = id::CLOSE_WINDOW;
2153 const NAME: &'static str = "close_window";
2154 const STATE: State = State::Play;
2155 const DIRECTION: Direction = Direction::Clientbound;
2156}
2157impl Decode for CloseWindow {
2158 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2159 Ok({
2160 let v233 = r.read_u8()?;
2161 CloseWindow { window_id: v233 }
2162 })
2163 }
2164}
2165impl Encode for CloseWindow {
2166 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2167 w.put_u8((*self).window_id);
2168 Ok(())
2169 }
2170}
2171#[cfg(feature = "testgen")]
2172impl Generate for CloseWindow {
2173 fn generate(g: &mut Gen) -> Self {
2174 {
2175 let v234 = (g.int_in(0, 255, &[]) as u8);
2176 CloseWindow { window_id: v234 }
2177 }
2178 }
2179}
2180impl From<CloseWindow> for ClientboundPlayPacket {
2181 fn from(p: CloseWindow) -> Self {
2182 Self::CloseWindow(p)
2183 }
2184}
2185
2186#[derive(Debug, Clone, PartialEq)]
2188pub struct WindowItems {
2189 pub window_id: u8,
2191 pub items: Vec<types::Slot>,
2193}
2194impl crate::packet::Packet for WindowItems {
2195 const ID: i32 = id::WINDOW_ITEMS;
2196 const NAME: &'static str = "window_items";
2197 const STATE: State = State::Play;
2198 const DIRECTION: Direction = Direction::Clientbound;
2199}
2200impl Decode for WindowItems {
2201 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2202 Ok({
2203 let v235 = r.read_u8()?;
2204 let v236 = {
2205 let v237 = {
2206 let c = r.read_i16()?;
2207 r.check_count(i64::from(c), 1)?
2208 };
2209 let mut v238 = Vec::with_capacity(v237.min(crate::codec::PREALLOC_LIMIT));
2210 for _ in 0..v237 {
2211 v238.push(<types::Slot as Decode>::decode(r)?);
2212 }
2213 v238
2214 };
2215 WindowItems {
2216 window_id: v235,
2217 items: v236,
2218 }
2219 })
2220 }
2221}
2222impl Encode for WindowItems {
2223 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2224 w.put_u8((*self).window_id);
2225 w.put_i16(crate::codec::count_i16((*self).items.len())?);
2226 for v239 in (*self).items.iter() {
2227 (*v239).encode(w)?;
2228 }
2229 Ok(())
2230 }
2231}
2232#[cfg(feature = "testgen")]
2233impl Generate for WindowItems {
2234 fn generate(g: &mut Gen) -> Self {
2235 {
2236 let v240 = (g.int_in(0, 255, &[]) as u8);
2237 let v241 = {
2238 let v242 = g.count();
2239 let mut v243 = Vec::with_capacity(v242.min(crate::codec::PREALLOC_LIMIT));
2240 for _ in 0..v242 {
2241 v243.push(<types::Slot as Generate>::generate(g));
2242 }
2243 v243
2244 };
2245 WindowItems {
2246 window_id: v240,
2247 items: v241,
2248 }
2249 }
2250 }
2251}
2252impl From<WindowItems> for ClientboundPlayPacket {
2253 fn from(p: WindowItems) -> Self {
2254 Self::WindowItems(p)
2255 }
2256}
2257
2258#[derive(Debug, Clone, PartialEq)]
2260pub struct CraftProgressBar {
2261 pub window_id: u8,
2263 pub property: i16,
2265 pub value: i16,
2267}
2268impl crate::packet::Packet for CraftProgressBar {
2269 const ID: i32 = id::CRAFT_PROGRESS_BAR;
2270 const NAME: &'static str = "craft_progress_bar";
2271 const STATE: State = State::Play;
2272 const DIRECTION: Direction = Direction::Clientbound;
2273}
2274impl Decode for CraftProgressBar {
2275 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2276 Ok({
2277 let v244 = r.read_u8()?;
2278 let v245 = r.read_i16()?;
2279 let v246 = r.read_i16()?;
2280 CraftProgressBar {
2281 window_id: v244,
2282 property: v245,
2283 value: v246,
2284 }
2285 })
2286 }
2287}
2288impl Encode for CraftProgressBar {
2289 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2290 w.put_u8((*self).window_id);
2291 w.put_i16((*self).property);
2292 w.put_i16((*self).value);
2293 Ok(())
2294 }
2295}
2296#[cfg(feature = "testgen")]
2297impl Generate for CraftProgressBar {
2298 fn generate(g: &mut Gen) -> Self {
2299 {
2300 let v247 = (g.int_in(0, 255, &[]) as u8);
2301 let v248 = (g.int_in(-32768, 32767, &[]) as i16);
2302 let v249 = (g.int_in(-32768, 32767, &[]) as i16);
2303 CraftProgressBar {
2304 window_id: v247,
2305 property: v248,
2306 value: v249,
2307 }
2308 }
2309 }
2310}
2311impl From<CraftProgressBar> for ClientboundPlayPacket {
2312 fn from(p: CraftProgressBar) -> Self {
2313 Self::CraftProgressBar(p)
2314 }
2315}
2316
2317#[derive(Debug, Clone, PartialEq)]
2319pub struct SetSlot {
2320 pub window_id: i8,
2322 pub slot: i16,
2324 pub item: types::Slot,
2326}
2327impl crate::packet::Packet for SetSlot {
2328 const ID: i32 = id::SET_SLOT;
2329 const NAME: &'static str = "set_slot";
2330 const STATE: State = State::Play;
2331 const DIRECTION: Direction = Direction::Clientbound;
2332}
2333impl Decode for SetSlot {
2334 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2335 Ok({
2336 let v250 = r.read_i8()?;
2337 let v251 = r.read_i16()?;
2338 let v252 = <types::Slot as Decode>::decode(r)?;
2339 SetSlot {
2340 window_id: v250,
2341 slot: v251,
2342 item: v252,
2343 }
2344 })
2345 }
2346}
2347impl Encode for SetSlot {
2348 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2349 w.put_i8((*self).window_id);
2350 w.put_i16((*self).slot);
2351 (*self).item.encode(w)?;
2352 Ok(())
2353 }
2354}
2355#[cfg(feature = "testgen")]
2356impl Generate for SetSlot {
2357 fn generate(g: &mut Gen) -> Self {
2358 {
2359 let v253 = (g.int_in(-128, 127, &[]) as i8);
2360 let v254 = (g.int_in(-32768, 32767, &[]) as i16);
2361 let v255 = <types::Slot as Generate>::generate(g);
2362 SetSlot {
2363 window_id: v253,
2364 slot: v254,
2365 item: v255,
2366 }
2367 }
2368 }
2369}
2370impl From<SetSlot> for ClientboundPlayPacket {
2371 fn from(p: SetSlot) -> Self {
2372 Self::SetSlot(p)
2373 }
2374}
2375
2376#[derive(Debug, Clone, PartialEq)]
2378pub struct SetCooldown {
2379 pub item_id: i32,
2381 pub cooldown_ticks: i32,
2383}
2384impl crate::packet::Packet for SetCooldown {
2385 const ID: i32 = id::SET_COOLDOWN;
2386 const NAME: &'static str = "set_cooldown";
2387 const STATE: State = State::Play;
2388 const DIRECTION: Direction = Direction::Clientbound;
2389}
2390impl Decode for SetCooldown {
2391 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2392 Ok({
2393 let v256 = r.read_varint()?;
2394 let v257 = r.read_varint()?;
2395 SetCooldown {
2396 item_id: v256,
2397 cooldown_ticks: v257,
2398 }
2399 })
2400 }
2401}
2402impl Encode for SetCooldown {
2403 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2404 w.put_varint((*self).item_id);
2405 w.put_varint((*self).cooldown_ticks);
2406 Ok(())
2407 }
2408}
2409#[cfg(feature = "testgen")]
2410impl Generate for SetCooldown {
2411 fn generate(g: &mut Gen) -> Self {
2412 {
2413 let v258 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2414 let v259 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2415 SetCooldown {
2416 item_id: v258,
2417 cooldown_ticks: v259,
2418 }
2419 }
2420 }
2421}
2422impl From<SetCooldown> for ClientboundPlayPacket {
2423 fn from(p: SetCooldown) -> Self {
2424 Self::SetCooldown(p)
2425 }
2426}
2427
2428#[derive(Debug, Clone, PartialEq)]
2430pub struct CustomPayload {
2431 pub channel: ByteString,
2433 pub data: Bytes,
2435}
2436impl crate::packet::Packet for CustomPayload {
2437 const ID: i32 = id::CUSTOM_PAYLOAD;
2438 const NAME: &'static str = "custom_payload";
2439 const STATE: State = State::Play;
2440 const DIRECTION: Direction = Direction::Clientbound;
2441}
2442impl Decode for CustomPayload {
2443 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2444 Ok({
2445 let v260 = r.read_string()?;
2446 let v261 = r.read_rest();
2447 CustomPayload {
2448 channel: v260,
2449 data: v261,
2450 }
2451 })
2452 }
2453}
2454impl Encode for CustomPayload {
2455 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2456 w.put_string(&(*self).channel)?;
2457 w.put_slice(&(*self).data);
2458 Ok(())
2459 }
2460}
2461#[cfg(feature = "testgen")]
2462impl Generate for CustomPayload {
2463 fn generate(g: &mut Gen) -> Self {
2464 {
2465 let v262 = g.string();
2466 let v263 = g.bytes();
2467 CustomPayload {
2468 channel: v262,
2469 data: v263,
2470 }
2471 }
2472 }
2473}
2474impl From<CustomPayload> for ClientboundPlayPacket {
2475 fn from(p: CustomPayload) -> Self {
2476 Self::CustomPayload(p)
2477 }
2478}
2479
2480#[derive(Debug, Clone, PartialEq)]
2482pub struct NamedSoundEffect {
2483 pub sound_name: ByteString,
2485 pub sound_category: i32,
2487 pub x: i32,
2489 pub y: i32,
2491 pub z: i32,
2493 pub volume: f32,
2495 pub pitch: f32,
2497}
2498impl crate::packet::Packet for NamedSoundEffect {
2499 const ID: i32 = id::NAMED_SOUND_EFFECT;
2500 const NAME: &'static str = "named_sound_effect";
2501 const STATE: State = State::Play;
2502 const DIRECTION: Direction = Direction::Clientbound;
2503}
2504impl Decode for NamedSoundEffect {
2505 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2506 Ok({
2507 let v264 = r.read_string()?;
2508 let v265 = r.read_varint()?;
2509 let v266 = r.read_i32()?;
2510 let v267 = r.read_i32()?;
2511 let v268 = r.read_i32()?;
2512 let v269 = r.read_f32()?;
2513 let v270 = r.read_f32()?;
2514 NamedSoundEffect {
2515 sound_name: v264,
2516 sound_category: v265,
2517 x: v266,
2518 y: v267,
2519 z: v268,
2520 volume: v269,
2521 pitch: v270,
2522 }
2523 })
2524 }
2525}
2526impl Encode for NamedSoundEffect {
2527 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2528 w.put_string(&(*self).sound_name)?;
2529 w.put_varint((*self).sound_category);
2530 w.put_i32((*self).x);
2531 w.put_i32((*self).y);
2532 w.put_i32((*self).z);
2533 w.put_f32((*self).volume);
2534 w.put_f32((*self).pitch);
2535 Ok(())
2536 }
2537}
2538#[cfg(feature = "testgen")]
2539impl Generate for NamedSoundEffect {
2540 fn generate(g: &mut Gen) -> Self {
2541 {
2542 let v271 = g.string();
2543 let v272 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2544 let v273 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2545 let v274 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2546 let v275 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2547 let v276 = g.f32();
2548 let v277 = g.f32();
2549 NamedSoundEffect {
2550 sound_name: v271,
2551 sound_category: v272,
2552 x: v273,
2553 y: v274,
2554 z: v275,
2555 volume: v276,
2556 pitch: v277,
2557 }
2558 }
2559 }
2560}
2561impl From<NamedSoundEffect> for ClientboundPlayPacket {
2562 fn from(p: NamedSoundEffect) -> Self {
2563 Self::NamedSoundEffect(p)
2564 }
2565}
2566
2567#[derive(Debug, Clone, PartialEq)]
2569pub struct KickDisconnect {
2570 pub reason: ByteString,
2572}
2573impl crate::packet::Packet for KickDisconnect {
2574 const ID: i32 = id::KICK_DISCONNECT;
2575 const NAME: &'static str = "kick_disconnect";
2576 const STATE: State = State::Play;
2577 const DIRECTION: Direction = Direction::Clientbound;
2578}
2579impl Decode for KickDisconnect {
2580 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2581 Ok({
2582 let v278 = r.read_string()?;
2583 KickDisconnect { reason: v278 }
2584 })
2585 }
2586}
2587impl Encode for KickDisconnect {
2588 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2589 w.put_string(&(*self).reason)?;
2590 Ok(())
2591 }
2592}
2593#[cfg(feature = "testgen")]
2594impl Generate for KickDisconnect {
2595 fn generate(g: &mut Gen) -> Self {
2596 {
2597 let v279 = g.string();
2598 KickDisconnect { reason: v279 }
2599 }
2600 }
2601}
2602impl From<KickDisconnect> for ClientboundPlayPacket {
2603 fn from(p: KickDisconnect) -> Self {
2604 Self::KickDisconnect(p)
2605 }
2606}
2607
2608#[derive(Debug, Clone, PartialEq)]
2610pub struct EntityStatus {
2611 pub entity_id: i32,
2613 pub entity_status: i8,
2615}
2616impl crate::packet::Packet for EntityStatus {
2617 const ID: i32 = id::ENTITY_STATUS;
2618 const NAME: &'static str = "entity_status";
2619 const STATE: State = State::Play;
2620 const DIRECTION: Direction = Direction::Clientbound;
2621}
2622impl Decode for EntityStatus {
2623 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2624 Ok({
2625 let v280 = r.read_i32()?;
2626 let v281 = r.read_i8()?;
2627 EntityStatus {
2628 entity_id: v280,
2629 entity_status: v281,
2630 }
2631 })
2632 }
2633}
2634impl Encode for EntityStatus {
2635 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2636 w.put_i32((*self).entity_id);
2637 w.put_i8((*self).entity_status);
2638 Ok(())
2639 }
2640}
2641#[cfg(feature = "testgen")]
2642impl Generate for EntityStatus {
2643 fn generate(g: &mut Gen) -> Self {
2644 {
2645 let v282 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2646 let v283 = (g.int_in(-128, 127, &[]) as i8);
2647 EntityStatus {
2648 entity_id: v282,
2649 entity_status: v283,
2650 }
2651 }
2652 }
2653}
2654impl From<EntityStatus> for ClientboundPlayPacket {
2655 fn from(p: EntityStatus) -> Self {
2656 Self::EntityStatus(p)
2657 }
2658}
2659
2660#[derive(Debug, Clone, PartialEq)]
2662pub struct Explosion {
2663 pub x: f32,
2665 pub y: f32,
2667 pub z: f32,
2669 pub radius: f32,
2671 pub affected_block_offsets: Vec<ExplosionAffectedBlockOffsets>,
2673 pub player_motion_x: f32,
2675 pub player_motion_y: f32,
2677 pub player_motion_z: f32,
2679}
2680impl crate::packet::Packet for Explosion {
2681 const ID: i32 = id::EXPLOSION;
2682 const NAME: &'static str = "explosion";
2683 const STATE: State = State::Play;
2684 const DIRECTION: Direction = Direction::Clientbound;
2685}
2686impl Decode for Explosion {
2687 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2688 Ok({
2689 let v284 = r.read_f32()?;
2690 let v285 = r.read_f32()?;
2691 let v286 = r.read_f32()?;
2692 let v287 = r.read_f32()?;
2693 let v288 = {
2694 let v289 = {
2695 let c = r.read_i32()?;
2696 r.check_count(i64::from(c), 3)?
2697 };
2698 let mut v290 = Vec::with_capacity(v289.min(crate::codec::PREALLOC_LIMIT));
2699 for _ in 0..v289 {
2700 v290.push({
2701 let v291 = r.read_i8()?;
2702 let v292 = r.read_i8()?;
2703 let v293 = r.read_i8()?;
2704 ExplosionAffectedBlockOffsets {
2705 x: v291,
2706 y: v292,
2707 z: v293,
2708 }
2709 });
2710 }
2711 v290
2712 };
2713 let v294 = r.read_f32()?;
2714 let v295 = r.read_f32()?;
2715 let v296 = r.read_f32()?;
2716 Explosion {
2717 x: v284,
2718 y: v285,
2719 z: v286,
2720 radius: v287,
2721 affected_block_offsets: v288,
2722 player_motion_x: v294,
2723 player_motion_y: v295,
2724 player_motion_z: v296,
2725 }
2726 })
2727 }
2728}
2729impl Encode for Explosion {
2730 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2731 w.put_f32((*self).x);
2732 w.put_f32((*self).y);
2733 w.put_f32((*self).z);
2734 w.put_f32((*self).radius);
2735 w.put_i32(crate::codec::count_i32(
2736 (*self).affected_block_offsets.len(),
2737 )?);
2738 for v297 in (*self).affected_block_offsets.iter() {
2739 w.put_i8((*v297).x);
2740 w.put_i8((*v297).y);
2741 w.put_i8((*v297).z);
2742 }
2743 w.put_f32((*self).player_motion_x);
2744 w.put_f32((*self).player_motion_y);
2745 w.put_f32((*self).player_motion_z);
2746 Ok(())
2747 }
2748}
2749#[cfg(feature = "testgen")]
2750impl Generate for Explosion {
2751 fn generate(g: &mut Gen) -> Self {
2752 {
2753 let v298 = g.f32();
2754 let v299 = g.f32();
2755 let v300 = g.f32();
2756 let v301 = g.f32();
2757 let v302 = {
2758 let v303 = g.count();
2759 let mut v304 = Vec::with_capacity(v303.min(crate::codec::PREALLOC_LIMIT));
2760 for _ in 0..v303 {
2761 v304.push({
2762 let v305 = (g.int_in(-128, 127, &[]) as i8);
2763 let v306 = (g.int_in(-128, 127, &[]) as i8);
2764 let v307 = (g.int_in(-128, 127, &[]) as i8);
2765 ExplosionAffectedBlockOffsets {
2766 x: v305,
2767 y: v306,
2768 z: v307,
2769 }
2770 });
2771 }
2772 v304
2773 };
2774 let v308 = g.f32();
2775 let v309 = g.f32();
2776 let v310 = g.f32();
2777 Explosion {
2778 x: v298,
2779 y: v299,
2780 z: v300,
2781 radius: v301,
2782 affected_block_offsets: v302,
2783 player_motion_x: v308,
2784 player_motion_y: v309,
2785 player_motion_z: v310,
2786 }
2787 }
2788 }
2789}
2790impl From<Explosion> for ClientboundPlayPacket {
2791 fn from(p: Explosion) -> Self {
2792 Self::Explosion(p)
2793 }
2794}
2795
2796#[derive(Debug, Clone, PartialEq)]
2798pub struct UnloadChunk {
2799 pub chunk_x: i32,
2801 pub chunk_z: i32,
2803}
2804impl crate::packet::Packet for UnloadChunk {
2805 const ID: i32 = id::UNLOAD_CHUNK;
2806 const NAME: &'static str = "unload_chunk";
2807 const STATE: State = State::Play;
2808 const DIRECTION: Direction = Direction::Clientbound;
2809}
2810impl Decode for UnloadChunk {
2811 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2812 Ok({
2813 let v311 = r.read_i32()?;
2814 let v312 = r.read_i32()?;
2815 UnloadChunk {
2816 chunk_x: v311,
2817 chunk_z: v312,
2818 }
2819 })
2820 }
2821}
2822impl Encode for UnloadChunk {
2823 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2824 w.put_i32((*self).chunk_x);
2825 w.put_i32((*self).chunk_z);
2826 Ok(())
2827 }
2828}
2829#[cfg(feature = "testgen")]
2830impl Generate for UnloadChunk {
2831 fn generate(g: &mut Gen) -> Self {
2832 {
2833 let v313 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2834 let v314 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2835 UnloadChunk {
2836 chunk_x: v313,
2837 chunk_z: v314,
2838 }
2839 }
2840 }
2841}
2842impl From<UnloadChunk> for ClientboundPlayPacket {
2843 fn from(p: UnloadChunk) -> Self {
2844 Self::UnloadChunk(p)
2845 }
2846}
2847
2848#[derive(Debug, Clone, PartialEq)]
2850pub struct GameStateChange {
2851 pub reason: GameStateChangeReason,
2853 pub game_mode: f32,
2855}
2856impl crate::packet::Packet for GameStateChange {
2857 const ID: i32 = id::GAME_STATE_CHANGE;
2858 const NAME: &'static str = "game_state_change";
2859 const STATE: State = State::Play;
2860 const DIRECTION: Direction = Direction::Clientbound;
2861}
2862impl Decode for GameStateChange {
2863 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2864 Ok({
2865 let v315 = GameStateChangeReason(r.read_u8()?);
2866 let v316 = r.read_f32()?;
2867 GameStateChange {
2868 reason: v315,
2869 game_mode: v316,
2870 }
2871 })
2872 }
2873}
2874impl Encode for GameStateChange {
2875 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2876 w.put_u8((*self).reason.0);
2877 w.put_f32((*self).game_mode);
2878 Ok(())
2879 }
2880}
2881#[cfg(feature = "testgen")]
2882impl Generate for GameStateChange {
2883 fn generate(g: &mut Gen) -> Self {
2884 {
2885 let v317 =
2886 GameStateChangeReason(
2887 g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) as u8
2888 );
2889 let v318 = g.f32();
2890 GameStateChange {
2891 reason: v317,
2892 game_mode: v318,
2893 }
2894 }
2895 }
2896}
2897impl From<GameStateChange> for ClientboundPlayPacket {
2898 fn from(p: GameStateChange) -> Self {
2899 Self::GameStateChange(p)
2900 }
2901}
2902
2903#[derive(Debug, Clone, PartialEq)]
2905pub struct OpenHorseWindow {
2906 pub window_id: u8,
2908 pub nb_slots: i32,
2910 pub entity_id: i32,
2912}
2913impl crate::packet::Packet for OpenHorseWindow {
2914 const ID: i32 = id::OPEN_HORSE_WINDOW;
2915 const NAME: &'static str = "open_horse_window";
2916 const STATE: State = State::Play;
2917 const DIRECTION: Direction = Direction::Clientbound;
2918}
2919impl Decode for OpenHorseWindow {
2920 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2921 Ok({
2922 let v319 = r.read_u8()?;
2923 let v320 = r.read_varint()?;
2924 let v321 = r.read_i32()?;
2925 OpenHorseWindow {
2926 window_id: v319,
2927 nb_slots: v320,
2928 entity_id: v321,
2929 }
2930 })
2931 }
2932}
2933impl Encode for OpenHorseWindow {
2934 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2935 w.put_u8((*self).window_id);
2936 w.put_varint((*self).nb_slots);
2937 w.put_i32((*self).entity_id);
2938 Ok(())
2939 }
2940}
2941#[cfg(feature = "testgen")]
2942impl Generate for OpenHorseWindow {
2943 fn generate(g: &mut Gen) -> Self {
2944 {
2945 let v322 = (g.int_in(0, 255, &[]) as u8);
2946 let v323 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2947 let v324 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
2948 OpenHorseWindow {
2949 window_id: v322,
2950 nb_slots: v323,
2951 entity_id: v324,
2952 }
2953 }
2954 }
2955}
2956impl From<OpenHorseWindow> for ClientboundPlayPacket {
2957 fn from(p: OpenHorseWindow) -> Self {
2958 Self::OpenHorseWindow(p)
2959 }
2960}
2961
2962#[derive(Debug, Clone, PartialEq)]
2964pub struct KeepAlive {
2965 pub keep_alive_id: i64,
2967}
2968impl crate::packet::Packet for KeepAlive {
2969 const ID: i32 = id::KEEP_ALIVE;
2970 const NAME: &'static str = "keep_alive";
2971 const STATE: State = State::Play;
2972 const DIRECTION: Direction = Direction::Clientbound;
2973}
2974impl Decode for KeepAlive {
2975 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
2976 Ok({
2977 let v325 = r.read_i64()?;
2978 KeepAlive {
2979 keep_alive_id: v325,
2980 }
2981 })
2982 }
2983}
2984impl Encode for KeepAlive {
2985 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
2986 w.put_i64((*self).keep_alive_id);
2987 Ok(())
2988 }
2989}
2990#[cfg(feature = "testgen")]
2991impl Generate for KeepAlive {
2992 fn generate(g: &mut Gen) -> Self {
2993 {
2994 let v326 = g.i64();
2995 KeepAlive {
2996 keep_alive_id: v326,
2997 }
2998 }
2999 }
3000}
3001impl From<KeepAlive> for ClientboundPlayPacket {
3002 fn from(p: KeepAlive) -> Self {
3003 Self::KeepAlive(p)
3004 }
3005}
3006
3007#[derive(Debug, Clone, PartialEq)]
3009pub struct MapChunk {
3010 pub x: i32,
3012 pub z: i32,
3014 pub ground_up: bool,
3016 pub bit_map: i32,
3018 pub heightmaps: RawNbt,
3020 pub biomes: Option<Vec<i32>>,
3022 pub chunk_data: Bytes,
3024 pub block_entities: Vec<RawNbt>,
3026}
3027impl crate::packet::Packet for MapChunk {
3028 const ID: i32 = id::MAP_CHUNK;
3029 const NAME: &'static str = "map_chunk";
3030 const STATE: State = State::Play;
3031 const DIRECTION: Direction = Direction::Clientbound;
3032}
3033impl Decode for MapChunk {
3034 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3035 Ok({
3036 let v327 = r.read_i32()?;
3037 let v328 = r.read_i32()?;
3038 let v329 = r.read_bool()?;
3039 let v330 = r.read_varint()?;
3040 let v331 = RawNbt::read(r)?;
3041 let v332 = if v329 {
3042 Some({
3043 let v333 = {
3044 let c = r.read_varint()?;
3045 r.check_count(i64::from(c), 1)?
3046 };
3047 let mut v334 = Vec::with_capacity(v333.min(crate::codec::PREALLOC_LIMIT));
3048 for _ in 0..v333 {
3049 v334.push(r.read_varint()?);
3050 }
3051 v334
3052 })
3053 } else {
3054 None
3055 };
3056 let v335 = r.read_byte_array()?;
3057 let v336 = {
3058 let v337 = {
3059 let c = r.read_varint()?;
3060 r.check_count(i64::from(c), 1)?
3061 };
3062 let mut v338 = Vec::with_capacity(v337.min(crate::codec::PREALLOC_LIMIT));
3063 for _ in 0..v337 {
3064 v338.push(RawNbt::read(r)?);
3065 }
3066 v338
3067 };
3068 MapChunk {
3069 x: v327,
3070 z: v328,
3071 ground_up: v329,
3072 bit_map: v330,
3073 heightmaps: v331,
3074 biomes: v332,
3075 chunk_data: v335,
3076 block_entities: v336,
3077 }
3078 })
3079 }
3080}
3081impl Encode for MapChunk {
3082 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3083 w.put_i32((*self).x);
3084 w.put_i32((*self).z);
3085 w.put_bool((*self).ground_up);
3086 w.put_varint((*self).bit_map);
3087 (*self).heightmaps.write(w);
3088 match (&(*self).biomes, (*self).ground_up) {
3089 (Some(v339), true) => {
3090 w.put_len_varint((*v339).len())?;
3091 for v340 in (*v339).iter() {
3092 w.put_varint((*v340));
3093 }
3094 }
3095 (None, false) => {}
3096 _ => {
3097 return Err(EncodeError::SwitchMismatch(
3098 "play.clientbound.map_chunk.biomes",
3099 ));
3100 }
3101 }
3102 w.put_byte_array(&(*self).chunk_data)?;
3103 w.put_len_varint((*self).block_entities.len())?;
3104 for v341 in (*self).block_entities.iter() {
3105 (*v341).write(w);
3106 }
3107 Ok(())
3108 }
3109}
3110#[cfg(feature = "testgen")]
3111impl Generate for MapChunk {
3112 fn generate(g: &mut Gen) -> Self {
3113 {
3114 let v342 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3115 let v343 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3116 let v344 = g.bool();
3117 let v345 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3118 let v346 = g.nbt();
3119 let v347 = if v344 {
3120 Some({
3121 let v348 = g.count();
3122 let mut v349 = Vec::with_capacity(v348.min(crate::codec::PREALLOC_LIMIT));
3123 for _ in 0..v348 {
3124 v349.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
3125 }
3126 v349
3127 })
3128 } else {
3129 None
3130 };
3131 let v350 = g.bytes();
3132 let v351 = {
3133 let v352 = g.count();
3134 let mut v353 = Vec::with_capacity(v352.min(crate::codec::PREALLOC_LIMIT));
3135 for _ in 0..v352 {
3136 v353.push(g.nbt());
3137 }
3138 v353
3139 };
3140 MapChunk {
3141 x: v342,
3142 z: v343,
3143 ground_up: v344,
3144 bit_map: v345,
3145 heightmaps: v346,
3146 biomes: v347,
3147 chunk_data: v350,
3148 block_entities: v351,
3149 }
3150 }
3151 }
3152}
3153impl From<MapChunk> for ClientboundPlayPacket {
3154 fn from(p: MapChunk) -> Self {
3155 Self::MapChunk(p)
3156 }
3157}
3158
3159#[derive(Debug, Clone, PartialEq)]
3161pub struct WorldEvent {
3162 pub effect_id: i32,
3164 pub location: BlockPos,
3166 pub data: i32,
3168 pub global: bool,
3170}
3171impl crate::packet::Packet for WorldEvent {
3172 const ID: i32 = id::WORLD_EVENT;
3173 const NAME: &'static str = "world_event";
3174 const STATE: State = State::Play;
3175 const DIRECTION: Direction = Direction::Clientbound;
3176}
3177impl Decode for WorldEvent {
3178 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3179 Ok({
3180 let v354 = r.read_i32()?;
3181 let v355 = BlockPos::read(r, PositionLayout::Xzy)?;
3182 let v356 = r.read_i32()?;
3183 let v357 = r.read_bool()?;
3184 WorldEvent {
3185 effect_id: v354,
3186 location: v355,
3187 data: v356,
3188 global: v357,
3189 }
3190 })
3191 }
3192}
3193impl Encode for WorldEvent {
3194 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3195 w.put_i32((*self).effect_id);
3196 (*self).location.write(w, PositionLayout::Xzy)?;
3197 w.put_i32((*self).data);
3198 w.put_bool((*self).global);
3199 Ok(())
3200 }
3201}
3202#[cfg(feature = "testgen")]
3203impl Generate for WorldEvent {
3204 fn generate(g: &mut Gen) -> Self {
3205 {
3206 let v358 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3207 let v359 = g.position();
3208 let v360 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3209 let v361 = g.bool();
3210 WorldEvent {
3211 effect_id: v358,
3212 location: v359,
3213 data: v360,
3214 global: v361,
3215 }
3216 }
3217 }
3218}
3219impl From<WorldEvent> for ClientboundPlayPacket {
3220 fn from(p: WorldEvent) -> Self {
3221 Self::WorldEvent(p)
3222 }
3223}
3224
3225#[derive(Debug, Clone, PartialEq)]
3227pub struct WorldParticles {
3228 pub particle_id: i32,
3230 pub long_distance: bool,
3232 pub x: f64,
3234 pub y: f64,
3236 pub z: f64,
3238 pub offset_x: f32,
3240 pub offset_y: f32,
3242 pub offset_z: f32,
3244 pub particle_data: f32,
3246 pub particles: i32,
3248 pub data: types::ParticleData,
3250}
3251impl crate::packet::Packet for WorldParticles {
3252 const ID: i32 = id::WORLD_PARTICLES;
3253 const NAME: &'static str = "world_particles";
3254 const STATE: State = State::Play;
3255 const DIRECTION: Direction = Direction::Clientbound;
3256}
3257impl Decode for WorldParticles {
3258 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3259 Ok({
3260 let v362 = r.read_i32()?;
3261 let v363 = r.read_bool()?;
3262 let v364 = r.read_f64()?;
3263 let v365 = r.read_f64()?;
3264 let v366 = r.read_f64()?;
3265 let v367 = r.read_f32()?;
3266 let v368 = r.read_f32()?;
3267 let v369 = r.read_f32()?;
3268 let v370 = r.read_f32()?;
3269 let v371 = r.read_i32()?;
3270 let v372 = (if (v362 == 3) {
3271 types::ParticleData::Case3({
3272 let v373 = r.read_varint()?;
3273 types::ParticleDataCase3 { block_state: v373 }
3274 })
3275 } else if (v362 == 14) {
3276 types::ParticleData::Case14({
3277 let v374 = r.read_f32()?;
3278 let v375 = r.read_f32()?;
3279 let v376 = r.read_f32()?;
3280 let v377 = r.read_f32()?;
3281 types::ParticleDataCase14 {
3282 red: v374,
3283 green: v375,
3284 blue: v376,
3285 scale: v377,
3286 }
3287 })
3288 } else if (v362 == 23) {
3289 types::ParticleData::Case23({
3290 let v378 = r.read_varint()?;
3291 types::ParticleDataCase23 { block_state: v378 }
3292 })
3293 } else if (v362 == 34) {
3294 types::ParticleData::Case34({
3295 let v379 = <types::Slot as Decode>::decode(r)?;
3296 types::ParticleDataCase34 { item: v379 }
3297 })
3298 } else {
3299 types::ParticleData::Other
3300 });
3301 WorldParticles {
3302 particle_id: v362,
3303 long_distance: v363,
3304 x: v364,
3305 y: v365,
3306 z: v366,
3307 offset_x: v367,
3308 offset_y: v368,
3309 offset_z: v369,
3310 particle_data: v370,
3311 particles: v371,
3312 data: v372,
3313 }
3314 })
3315 }
3316}
3317impl Encode for WorldParticles {
3318 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3319 w.put_i32((*self).particle_id);
3320 w.put_bool((*self).long_distance);
3321 w.put_f64((*self).x);
3322 w.put_f64((*self).y);
3323 w.put_f64((*self).z);
3324 w.put_f32((*self).offset_x);
3325 w.put_f32((*self).offset_y);
3326 w.put_f32((*self).offset_z);
3327 w.put_f32((*self).particle_data);
3328 w.put_i32((*self).particles);
3329 match &(*self).data {
3330 types::ParticleData::Case3(v380) => {
3331 if !((*self).particle_id == 3) {
3332 return Err(EncodeError::SwitchMismatch(
3333 "play.clientbound.world_particles.data",
3334 ));
3335 }
3336 w.put_varint((*v380).block_state);
3337 }
3338 types::ParticleData::Case14(v381) => {
3339 if !((*self).particle_id == 14) {
3340 return Err(EncodeError::SwitchMismatch(
3341 "play.clientbound.world_particles.data",
3342 ));
3343 }
3344 w.put_f32((*v381).red);
3345 w.put_f32((*v381).green);
3346 w.put_f32((*v381).blue);
3347 w.put_f32((*v381).scale);
3348 }
3349 types::ParticleData::Case23(v382) => {
3350 if !((*self).particle_id == 23) {
3351 return Err(EncodeError::SwitchMismatch(
3352 "play.clientbound.world_particles.data",
3353 ));
3354 }
3355 w.put_varint((*v382).block_state);
3356 }
3357 types::ParticleData::Case34(v383) => {
3358 if !((*self).particle_id == 34) {
3359 return Err(EncodeError::SwitchMismatch(
3360 "play.clientbound.world_particles.data",
3361 ));
3362 }
3363 (*v383).item.encode(w)?;
3364 }
3365 types::ParticleData::Other => {
3366 if !(!(((*self).particle_id == 3)
3367 || ((*self).particle_id == 14)
3368 || ((*self).particle_id == 23)
3369 || ((*self).particle_id == 34)))
3370 {
3371 return Err(EncodeError::SwitchMismatch(
3372 "play.clientbound.world_particles.data",
3373 ));
3374 }
3375 }
3376 }
3377 Ok(())
3378 }
3379}
3380#[cfg(feature = "testgen")]
3381impl Generate for WorldParticles {
3382 fn generate(g: &mut Gen) -> Self {
3383 {
3384 let v384 = (g.int_in(-2147483648, 2147483647, &[3, 14, 23, 34]) as i32);
3385 let v385 = g.bool();
3386 let v386 = g.f64();
3387 let v387 = g.f64();
3388 let v388 = g.f64();
3389 let v389 = g.f32();
3390 let v390 = g.f32();
3391 let v391 = g.f32();
3392 let v392 = g.f32();
3393 let v393 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3394 let v394 = (if (v384 == 3) {
3395 types::ParticleData::Case3({
3396 let v395 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3397 types::ParticleDataCase3 { block_state: v395 }
3398 })
3399 } else if (v384 == 14) {
3400 types::ParticleData::Case14({
3401 let v396 = g.f32();
3402 let v397 = g.f32();
3403 let v398 = g.f32();
3404 let v399 = g.f32();
3405 types::ParticleDataCase14 {
3406 red: v396,
3407 green: v397,
3408 blue: v398,
3409 scale: v399,
3410 }
3411 })
3412 } else if (v384 == 23) {
3413 types::ParticleData::Case23({
3414 let v400 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3415 types::ParticleDataCase23 { block_state: v400 }
3416 })
3417 } else if (v384 == 34) {
3418 types::ParticleData::Case34({
3419 let v401 = <types::Slot as Generate>::generate(g);
3420 types::ParticleDataCase34 { item: v401 }
3421 })
3422 } else {
3423 types::ParticleData::Other
3424 });
3425 WorldParticles {
3426 particle_id: v384,
3427 long_distance: v385,
3428 x: v386,
3429 y: v387,
3430 z: v388,
3431 offset_x: v389,
3432 offset_y: v390,
3433 offset_z: v391,
3434 particle_data: v392,
3435 particles: v393,
3436 data: v394,
3437 }
3438 }
3439 }
3440}
3441impl From<WorldParticles> for ClientboundPlayPacket {
3442 fn from(p: WorldParticles) -> Self {
3443 Self::WorldParticles(p)
3444 }
3445}
3446
3447#[derive(Debug, Clone, PartialEq)]
3449pub struct UpdateLight {
3450 pub chunk_x: i32,
3452 pub chunk_z: i32,
3454 pub trust_edges: bool,
3456 pub sky_light_mask: i32,
3458 pub block_light_mask: i32,
3460 pub empty_sky_light_mask: i32,
3462 pub empty_block_light_mask: i32,
3464 pub data: Bytes,
3466}
3467impl crate::packet::Packet for UpdateLight {
3468 const ID: i32 = id::UPDATE_LIGHT;
3469 const NAME: &'static str = "update_light";
3470 const STATE: State = State::Play;
3471 const DIRECTION: Direction = Direction::Clientbound;
3472}
3473impl Decode for UpdateLight {
3474 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3475 Ok({
3476 let v402 = r.read_varint()?;
3477 let v403 = r.read_varint()?;
3478 let v404 = r.read_bool()?;
3479 let v405 = r.read_varint()?;
3480 let v406 = r.read_varint()?;
3481 let v407 = r.read_varint()?;
3482 let v408 = r.read_varint()?;
3483 let v409 = r.read_rest();
3484 UpdateLight {
3485 chunk_x: v402,
3486 chunk_z: v403,
3487 trust_edges: v404,
3488 sky_light_mask: v405,
3489 block_light_mask: v406,
3490 empty_sky_light_mask: v407,
3491 empty_block_light_mask: v408,
3492 data: v409,
3493 }
3494 })
3495 }
3496}
3497impl Encode for UpdateLight {
3498 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3499 w.put_varint((*self).chunk_x);
3500 w.put_varint((*self).chunk_z);
3501 w.put_bool((*self).trust_edges);
3502 w.put_varint((*self).sky_light_mask);
3503 w.put_varint((*self).block_light_mask);
3504 w.put_varint((*self).empty_sky_light_mask);
3505 w.put_varint((*self).empty_block_light_mask);
3506 w.put_slice(&(*self).data);
3507 Ok(())
3508 }
3509}
3510#[cfg(feature = "testgen")]
3511impl Generate for UpdateLight {
3512 fn generate(g: &mut Gen) -> Self {
3513 {
3514 let v410 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3515 let v411 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3516 let v412 = g.bool();
3517 let v413 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3518 let v414 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3519 let v415 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3520 let v416 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3521 let v417 = g.bytes();
3522 UpdateLight {
3523 chunk_x: v410,
3524 chunk_z: v411,
3525 trust_edges: v412,
3526 sky_light_mask: v413,
3527 block_light_mask: v414,
3528 empty_sky_light_mask: v415,
3529 empty_block_light_mask: v416,
3530 data: v417,
3531 }
3532 }
3533 }
3534}
3535impl From<UpdateLight> for ClientboundPlayPacket {
3536 fn from(p: UpdateLight) -> Self {
3537 Self::UpdateLight(p)
3538 }
3539}
3540
3541#[derive(Debug, Clone, PartialEq)]
3543pub struct Login {
3544 pub entity_id: i32,
3546 pub is_hardcore: bool,
3548 pub game_mode: u8,
3550 pub previous_game_mode: u8,
3552 pub world_names: Vec<ByteString>,
3554 pub dimension_codec: RawNbt,
3556 pub dimension: RawNbt,
3558 pub world_name: ByteString,
3560 pub hashed_seed: i64,
3562 pub max_players: i32,
3564 pub view_distance: i32,
3566 pub reduced_debug_info: bool,
3568 pub enable_respawn_screen: bool,
3570 pub is_debug: bool,
3572 pub is_flat: bool,
3574}
3575impl crate::packet::Packet for Login {
3576 const ID: i32 = id::LOGIN;
3577 const NAME: &'static str = "login";
3578 const STATE: State = State::Play;
3579 const DIRECTION: Direction = Direction::Clientbound;
3580}
3581impl Decode for Login {
3582 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3583 Ok({
3584 let v418 = r.read_i32()?;
3585 let v419 = r.read_bool()?;
3586 let v420 = r.read_u8()?;
3587 let v421 = r.read_u8()?;
3588 let v422 = {
3589 let v423 = {
3590 let c = r.read_varint()?;
3591 r.check_count(i64::from(c), 1)?
3592 };
3593 let mut v424 = Vec::with_capacity(v423.min(crate::codec::PREALLOC_LIMIT));
3594 for _ in 0..v423 {
3595 v424.push(r.read_string()?);
3596 }
3597 v424
3598 };
3599 let v425 = RawNbt::read(r)?;
3600 let v426 = RawNbt::read(r)?;
3601 let v427 = r.read_string()?;
3602 let v428 = r.read_i64()?;
3603 let v429 = r.read_varint()?;
3604 let v430 = r.read_varint()?;
3605 let v431 = r.read_bool()?;
3606 let v432 = r.read_bool()?;
3607 let v433 = r.read_bool()?;
3608 let v434 = r.read_bool()?;
3609 Login {
3610 entity_id: v418,
3611 is_hardcore: v419,
3612 game_mode: v420,
3613 previous_game_mode: v421,
3614 world_names: v422,
3615 dimension_codec: v425,
3616 dimension: v426,
3617 world_name: v427,
3618 hashed_seed: v428,
3619 max_players: v429,
3620 view_distance: v430,
3621 reduced_debug_info: v431,
3622 enable_respawn_screen: v432,
3623 is_debug: v433,
3624 is_flat: v434,
3625 }
3626 })
3627 }
3628}
3629impl Encode for Login {
3630 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3631 w.put_i32((*self).entity_id);
3632 w.put_bool((*self).is_hardcore);
3633 w.put_u8((*self).game_mode);
3634 w.put_u8((*self).previous_game_mode);
3635 w.put_len_varint((*self).world_names.len())?;
3636 for v435 in (*self).world_names.iter() {
3637 w.put_string(&(*v435))?;
3638 }
3639 (*self).dimension_codec.write(w);
3640 (*self).dimension.write(w);
3641 w.put_string(&(*self).world_name)?;
3642 w.put_i64((*self).hashed_seed);
3643 w.put_varint((*self).max_players);
3644 w.put_varint((*self).view_distance);
3645 w.put_bool((*self).reduced_debug_info);
3646 w.put_bool((*self).enable_respawn_screen);
3647 w.put_bool((*self).is_debug);
3648 w.put_bool((*self).is_flat);
3649 Ok(())
3650 }
3651}
3652#[cfg(feature = "testgen")]
3653impl Generate for Login {
3654 fn generate(g: &mut Gen) -> Self {
3655 {
3656 let v436 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3657 let v437 = g.bool();
3658 let v438 = (g.int_in(0, 255, &[]) as u8);
3659 let v439 = (g.int_in(0, 255, &[]) as u8);
3660 let v440 = {
3661 let v441 = g.count();
3662 let mut v442 = Vec::with_capacity(v441.min(crate::codec::PREALLOC_LIMIT));
3663 for _ in 0..v441 {
3664 v442.push(g.string());
3665 }
3666 v442
3667 };
3668 let v443 = g.nbt();
3669 let v444 = g.nbt();
3670 let v445 = g.string();
3671 let v446 = g.i64();
3672 let v447 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3673 let v448 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3674 let v449 = g.bool();
3675 let v450 = g.bool();
3676 let v451 = g.bool();
3677 let v452 = g.bool();
3678 Login {
3679 entity_id: v436,
3680 is_hardcore: v437,
3681 game_mode: v438,
3682 previous_game_mode: v439,
3683 world_names: v440,
3684 dimension_codec: v443,
3685 dimension: v444,
3686 world_name: v445,
3687 hashed_seed: v446,
3688 max_players: v447,
3689 view_distance: v448,
3690 reduced_debug_info: v449,
3691 enable_respawn_screen: v450,
3692 is_debug: v451,
3693 is_flat: v452,
3694 }
3695 }
3696 }
3697}
3698impl From<Login> for ClientboundPlayPacket {
3699 fn from(p: Login) -> Self {
3700 Self::Login(p)
3701 }
3702}
3703
3704#[derive(Debug, Clone, PartialEq)]
3706pub struct Map {
3707 pub item_damage: i32,
3709 pub scale: i8,
3711 pub tracking_position: bool,
3713 pub locked: bool,
3715 pub icons: Vec<MapIcons>,
3717 pub columns: i8,
3719 pub rows: Option<i8>,
3721 pub x: Option<i8>,
3723 pub y: Option<i8>,
3725 pub data: Option<Bytes>,
3727}
3728impl crate::packet::Packet for Map {
3729 const ID: i32 = id::MAP;
3730 const NAME: &'static str = "map";
3731 const STATE: State = State::Play;
3732 const DIRECTION: Direction = Direction::Clientbound;
3733}
3734impl Decode for Map {
3735 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3736 Ok({
3737 let v453 = r.read_varint()?;
3738 let v454 = r.read_i8()?;
3739 let v455 = r.read_bool()?;
3740 let v456 = r.read_bool()?;
3741 let v457 = {
3742 let v458 = {
3743 let c = r.read_varint()?;
3744 r.check_count(i64::from(c), 5)?
3745 };
3746 let mut v459 = Vec::with_capacity(v458.min(crate::codec::PREALLOC_LIMIT));
3747 for _ in 0..v458 {
3748 v459.push({
3749 let v460 = r.read_varint()?;
3750 let v461 = r.read_i8()?;
3751 let v462 = r.read_i8()?;
3752 let v463 = r.read_u8()?;
3753 let v464 = if r.read_bool()? {
3754 Some(r.read_string()?)
3755 } else {
3756 None
3757 };
3758 MapIcons {
3759 r#type: v460,
3760 x: v461,
3761 z: v462,
3762 direction: v463,
3763 display_name: v464,
3764 }
3765 });
3766 }
3767 v459
3768 };
3769 let v465 = r.read_i8()?;
3770 let v466 = if !(v465 == 0) {
3771 Some(r.read_i8()?)
3772 } else {
3773 None
3774 };
3775 let v467 = if !(v465 == 0) {
3776 Some(r.read_i8()?)
3777 } else {
3778 None
3779 };
3780 let v468 = if !(v465 == 0) {
3781 Some(r.read_i8()?)
3782 } else {
3783 None
3784 };
3785 let v469 = if !(v465 == 0) {
3786 Some(r.read_byte_array()?)
3787 } else {
3788 None
3789 };
3790 Map {
3791 item_damage: v453,
3792 scale: v454,
3793 tracking_position: v455,
3794 locked: v456,
3795 icons: v457,
3796 columns: v465,
3797 rows: v466,
3798 x: v467,
3799 y: v468,
3800 data: v469,
3801 }
3802 })
3803 }
3804}
3805impl Encode for Map {
3806 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
3807 w.put_varint((*self).item_damage);
3808 w.put_i8((*self).scale);
3809 w.put_bool((*self).tracking_position);
3810 w.put_bool((*self).locked);
3811 w.put_len_varint((*self).icons.len())?;
3812 for v470 in (*self).icons.iter() {
3813 w.put_varint((*v470).r#type);
3814 w.put_i8((*v470).x);
3815 w.put_i8((*v470).z);
3816 w.put_u8((*v470).direction);
3817 match &(*v470).display_name {
3818 Some(v471) => {
3819 w.put_u8(1);
3820 w.put_string(&(*v471))?;
3821 }
3822 None => w.put_u8(0),
3823 }
3824 }
3825 w.put_i8((*self).columns);
3826 match (&(*self).rows, !((*self).columns == 0)) {
3827 (Some(v472), true) => {
3828 w.put_i8((*v472));
3829 }
3830 (None, false) => {}
3831 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
3832 }
3833 match (&(*self).x, !((*self).columns == 0)) {
3834 (Some(v473), true) => {
3835 w.put_i8((*v473));
3836 }
3837 (None, false) => {}
3838 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
3839 }
3840 match (&(*self).y, !((*self).columns == 0)) {
3841 (Some(v474), true) => {
3842 w.put_i8((*v474));
3843 }
3844 (None, false) => {}
3845 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
3846 }
3847 match (&(*self).data, !((*self).columns == 0)) {
3848 (Some(v475), true) => {
3849 w.put_byte_array(&(*v475))?;
3850 }
3851 (None, false) => {}
3852 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
3853 }
3854 Ok(())
3855 }
3856}
3857#[cfg(feature = "testgen")]
3858impl Generate for Map {
3859 fn generate(g: &mut Gen) -> Self {
3860 {
3861 let v476 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3862 let v477 = (g.int_in(-128, 127, &[]) as i8);
3863 let v478 = g.bool();
3864 let v479 = g.bool();
3865 let v480 = {
3866 let v481 = g.count();
3867 let mut v482 = Vec::with_capacity(v481.min(crate::codec::PREALLOC_LIMIT));
3868 for _ in 0..v481 {
3869 v482.push({
3870 let v483 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
3871 let v484 = (g.int_in(-128, 127, &[]) as i8);
3872 let v485 = (g.int_in(-128, 127, &[]) as i8);
3873 let v486 = (g.int_in(0, 255, &[]) as u8);
3874 let v487 = if g.bool() { Some(g.string()) } else { None };
3875 MapIcons {
3876 r#type: v483,
3877 x: v484,
3878 z: v485,
3879 direction: v486,
3880 display_name: v487,
3881 }
3882 });
3883 }
3884 v482
3885 };
3886 let v488 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
3887 let v489 = if !(v488 == 0) {
3888 Some((g.int_in(-128, 127, &[]) as i8))
3889 } else {
3890 None
3891 };
3892 let v490 = if !(v488 == 0) {
3893 Some((g.int_in(-128, 127, &[]) as i8))
3894 } else {
3895 None
3896 };
3897 let v491 = if !(v488 == 0) {
3898 Some((g.int_in(-128, 127, &[]) as i8))
3899 } else {
3900 None
3901 };
3902 let v492 = if !(v488 == 0) { Some(g.bytes()) } else { None };
3903 Map {
3904 item_damage: v476,
3905 scale: v477,
3906 tracking_position: v478,
3907 locked: v479,
3908 icons: v480,
3909 columns: v488,
3910 rows: v489,
3911 x: v490,
3912 y: v491,
3913 data: v492,
3914 }
3915 }
3916 }
3917}
3918impl From<Map> for ClientboundPlayPacket {
3919 fn from(p: Map) -> Self {
3920 Self::Map(p)
3921 }
3922}
3923
3924#[derive(Debug, Clone, PartialEq)]
3926pub struct TradeList {
3927 pub window_id: i32,
3929 pub trades: Vec<TradeListTrades>,
3931 pub villager_level: i32,
3933 pub experience: i32,
3935 pub is_regular_villager: bool,
3937 pub can_restock: bool,
3939}
3940impl crate::packet::Packet for TradeList {
3941 const ID: i32 = id::TRADE_LIST;
3942 const NAME: &'static str = "trade_list";
3943 const STATE: State = State::Play;
3944 const DIRECTION: Direction = Direction::Clientbound;
3945}
3946impl Decode for TradeList {
3947 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
3948 Ok({
3949 let v493 = r.read_varint()?;
3950 let v494 = {
3951 let v495 = {
3952 let c = r.read_u8()?;
3953 r.check_count(i64::from(c), 28)?
3954 };
3955 let mut v496 = Vec::with_capacity(v495.min(crate::codec::PREALLOC_LIMIT));
3956 for _ in 0..v495 {
3957 v496.push({
3958 let v497 = <types::Slot as Decode>::decode(r)?;
3959 let v498 = <types::Slot as Decode>::decode(r)?;
3960 let v499 = if r.read_bool()? {
3961 Some(<types::Slot as Decode>::decode(r)?)
3962 } else {
3963 None
3964 };
3965 let v500 = r.read_bool()?;
3966 let v501 = r.read_i32()?;
3967 let v502 = r.read_i32()?;
3968 let v503 = r.read_i32()?;
3969 let v504 = r.read_i32()?;
3970 let v505 = r.read_f32()?;
3971 let v506 = r.read_i32()?;
3972 TradeListTrades {
3973 input_item1: v497,
3974 output_item: v498,
3975 input_item2: v499,
3976 trade_disabled: v500,
3977 nb_trade_uses: v501,
3978 maximum_nb_trade_uses: v502,
3979 xp: v503,
3980 special_price: v504,
3981 price_multiplier: v505,
3982 demand: v506,
3983 }
3984 });
3985 }
3986 v496
3987 };
3988 let v507 = r.read_varint()?;
3989 let v508 = r.read_varint()?;
3990 let v509 = r.read_bool()?;
3991 let v510 = r.read_bool()?;
3992 TradeList {
3993 window_id: v493,
3994 trades: v494,
3995 villager_level: v507,
3996 experience: v508,
3997 is_regular_villager: v509,
3998 can_restock: v510,
3999 }
4000 })
4001 }
4002}
4003impl Encode for TradeList {
4004 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4005 w.put_varint((*self).window_id);
4006 w.put_u8(crate::codec::count_u8((*self).trades.len())?);
4007 for v511 in (*self).trades.iter() {
4008 (*v511).input_item1.encode(w)?;
4009 (*v511).output_item.encode(w)?;
4010 match &(*v511).input_item2 {
4011 Some(v512) => {
4012 w.put_u8(1);
4013 (*v512).encode(w)?;
4014 }
4015 None => w.put_u8(0),
4016 }
4017 w.put_bool((*v511).trade_disabled);
4018 w.put_i32((*v511).nb_trade_uses);
4019 w.put_i32((*v511).maximum_nb_trade_uses);
4020 w.put_i32((*v511).xp);
4021 w.put_i32((*v511).special_price);
4022 w.put_f32((*v511).price_multiplier);
4023 w.put_i32((*v511).demand);
4024 }
4025 w.put_varint((*self).villager_level);
4026 w.put_varint((*self).experience);
4027 w.put_bool((*self).is_regular_villager);
4028 w.put_bool((*self).can_restock);
4029 Ok(())
4030 }
4031}
4032#[cfg(feature = "testgen")]
4033impl Generate for TradeList {
4034 fn generate(g: &mut Gen) -> Self {
4035 {
4036 let v513 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4037 let v514 = {
4038 let v515 = g.count();
4039 let mut v516 = Vec::with_capacity(v515.min(crate::codec::PREALLOC_LIMIT));
4040 for _ in 0..v515 {
4041 v516.push({
4042 let v517 = <types::Slot as Generate>::generate(g);
4043 let v518 = <types::Slot as Generate>::generate(g);
4044 let v519 = if g.bool() {
4045 Some(<types::Slot as Generate>::generate(g))
4046 } else {
4047 None
4048 };
4049 let v520 = g.bool();
4050 let v521 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4051 let v522 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4052 let v523 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4053 let v524 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4054 let v525 = g.f32();
4055 let v526 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4056 TradeListTrades {
4057 input_item1: v517,
4058 output_item: v518,
4059 input_item2: v519,
4060 trade_disabled: v520,
4061 nb_trade_uses: v521,
4062 maximum_nb_trade_uses: v522,
4063 xp: v523,
4064 special_price: v524,
4065 price_multiplier: v525,
4066 demand: v526,
4067 }
4068 });
4069 }
4070 v516
4071 };
4072 let v527 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4073 let v528 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4074 let v529 = g.bool();
4075 let v530 = g.bool();
4076 TradeList {
4077 window_id: v513,
4078 trades: v514,
4079 villager_level: v527,
4080 experience: v528,
4081 is_regular_villager: v529,
4082 can_restock: v530,
4083 }
4084 }
4085 }
4086}
4087impl From<TradeList> for ClientboundPlayPacket {
4088 fn from(p: TradeList) -> Self {
4089 Self::TradeList(p)
4090 }
4091}
4092
4093#[derive(Debug, Clone, PartialEq)]
4095pub struct RelEntityMove {
4096 pub entity_id: i32,
4098 pub d_x: i16,
4100 pub d_y: i16,
4102 pub d_z: i16,
4104 pub on_ground: bool,
4106}
4107impl crate::packet::Packet for RelEntityMove {
4108 const ID: i32 = id::REL_ENTITY_MOVE;
4109 const NAME: &'static str = "rel_entity_move";
4110 const STATE: State = State::Play;
4111 const DIRECTION: Direction = Direction::Clientbound;
4112}
4113impl Decode for RelEntityMove {
4114 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4115 Ok({
4116 let v531 = r.read_varint()?;
4117 let v532 = r.read_i16()?;
4118 let v533 = r.read_i16()?;
4119 let v534 = r.read_i16()?;
4120 let v535 = r.read_bool()?;
4121 RelEntityMove {
4122 entity_id: v531,
4123 d_x: v532,
4124 d_y: v533,
4125 d_z: v534,
4126 on_ground: v535,
4127 }
4128 })
4129 }
4130}
4131impl Encode for RelEntityMove {
4132 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4133 w.put_varint((*self).entity_id);
4134 w.put_i16((*self).d_x);
4135 w.put_i16((*self).d_y);
4136 w.put_i16((*self).d_z);
4137 w.put_bool((*self).on_ground);
4138 Ok(())
4139 }
4140}
4141#[cfg(feature = "testgen")]
4142impl Generate for RelEntityMove {
4143 fn generate(g: &mut Gen) -> Self {
4144 {
4145 let v536 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4146 let v537 = (g.int_in(-32768, 32767, &[]) as i16);
4147 let v538 = (g.int_in(-32768, 32767, &[]) as i16);
4148 let v539 = (g.int_in(-32768, 32767, &[]) as i16);
4149 let v540 = g.bool();
4150 RelEntityMove {
4151 entity_id: v536,
4152 d_x: v537,
4153 d_y: v538,
4154 d_z: v539,
4155 on_ground: v540,
4156 }
4157 }
4158 }
4159}
4160impl From<RelEntityMove> for ClientboundPlayPacket {
4161 fn from(p: RelEntityMove) -> Self {
4162 Self::RelEntityMove(p)
4163 }
4164}
4165
4166#[derive(Debug, Clone, PartialEq)]
4168pub struct EntityMoveLook {
4169 pub entity_id: i32,
4171 pub d_x: i16,
4173 pub d_y: i16,
4175 pub d_z: i16,
4177 pub yaw: i8,
4179 pub pitch: i8,
4181 pub on_ground: bool,
4183}
4184impl crate::packet::Packet for EntityMoveLook {
4185 const ID: i32 = id::ENTITY_MOVE_LOOK;
4186 const NAME: &'static str = "entity_move_look";
4187 const STATE: State = State::Play;
4188 const DIRECTION: Direction = Direction::Clientbound;
4189}
4190impl Decode for EntityMoveLook {
4191 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4192 Ok({
4193 let v541 = r.read_varint()?;
4194 let v542 = r.read_i16()?;
4195 let v543 = r.read_i16()?;
4196 let v544 = r.read_i16()?;
4197 let v545 = r.read_i8()?;
4198 let v546 = r.read_i8()?;
4199 let v547 = r.read_bool()?;
4200 EntityMoveLook {
4201 entity_id: v541,
4202 d_x: v542,
4203 d_y: v543,
4204 d_z: v544,
4205 yaw: v545,
4206 pitch: v546,
4207 on_ground: v547,
4208 }
4209 })
4210 }
4211}
4212impl Encode for EntityMoveLook {
4213 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4214 w.put_varint((*self).entity_id);
4215 w.put_i16((*self).d_x);
4216 w.put_i16((*self).d_y);
4217 w.put_i16((*self).d_z);
4218 w.put_i8((*self).yaw);
4219 w.put_i8((*self).pitch);
4220 w.put_bool((*self).on_ground);
4221 Ok(())
4222 }
4223}
4224#[cfg(feature = "testgen")]
4225impl Generate for EntityMoveLook {
4226 fn generate(g: &mut Gen) -> Self {
4227 {
4228 let v548 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4229 let v549 = (g.int_in(-32768, 32767, &[]) as i16);
4230 let v550 = (g.int_in(-32768, 32767, &[]) as i16);
4231 let v551 = (g.int_in(-32768, 32767, &[]) as i16);
4232 let v552 = (g.int_in(-128, 127, &[]) as i8);
4233 let v553 = (g.int_in(-128, 127, &[]) as i8);
4234 let v554 = g.bool();
4235 EntityMoveLook {
4236 entity_id: v548,
4237 d_x: v549,
4238 d_y: v550,
4239 d_z: v551,
4240 yaw: v552,
4241 pitch: v553,
4242 on_ground: v554,
4243 }
4244 }
4245 }
4246}
4247impl From<EntityMoveLook> for ClientboundPlayPacket {
4248 fn from(p: EntityMoveLook) -> Self {
4249 Self::EntityMoveLook(p)
4250 }
4251}
4252
4253#[derive(Debug, Clone, PartialEq)]
4255pub struct EntityLook {
4256 pub entity_id: i32,
4258 pub yaw: i8,
4260 pub pitch: i8,
4262 pub on_ground: bool,
4264}
4265impl crate::packet::Packet for EntityLook {
4266 const ID: i32 = id::ENTITY_LOOK;
4267 const NAME: &'static str = "entity_look";
4268 const STATE: State = State::Play;
4269 const DIRECTION: Direction = Direction::Clientbound;
4270}
4271impl Decode for EntityLook {
4272 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4273 Ok({
4274 let v555 = r.read_varint()?;
4275 let v556 = r.read_i8()?;
4276 let v557 = r.read_i8()?;
4277 let v558 = r.read_bool()?;
4278 EntityLook {
4279 entity_id: v555,
4280 yaw: v556,
4281 pitch: v557,
4282 on_ground: v558,
4283 }
4284 })
4285 }
4286}
4287impl Encode for EntityLook {
4288 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4289 w.put_varint((*self).entity_id);
4290 w.put_i8((*self).yaw);
4291 w.put_i8((*self).pitch);
4292 w.put_bool((*self).on_ground);
4293 Ok(())
4294 }
4295}
4296#[cfg(feature = "testgen")]
4297impl Generate for EntityLook {
4298 fn generate(g: &mut Gen) -> Self {
4299 {
4300 let v559 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4301 let v560 = (g.int_in(-128, 127, &[]) as i8);
4302 let v561 = (g.int_in(-128, 127, &[]) as i8);
4303 let v562 = g.bool();
4304 EntityLook {
4305 entity_id: v559,
4306 yaw: v560,
4307 pitch: v561,
4308 on_ground: v562,
4309 }
4310 }
4311 }
4312}
4313impl From<EntityLook> for ClientboundPlayPacket {
4314 fn from(p: EntityLook) -> Self {
4315 Self::EntityLook(p)
4316 }
4317}
4318
4319#[derive(Debug, Clone, PartialEq)]
4321pub struct Entity {
4322 pub entity_id: i32,
4324}
4325impl crate::packet::Packet for Entity {
4326 const ID: i32 = id::ENTITY;
4327 const NAME: &'static str = "entity";
4328 const STATE: State = State::Play;
4329 const DIRECTION: Direction = Direction::Clientbound;
4330}
4331impl Decode for Entity {
4332 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4333 Ok({
4334 let v563 = r.read_varint()?;
4335 Entity { entity_id: v563 }
4336 })
4337 }
4338}
4339impl Encode for Entity {
4340 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4341 w.put_varint((*self).entity_id);
4342 Ok(())
4343 }
4344}
4345#[cfg(feature = "testgen")]
4346impl Generate for Entity {
4347 fn generate(g: &mut Gen) -> Self {
4348 {
4349 let v564 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4350 Entity { entity_id: v564 }
4351 }
4352 }
4353}
4354impl From<Entity> for ClientboundPlayPacket {
4355 fn from(p: Entity) -> Self {
4356 Self::Entity(p)
4357 }
4358}
4359
4360#[derive(Debug, Clone, PartialEq)]
4362pub struct VehicleMove {
4363 pub x: f64,
4365 pub y: f64,
4367 pub z: f64,
4369 pub yaw: f32,
4371 pub pitch: f32,
4373}
4374impl crate::packet::Packet for VehicleMove {
4375 const ID: i32 = id::VEHICLE_MOVE;
4376 const NAME: &'static str = "vehicle_move";
4377 const STATE: State = State::Play;
4378 const DIRECTION: Direction = Direction::Clientbound;
4379}
4380impl Decode for VehicleMove {
4381 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4382 Ok({
4383 let v565 = r.read_f64()?;
4384 let v566 = r.read_f64()?;
4385 let v567 = r.read_f64()?;
4386 let v568 = r.read_f32()?;
4387 let v569 = r.read_f32()?;
4388 VehicleMove {
4389 x: v565,
4390 y: v566,
4391 z: v567,
4392 yaw: v568,
4393 pitch: v569,
4394 }
4395 })
4396 }
4397}
4398impl Encode for VehicleMove {
4399 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4400 w.put_f64((*self).x);
4401 w.put_f64((*self).y);
4402 w.put_f64((*self).z);
4403 w.put_f32((*self).yaw);
4404 w.put_f32((*self).pitch);
4405 Ok(())
4406 }
4407}
4408#[cfg(feature = "testgen")]
4409impl Generate for VehicleMove {
4410 fn generate(g: &mut Gen) -> Self {
4411 {
4412 let v570 = g.f64();
4413 let v571 = g.f64();
4414 let v572 = g.f64();
4415 let v573 = g.f32();
4416 let v574 = g.f32();
4417 VehicleMove {
4418 x: v570,
4419 y: v571,
4420 z: v572,
4421 yaw: v573,
4422 pitch: v574,
4423 }
4424 }
4425 }
4426}
4427impl From<VehicleMove> for ClientboundPlayPacket {
4428 fn from(p: VehicleMove) -> Self {
4429 Self::VehicleMove(p)
4430 }
4431}
4432
4433#[derive(Debug, Clone, PartialEq)]
4435pub struct OpenBook {
4436 pub hand: i32,
4438}
4439impl crate::packet::Packet for OpenBook {
4440 const ID: i32 = id::OPEN_BOOK;
4441 const NAME: &'static str = "open_book";
4442 const STATE: State = State::Play;
4443 const DIRECTION: Direction = Direction::Clientbound;
4444}
4445impl Decode for OpenBook {
4446 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4447 Ok({
4448 let v575 = r.read_varint()?;
4449 OpenBook { hand: v575 }
4450 })
4451 }
4452}
4453impl Encode for OpenBook {
4454 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4455 w.put_varint((*self).hand);
4456 Ok(())
4457 }
4458}
4459#[cfg(feature = "testgen")]
4460impl Generate for OpenBook {
4461 fn generate(g: &mut Gen) -> Self {
4462 {
4463 let v576 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4464 OpenBook { hand: v576 }
4465 }
4466 }
4467}
4468impl From<OpenBook> for ClientboundPlayPacket {
4469 fn from(p: OpenBook) -> Self {
4470 Self::OpenBook(p)
4471 }
4472}
4473
4474#[derive(Debug, Clone, PartialEq)]
4476pub struct OpenWindow {
4477 pub window_id: i32,
4479 pub inventory_type: i32,
4481 pub window_title: ByteString,
4483}
4484impl crate::packet::Packet for OpenWindow {
4485 const ID: i32 = id::OPEN_WINDOW;
4486 const NAME: &'static str = "open_window";
4487 const STATE: State = State::Play;
4488 const DIRECTION: Direction = Direction::Clientbound;
4489}
4490impl Decode for OpenWindow {
4491 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4492 Ok({
4493 let v577 = r.read_varint()?;
4494 let v578 = r.read_varint()?;
4495 let v579 = r.read_string()?;
4496 OpenWindow {
4497 window_id: v577,
4498 inventory_type: v578,
4499 window_title: v579,
4500 }
4501 })
4502 }
4503}
4504impl Encode for OpenWindow {
4505 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4506 w.put_varint((*self).window_id);
4507 w.put_varint((*self).inventory_type);
4508 w.put_string(&(*self).window_title)?;
4509 Ok(())
4510 }
4511}
4512#[cfg(feature = "testgen")]
4513impl Generate for OpenWindow {
4514 fn generate(g: &mut Gen) -> Self {
4515 {
4516 let v580 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4517 let v581 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
4518 let v582 = g.string();
4519 OpenWindow {
4520 window_id: v580,
4521 inventory_type: v581,
4522 window_title: v582,
4523 }
4524 }
4525 }
4526}
4527impl From<OpenWindow> for ClientboundPlayPacket {
4528 fn from(p: OpenWindow) -> Self {
4529 Self::OpenWindow(p)
4530 }
4531}
4532
4533#[derive(Debug, Clone, PartialEq)]
4535pub struct OpenSignEntity {
4536 pub location: BlockPos,
4538}
4539impl crate::packet::Packet for OpenSignEntity {
4540 const ID: i32 = id::OPEN_SIGN_ENTITY;
4541 const NAME: &'static str = "open_sign_entity";
4542 const STATE: State = State::Play;
4543 const DIRECTION: Direction = Direction::Clientbound;
4544}
4545impl Decode for OpenSignEntity {
4546 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4547 Ok({
4548 let v583 = BlockPos::read(r, PositionLayout::Xzy)?;
4549 OpenSignEntity { location: v583 }
4550 })
4551 }
4552}
4553impl Encode for OpenSignEntity {
4554 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4555 (*self).location.write(w, PositionLayout::Xzy)?;
4556 Ok(())
4557 }
4558}
4559#[cfg(feature = "testgen")]
4560impl Generate for OpenSignEntity {
4561 fn generate(g: &mut Gen) -> Self {
4562 {
4563 let v584 = g.position();
4564 OpenSignEntity { location: v584 }
4565 }
4566 }
4567}
4568impl From<OpenSignEntity> for ClientboundPlayPacket {
4569 fn from(p: OpenSignEntity) -> Self {
4570 Self::OpenSignEntity(p)
4571 }
4572}
4573
4574#[derive(Debug, Clone, PartialEq)]
4576pub struct CraftRecipeResponse {
4577 pub window_id: i8,
4579 pub recipe: ByteString,
4581}
4582impl crate::packet::Packet for CraftRecipeResponse {
4583 const ID: i32 = id::CRAFT_RECIPE_RESPONSE;
4584 const NAME: &'static str = "craft_recipe_response";
4585 const STATE: State = State::Play;
4586 const DIRECTION: Direction = Direction::Clientbound;
4587}
4588impl Decode for CraftRecipeResponse {
4589 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4590 Ok({
4591 let v585 = r.read_i8()?;
4592 let v586 = r.read_string()?;
4593 CraftRecipeResponse {
4594 window_id: v585,
4595 recipe: v586,
4596 }
4597 })
4598 }
4599}
4600impl Encode for CraftRecipeResponse {
4601 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4602 w.put_i8((*self).window_id);
4603 w.put_string(&(*self).recipe)?;
4604 Ok(())
4605 }
4606}
4607#[cfg(feature = "testgen")]
4608impl Generate for CraftRecipeResponse {
4609 fn generate(g: &mut Gen) -> Self {
4610 {
4611 let v587 = (g.int_in(-128, 127, &[]) as i8);
4612 let v588 = g.string();
4613 CraftRecipeResponse {
4614 window_id: v587,
4615 recipe: v588,
4616 }
4617 }
4618 }
4619}
4620impl From<CraftRecipeResponse> for ClientboundPlayPacket {
4621 fn from(p: CraftRecipeResponse) -> Self {
4622 Self::CraftRecipeResponse(p)
4623 }
4624}
4625
4626#[derive(Debug, Clone, PartialEq)]
4628pub struct Abilities {
4629 pub flags: i8,
4631 pub flying_speed: f32,
4633 pub walking_speed: f32,
4635}
4636impl crate::packet::Packet for Abilities {
4637 const ID: i32 = id::ABILITIES;
4638 const NAME: &'static str = "abilities";
4639 const STATE: State = State::Play;
4640 const DIRECTION: Direction = Direction::Clientbound;
4641}
4642impl Decode for Abilities {
4643 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4644 Ok({
4645 let v589 = r.read_i8()?;
4646 let v590 = r.read_f32()?;
4647 let v591 = r.read_f32()?;
4648 Abilities {
4649 flags: v589,
4650 flying_speed: v590,
4651 walking_speed: v591,
4652 }
4653 })
4654 }
4655}
4656impl Encode for Abilities {
4657 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4658 w.put_i8((*self).flags);
4659 w.put_f32((*self).flying_speed);
4660 w.put_f32((*self).walking_speed);
4661 Ok(())
4662 }
4663}
4664#[cfg(feature = "testgen")]
4665impl Generate for Abilities {
4666 fn generate(g: &mut Gen) -> Self {
4667 {
4668 let v592 = (g.int_in(-128, 127, &[]) as i8);
4669 let v593 = g.f32();
4670 let v594 = g.f32();
4671 Abilities {
4672 flags: v592,
4673 flying_speed: v593,
4674 walking_speed: v594,
4675 }
4676 }
4677 }
4678}
4679impl From<Abilities> for ClientboundPlayPacket {
4680 fn from(p: Abilities) -> Self {
4681 Self::Abilities(p)
4682 }
4683}
4684
4685#[derive(Debug, Clone, PartialEq)]
4687pub struct CombatEvent {
4688 pub event: i32,
4690 pub duration: Option<i32>,
4692 pub player_id: Option<i32>,
4694 pub entity_id: Option<i32>,
4696 pub message: Option<ByteString>,
4698}
4699impl crate::packet::Packet for CombatEvent {
4700 const ID: i32 = id::COMBAT_EVENT;
4701 const NAME: &'static str = "combat_event";
4702 const STATE: State = State::Play;
4703 const DIRECTION: Direction = Direction::Clientbound;
4704}
4705impl Decode for CombatEvent {
4706 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4707 Ok({
4708 let v595 = r.read_varint()?;
4709 let v596 = if (v595 == 1) {
4710 Some(r.read_varint()?)
4711 } else {
4712 None
4713 };
4714 let v597 = if (v595 == 2) {
4715 Some(r.read_varint()?)
4716 } else {
4717 None
4718 };
4719 let v598 = if (v595 == 1) || (v595 == 2) {
4720 Some(r.read_i32()?)
4721 } else {
4722 None
4723 };
4724 let v599 = if (v595 == 2) {
4725 Some(r.read_string()?)
4726 } else {
4727 None
4728 };
4729 CombatEvent {
4730 event: v595,
4731 duration: v596,
4732 player_id: v597,
4733 entity_id: v598,
4734 message: v599,
4735 }
4736 })
4737 }
4738}
4739impl Encode for CombatEvent {
4740 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4741 w.put_varint((*self).event);
4742 match (&(*self).duration, ((*self).event == 1)) {
4743 (Some(v600), true) => {
4744 w.put_varint((*v600));
4745 }
4746 (None, false) => {}
4747 _ => {
4748 return Err(EncodeError::SwitchMismatch(
4749 "play.clientbound.combat_event.duration",
4750 ));
4751 }
4752 }
4753 match (&(*self).player_id, ((*self).event == 2)) {
4754 (Some(v601), true) => {
4755 w.put_varint((*v601));
4756 }
4757 (None, false) => {}
4758 _ => {
4759 return Err(EncodeError::SwitchMismatch(
4760 "play.clientbound.combat_event.playerId",
4761 ));
4762 }
4763 }
4764 match (
4765 &(*self).entity_id,
4766 ((*self).event == 1) || ((*self).event == 2),
4767 ) {
4768 (Some(v602), true) => {
4769 w.put_i32((*v602));
4770 }
4771 (None, false) => {}
4772 _ => {
4773 return Err(EncodeError::SwitchMismatch(
4774 "play.clientbound.combat_event.entityId",
4775 ));
4776 }
4777 }
4778 match (&(*self).message, ((*self).event == 2)) {
4779 (Some(v603), true) => {
4780 w.put_string(&(*v603))?;
4781 }
4782 (None, false) => {}
4783 _ => {
4784 return Err(EncodeError::SwitchMismatch(
4785 "play.clientbound.combat_event.message",
4786 ));
4787 }
4788 }
4789 Ok(())
4790 }
4791}
4792#[cfg(feature = "testgen")]
4793impl Generate for CombatEvent {
4794 fn generate(g: &mut Gen) -> Self {
4795 {
4796 let v604 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
4797 let v605 = if (v604 == 1) {
4798 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4799 } else {
4800 None
4801 };
4802 let v606 = if (v604 == 2) {
4803 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4804 } else {
4805 None
4806 };
4807 let v607 = if (v604 == 1) || (v604 == 2) {
4808 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
4809 } else {
4810 None
4811 };
4812 let v608 = if (v604 == 2) { Some(g.string()) } else { None };
4813 CombatEvent {
4814 event: v604,
4815 duration: v605,
4816 player_id: v606,
4817 entity_id: v607,
4818 message: v608,
4819 }
4820 }
4821 }
4822}
4823impl From<CombatEvent> for ClientboundPlayPacket {
4824 fn from(p: CombatEvent) -> Self {
4825 Self::CombatEvent(p)
4826 }
4827}
4828
4829#[derive(Debug, Clone, PartialEq)]
4831pub struct PlayerInfo {
4832 pub action: PlayerInfoAction,
4834 pub data: Vec<PlayerInfoData>,
4836}
4837impl crate::packet::Packet for PlayerInfo {
4838 const ID: i32 = id::PLAYER_INFO;
4839 const NAME: &'static str = "player_info";
4840 const STATE: State = State::Play;
4841 const DIRECTION: Direction = Direction::Clientbound;
4842}
4843impl Decode for PlayerInfo {
4844 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
4845 Ok({
4846 let v609 = PlayerInfoAction(r.read_varint()?);
4847 let v610 = {
4848 let v611 = {
4849 let c = r.read_varint()?;
4850 r.check_count(i64::from(c), 16)?
4851 };
4852 let mut v612 = Vec::with_capacity(v611.min(crate::codec::PREALLOC_LIMIT));
4853 for _ in 0..v611 {
4854 v612.push({
4855 let v613 = r.read_uuid()?;
4856 let v614 = (if (v609.0 == 0) {
4857 PlayerInfoDataBody::AddPlayer({
4858 let v615 = r.read_string()?;
4859 let v616 = {
4860 let v617 = {
4861 let c = r.read_varint()?;
4862 r.check_count(i64::from(c), 3)?
4863 };
4864 let mut v618 =
4865 Vec::with_capacity(v617.min(crate::codec::PREALLOC_LIMIT));
4866 for _ in 0..v617 {
4867 v618.push({
4868 let v619 = r.read_string()?;
4869 let v620 = r.read_string()?;
4870 let v621 = if r.read_bool()? {
4871 Some(r.read_string()?)
4872 } else {
4873 None
4874 };
4875 PlayerInfoDataBodyAddPlayerProperties {
4876 name: v619,
4877 value: v620,
4878 signature: v621,
4879 }
4880 });
4881 }
4882 v618
4883 };
4884 let v622 = r.read_varint()?;
4885 let v623 = r.read_varint()?;
4886 let v624 = if r.read_bool()? {
4887 Some(r.read_string()?)
4888 } else {
4889 None
4890 };
4891 PlayerInfoDataBodyAddPlayer {
4892 name: v615,
4893 properties: v616,
4894 gamemode: v622,
4895 ping: v623,
4896 display_name: v624,
4897 }
4898 })
4899 } else if (v609.0 == 1) {
4900 PlayerInfoDataBody::UpdateGameMode({
4901 let v625 = r.read_varint()?;
4902 PlayerInfoDataBodyUpdateGameMode { gamemode: v625 }
4903 })
4904 } else if (v609.0 == 2) {
4905 PlayerInfoDataBody::UpdateLatency({
4906 let v626 = r.read_varint()?;
4907 PlayerInfoDataBodyUpdateLatency { ping: v626 }
4908 })
4909 } else if (v609.0 == 3) {
4910 PlayerInfoDataBody::UpdateDisplayName({
4911 let v627 = if r.read_bool()? {
4912 Some(r.read_string()?)
4913 } else {
4914 None
4915 };
4916 PlayerInfoDataBodyUpdateDisplayName { display_name: v627 }
4917 })
4918 } else if (v609.0 == 4) {
4919 PlayerInfoDataBody::RemovePlayer
4920 } else {
4921 PlayerInfoDataBody::Other
4922 });
4923 PlayerInfoData {
4924 uuid: v613,
4925 body: v614,
4926 }
4927 });
4928 }
4929 v612
4930 };
4931 PlayerInfo {
4932 action: v609,
4933 data: v610,
4934 }
4935 })
4936 }
4937}
4938impl Encode for PlayerInfo {
4939 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
4940 w.put_varint((*self).action.0);
4941 w.put_len_varint((*self).data.len())?;
4942 for v628 in (*self).data.iter() {
4943 w.put_uuid(&(*v628).uuid);
4944 match &(*v628).body {
4945 PlayerInfoDataBody::AddPlayer(v629) => {
4946 if !((*self).action.0 == 0) {
4947 return Err(EncodeError::SwitchMismatch(
4948 "play.clientbound.player_info.data.body",
4949 ));
4950 }
4951 w.put_string(&(*v629).name)?;
4952 w.put_len_varint((*v629).properties.len())?;
4953 for v630 in (*v629).properties.iter() {
4954 w.put_string(&(*v630).name)?;
4955 w.put_string(&(*v630).value)?;
4956 match &(*v630).signature {
4957 Some(v631) => {
4958 w.put_u8(1);
4959 w.put_string(&(*v631))?;
4960 }
4961 None => w.put_u8(0),
4962 }
4963 }
4964 w.put_varint((*v629).gamemode);
4965 w.put_varint((*v629).ping);
4966 match &(*v629).display_name {
4967 Some(v632) => {
4968 w.put_u8(1);
4969 w.put_string(&(*v632))?;
4970 }
4971 None => w.put_u8(0),
4972 }
4973 }
4974 PlayerInfoDataBody::UpdateGameMode(v633) => {
4975 if !((*self).action.0 == 1) {
4976 return Err(EncodeError::SwitchMismatch(
4977 "play.clientbound.player_info.data.body",
4978 ));
4979 }
4980 w.put_varint((*v633).gamemode);
4981 }
4982 PlayerInfoDataBody::UpdateLatency(v634) => {
4983 if !((*self).action.0 == 2) {
4984 return Err(EncodeError::SwitchMismatch(
4985 "play.clientbound.player_info.data.body",
4986 ));
4987 }
4988 w.put_varint((*v634).ping);
4989 }
4990 PlayerInfoDataBody::UpdateDisplayName(v635) => {
4991 if !((*self).action.0 == 3) {
4992 return Err(EncodeError::SwitchMismatch(
4993 "play.clientbound.player_info.data.body",
4994 ));
4995 }
4996 match &(*v635).display_name {
4997 Some(v636) => {
4998 w.put_u8(1);
4999 w.put_string(&(*v636))?;
5000 }
5001 None => w.put_u8(0),
5002 }
5003 }
5004 PlayerInfoDataBody::RemovePlayer => {
5005 if !((*self).action.0 == 4) {
5006 return Err(EncodeError::SwitchMismatch(
5007 "play.clientbound.player_info.data.body",
5008 ));
5009 }
5010 }
5011 PlayerInfoDataBody::Other => {
5012 if !(!(((*self).action.0 == 0)
5013 || ((*self).action.0 == 1)
5014 || ((*self).action.0 == 2)
5015 || ((*self).action.0 == 3)
5016 || ((*self).action.0 == 4)))
5017 {
5018 return Err(EncodeError::SwitchMismatch(
5019 "play.clientbound.player_info.data.body",
5020 ));
5021 }
5022 }
5023 }
5024 }
5025 Ok(())
5026 }
5027}
5028#[cfg(feature = "testgen")]
5029impl Generate for PlayerInfo {
5030 fn generate(g: &mut Gen) -> Self {
5031 {
5032 let v637 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
5033 let v638 = {
5034 let v639 = g.count();
5035 let mut v640 = Vec::with_capacity(v639.min(crate::codec::PREALLOC_LIMIT));
5036 for _ in 0..v639 {
5037 v640.push({
5038 let v641 = g.uuid();
5039 let v642 = (if (v637.0 == 0) {
5040 PlayerInfoDataBody::AddPlayer({
5041 let v643 = g.string();
5042 let v644 = {
5043 let v645 = g.count();
5044 let mut v646 =
5045 Vec::with_capacity(v645.min(crate::codec::PREALLOC_LIMIT));
5046 for _ in 0..v645 {
5047 v646.push({
5048 let v647 = g.string();
5049 let v648 = g.string();
5050 let v649 =
5051 if g.bool() { Some(g.string()) } else { None };
5052 PlayerInfoDataBodyAddPlayerProperties {
5053 name: v647,
5054 value: v648,
5055 signature: v649,
5056 }
5057 });
5058 }
5059 v646
5060 };
5061 let v650 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5062 let v651 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5063 let v652 = if g.bool() { Some(g.string()) } else { None };
5064 PlayerInfoDataBodyAddPlayer {
5065 name: v643,
5066 properties: v644,
5067 gamemode: v650,
5068 ping: v651,
5069 display_name: v652,
5070 }
5071 })
5072 } else if (v637.0 == 1) {
5073 PlayerInfoDataBody::UpdateGameMode({
5074 let v653 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5075 PlayerInfoDataBodyUpdateGameMode { gamemode: v653 }
5076 })
5077 } else if (v637.0 == 2) {
5078 PlayerInfoDataBody::UpdateLatency({
5079 let v654 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5080 PlayerInfoDataBodyUpdateLatency { ping: v654 }
5081 })
5082 } else if (v637.0 == 3) {
5083 PlayerInfoDataBody::UpdateDisplayName({
5084 let v655 = if g.bool() { Some(g.string()) } else { None };
5085 PlayerInfoDataBodyUpdateDisplayName { display_name: v655 }
5086 })
5087 } else if (v637.0 == 4) {
5088 PlayerInfoDataBody::RemovePlayer
5089 } else {
5090 PlayerInfoDataBody::Other
5091 });
5092 PlayerInfoData {
5093 uuid: v641,
5094 body: v642,
5095 }
5096 });
5097 }
5098 v640
5099 };
5100 PlayerInfo {
5101 action: v637,
5102 data: v638,
5103 }
5104 }
5105 }
5106}
5107impl From<PlayerInfo> for ClientboundPlayPacket {
5108 fn from(p: PlayerInfo) -> Self {
5109 Self::PlayerInfo(p)
5110 }
5111}
5112
5113#[derive(Debug, Clone, PartialEq)]
5115pub struct FacePlayer {
5116 pub feet_eyes: i32,
5118 pub x: f64,
5120 pub y: f64,
5122 pub z: f64,
5124 pub is_entity: bool,
5126 pub entity_id: Option<i32>,
5128 pub entity_feet_eyes: Option<ByteString>,
5130}
5131impl crate::packet::Packet for FacePlayer {
5132 const ID: i32 = id::FACE_PLAYER;
5133 const NAME: &'static str = "face_player";
5134 const STATE: State = State::Play;
5135 const DIRECTION: Direction = Direction::Clientbound;
5136}
5137impl Decode for FacePlayer {
5138 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5139 Ok({
5140 let v656 = r.read_varint()?;
5141 let v657 = r.read_f64()?;
5142 let v658 = r.read_f64()?;
5143 let v659 = r.read_f64()?;
5144 let v660 = r.read_bool()?;
5145 let v661 = if v660 { Some(r.read_varint()?) } else { None };
5146 let v662 = if v660 { Some(r.read_string()?) } else { None };
5147 FacePlayer {
5148 feet_eyes: v656,
5149 x: v657,
5150 y: v658,
5151 z: v659,
5152 is_entity: v660,
5153 entity_id: v661,
5154 entity_feet_eyes: v662,
5155 }
5156 })
5157 }
5158}
5159impl Encode for FacePlayer {
5160 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5161 w.put_varint((*self).feet_eyes);
5162 w.put_f64((*self).x);
5163 w.put_f64((*self).y);
5164 w.put_f64((*self).z);
5165 w.put_bool((*self).is_entity);
5166 match (&(*self).entity_id, (*self).is_entity) {
5167 (Some(v663), true) => {
5168 w.put_varint((*v663));
5169 }
5170 (None, false) => {}
5171 _ => {
5172 return Err(EncodeError::SwitchMismatch(
5173 "play.clientbound.face_player.entityId",
5174 ));
5175 }
5176 }
5177 match (&(*self).entity_feet_eyes, (*self).is_entity) {
5178 (Some(v664), true) => {
5179 w.put_string(&(*v664))?;
5180 }
5181 (None, false) => {}
5182 _ => {
5183 return Err(EncodeError::SwitchMismatch(
5184 "play.clientbound.face_player.entity_feet_eyes",
5185 ));
5186 }
5187 }
5188 Ok(())
5189 }
5190}
5191#[cfg(feature = "testgen")]
5192impl Generate for FacePlayer {
5193 fn generate(g: &mut Gen) -> Self {
5194 {
5195 let v665 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5196 let v666 = g.f64();
5197 let v667 = g.f64();
5198 let v668 = g.f64();
5199 let v669 = g.bool();
5200 let v670 = if v669 {
5201 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
5202 } else {
5203 None
5204 };
5205 let v671 = if v669 { Some(g.string()) } else { None };
5206 FacePlayer {
5207 feet_eyes: v665,
5208 x: v666,
5209 y: v667,
5210 z: v668,
5211 is_entity: v669,
5212 entity_id: v670,
5213 entity_feet_eyes: v671,
5214 }
5215 }
5216 }
5217}
5218impl From<FacePlayer> for ClientboundPlayPacket {
5219 fn from(p: FacePlayer) -> Self {
5220 Self::FacePlayer(p)
5221 }
5222}
5223
5224#[derive(Debug, Clone, PartialEq)]
5226pub struct Position {
5227 pub x: f64,
5229 pub y: f64,
5231 pub z: f64,
5233 pub yaw: f32,
5235 pub pitch: f32,
5237 pub flags: i8,
5239 pub teleport_id: i32,
5241}
5242impl crate::packet::Packet for Position {
5243 const ID: i32 = id::POSITION;
5244 const NAME: &'static str = "position";
5245 const STATE: State = State::Play;
5246 const DIRECTION: Direction = Direction::Clientbound;
5247}
5248impl Decode for Position {
5249 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5250 Ok({
5251 let v672 = r.read_f64()?;
5252 let v673 = r.read_f64()?;
5253 let v674 = r.read_f64()?;
5254 let v675 = r.read_f32()?;
5255 let v676 = r.read_f32()?;
5256 let v677 = r.read_i8()?;
5257 let v678 = r.read_varint()?;
5258 Position {
5259 x: v672,
5260 y: v673,
5261 z: v674,
5262 yaw: v675,
5263 pitch: v676,
5264 flags: v677,
5265 teleport_id: v678,
5266 }
5267 })
5268 }
5269}
5270impl Encode for Position {
5271 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5272 w.put_f64((*self).x);
5273 w.put_f64((*self).y);
5274 w.put_f64((*self).z);
5275 w.put_f32((*self).yaw);
5276 w.put_f32((*self).pitch);
5277 w.put_i8((*self).flags);
5278 w.put_varint((*self).teleport_id);
5279 Ok(())
5280 }
5281}
5282#[cfg(feature = "testgen")]
5283impl Generate for Position {
5284 fn generate(g: &mut Gen) -> Self {
5285 {
5286 let v679 = g.f64();
5287 let v680 = g.f64();
5288 let v681 = g.f64();
5289 let v682 = g.f32();
5290 let v683 = g.f32();
5291 let v684 = (g.int_in(-128, 127, &[]) as i8);
5292 let v685 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5293 Position {
5294 x: v679,
5295 y: v680,
5296 z: v681,
5297 yaw: v682,
5298 pitch: v683,
5299 flags: v684,
5300 teleport_id: v685,
5301 }
5302 }
5303 }
5304}
5305impl From<Position> for ClientboundPlayPacket {
5306 fn from(p: Position) -> Self {
5307 Self::Position(p)
5308 }
5309}
5310
5311#[derive(Debug, Clone, PartialEq)]
5313pub struct UnlockRecipes {
5314 pub action: i32,
5316 pub crafting_book_open: bool,
5318 pub filtering_craftable: bool,
5320 pub smelting_book_open: bool,
5322 pub filtering_smeltable: bool,
5324 pub blast_furnace_open: bool,
5326 pub filtering_blast_furnace: bool,
5328 pub smoker_book_open: bool,
5330 pub filtering_smoker: bool,
5332 pub recipes1: Vec<ByteString>,
5334 pub recipes2: Option<Vec<ByteString>>,
5336}
5337impl crate::packet::Packet for UnlockRecipes {
5338 const ID: i32 = id::UNLOCK_RECIPES;
5339 const NAME: &'static str = "unlock_recipes";
5340 const STATE: State = State::Play;
5341 const DIRECTION: Direction = Direction::Clientbound;
5342}
5343impl Decode for UnlockRecipes {
5344 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5345 Ok({
5346 let v686 = r.read_varint()?;
5347 let v687 = r.read_bool()?;
5348 let v688 = r.read_bool()?;
5349 let v689 = r.read_bool()?;
5350 let v690 = r.read_bool()?;
5351 let v691 = r.read_bool()?;
5352 let v692 = r.read_bool()?;
5353 let v693 = r.read_bool()?;
5354 let v694 = r.read_bool()?;
5355 let v695 = {
5356 let v696 = {
5357 let c = r.read_varint()?;
5358 r.check_count(i64::from(c), 1)?
5359 };
5360 let mut v697 = Vec::with_capacity(v696.min(crate::codec::PREALLOC_LIMIT));
5361 for _ in 0..v696 {
5362 v697.push(r.read_string()?);
5363 }
5364 v697
5365 };
5366 let v698 = if (v686 == 0) {
5367 Some({
5368 let v699 = {
5369 let c = r.read_varint()?;
5370 r.check_count(i64::from(c), 1)?
5371 };
5372 let mut v700 = Vec::with_capacity(v699.min(crate::codec::PREALLOC_LIMIT));
5373 for _ in 0..v699 {
5374 v700.push(r.read_string()?);
5375 }
5376 v700
5377 })
5378 } else {
5379 None
5380 };
5381 UnlockRecipes {
5382 action: v686,
5383 crafting_book_open: v687,
5384 filtering_craftable: v688,
5385 smelting_book_open: v689,
5386 filtering_smeltable: v690,
5387 blast_furnace_open: v691,
5388 filtering_blast_furnace: v692,
5389 smoker_book_open: v693,
5390 filtering_smoker: v694,
5391 recipes1: v695,
5392 recipes2: v698,
5393 }
5394 })
5395 }
5396}
5397impl Encode for UnlockRecipes {
5398 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5399 w.put_varint((*self).action);
5400 w.put_bool((*self).crafting_book_open);
5401 w.put_bool((*self).filtering_craftable);
5402 w.put_bool((*self).smelting_book_open);
5403 w.put_bool((*self).filtering_smeltable);
5404 w.put_bool((*self).blast_furnace_open);
5405 w.put_bool((*self).filtering_blast_furnace);
5406 w.put_bool((*self).smoker_book_open);
5407 w.put_bool((*self).filtering_smoker);
5408 w.put_len_varint((*self).recipes1.len())?;
5409 for v701 in (*self).recipes1.iter() {
5410 w.put_string(&(*v701))?;
5411 }
5412 match (&(*self).recipes2, ((*self).action == 0)) {
5413 (Some(v702), true) => {
5414 w.put_len_varint((*v702).len())?;
5415 for v703 in (*v702).iter() {
5416 w.put_string(&(*v703))?;
5417 }
5418 }
5419 (None, false) => {}
5420 _ => {
5421 return Err(EncodeError::SwitchMismatch(
5422 "play.clientbound.unlock_recipes.recipes2",
5423 ));
5424 }
5425 }
5426 Ok(())
5427 }
5428}
5429#[cfg(feature = "testgen")]
5430impl Generate for UnlockRecipes {
5431 fn generate(g: &mut Gen) -> Self {
5432 {
5433 let v704 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
5434 let v705 = g.bool();
5435 let v706 = g.bool();
5436 let v707 = g.bool();
5437 let v708 = g.bool();
5438 let v709 = g.bool();
5439 let v710 = g.bool();
5440 let v711 = g.bool();
5441 let v712 = g.bool();
5442 let v713 = {
5443 let v714 = g.count();
5444 let mut v715 = Vec::with_capacity(v714.min(crate::codec::PREALLOC_LIMIT));
5445 for _ in 0..v714 {
5446 v715.push(g.string());
5447 }
5448 v715
5449 };
5450 let v716 = if (v704 == 0) {
5451 Some({
5452 let v717 = g.count();
5453 let mut v718 = Vec::with_capacity(v717.min(crate::codec::PREALLOC_LIMIT));
5454 for _ in 0..v717 {
5455 v718.push(g.string());
5456 }
5457 v718
5458 })
5459 } else {
5460 None
5461 };
5462 UnlockRecipes {
5463 action: v704,
5464 crafting_book_open: v705,
5465 filtering_craftable: v706,
5466 smelting_book_open: v707,
5467 filtering_smeltable: v708,
5468 blast_furnace_open: v709,
5469 filtering_blast_furnace: v710,
5470 smoker_book_open: v711,
5471 filtering_smoker: v712,
5472 recipes1: v713,
5473 recipes2: v716,
5474 }
5475 }
5476 }
5477}
5478impl From<UnlockRecipes> for ClientboundPlayPacket {
5479 fn from(p: UnlockRecipes) -> Self {
5480 Self::UnlockRecipes(p)
5481 }
5482}
5483
5484#[derive(Debug, Clone, PartialEq)]
5486pub struct EntityDestroy {
5487 pub entity_ids: Vec<i32>,
5489}
5490impl crate::packet::Packet for EntityDestroy {
5491 const ID: i32 = id::ENTITY_DESTROY;
5492 const NAME: &'static str = "entity_destroy";
5493 const STATE: State = State::Play;
5494 const DIRECTION: Direction = Direction::Clientbound;
5495}
5496impl Decode for EntityDestroy {
5497 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5498 Ok({
5499 let v719 = {
5500 let v720 = {
5501 let c = r.read_varint()?;
5502 r.check_count(i64::from(c), 1)?
5503 };
5504 let mut v721 = Vec::with_capacity(v720.min(crate::codec::PREALLOC_LIMIT));
5505 for _ in 0..v720 {
5506 v721.push(r.read_varint()?);
5507 }
5508 v721
5509 };
5510 EntityDestroy { entity_ids: v719 }
5511 })
5512 }
5513}
5514impl Encode for EntityDestroy {
5515 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5516 w.put_len_varint((*self).entity_ids.len())?;
5517 for v722 in (*self).entity_ids.iter() {
5518 w.put_varint((*v722));
5519 }
5520 Ok(())
5521 }
5522}
5523#[cfg(feature = "testgen")]
5524impl Generate for EntityDestroy {
5525 fn generate(g: &mut Gen) -> Self {
5526 {
5527 let v723 = {
5528 let v724 = g.count();
5529 let mut v725 = Vec::with_capacity(v724.min(crate::codec::PREALLOC_LIMIT));
5530 for _ in 0..v724 {
5531 v725.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
5532 }
5533 v725
5534 };
5535 EntityDestroy { entity_ids: v723 }
5536 }
5537 }
5538}
5539impl From<EntityDestroy> for ClientboundPlayPacket {
5540 fn from(p: EntityDestroy) -> Self {
5541 Self::EntityDestroy(p)
5542 }
5543}
5544
5545#[derive(Debug, Clone, PartialEq)]
5547pub struct RemoveEntityEffect {
5548 pub entity_id: i32,
5550 pub effect_id: i8,
5552}
5553impl crate::packet::Packet for RemoveEntityEffect {
5554 const ID: i32 = id::REMOVE_ENTITY_EFFECT;
5555 const NAME: &'static str = "remove_entity_effect";
5556 const STATE: State = State::Play;
5557 const DIRECTION: Direction = Direction::Clientbound;
5558}
5559impl Decode for RemoveEntityEffect {
5560 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5561 Ok({
5562 let v726 = r.read_varint()?;
5563 let v727 = r.read_i8()?;
5564 RemoveEntityEffect {
5565 entity_id: v726,
5566 effect_id: v727,
5567 }
5568 })
5569 }
5570}
5571impl Encode for RemoveEntityEffect {
5572 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5573 w.put_varint((*self).entity_id);
5574 w.put_i8((*self).effect_id);
5575 Ok(())
5576 }
5577}
5578#[cfg(feature = "testgen")]
5579impl Generate for RemoveEntityEffect {
5580 fn generate(g: &mut Gen) -> Self {
5581 {
5582 let v728 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5583 let v729 = (g.int_in(-128, 127, &[]) as i8);
5584 RemoveEntityEffect {
5585 entity_id: v728,
5586 effect_id: v729,
5587 }
5588 }
5589 }
5590}
5591impl From<RemoveEntityEffect> for ClientboundPlayPacket {
5592 fn from(p: RemoveEntityEffect) -> Self {
5593 Self::RemoveEntityEffect(p)
5594 }
5595}
5596
5597#[derive(Debug, Clone, PartialEq)]
5599pub struct ResourcePackSend {
5600 pub url: ByteString,
5602 pub hash: ByteString,
5604}
5605impl crate::packet::Packet for ResourcePackSend {
5606 const ID: i32 = id::RESOURCE_PACK_SEND;
5607 const NAME: &'static str = "resource_pack_send";
5608 const STATE: State = State::Play;
5609 const DIRECTION: Direction = Direction::Clientbound;
5610}
5611impl Decode for ResourcePackSend {
5612 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5613 Ok({
5614 let v730 = r.read_string()?;
5615 let v731 = r.read_string()?;
5616 ResourcePackSend {
5617 url: v730,
5618 hash: v731,
5619 }
5620 })
5621 }
5622}
5623impl Encode for ResourcePackSend {
5624 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5625 w.put_string(&(*self).url)?;
5626 w.put_string(&(*self).hash)?;
5627 Ok(())
5628 }
5629}
5630#[cfg(feature = "testgen")]
5631impl Generate for ResourcePackSend {
5632 fn generate(g: &mut Gen) -> Self {
5633 {
5634 let v732 = g.string();
5635 let v733 = g.string();
5636 ResourcePackSend {
5637 url: v732,
5638 hash: v733,
5639 }
5640 }
5641 }
5642}
5643impl From<ResourcePackSend> for ClientboundPlayPacket {
5644 fn from(p: ResourcePackSend) -> Self {
5645 Self::ResourcePackSend(p)
5646 }
5647}
5648
5649#[derive(Debug, Clone, PartialEq)]
5651pub struct Respawn {
5652 pub dimension: RawNbt,
5654 pub world_name: ByteString,
5656 pub hashed_seed: i64,
5658 pub gamemode: u8,
5660 pub previous_gamemode: u8,
5662 pub is_debug: bool,
5664 pub is_flat: bool,
5666 pub copy_metadata: bool,
5668}
5669impl crate::packet::Packet for Respawn {
5670 const ID: i32 = id::RESPAWN;
5671 const NAME: &'static str = "respawn";
5672 const STATE: State = State::Play;
5673 const DIRECTION: Direction = Direction::Clientbound;
5674}
5675impl Decode for Respawn {
5676 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5677 Ok({
5678 let v734 = RawNbt::read(r)?;
5679 let v735 = r.read_string()?;
5680 let v736 = r.read_i64()?;
5681 let v737 = r.read_u8()?;
5682 let v738 = r.read_u8()?;
5683 let v739 = r.read_bool()?;
5684 let v740 = r.read_bool()?;
5685 let v741 = r.read_bool()?;
5686 Respawn {
5687 dimension: v734,
5688 world_name: v735,
5689 hashed_seed: v736,
5690 gamemode: v737,
5691 previous_gamemode: v738,
5692 is_debug: v739,
5693 is_flat: v740,
5694 copy_metadata: v741,
5695 }
5696 })
5697 }
5698}
5699impl Encode for Respawn {
5700 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5701 (*self).dimension.write(w);
5702 w.put_string(&(*self).world_name)?;
5703 w.put_i64((*self).hashed_seed);
5704 w.put_u8((*self).gamemode);
5705 w.put_u8((*self).previous_gamemode);
5706 w.put_bool((*self).is_debug);
5707 w.put_bool((*self).is_flat);
5708 w.put_bool((*self).copy_metadata);
5709 Ok(())
5710 }
5711}
5712#[cfg(feature = "testgen")]
5713impl Generate for Respawn {
5714 fn generate(g: &mut Gen) -> Self {
5715 {
5716 let v742 = g.nbt();
5717 let v743 = g.string();
5718 let v744 = g.i64();
5719 let v745 = (g.int_in(0, 255, &[]) as u8);
5720 let v746 = (g.int_in(0, 255, &[]) as u8);
5721 let v747 = g.bool();
5722 let v748 = g.bool();
5723 let v749 = g.bool();
5724 Respawn {
5725 dimension: v742,
5726 world_name: v743,
5727 hashed_seed: v744,
5728 gamemode: v745,
5729 previous_gamemode: v746,
5730 is_debug: v747,
5731 is_flat: v748,
5732 copy_metadata: v749,
5733 }
5734 }
5735 }
5736}
5737impl From<Respawn> for ClientboundPlayPacket {
5738 fn from(p: Respawn) -> Self {
5739 Self::Respawn(p)
5740 }
5741}
5742
5743#[derive(Debug, Clone, PartialEq)]
5745pub struct EntityHeadRotation {
5746 pub entity_id: i32,
5748 pub head_yaw: i8,
5750}
5751impl crate::packet::Packet for EntityHeadRotation {
5752 const ID: i32 = id::ENTITY_HEAD_ROTATION;
5753 const NAME: &'static str = "entity_head_rotation";
5754 const STATE: State = State::Play;
5755 const DIRECTION: Direction = Direction::Clientbound;
5756}
5757impl Decode for EntityHeadRotation {
5758 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5759 Ok({
5760 let v750 = r.read_varint()?;
5761 let v751 = r.read_i8()?;
5762 EntityHeadRotation {
5763 entity_id: v750,
5764 head_yaw: v751,
5765 }
5766 })
5767 }
5768}
5769impl Encode for EntityHeadRotation {
5770 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5771 w.put_varint((*self).entity_id);
5772 w.put_i8((*self).head_yaw);
5773 Ok(())
5774 }
5775}
5776#[cfg(feature = "testgen")]
5777impl Generate for EntityHeadRotation {
5778 fn generate(g: &mut Gen) -> Self {
5779 {
5780 let v752 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
5781 let v753 = (g.int_in(-128, 127, &[]) as i8);
5782 EntityHeadRotation {
5783 entity_id: v752,
5784 head_yaw: v753,
5785 }
5786 }
5787 }
5788}
5789impl From<EntityHeadRotation> for ClientboundPlayPacket {
5790 fn from(p: EntityHeadRotation) -> Self {
5791 Self::EntityHeadRotation(p)
5792 }
5793}
5794
5795#[derive(Debug, Clone, PartialEq)]
5797pub struct MultiBlockChange {
5798 pub chunk_coordinates: MultiBlockChangeChunkCoordinates,
5800 pub not_trust_edges: bool,
5802 pub records: Vec<i64>,
5804}
5805impl crate::packet::Packet for MultiBlockChange {
5806 const ID: i32 = id::MULTI_BLOCK_CHANGE;
5807 const NAME: &'static str = "multi_block_change";
5808 const STATE: State = State::Play;
5809 const DIRECTION: Direction = Direction::Clientbound;
5810}
5811impl Decode for MultiBlockChange {
5812 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5813 Ok({
5814 let v754 = {
5815 let v755 = r.read_u64()?;
5816 MultiBlockChangeChunkCoordinates {
5817 x: ((((((v755 >> 42) & 0x3fffff) << 42) as i64) >> 42) as i32),
5818 z: ((((((v755 >> 20) & 0x3fffff) << 42) as i64) >> 42) as i32),
5819 y: (((v755 >> 0) & 0xfffff) as u32),
5820 }
5821 };
5822 let v756 = r.read_bool()?;
5823 let v757 = {
5824 let v758 = {
5825 let c = r.read_varint()?;
5826 r.check_count(i64::from(c), 1)?
5827 };
5828 let mut v759 = Vec::with_capacity(v758.min(crate::codec::PREALLOC_LIMIT));
5829 for _ in 0..v758 {
5830 v759.push(r.read_varlong()?);
5831 }
5832 v759
5833 };
5834 MultiBlockChange {
5835 chunk_coordinates: v754,
5836 not_trust_edges: v756,
5837 records: v757,
5838 }
5839 })
5840 }
5841}
5842impl Encode for MultiBlockChange {
5843 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5844 {
5845 let mut bits: u64 = 0;
5846 {
5847 let x = i128::from((*self).chunk_coordinates.x);
5848 if x < -2097152 || x > 2097151 {
5849 return Err(EncodeError::OutOfRange("x"));
5850 }
5851 bits = (bits << 22) | ((x as u64) & 0x3fffff);
5852 }
5853 {
5854 let x = i128::from((*self).chunk_coordinates.z);
5855 if x < -2097152 || x > 2097151 {
5856 return Err(EncodeError::OutOfRange("z"));
5857 }
5858 bits = (bits << 22) | ((x as u64) & 0x3fffff);
5859 }
5860 {
5861 let x = i128::from((*self).chunk_coordinates.y);
5862 if x < 0 || x > 1048575 {
5863 return Err(EncodeError::OutOfRange("y"));
5864 }
5865 bits = (bits << 20) | ((x as u64) & 0xfffff);
5866 }
5867 w.put_u64(bits);
5868 }
5869 w.put_bool((*self).not_trust_edges);
5870 w.put_len_varint((*self).records.len())?;
5871 for v760 in (*self).records.iter() {
5872 w.put_varlong((*v760));
5873 }
5874 Ok(())
5875 }
5876}
5877#[cfg(feature = "testgen")]
5878impl Generate for MultiBlockChange {
5879 fn generate(g: &mut Gen) -> Self {
5880 {
5881 let v761 = {
5882 MultiBlockChangeChunkCoordinates {
5883 x: (g.int_in(-2097152, 2097151, &[]) as i32),
5884 z: (g.int_in(-2097152, 2097151, &[]) as i32),
5885 y: (g.int_in(0, 1048575, &[]) as u32),
5886 }
5887 };
5888 let v763 = g.bool();
5889 let v764 = {
5890 let v765 = g.count();
5891 let mut v766 = Vec::with_capacity(v765.min(crate::codec::PREALLOC_LIMIT));
5892 for _ in 0..v765 {
5893 v766.push(g.varlong());
5894 }
5895 v766
5896 };
5897 MultiBlockChange {
5898 chunk_coordinates: v761,
5899 not_trust_edges: v763,
5900 records: v764,
5901 }
5902 }
5903 }
5904}
5905impl From<MultiBlockChange> for ClientboundPlayPacket {
5906 fn from(p: MultiBlockChange) -> Self {
5907 Self::MultiBlockChange(p)
5908 }
5909}
5910
5911#[derive(Debug, Clone, PartialEq)]
5913pub struct SelectAdvancementTab {
5914 pub id: Option<ByteString>,
5916}
5917impl crate::packet::Packet for SelectAdvancementTab {
5918 const ID: i32 = id::SELECT_ADVANCEMENT_TAB;
5919 const NAME: &'static str = "select_advancement_tab";
5920 const STATE: State = State::Play;
5921 const DIRECTION: Direction = Direction::Clientbound;
5922}
5923impl Decode for SelectAdvancementTab {
5924 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5925 Ok({
5926 let v767 = if r.read_bool()? {
5927 Some(r.read_string()?)
5928 } else {
5929 None
5930 };
5931 SelectAdvancementTab { id: v767 }
5932 })
5933 }
5934}
5935impl Encode for SelectAdvancementTab {
5936 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
5937 match &(*self).id {
5938 Some(v768) => {
5939 w.put_u8(1);
5940 w.put_string(&(*v768))?;
5941 }
5942 None => w.put_u8(0),
5943 }
5944 Ok(())
5945 }
5946}
5947#[cfg(feature = "testgen")]
5948impl Generate for SelectAdvancementTab {
5949 fn generate(g: &mut Gen) -> Self {
5950 {
5951 let v769 = if g.bool() { Some(g.string()) } else { None };
5952 SelectAdvancementTab { id: v769 }
5953 }
5954 }
5955}
5956impl From<SelectAdvancementTab> for ClientboundPlayPacket {
5957 fn from(p: SelectAdvancementTab) -> Self {
5958 Self::SelectAdvancementTab(p)
5959 }
5960}
5961
5962#[derive(Debug, Clone, PartialEq)]
5964pub struct WorldBorder {
5965 pub action: i32,
5967 pub radius: Option<f64>,
5969 pub x: Option<f64>,
5971 pub z: Option<f64>,
5973 pub old_radius: Option<f64>,
5975 pub new_radius: Option<f64>,
5977 pub speed: Option<i64>,
5979 pub portal_boundary: Option<i32>,
5981 pub warning_time: Option<i32>,
5983 pub warning_blocks: Option<i32>,
5985}
5986impl crate::packet::Packet for WorldBorder {
5987 const ID: i32 = id::WORLD_BORDER;
5988 const NAME: &'static str = "world_border";
5989 const STATE: State = State::Play;
5990 const DIRECTION: Direction = Direction::Clientbound;
5991}
5992impl Decode for WorldBorder {
5993 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
5994 Ok({
5995 let v770 = r.read_varint()?;
5996 let v771 = if (v770 == 0) {
5997 Some(r.read_f64()?)
5998 } else {
5999 None
6000 };
6001 let v772 = if (v770 == 2) || (v770 == 3) {
6002 Some(r.read_f64()?)
6003 } else {
6004 None
6005 };
6006 let v773 = if (v770 == 2) || (v770 == 3) {
6007 Some(r.read_f64()?)
6008 } else {
6009 None
6010 };
6011 let v774 = if (v770 == 1) || (v770 == 3) {
6012 Some(r.read_f64()?)
6013 } else {
6014 None
6015 };
6016 let v775 = if (v770 == 1) || (v770 == 3) {
6017 Some(r.read_f64()?)
6018 } else {
6019 None
6020 };
6021 let v776 = if (v770 == 1) || (v770 == 3) {
6022 Some(r.read_varlong()?)
6023 } else {
6024 None
6025 };
6026 let v777 = if (v770 == 3) {
6027 Some(r.read_varint()?)
6028 } else {
6029 None
6030 };
6031 let v778 = if (v770 == 3) || (v770 == 4) {
6032 Some(r.read_varint()?)
6033 } else {
6034 None
6035 };
6036 let v779 = if (v770 == 3) || (v770 == 5) {
6037 Some(r.read_varint()?)
6038 } else {
6039 None
6040 };
6041 WorldBorder {
6042 action: v770,
6043 radius: v771,
6044 x: v772,
6045 z: v773,
6046 old_radius: v774,
6047 new_radius: v775,
6048 speed: v776,
6049 portal_boundary: v777,
6050 warning_time: v778,
6051 warning_blocks: v779,
6052 }
6053 })
6054 }
6055}
6056impl Encode for WorldBorder {
6057 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6058 w.put_varint((*self).action);
6059 match (&(*self).radius, ((*self).action == 0)) {
6060 (Some(v780), true) => {
6061 w.put_f64((*v780));
6062 }
6063 (None, false) => {}
6064 _ => {
6065 return Err(EncodeError::SwitchMismatch(
6066 "play.clientbound.world_border.radius",
6067 ));
6068 }
6069 }
6070 match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
6071 (Some(v781), true) => {
6072 w.put_f64((*v781));
6073 }
6074 (None, false) => {}
6075 _ => {
6076 return Err(EncodeError::SwitchMismatch(
6077 "play.clientbound.world_border.x",
6078 ));
6079 }
6080 }
6081 match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
6082 (Some(v782), true) => {
6083 w.put_f64((*v782));
6084 }
6085 (None, false) => {}
6086 _ => {
6087 return Err(EncodeError::SwitchMismatch(
6088 "play.clientbound.world_border.z",
6089 ));
6090 }
6091 }
6092 match (
6093 &(*self).old_radius,
6094 ((*self).action == 1) || ((*self).action == 3),
6095 ) {
6096 (Some(v783), true) => {
6097 w.put_f64((*v783));
6098 }
6099 (None, false) => {}
6100 _ => {
6101 return Err(EncodeError::SwitchMismatch(
6102 "play.clientbound.world_border.old_radius",
6103 ));
6104 }
6105 }
6106 match (
6107 &(*self).new_radius,
6108 ((*self).action == 1) || ((*self).action == 3),
6109 ) {
6110 (Some(v784), true) => {
6111 w.put_f64((*v784));
6112 }
6113 (None, false) => {}
6114 _ => {
6115 return Err(EncodeError::SwitchMismatch(
6116 "play.clientbound.world_border.new_radius",
6117 ));
6118 }
6119 }
6120 match (
6121 &(*self).speed,
6122 ((*self).action == 1) || ((*self).action == 3),
6123 ) {
6124 (Some(v785), true) => {
6125 w.put_varlong((*v785));
6126 }
6127 (None, false) => {}
6128 _ => {
6129 return Err(EncodeError::SwitchMismatch(
6130 "play.clientbound.world_border.speed",
6131 ));
6132 }
6133 }
6134 match (&(*self).portal_boundary, ((*self).action == 3)) {
6135 (Some(v786), true) => {
6136 w.put_varint((*v786));
6137 }
6138 (None, false) => {}
6139 _ => {
6140 return Err(EncodeError::SwitchMismatch(
6141 "play.clientbound.world_border.portalBoundary",
6142 ));
6143 }
6144 }
6145 match (
6146 &(*self).warning_time,
6147 ((*self).action == 3) || ((*self).action == 4),
6148 ) {
6149 (Some(v787), true) => {
6150 w.put_varint((*v787));
6151 }
6152 (None, false) => {}
6153 _ => {
6154 return Err(EncodeError::SwitchMismatch(
6155 "play.clientbound.world_border.warning_time",
6156 ));
6157 }
6158 }
6159 match (
6160 &(*self).warning_blocks,
6161 ((*self).action == 3) || ((*self).action == 5),
6162 ) {
6163 (Some(v788), true) => {
6164 w.put_varint((*v788));
6165 }
6166 (None, false) => {}
6167 _ => {
6168 return Err(EncodeError::SwitchMismatch(
6169 "play.clientbound.world_border.warning_blocks",
6170 ));
6171 }
6172 }
6173 Ok(())
6174 }
6175}
6176#[cfg(feature = "testgen")]
6177impl Generate for WorldBorder {
6178 fn generate(g: &mut Gen) -> Self {
6179 {
6180 let v789 = (g.int_in(
6181 -2147483648,
6182 2147483647,
6183 &[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
6184 ) as i32);
6185 let v790 = if (v789 == 0) { Some(g.f64()) } else { None };
6186 let v791 = if (v789 == 2) || (v789 == 3) {
6187 Some(g.f64())
6188 } else {
6189 None
6190 };
6191 let v792 = if (v789 == 2) || (v789 == 3) {
6192 Some(g.f64())
6193 } else {
6194 None
6195 };
6196 let v793 = if (v789 == 1) || (v789 == 3) {
6197 Some(g.f64())
6198 } else {
6199 None
6200 };
6201 let v794 = if (v789 == 1) || (v789 == 3) {
6202 Some(g.f64())
6203 } else {
6204 None
6205 };
6206 let v795 = if (v789 == 1) || (v789 == 3) {
6207 Some(g.varlong())
6208 } else {
6209 None
6210 };
6211 let v796 = if (v789 == 3) {
6212 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6213 } else {
6214 None
6215 };
6216 let v797 = if (v789 == 3) || (v789 == 4) {
6217 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6218 } else {
6219 None
6220 };
6221 let v798 = if (v789 == 3) || (v789 == 5) {
6222 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
6223 } else {
6224 None
6225 };
6226 WorldBorder {
6227 action: v789,
6228 radius: v790,
6229 x: v791,
6230 z: v792,
6231 old_radius: v793,
6232 new_radius: v794,
6233 speed: v795,
6234 portal_boundary: v796,
6235 warning_time: v797,
6236 warning_blocks: v798,
6237 }
6238 }
6239 }
6240}
6241impl From<WorldBorder> for ClientboundPlayPacket {
6242 fn from(p: WorldBorder) -> Self {
6243 Self::WorldBorder(p)
6244 }
6245}
6246
6247#[derive(Debug, Clone, PartialEq)]
6249pub struct Camera {
6250 pub camera_id: i32,
6252}
6253impl crate::packet::Packet for Camera {
6254 const ID: i32 = id::CAMERA;
6255 const NAME: &'static str = "camera";
6256 const STATE: State = State::Play;
6257 const DIRECTION: Direction = Direction::Clientbound;
6258}
6259impl Decode for Camera {
6260 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6261 Ok({
6262 let v799 = r.read_varint()?;
6263 Camera { camera_id: v799 }
6264 })
6265 }
6266}
6267impl Encode for Camera {
6268 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6269 w.put_varint((*self).camera_id);
6270 Ok(())
6271 }
6272}
6273#[cfg(feature = "testgen")]
6274impl Generate for Camera {
6275 fn generate(g: &mut Gen) -> Self {
6276 {
6277 let v800 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6278 Camera { camera_id: v800 }
6279 }
6280 }
6281}
6282impl From<Camera> for ClientboundPlayPacket {
6283 fn from(p: Camera) -> Self {
6284 Self::Camera(p)
6285 }
6286}
6287
6288#[derive(Debug, Clone, PartialEq)]
6290pub struct HeldItemSlot {
6291 pub slot: i8,
6293}
6294impl crate::packet::Packet for HeldItemSlot {
6295 const ID: i32 = id::HELD_ITEM_SLOT;
6296 const NAME: &'static str = "held_item_slot";
6297 const STATE: State = State::Play;
6298 const DIRECTION: Direction = Direction::Clientbound;
6299}
6300impl Decode for HeldItemSlot {
6301 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6302 Ok({
6303 let v801 = r.read_i8()?;
6304 HeldItemSlot { slot: v801 }
6305 })
6306 }
6307}
6308impl Encode for HeldItemSlot {
6309 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6310 w.put_i8((*self).slot);
6311 Ok(())
6312 }
6313}
6314#[cfg(feature = "testgen")]
6315impl Generate for HeldItemSlot {
6316 fn generate(g: &mut Gen) -> Self {
6317 {
6318 let v802 = (g.int_in(-128, 127, &[]) as i8);
6319 HeldItemSlot { slot: v802 }
6320 }
6321 }
6322}
6323impl From<HeldItemSlot> for ClientboundPlayPacket {
6324 fn from(p: HeldItemSlot) -> Self {
6325 Self::HeldItemSlot(p)
6326 }
6327}
6328
6329#[derive(Debug, Clone, PartialEq)]
6331pub struct UpdateViewPosition {
6332 pub chunk_x: i32,
6334 pub chunk_z: i32,
6336}
6337impl crate::packet::Packet for UpdateViewPosition {
6338 const ID: i32 = id::UPDATE_VIEW_POSITION;
6339 const NAME: &'static str = "update_view_position";
6340 const STATE: State = State::Play;
6341 const DIRECTION: Direction = Direction::Clientbound;
6342}
6343impl Decode for UpdateViewPosition {
6344 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6345 Ok({
6346 let v803 = r.read_varint()?;
6347 let v804 = r.read_varint()?;
6348 UpdateViewPosition {
6349 chunk_x: v803,
6350 chunk_z: v804,
6351 }
6352 })
6353 }
6354}
6355impl Encode for UpdateViewPosition {
6356 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6357 w.put_varint((*self).chunk_x);
6358 w.put_varint((*self).chunk_z);
6359 Ok(())
6360 }
6361}
6362#[cfg(feature = "testgen")]
6363impl Generate for UpdateViewPosition {
6364 fn generate(g: &mut Gen) -> Self {
6365 {
6366 let v805 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6367 let v806 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6368 UpdateViewPosition {
6369 chunk_x: v805,
6370 chunk_z: v806,
6371 }
6372 }
6373 }
6374}
6375impl From<UpdateViewPosition> for ClientboundPlayPacket {
6376 fn from(p: UpdateViewPosition) -> Self {
6377 Self::UpdateViewPosition(p)
6378 }
6379}
6380
6381#[derive(Debug, Clone, PartialEq)]
6383pub struct UpdateViewDistance {
6384 pub view_distance: i32,
6386}
6387impl crate::packet::Packet for UpdateViewDistance {
6388 const ID: i32 = id::UPDATE_VIEW_DISTANCE;
6389 const NAME: &'static str = "update_view_distance";
6390 const STATE: State = State::Play;
6391 const DIRECTION: Direction = Direction::Clientbound;
6392}
6393impl Decode for UpdateViewDistance {
6394 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6395 Ok({
6396 let v807 = r.read_varint()?;
6397 UpdateViewDistance {
6398 view_distance: v807,
6399 }
6400 })
6401 }
6402}
6403impl Encode for UpdateViewDistance {
6404 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6405 w.put_varint((*self).view_distance);
6406 Ok(())
6407 }
6408}
6409#[cfg(feature = "testgen")]
6410impl Generate for UpdateViewDistance {
6411 fn generate(g: &mut Gen) -> Self {
6412 {
6413 let v808 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6414 UpdateViewDistance {
6415 view_distance: v808,
6416 }
6417 }
6418 }
6419}
6420impl From<UpdateViewDistance> for ClientboundPlayPacket {
6421 fn from(p: UpdateViewDistance) -> Self {
6422 Self::UpdateViewDistance(p)
6423 }
6424}
6425
6426#[derive(Debug, Clone, PartialEq)]
6428pub struct SpawnPosition {
6429 pub location: BlockPos,
6431}
6432impl crate::packet::Packet for SpawnPosition {
6433 const ID: i32 = id::SPAWN_POSITION;
6434 const NAME: &'static str = "spawn_position";
6435 const STATE: State = State::Play;
6436 const DIRECTION: Direction = Direction::Clientbound;
6437}
6438impl Decode for SpawnPosition {
6439 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6440 Ok({
6441 let v809 = BlockPos::read(r, PositionLayout::Xzy)?;
6442 SpawnPosition { location: v809 }
6443 })
6444 }
6445}
6446impl Encode for SpawnPosition {
6447 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6448 (*self).location.write(w, PositionLayout::Xzy)?;
6449 Ok(())
6450 }
6451}
6452#[cfg(feature = "testgen")]
6453impl Generate for SpawnPosition {
6454 fn generate(g: &mut Gen) -> Self {
6455 {
6456 let v810 = g.position();
6457 SpawnPosition { location: v810 }
6458 }
6459 }
6460}
6461impl From<SpawnPosition> for ClientboundPlayPacket {
6462 fn from(p: SpawnPosition) -> Self {
6463 Self::SpawnPosition(p)
6464 }
6465}
6466
6467#[derive(Debug, Clone, PartialEq)]
6469pub struct ScoreboardDisplayObjective {
6470 pub position: i8,
6472 pub name: ByteString,
6474}
6475impl crate::packet::Packet for ScoreboardDisplayObjective {
6476 const ID: i32 = id::SCOREBOARD_DISPLAY_OBJECTIVE;
6477 const NAME: &'static str = "scoreboard_display_objective";
6478 const STATE: State = State::Play;
6479 const DIRECTION: Direction = Direction::Clientbound;
6480}
6481impl Decode for ScoreboardDisplayObjective {
6482 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6483 Ok({
6484 let v811 = r.read_i8()?;
6485 let v812 = r.read_string()?;
6486 ScoreboardDisplayObjective {
6487 position: v811,
6488 name: v812,
6489 }
6490 })
6491 }
6492}
6493impl Encode for ScoreboardDisplayObjective {
6494 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6495 w.put_i8((*self).position);
6496 w.put_string(&(*self).name)?;
6497 Ok(())
6498 }
6499}
6500#[cfg(feature = "testgen")]
6501impl Generate for ScoreboardDisplayObjective {
6502 fn generate(g: &mut Gen) -> Self {
6503 {
6504 let v813 = (g.int_in(-128, 127, &[]) as i8);
6505 let v814 = g.string();
6506 ScoreboardDisplayObjective {
6507 position: v813,
6508 name: v814,
6509 }
6510 }
6511 }
6512}
6513impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
6514 fn from(p: ScoreboardDisplayObjective) -> Self {
6515 Self::ScoreboardDisplayObjective(p)
6516 }
6517}
6518
6519#[derive(Debug, Clone, PartialEq)]
6521pub struct EntityMetadata {
6522 pub entity_id: i32,
6524 pub metadata: Vec<types::EntityMetadataEntry>,
6526}
6527impl crate::packet::Packet for EntityMetadata {
6528 const ID: i32 = id::ENTITY_METADATA;
6529 const NAME: &'static str = "entity_metadata";
6530 const STATE: State = State::Play;
6531 const DIRECTION: Direction = Direction::Clientbound;
6532}
6533impl Decode for EntityMetadata {
6534 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
6535 Ok({
6536 let v815 = r.read_varint()?;
6537 let v816 = {
6538 let mut v817 = Vec::new();
6539 loop {
6540 if r.peek_u8()? == 255 {
6541 r.skip(1)?;
6542 break;
6543 }
6544 v817.push({
6545 let v818 = r.read_u8()?;
6546 let v819 = r.read_varint()?;
6547 let v820 = (if (v819 == 0) {
6548 types::EntityMetadataValue::Byte(r.read_i8()?)
6549 } else if (v819 == 1) {
6550 types::EntityMetadataValue::VarInt(r.read_varint()?)
6551 } else if (v819 == 2) {
6552 types::EntityMetadataValue::Float(r.read_f32()?)
6553 } else if (v819 == 3) {
6554 types::EntityMetadataValue::String(r.read_string()?)
6555 } else if (v819 == 4) {
6556 types::EntityMetadataValue::Chat(r.read_string()?)
6557 } else if (v819 == 5) {
6558 types::EntityMetadataValue::OptChat(if r.read_bool()? {
6559 Some(r.read_string()?)
6560 } else {
6561 None
6562 })
6563 } else if (v819 == 6) {
6564 types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
6565 } else if (v819 == 7) {
6566 types::EntityMetadataValue::Boolean(r.read_bool()?)
6567 } else if (v819 == 8) {
6568 types::EntityMetadataValue::Rotation({
6569 let v821 = r.read_f32()?;
6570 let v822 = r.read_f32()?;
6571 let v823 = r.read_f32()?;
6572 types::EntityMetadataValueRotation {
6573 pitch: v821,
6574 yaw: v822,
6575 roll: v823,
6576 }
6577 })
6578 } else if (v819 == 9) {
6579 types::EntityMetadataValue::Position(BlockPos::read(
6580 r,
6581 PositionLayout::Xzy,
6582 )?)
6583 } else if (v819 == 10) {
6584 types::EntityMetadataValue::OptPosition(if r.read_bool()? {
6585 Some(BlockPos::read(r, PositionLayout::Xzy)?)
6586 } else {
6587 None
6588 })
6589 } else if (v819 == 11) {
6590 types::EntityMetadataValue::Direction(r.read_varint()?)
6591 } else if (v819 == 12) {
6592 types::EntityMetadataValue::OptUuid(if r.read_bool()? {
6593 Some(r.read_uuid()?)
6594 } else {
6595 None
6596 })
6597 } else if (v819 == 13) {
6598 types::EntityMetadataValue::BlockState(r.read_varint()?)
6599 } else if (v819 == 14) {
6600 types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
6601 } else if (v819 == 15) {
6602 types::EntityMetadataValue::Particle(
6603 <types::Particle as Decode>::decode(r)?,
6604 )
6605 } else if (v819 == 16) {
6606 types::EntityMetadataValue::VillagerData({
6607 let v824 = r.read_varint()?;
6608 let v825 = r.read_varint()?;
6609 let v826 = r.read_varint()?;
6610 types::EntityMetadataValueVillagerData {
6611 villager_type: v824,
6612 villager_profession: v825,
6613 level: v826,
6614 }
6615 })
6616 } else if (v819 == 17) {
6617 types::EntityMetadataValue::OptVarInt(r.read_varint()?)
6618 } else if (v819 == 18) {
6619 types::EntityMetadataValue::Pose(r.read_varint()?)
6620 } else {
6621 types::EntityMetadataValue::Other
6622 });
6623 types::EntityMetadataEntry {
6624 key: v818,
6625 r#type: v819,
6626 value: v820,
6627 }
6628 });
6629 }
6630 v817
6631 };
6632 EntityMetadata {
6633 entity_id: v815,
6634 metadata: v816,
6635 }
6636 })
6637 }
6638}
6639impl Encode for EntityMetadata {
6640 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
6641 w.put_varint((*self).entity_id);
6642 for v827 in (*self).metadata.iter() {
6643 let v828 = w.len();
6644 w.put_u8((*v827).key);
6645 w.put_varint((*v827).r#type);
6646 match &(*v827).value {
6647 types::EntityMetadataValue::Byte(v829) => {
6648 if !((*v827).r#type == 0) {
6649 return Err(EncodeError::SwitchMismatch(
6650 "play.clientbound.entity_metadata.metadata.value",
6651 ));
6652 }
6653 w.put_i8((*v829));
6654 }
6655 types::EntityMetadataValue::VarInt(v830) => {
6656 if !((*v827).r#type == 1) {
6657 return Err(EncodeError::SwitchMismatch(
6658 "play.clientbound.entity_metadata.metadata.value",
6659 ));
6660 }
6661 w.put_varint((*v830));
6662 }
6663 types::EntityMetadataValue::Float(v831) => {
6664 if !((*v827).r#type == 2) {
6665 return Err(EncodeError::SwitchMismatch(
6666 "play.clientbound.entity_metadata.metadata.value",
6667 ));
6668 }
6669 w.put_f32((*v831));
6670 }
6671 types::EntityMetadataValue::String(v832) => {
6672 if !((*v827).r#type == 3) {
6673 return Err(EncodeError::SwitchMismatch(
6674 "play.clientbound.entity_metadata.metadata.value",
6675 ));
6676 }
6677 w.put_string(&(*v832))?;
6678 }
6679 types::EntityMetadataValue::Chat(v833) => {
6680 if !((*v827).r#type == 4) {
6681 return Err(EncodeError::SwitchMismatch(
6682 "play.clientbound.entity_metadata.metadata.value",
6683 ));
6684 }
6685 w.put_string(&(*v833))?;
6686 }
6687 types::EntityMetadataValue::OptChat(v834) => {
6688 if !((*v827).r#type == 5) {
6689 return Err(EncodeError::SwitchMismatch(
6690 "play.clientbound.entity_metadata.metadata.value",
6691 ));
6692 }
6693 match &(*v834) {
6694 Some(v835) => {
6695 w.put_u8(1);
6696 w.put_string(&(*v835))?;
6697 }
6698 None => w.put_u8(0),
6699 }
6700 }
6701 types::EntityMetadataValue::Slot(v836) => {
6702 if !((*v827).r#type == 6) {
6703 return Err(EncodeError::SwitchMismatch(
6704 "play.clientbound.entity_metadata.metadata.value",
6705 ));
6706 }
6707 (*v836).encode(w)?;
6708 }
6709 types::EntityMetadataValue::Boolean(v837) => {
6710 if !((*v827).r#type == 7) {
6711 return Err(EncodeError::SwitchMismatch(
6712 "play.clientbound.entity_metadata.metadata.value",
6713 ));
6714 }
6715 w.put_bool((*v837));
6716 }
6717 types::EntityMetadataValue::Rotation(v838) => {
6718 if !((*v827).r#type == 8) {
6719 return Err(EncodeError::SwitchMismatch(
6720 "play.clientbound.entity_metadata.metadata.value",
6721 ));
6722 }
6723 w.put_f32((*v838).pitch);
6724 w.put_f32((*v838).yaw);
6725 w.put_f32((*v838).roll);
6726 }
6727 types::EntityMetadataValue::Position(v839) => {
6728 if !((*v827).r#type == 9) {
6729 return Err(EncodeError::SwitchMismatch(
6730 "play.clientbound.entity_metadata.metadata.value",
6731 ));
6732 }
6733 (*v839).write(w, PositionLayout::Xzy)?;
6734 }
6735 types::EntityMetadataValue::OptPosition(v840) => {
6736 if !((*v827).r#type == 10) {
6737 return Err(EncodeError::SwitchMismatch(
6738 "play.clientbound.entity_metadata.metadata.value",
6739 ));
6740 }
6741 match &(*v840) {
6742 Some(v841) => {
6743 w.put_u8(1);
6744 (*v841).write(w, PositionLayout::Xzy)?;
6745 }
6746 None => w.put_u8(0),
6747 }
6748 }
6749 types::EntityMetadataValue::Direction(v842) => {
6750 if !((*v827).r#type == 11) {
6751 return Err(EncodeError::SwitchMismatch(
6752 "play.clientbound.entity_metadata.metadata.value",
6753 ));
6754 }
6755 w.put_varint((*v842));
6756 }
6757 types::EntityMetadataValue::OptUuid(v843) => {
6758 if !((*v827).r#type == 12) {
6759 return Err(EncodeError::SwitchMismatch(
6760 "play.clientbound.entity_metadata.metadata.value",
6761 ));
6762 }
6763 match &(*v843) {
6764 Some(v844) => {
6765 w.put_u8(1);
6766 w.put_uuid(&(*v844));
6767 }
6768 None => w.put_u8(0),
6769 }
6770 }
6771 types::EntityMetadataValue::BlockState(v845) => {
6772 if !((*v827).r#type == 13) {
6773 return Err(EncodeError::SwitchMismatch(
6774 "play.clientbound.entity_metadata.metadata.value",
6775 ));
6776 }
6777 w.put_varint((*v845));
6778 }
6779 types::EntityMetadataValue::Nbt(v846) => {
6780 if !((*v827).r#type == 14) {
6781 return Err(EncodeError::SwitchMismatch(
6782 "play.clientbound.entity_metadata.metadata.value",
6783 ));
6784 }
6785 (*v846).write(w);
6786 }
6787 types::EntityMetadataValue::Particle(v847) => {
6788 if !((*v827).r#type == 15) {
6789 return Err(EncodeError::SwitchMismatch(
6790 "play.clientbound.entity_metadata.metadata.value",
6791 ));
6792 }
6793 (*v847).encode(w)?;
6794 }
6795 types::EntityMetadataValue::VillagerData(v848) => {
6796 if !((*v827).r#type == 16) {
6797 return Err(EncodeError::SwitchMismatch(
6798 "play.clientbound.entity_metadata.metadata.value",
6799 ));
6800 }
6801 w.put_varint((*v848).villager_type);
6802 w.put_varint((*v848).villager_profession);
6803 w.put_varint((*v848).level);
6804 }
6805 types::EntityMetadataValue::OptVarInt(v849) => {
6806 if !((*v827).r#type == 17) {
6807 return Err(EncodeError::SwitchMismatch(
6808 "play.clientbound.entity_metadata.metadata.value",
6809 ));
6810 }
6811 w.put_varint((*v849));
6812 }
6813 types::EntityMetadataValue::Pose(v850) => {
6814 if !((*v827).r#type == 18) {
6815 return Err(EncodeError::SwitchMismatch(
6816 "play.clientbound.entity_metadata.metadata.value",
6817 ));
6818 }
6819 w.put_varint((*v850));
6820 }
6821 types::EntityMetadataValue::Other => {
6822 if !(!(((*v827).r#type == 0)
6823 || ((*v827).r#type == 1)
6824 || ((*v827).r#type == 2)
6825 || ((*v827).r#type == 3)
6826 || ((*v827).r#type == 4)
6827 || ((*v827).r#type == 5)
6828 || ((*v827).r#type == 6)
6829 || ((*v827).r#type == 7)
6830 || ((*v827).r#type == 8)
6831 || ((*v827).r#type == 9)
6832 || ((*v827).r#type == 10)
6833 || ((*v827).r#type == 11)
6834 || ((*v827).r#type == 12)
6835 || ((*v827).r#type == 13)
6836 || ((*v827).r#type == 14)
6837 || ((*v827).r#type == 15)
6838 || ((*v827).r#type == 16)
6839 || ((*v827).r#type == 17)
6840 || ((*v827).r#type == 18)))
6841 {
6842 return Err(EncodeError::SwitchMismatch(
6843 "play.clientbound.entity_metadata.metadata.value",
6844 ));
6845 }
6846 }
6847 }
6848 if w.get(v828) == Some(&255) {
6849 return Err(EncodeError::OutOfRange(
6850 "play.clientbound.entity_metadata.metadata",
6851 ));
6852 }
6853 }
6854 w.put_u8(255);
6855 Ok(())
6856 }
6857}
6858#[cfg(feature = "testgen")]
6859impl Generate for EntityMetadata {
6860 fn generate(g: &mut Gen) -> Self {
6861 {
6862 let v851 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6863 let v852 = {
6864 let n = g.count();
6865 let mut v853 = Vec::with_capacity(n);
6866 for _ in 0..n {
6867 v853.push(loop {
6868 let v854 = {
6869 let v855 = (g.int_in(0, 255, &[]) as u8);
6870 let v856 = (g.int_in(
6871 -2147483648,
6872 2147483647,
6873 &[
6874 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
6875 18,
6876 ],
6877 ) as i32);
6878 let v857 = (if (v856 == 0) {
6879 types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
6880 } else if (v856 == 1) {
6881 types::EntityMetadataValue::VarInt(
6882 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6883 )
6884 } else if (v856 == 2) {
6885 types::EntityMetadataValue::Float(g.f32())
6886 } else if (v856 == 3) {
6887 types::EntityMetadataValue::String(g.string())
6888 } else if (v856 == 4) {
6889 types::EntityMetadataValue::Chat(g.string())
6890 } else if (v856 == 5) {
6891 types::EntityMetadataValue::OptChat(if g.bool() {
6892 Some(g.string())
6893 } else {
6894 None
6895 })
6896 } else if (v856 == 6) {
6897 types::EntityMetadataValue::Slot(
6898 <types::Slot as Generate>::generate(g),
6899 )
6900 } else if (v856 == 7) {
6901 types::EntityMetadataValue::Boolean(g.bool())
6902 } else if (v856 == 8) {
6903 types::EntityMetadataValue::Rotation({
6904 let v858 = g.f32();
6905 let v859 = g.f32();
6906 let v860 = g.f32();
6907 types::EntityMetadataValueRotation {
6908 pitch: v858,
6909 yaw: v859,
6910 roll: v860,
6911 }
6912 })
6913 } else if (v856 == 9) {
6914 types::EntityMetadataValue::Position(g.position())
6915 } else if (v856 == 10) {
6916 types::EntityMetadataValue::OptPosition(if g.bool() {
6917 Some(g.position())
6918 } else {
6919 None
6920 })
6921 } else if (v856 == 11) {
6922 types::EntityMetadataValue::Direction(
6923 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6924 )
6925 } else if (v856 == 12) {
6926 types::EntityMetadataValue::OptUuid(if g.bool() {
6927 Some(g.uuid())
6928 } else {
6929 None
6930 })
6931 } else if (v856 == 13) {
6932 types::EntityMetadataValue::BlockState(
6933 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6934 )
6935 } else if (v856 == 14) {
6936 types::EntityMetadataValue::Nbt(g.nbt())
6937 } else if (v856 == 15) {
6938 types::EntityMetadataValue::Particle(
6939 <types::Particle as Generate>::generate(g),
6940 )
6941 } else if (v856 == 16) {
6942 types::EntityMetadataValue::VillagerData({
6943 let v861 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6944 let v862 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6945 let v863 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
6946 types::EntityMetadataValueVillagerData {
6947 villager_type: v861,
6948 villager_profession: v862,
6949 level: v863,
6950 }
6951 })
6952 } else if (v856 == 17) {
6953 types::EntityMetadataValue::OptVarInt(
6954 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6955 )
6956 } else if (v856 == 18) {
6957 types::EntityMetadataValue::Pose(
6958 (g.int_in(-2147483648, 2147483647, &[]) as i32),
6959 )
6960 } else {
6961 types::EntityMetadataValue::Other
6962 });
6963 types::EntityMetadataEntry {
6964 key: v855,
6965 r#type: v856,
6966 value: v857,
6967 }
6968 };
6969 if crate::testgen::first_byte_ok(
6970 |w: &mut BytesMut| -> EncodeResult {
6971 w.put_u8(v854.key);
6972 w.put_varint(v854.r#type);
6973 match &v854.value {
6974 types::EntityMetadataValue::Byte(v864) => {
6975 if !(v854.r#type == 0) {
6976 return Err(EncodeError::SwitchMismatch(
6977 "play.clientbound.entity_metadata.metadata.value",
6978 ));
6979 }
6980 w.put_i8((*v864));
6981 }
6982 types::EntityMetadataValue::VarInt(v865) => {
6983 if !(v854.r#type == 1) {
6984 return Err(EncodeError::SwitchMismatch(
6985 "play.clientbound.entity_metadata.metadata.value",
6986 ));
6987 }
6988 w.put_varint((*v865));
6989 }
6990 types::EntityMetadataValue::Float(v866) => {
6991 if !(v854.r#type == 2) {
6992 return Err(EncodeError::SwitchMismatch(
6993 "play.clientbound.entity_metadata.metadata.value",
6994 ));
6995 }
6996 w.put_f32((*v866));
6997 }
6998 types::EntityMetadataValue::String(v867) => {
6999 if !(v854.r#type == 3) {
7000 return Err(EncodeError::SwitchMismatch(
7001 "play.clientbound.entity_metadata.metadata.value",
7002 ));
7003 }
7004 w.put_string(&(*v867))?;
7005 }
7006 types::EntityMetadataValue::Chat(v868) => {
7007 if !(v854.r#type == 4) {
7008 return Err(EncodeError::SwitchMismatch(
7009 "play.clientbound.entity_metadata.metadata.value",
7010 ));
7011 }
7012 w.put_string(&(*v868))?;
7013 }
7014 types::EntityMetadataValue::OptChat(v869) => {
7015 if !(v854.r#type == 5) {
7016 return Err(EncodeError::SwitchMismatch(
7017 "play.clientbound.entity_metadata.metadata.value",
7018 ));
7019 }
7020 match &(*v869) {
7021 Some(v870) => {
7022 w.put_u8(1);
7023 w.put_string(&(*v870))?;
7024 }
7025 None => w.put_u8(0),
7026 }
7027 }
7028 types::EntityMetadataValue::Slot(v871) => {
7029 if !(v854.r#type == 6) {
7030 return Err(EncodeError::SwitchMismatch(
7031 "play.clientbound.entity_metadata.metadata.value",
7032 ));
7033 }
7034 (*v871).encode(w)?;
7035 }
7036 types::EntityMetadataValue::Boolean(v872) => {
7037 if !(v854.r#type == 7) {
7038 return Err(EncodeError::SwitchMismatch(
7039 "play.clientbound.entity_metadata.metadata.value",
7040 ));
7041 }
7042 w.put_bool((*v872));
7043 }
7044 types::EntityMetadataValue::Rotation(v873) => {
7045 if !(v854.r#type == 8) {
7046 return Err(EncodeError::SwitchMismatch(
7047 "play.clientbound.entity_metadata.metadata.value",
7048 ));
7049 }
7050 w.put_f32((*v873).pitch);
7051 w.put_f32((*v873).yaw);
7052 w.put_f32((*v873).roll);
7053 }
7054 types::EntityMetadataValue::Position(v874) => {
7055 if !(v854.r#type == 9) {
7056 return Err(EncodeError::SwitchMismatch(
7057 "play.clientbound.entity_metadata.metadata.value",
7058 ));
7059 }
7060 (*v874).write(w, PositionLayout::Xzy)?;
7061 }
7062 types::EntityMetadataValue::OptPosition(v875) => {
7063 if !(v854.r#type == 10) {
7064 return Err(EncodeError::SwitchMismatch(
7065 "play.clientbound.entity_metadata.metadata.value",
7066 ));
7067 }
7068 match &(*v875) {
7069 Some(v876) => {
7070 w.put_u8(1);
7071 (*v876).write(w, PositionLayout::Xzy)?;
7072 }
7073 None => w.put_u8(0),
7074 }
7075 }
7076 types::EntityMetadataValue::Direction(v877) => {
7077 if !(v854.r#type == 11) {
7078 return Err(EncodeError::SwitchMismatch(
7079 "play.clientbound.entity_metadata.metadata.value",
7080 ));
7081 }
7082 w.put_varint((*v877));
7083 }
7084 types::EntityMetadataValue::OptUuid(v878) => {
7085 if !(v854.r#type == 12) {
7086 return Err(EncodeError::SwitchMismatch(
7087 "play.clientbound.entity_metadata.metadata.value",
7088 ));
7089 }
7090 match &(*v878) {
7091 Some(v879) => {
7092 w.put_u8(1);
7093 w.put_uuid(&(*v879));
7094 }
7095 None => w.put_u8(0),
7096 }
7097 }
7098 types::EntityMetadataValue::BlockState(v880) => {
7099 if !(v854.r#type == 13) {
7100 return Err(EncodeError::SwitchMismatch(
7101 "play.clientbound.entity_metadata.metadata.value",
7102 ));
7103 }
7104 w.put_varint((*v880));
7105 }
7106 types::EntityMetadataValue::Nbt(v881) => {
7107 if !(v854.r#type == 14) {
7108 return Err(EncodeError::SwitchMismatch(
7109 "play.clientbound.entity_metadata.metadata.value",
7110 ));
7111 }
7112 (*v881).write(w);
7113 }
7114 types::EntityMetadataValue::Particle(v882) => {
7115 if !(v854.r#type == 15) {
7116 return Err(EncodeError::SwitchMismatch(
7117 "play.clientbound.entity_metadata.metadata.value",
7118 ));
7119 }
7120 (*v882).encode(w)?;
7121 }
7122 types::EntityMetadataValue::VillagerData(v883) => {
7123 if !(v854.r#type == 16) {
7124 return Err(EncodeError::SwitchMismatch(
7125 "play.clientbound.entity_metadata.metadata.value",
7126 ));
7127 }
7128 w.put_varint((*v883).villager_type);
7129 w.put_varint((*v883).villager_profession);
7130 w.put_varint((*v883).level);
7131 }
7132 types::EntityMetadataValue::OptVarInt(v884) => {
7133 if !(v854.r#type == 17) {
7134 return Err(EncodeError::SwitchMismatch(
7135 "play.clientbound.entity_metadata.metadata.value",
7136 ));
7137 }
7138 w.put_varint((*v884));
7139 }
7140 types::EntityMetadataValue::Pose(v885) => {
7141 if !(v854.r#type == 18) {
7142 return Err(EncodeError::SwitchMismatch(
7143 "play.clientbound.entity_metadata.metadata.value",
7144 ));
7145 }
7146 w.put_varint((*v885));
7147 }
7148 types::EntityMetadataValue::Other => {
7149 if !(!((v854.r#type == 0)
7150 || (v854.r#type == 1)
7151 || (v854.r#type == 2)
7152 || (v854.r#type == 3)
7153 || (v854.r#type == 4)
7154 || (v854.r#type == 5)
7155 || (v854.r#type == 6)
7156 || (v854.r#type == 7)
7157 || (v854.r#type == 8)
7158 || (v854.r#type == 9)
7159 || (v854.r#type == 10)
7160 || (v854.r#type == 11)
7161 || (v854.r#type == 12)
7162 || (v854.r#type == 13)
7163 || (v854.r#type == 14)
7164 || (v854.r#type == 15)
7165 || (v854.r#type == 16)
7166 || (v854.r#type == 17)
7167 || (v854.r#type == 18)))
7168 {
7169 return Err(EncodeError::SwitchMismatch(
7170 "play.clientbound.entity_metadata.metadata.value",
7171 ));
7172 }
7173 }
7174 }
7175 Ok(())
7176 },
7177 |b| b != 255,
7178 ) {
7179 break v854;
7180 }
7181 });
7182 }
7183 v853
7184 };
7185 EntityMetadata {
7186 entity_id: v851,
7187 metadata: v852,
7188 }
7189 }
7190 }
7191}
7192impl From<EntityMetadata> for ClientboundPlayPacket {
7193 fn from(p: EntityMetadata) -> Self {
7194 Self::EntityMetadata(p)
7195 }
7196}
7197
7198#[derive(Debug, Clone, PartialEq)]
7200pub struct AttachEntity {
7201 pub entity_id: i32,
7203 pub vehicle_id: i32,
7205}
7206impl crate::packet::Packet for AttachEntity {
7207 const ID: i32 = id::ATTACH_ENTITY;
7208 const NAME: &'static str = "attach_entity";
7209 const STATE: State = State::Play;
7210 const DIRECTION: Direction = Direction::Clientbound;
7211}
7212impl Decode for AttachEntity {
7213 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7214 Ok({
7215 let v886 = r.read_i32()?;
7216 let v887 = r.read_i32()?;
7217 AttachEntity {
7218 entity_id: v886,
7219 vehicle_id: v887,
7220 }
7221 })
7222 }
7223}
7224impl Encode for AttachEntity {
7225 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7226 w.put_i32((*self).entity_id);
7227 w.put_i32((*self).vehicle_id);
7228 Ok(())
7229 }
7230}
7231#[cfg(feature = "testgen")]
7232impl Generate for AttachEntity {
7233 fn generate(g: &mut Gen) -> Self {
7234 {
7235 let v888 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7236 let v889 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7237 AttachEntity {
7238 entity_id: v888,
7239 vehicle_id: v889,
7240 }
7241 }
7242 }
7243}
7244impl From<AttachEntity> for ClientboundPlayPacket {
7245 fn from(p: AttachEntity) -> Self {
7246 Self::AttachEntity(p)
7247 }
7248}
7249
7250#[derive(Debug, Clone, PartialEq)]
7252pub struct EntityVelocity {
7253 pub entity_id: i32,
7255 pub velocity: types::Vec3i16,
7257}
7258impl crate::packet::Packet for EntityVelocity {
7259 const ID: i32 = id::ENTITY_VELOCITY;
7260 const NAME: &'static str = "entity_velocity";
7261 const STATE: State = State::Play;
7262 const DIRECTION: Direction = Direction::Clientbound;
7263}
7264impl Decode for EntityVelocity {
7265 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7266 Ok({
7267 let v890 = r.read_varint()?;
7268 let v891 = <types::Vec3i16 as Decode>::decode(r)?;
7269 EntityVelocity {
7270 entity_id: v890,
7271 velocity: v891,
7272 }
7273 })
7274 }
7275}
7276impl Encode for EntityVelocity {
7277 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7278 w.put_varint((*self).entity_id);
7279 (*self).velocity.encode(w)?;
7280 Ok(())
7281 }
7282}
7283#[cfg(feature = "testgen")]
7284impl Generate for EntityVelocity {
7285 fn generate(g: &mut Gen) -> Self {
7286 {
7287 let v892 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7288 let v893 = <types::Vec3i16 as Generate>::generate(g);
7289 EntityVelocity {
7290 entity_id: v892,
7291 velocity: v893,
7292 }
7293 }
7294 }
7295}
7296impl From<EntityVelocity> for ClientboundPlayPacket {
7297 fn from(p: EntityVelocity) -> Self {
7298 Self::EntityVelocity(p)
7299 }
7300}
7301
7302#[derive(Debug, Clone, PartialEq)]
7304pub struct EntityEquipment {
7305 pub entity_id: i32,
7307 pub equipments: Vec<EntityEquipmentEquipments>,
7309}
7310impl crate::packet::Packet for EntityEquipment {
7311 const ID: i32 = id::ENTITY_EQUIPMENT;
7312 const NAME: &'static str = "entity_equipment";
7313 const STATE: State = State::Play;
7314 const DIRECTION: Direction = Direction::Clientbound;
7315}
7316impl Decode for EntityEquipment {
7317 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7318 Ok({
7319 let v894 = r.read_varint()?;
7320 let v895 = {
7321 let mut v896 = Vec::new();
7322 loop {
7323 let v897 = r.read_u8()?;
7324 v896.push({
7325 let v898 = ((v897 & 0x7f) as i8);
7326 let v899 = <types::Slot as Decode>::decode(r)?;
7327 EntityEquipmentEquipments {
7328 slot: v898,
7329 item: v899,
7330 }
7331 });
7332 if v897 & 0x80 == 0 {
7333 break;
7334 }
7335 }
7336 v896
7337 };
7338 EntityEquipment {
7339 entity_id: v894,
7340 equipments: v895,
7341 }
7342 })
7343 }
7344}
7345impl Encode for EntityEquipment {
7346 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7347 w.put_varint((*self).entity_id);
7348 if (*self).equipments.is_empty() {
7349 return Err(EncodeError::CountMismatch {
7350 field: "play.clientbound.entity_equipment.equipments",
7351 expected: 1,
7352 actual: 0,
7353 });
7354 }
7355 for (v901, v900) in (*self).equipments.iter().enumerate() {
7356 let v902 = w.len();
7357 w.put_i8((*v900).slot);
7358 (*v900).item.encode(w)?;
7359 match w.get_mut(v902) {
7360 Some(b) if *b & 0x80 == 0 => {
7361 if v901 + 1 < (*self).equipments.len() {
7362 *b |= 0x80;
7363 }
7364 }
7365 _ => {
7366 return Err(EncodeError::OutOfRange(
7367 "play.clientbound.entity_equipment.equipments",
7368 ));
7369 }
7370 }
7371 }
7372 Ok(())
7373 }
7374}
7375#[cfg(feature = "testgen")]
7376impl Generate for EntityEquipment {
7377 fn generate(g: &mut Gen) -> Self {
7378 {
7379 let v903 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7380 let v904 = {
7381 let n = 1 + g.count();
7382 let mut v905 = Vec::with_capacity(n);
7383 for _ in 0..n {
7384 v905.push(loop {
7385 let v906 = {
7386 let v907 = (g.int_in(-128, 127, &[]) as i8);
7387 let v908 = <types::Slot as Generate>::generate(g);
7388 EntityEquipmentEquipments {
7389 slot: v907,
7390 item: v908,
7391 }
7392 };
7393 if crate::testgen::first_byte_ok(
7394 |w: &mut BytesMut| -> EncodeResult {
7395 w.put_i8(v906.slot);
7396 v906.item.encode(w)?;
7397 Ok(())
7398 },
7399 |b| b & 0x80 == 0,
7400 ) {
7401 break v906;
7402 }
7403 });
7404 }
7405 v905
7406 };
7407 EntityEquipment {
7408 entity_id: v903,
7409 equipments: v904,
7410 }
7411 }
7412 }
7413}
7414impl From<EntityEquipment> for ClientboundPlayPacket {
7415 fn from(p: EntityEquipment) -> Self {
7416 Self::EntityEquipment(p)
7417 }
7418}
7419
7420#[derive(Debug, Clone, PartialEq)]
7422pub struct Experience {
7423 pub experience_bar: f32,
7425 pub level: i32,
7427 pub total_experience: i32,
7429}
7430impl crate::packet::Packet for Experience {
7431 const ID: i32 = id::EXPERIENCE;
7432 const NAME: &'static str = "experience";
7433 const STATE: State = State::Play;
7434 const DIRECTION: Direction = Direction::Clientbound;
7435}
7436impl Decode for Experience {
7437 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7438 Ok({
7439 let v909 = r.read_f32()?;
7440 let v910 = r.read_varint()?;
7441 let v911 = r.read_varint()?;
7442 Experience {
7443 experience_bar: v909,
7444 level: v910,
7445 total_experience: v911,
7446 }
7447 })
7448 }
7449}
7450impl Encode for Experience {
7451 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7452 w.put_f32((*self).experience_bar);
7453 w.put_varint((*self).level);
7454 w.put_varint((*self).total_experience);
7455 Ok(())
7456 }
7457}
7458#[cfg(feature = "testgen")]
7459impl Generate for Experience {
7460 fn generate(g: &mut Gen) -> Self {
7461 {
7462 let v912 = g.f32();
7463 let v913 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7464 let v914 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7465 Experience {
7466 experience_bar: v912,
7467 level: v913,
7468 total_experience: v914,
7469 }
7470 }
7471 }
7472}
7473impl From<Experience> for ClientboundPlayPacket {
7474 fn from(p: Experience) -> Self {
7475 Self::Experience(p)
7476 }
7477}
7478
7479#[derive(Debug, Clone, PartialEq)]
7481pub struct UpdateHealth {
7482 pub health: f32,
7484 pub food: i32,
7486 pub food_saturation: f32,
7488}
7489impl crate::packet::Packet for UpdateHealth {
7490 const ID: i32 = id::UPDATE_HEALTH;
7491 const NAME: &'static str = "update_health";
7492 const STATE: State = State::Play;
7493 const DIRECTION: Direction = Direction::Clientbound;
7494}
7495impl Decode for UpdateHealth {
7496 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7497 Ok({
7498 let v915 = r.read_f32()?;
7499 let v916 = r.read_varint()?;
7500 let v917 = r.read_f32()?;
7501 UpdateHealth {
7502 health: v915,
7503 food: v916,
7504 food_saturation: v917,
7505 }
7506 })
7507 }
7508}
7509impl Encode for UpdateHealth {
7510 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7511 w.put_f32((*self).health);
7512 w.put_varint((*self).food);
7513 w.put_f32((*self).food_saturation);
7514 Ok(())
7515 }
7516}
7517#[cfg(feature = "testgen")]
7518impl Generate for UpdateHealth {
7519 fn generate(g: &mut Gen) -> Self {
7520 {
7521 let v918 = g.f32();
7522 let v919 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7523 let v920 = g.f32();
7524 UpdateHealth {
7525 health: v918,
7526 food: v919,
7527 food_saturation: v920,
7528 }
7529 }
7530 }
7531}
7532impl From<UpdateHealth> for ClientboundPlayPacket {
7533 fn from(p: UpdateHealth) -> Self {
7534 Self::UpdateHealth(p)
7535 }
7536}
7537
7538#[derive(Debug, Clone, PartialEq)]
7540pub struct ScoreboardObjective {
7541 pub name: ByteString,
7543 pub action: i8,
7545 pub display_text: Option<ByteString>,
7547 pub r#type: Option<i32>,
7549}
7550impl crate::packet::Packet for ScoreboardObjective {
7551 const ID: i32 = id::SCOREBOARD_OBJECTIVE;
7552 const NAME: &'static str = "scoreboard_objective";
7553 const STATE: State = State::Play;
7554 const DIRECTION: Direction = Direction::Clientbound;
7555}
7556impl Decode for ScoreboardObjective {
7557 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7558 Ok({
7559 let v921 = r.read_string()?;
7560 let v922 = r.read_i8()?;
7561 let v923 = if (v922 == 0) || (v922 == 2) {
7562 Some(r.read_string()?)
7563 } else {
7564 None
7565 };
7566 let v924 = if (v922 == 0) || (v922 == 2) {
7567 Some(r.read_varint()?)
7568 } else {
7569 None
7570 };
7571 ScoreboardObjective {
7572 name: v921,
7573 action: v922,
7574 display_text: v923,
7575 r#type: v924,
7576 }
7577 })
7578 }
7579}
7580impl Encode for ScoreboardObjective {
7581 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7582 w.put_string(&(*self).name)?;
7583 w.put_i8((*self).action);
7584 match (
7585 &(*self).display_text,
7586 ((*self).action == 0) || ((*self).action == 2),
7587 ) {
7588 (Some(v925), true) => {
7589 w.put_string(&(*v925))?;
7590 }
7591 (None, false) => {}
7592 _ => {
7593 return Err(EncodeError::SwitchMismatch(
7594 "play.clientbound.scoreboard_objective.displayText",
7595 ));
7596 }
7597 }
7598 match (
7599 &(*self).r#type,
7600 ((*self).action == 0) || ((*self).action == 2),
7601 ) {
7602 (Some(v926), true) => {
7603 w.put_varint((*v926));
7604 }
7605 (None, false) => {}
7606 _ => {
7607 return Err(EncodeError::SwitchMismatch(
7608 "play.clientbound.scoreboard_objective.type",
7609 ));
7610 }
7611 }
7612 Ok(())
7613 }
7614}
7615#[cfg(feature = "testgen")]
7616impl Generate for ScoreboardObjective {
7617 fn generate(g: &mut Gen) -> Self {
7618 {
7619 let v927 = g.string();
7620 let v928 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
7621 let v929 = if (v928 == 0) || (v928 == 2) {
7622 Some(g.string())
7623 } else {
7624 None
7625 };
7626 let v930 = if (v928 == 0) || (v928 == 2) {
7627 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7628 } else {
7629 None
7630 };
7631 ScoreboardObjective {
7632 name: v927,
7633 action: v928,
7634 display_text: v929,
7635 r#type: v930,
7636 }
7637 }
7638 }
7639}
7640impl From<ScoreboardObjective> for ClientboundPlayPacket {
7641 fn from(p: ScoreboardObjective) -> Self {
7642 Self::ScoreboardObjective(p)
7643 }
7644}
7645
7646#[derive(Debug, Clone, PartialEq)]
7648pub struct SetPassengers {
7649 pub entity_id: i32,
7651 pub passengers: Vec<i32>,
7653}
7654impl crate::packet::Packet for SetPassengers {
7655 const ID: i32 = id::SET_PASSENGERS;
7656 const NAME: &'static str = "set_passengers";
7657 const STATE: State = State::Play;
7658 const DIRECTION: Direction = Direction::Clientbound;
7659}
7660impl Decode for SetPassengers {
7661 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7662 Ok({
7663 let v931 = r.read_varint()?;
7664 let v932 = {
7665 let v933 = {
7666 let c = r.read_varint()?;
7667 r.check_count(i64::from(c), 1)?
7668 };
7669 let mut v934 = Vec::with_capacity(v933.min(crate::codec::PREALLOC_LIMIT));
7670 for _ in 0..v933 {
7671 v934.push(r.read_varint()?);
7672 }
7673 v934
7674 };
7675 SetPassengers {
7676 entity_id: v931,
7677 passengers: v932,
7678 }
7679 })
7680 }
7681}
7682impl Encode for SetPassengers {
7683 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7684 w.put_varint((*self).entity_id);
7685 w.put_len_varint((*self).passengers.len())?;
7686 for v935 in (*self).passengers.iter() {
7687 w.put_varint((*v935));
7688 }
7689 Ok(())
7690 }
7691}
7692#[cfg(feature = "testgen")]
7693impl Generate for SetPassengers {
7694 fn generate(g: &mut Gen) -> Self {
7695 {
7696 let v936 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
7697 let v937 = {
7698 let v938 = g.count();
7699 let mut v939 = Vec::with_capacity(v938.min(crate::codec::PREALLOC_LIMIT));
7700 for _ in 0..v938 {
7701 v939.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
7702 }
7703 v939
7704 };
7705 SetPassengers {
7706 entity_id: v936,
7707 passengers: v937,
7708 }
7709 }
7710 }
7711}
7712impl From<SetPassengers> for ClientboundPlayPacket {
7713 fn from(p: SetPassengers) -> Self {
7714 Self::SetPassengers(p)
7715 }
7716}
7717
7718#[derive(Debug, Clone, PartialEq)]
7720pub struct Teams {
7721 pub team: ByteString,
7723 pub mode: i8,
7725 pub name: Option<ByteString>,
7727 pub friendly_fire: Option<i8>,
7729 pub name_tag_visibility: Option<ByteString>,
7731 pub collision_rule: Option<ByteString>,
7733 pub formatting: Option<i32>,
7735 pub prefix: Option<ByteString>,
7737 pub suffix: Option<ByteString>,
7739 pub players: Option<Vec<ByteString>>,
7741}
7742impl crate::packet::Packet for Teams {
7743 const ID: i32 = id::TEAMS;
7744 const NAME: &'static str = "teams";
7745 const STATE: State = State::Play;
7746 const DIRECTION: Direction = Direction::Clientbound;
7747}
7748impl Decode for Teams {
7749 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
7750 Ok({
7751 let v940 = r.read_string()?;
7752 let v941 = r.read_i8()?;
7753 let v942 = if (v941 == 0) || (v941 == 2) {
7754 Some(r.read_string()?)
7755 } else {
7756 None
7757 };
7758 let v943 = if (v941 == 0) || (v941 == 2) {
7759 Some(r.read_i8()?)
7760 } else {
7761 None
7762 };
7763 let v944 = if (v941 == 0) || (v941 == 2) {
7764 Some(r.read_string()?)
7765 } else {
7766 None
7767 };
7768 let v945 = if (v941 == 0) || (v941 == 2) {
7769 Some(r.read_string()?)
7770 } else {
7771 None
7772 };
7773 let v946 = if (v941 == 0) || (v941 == 2) {
7774 Some(r.read_varint()?)
7775 } else {
7776 None
7777 };
7778 let v947 = if (v941 == 0) || (v941 == 2) {
7779 Some(r.read_string()?)
7780 } else {
7781 None
7782 };
7783 let v948 = if (v941 == 0) || (v941 == 2) {
7784 Some(r.read_string()?)
7785 } else {
7786 None
7787 };
7788 let v949 = if (v941 == 0) || (v941 == 3) || (v941 == 4) {
7789 Some({
7790 let v950 = {
7791 let c = r.read_varint()?;
7792 r.check_count(i64::from(c), 1)?
7793 };
7794 let mut v951 = Vec::with_capacity(v950.min(crate::codec::PREALLOC_LIMIT));
7795 for _ in 0..v950 {
7796 v951.push(r.read_string()?);
7797 }
7798 v951
7799 })
7800 } else {
7801 None
7802 };
7803 Teams {
7804 team: v940,
7805 mode: v941,
7806 name: v942,
7807 friendly_fire: v943,
7808 name_tag_visibility: v944,
7809 collision_rule: v945,
7810 formatting: v946,
7811 prefix: v947,
7812 suffix: v948,
7813 players: v949,
7814 }
7815 })
7816 }
7817}
7818impl Encode for Teams {
7819 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
7820 w.put_string(&(*self).team)?;
7821 w.put_i8((*self).mode);
7822 match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
7823 (Some(v952), true) => {
7824 w.put_string(&(*v952))?;
7825 }
7826 (None, false) => {}
7827 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
7828 }
7829 match (
7830 &(*self).friendly_fire,
7831 ((*self).mode == 0) || ((*self).mode == 2),
7832 ) {
7833 (Some(v953), true) => {
7834 w.put_i8((*v953));
7835 }
7836 (None, false) => {}
7837 _ => {
7838 return Err(EncodeError::SwitchMismatch(
7839 "play.clientbound.teams.friendlyFire",
7840 ));
7841 }
7842 }
7843 match (
7844 &(*self).name_tag_visibility,
7845 ((*self).mode == 0) || ((*self).mode == 2),
7846 ) {
7847 (Some(v954), true) => {
7848 w.put_string(&(*v954))?;
7849 }
7850 (None, false) => {}
7851 _ => {
7852 return Err(EncodeError::SwitchMismatch(
7853 "play.clientbound.teams.nameTagVisibility",
7854 ));
7855 }
7856 }
7857 match (
7858 &(*self).collision_rule,
7859 ((*self).mode == 0) || ((*self).mode == 2),
7860 ) {
7861 (Some(v955), true) => {
7862 w.put_string(&(*v955))?;
7863 }
7864 (None, false) => {}
7865 _ => {
7866 return Err(EncodeError::SwitchMismatch(
7867 "play.clientbound.teams.collisionRule",
7868 ));
7869 }
7870 }
7871 match (
7872 &(*self).formatting,
7873 ((*self).mode == 0) || ((*self).mode == 2),
7874 ) {
7875 (Some(v956), true) => {
7876 w.put_varint((*v956));
7877 }
7878 (None, false) => {}
7879 _ => {
7880 return Err(EncodeError::SwitchMismatch(
7881 "play.clientbound.teams.formatting",
7882 ));
7883 }
7884 }
7885 match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
7886 (Some(v957), true) => {
7887 w.put_string(&(*v957))?;
7888 }
7889 (None, false) => {}
7890 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
7891 }
7892 match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
7893 (Some(v958), true) => {
7894 w.put_string(&(*v958))?;
7895 }
7896 (None, false) => {}
7897 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
7898 }
7899 match (
7900 &(*self).players,
7901 ((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
7902 ) {
7903 (Some(v959), true) => {
7904 w.put_len_varint((*v959).len())?;
7905 for v960 in (*v959).iter() {
7906 w.put_string(&(*v960))?;
7907 }
7908 }
7909 (None, false) => {}
7910 _ => {
7911 return Err(EncodeError::SwitchMismatch(
7912 "play.clientbound.teams.players",
7913 ));
7914 }
7915 }
7916 Ok(())
7917 }
7918}
7919#[cfg(feature = "testgen")]
7920impl Generate for Teams {
7921 fn generate(g: &mut Gen) -> Self {
7922 {
7923 let v961 = g.string();
7924 let v962 = (g.int_in(
7925 -128,
7926 127,
7927 &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4],
7928 ) as i8);
7929 let v963 = if (v962 == 0) || (v962 == 2) {
7930 Some(g.string())
7931 } else {
7932 None
7933 };
7934 let v964 = if (v962 == 0) || (v962 == 2) {
7935 Some((g.int_in(-128, 127, &[]) as i8))
7936 } else {
7937 None
7938 };
7939 let v965 = if (v962 == 0) || (v962 == 2) {
7940 Some(g.string())
7941 } else {
7942 None
7943 };
7944 let v966 = if (v962 == 0) || (v962 == 2) {
7945 Some(g.string())
7946 } else {
7947 None
7948 };
7949 let v967 = if (v962 == 0) || (v962 == 2) {
7950 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
7951 } else {
7952 None
7953 };
7954 let v968 = if (v962 == 0) || (v962 == 2) {
7955 Some(g.string())
7956 } else {
7957 None
7958 };
7959 let v969 = if (v962 == 0) || (v962 == 2) {
7960 Some(g.string())
7961 } else {
7962 None
7963 };
7964 let v970 = if (v962 == 0) || (v962 == 3) || (v962 == 4) {
7965 Some({
7966 let v971 = g.count();
7967 let mut v972 = Vec::with_capacity(v971.min(crate::codec::PREALLOC_LIMIT));
7968 for _ in 0..v971 {
7969 v972.push(g.string());
7970 }
7971 v972
7972 })
7973 } else {
7974 None
7975 };
7976 Teams {
7977 team: v961,
7978 mode: v962,
7979 name: v963,
7980 friendly_fire: v964,
7981 name_tag_visibility: v965,
7982 collision_rule: v966,
7983 formatting: v967,
7984 prefix: v968,
7985 suffix: v969,
7986 players: v970,
7987 }
7988 }
7989 }
7990}
7991impl From<Teams> for ClientboundPlayPacket {
7992 fn from(p: Teams) -> Self {
7993 Self::Teams(p)
7994 }
7995}
7996
7997#[derive(Debug, Clone, PartialEq)]
7999pub struct ScoreboardScore {
8000 pub item_name: ByteString,
8002 pub action: i32,
8004 pub score_name: ByteString,
8006 pub value: Option<i32>,
8008}
8009impl crate::packet::Packet for ScoreboardScore {
8010 const ID: i32 = id::SCOREBOARD_SCORE;
8011 const NAME: &'static str = "scoreboard_score";
8012 const STATE: State = State::Play;
8013 const DIRECTION: Direction = Direction::Clientbound;
8014}
8015impl Decode for ScoreboardScore {
8016 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8017 Ok({
8018 let v973 = r.read_string()?;
8019 let v974 = r.read_varint()?;
8020 let v975 = r.read_string()?;
8021 let v976 = if !(v974 == 1) {
8022 Some(r.read_varint()?)
8023 } else {
8024 None
8025 };
8026 ScoreboardScore {
8027 item_name: v973,
8028 action: v974,
8029 score_name: v975,
8030 value: v976,
8031 }
8032 })
8033 }
8034}
8035impl Encode for ScoreboardScore {
8036 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8037 w.put_string(&(*self).item_name)?;
8038 w.put_varint((*self).action);
8039 w.put_string(&(*self).score_name)?;
8040 match (&(*self).value, !((*self).action == 1)) {
8041 (Some(v977), true) => {
8042 w.put_varint((*v977));
8043 }
8044 (None, false) => {}
8045 _ => {
8046 return Err(EncodeError::SwitchMismatch(
8047 "play.clientbound.scoreboard_score.value",
8048 ));
8049 }
8050 }
8051 Ok(())
8052 }
8053}
8054#[cfg(feature = "testgen")]
8055impl Generate for ScoreboardScore {
8056 fn generate(g: &mut Gen) -> Self {
8057 {
8058 let v978 = g.string();
8059 let v979 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
8060 let v980 = g.string();
8061 let v981 = if !(v979 == 1) {
8062 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
8063 } else {
8064 None
8065 };
8066 ScoreboardScore {
8067 item_name: v978,
8068 action: v979,
8069 score_name: v980,
8070 value: v981,
8071 }
8072 }
8073 }
8074}
8075impl From<ScoreboardScore> for ClientboundPlayPacket {
8076 fn from(p: ScoreboardScore) -> Self {
8077 Self::ScoreboardScore(p)
8078 }
8079}
8080
8081#[derive(Debug, Clone, PartialEq)]
8083pub struct UpdateTime {
8084 pub age: i64,
8086 pub time: i64,
8088}
8089impl crate::packet::Packet for UpdateTime {
8090 const ID: i32 = id::UPDATE_TIME;
8091 const NAME: &'static str = "update_time";
8092 const STATE: State = State::Play;
8093 const DIRECTION: Direction = Direction::Clientbound;
8094}
8095impl Decode for UpdateTime {
8096 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8097 Ok({
8098 let v982 = r.read_i64()?;
8099 let v983 = r.read_i64()?;
8100 UpdateTime {
8101 age: v982,
8102 time: v983,
8103 }
8104 })
8105 }
8106}
8107impl Encode for UpdateTime {
8108 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8109 w.put_i64((*self).age);
8110 w.put_i64((*self).time);
8111 Ok(())
8112 }
8113}
8114#[cfg(feature = "testgen")]
8115impl Generate for UpdateTime {
8116 fn generate(g: &mut Gen) -> Self {
8117 {
8118 let v984 = g.i64();
8119 let v985 = g.i64();
8120 UpdateTime {
8121 age: v984,
8122 time: v985,
8123 }
8124 }
8125 }
8126}
8127impl From<UpdateTime> for ClientboundPlayPacket {
8128 fn from(p: UpdateTime) -> Self {
8129 Self::UpdateTime(p)
8130 }
8131}
8132
8133#[derive(Debug, Clone, PartialEq)]
8135pub struct Title {
8136 pub action: i32,
8138 pub text: Option<ByteString>,
8140 pub fade_in: Option<i32>,
8142 pub stay: Option<i32>,
8144 pub fade_out: Option<i32>,
8146}
8147impl crate::packet::Packet for Title {
8148 const ID: i32 = id::TITLE;
8149 const NAME: &'static str = "title";
8150 const STATE: State = State::Play;
8151 const DIRECTION: Direction = Direction::Clientbound;
8152}
8153impl Decode for Title {
8154 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8155 Ok({
8156 let v986 = r.read_varint()?;
8157 let v987 = if (v986 == 0) || (v986 == 1) || (v986 == 2) {
8158 Some(r.read_string()?)
8159 } else {
8160 None
8161 };
8162 let v988 = if (v986 == 3) {
8163 Some(r.read_i32()?)
8164 } else {
8165 None
8166 };
8167 let v989 = if (v986 == 3) {
8168 Some(r.read_i32()?)
8169 } else {
8170 None
8171 };
8172 let v990 = if (v986 == 3) {
8173 Some(r.read_i32()?)
8174 } else {
8175 None
8176 };
8177 Title {
8178 action: v986,
8179 text: v987,
8180 fade_in: v988,
8181 stay: v989,
8182 fade_out: v990,
8183 }
8184 })
8185 }
8186}
8187impl Encode for Title {
8188 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8189 w.put_varint((*self).action);
8190 match (
8191 &(*self).text,
8192 ((*self).action == 0) || ((*self).action == 1) || ((*self).action == 2),
8193 ) {
8194 (Some(v991), true) => {
8195 w.put_string(&(*v991))?;
8196 }
8197 (None, false) => {}
8198 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
8199 }
8200 match (&(*self).fade_in, ((*self).action == 3)) {
8201 (Some(v992), true) => {
8202 w.put_i32((*v992));
8203 }
8204 (None, false) => {}
8205 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
8206 }
8207 match (&(*self).stay, ((*self).action == 3)) {
8208 (Some(v993), true) => {
8209 w.put_i32((*v993));
8210 }
8211 (None, false) => {}
8212 _ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
8213 }
8214 match (&(*self).fade_out, ((*self).action == 3)) {
8215 (Some(v994), true) => {
8216 w.put_i32((*v994));
8217 }
8218 (None, false) => {}
8219 _ => {
8220 return Err(EncodeError::SwitchMismatch(
8221 "play.clientbound.title.fadeOut",
8222 ));
8223 }
8224 }
8225 Ok(())
8226 }
8227}
8228#[cfg(feature = "testgen")]
8229impl Generate for Title {
8230 fn generate(g: &mut Gen) -> Self {
8231 {
8232 let v995 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 3, 3]) as i32);
8233 let v996 = if (v995 == 0) || (v995 == 1) || (v995 == 2) {
8234 Some(g.string())
8235 } else {
8236 None
8237 };
8238 let v997 = if (v995 == 3) {
8239 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
8240 } else {
8241 None
8242 };
8243 let v998 = if (v995 == 3) {
8244 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
8245 } else {
8246 None
8247 };
8248 let v999 = if (v995 == 3) {
8249 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
8250 } else {
8251 None
8252 };
8253 Title {
8254 action: v995,
8255 text: v996,
8256 fade_in: v997,
8257 stay: v998,
8258 fade_out: v999,
8259 }
8260 }
8261 }
8262}
8263impl From<Title> for ClientboundPlayPacket {
8264 fn from(p: Title) -> Self {
8265 Self::Title(p)
8266 }
8267}
8268
8269#[derive(Debug, Clone, PartialEq)]
8271pub struct EntitySoundEffect {
8272 pub sound_id: i32,
8274 pub sound_category: i32,
8276 pub entity_id: i32,
8278 pub volume: f32,
8280 pub pitch: f32,
8282}
8283impl crate::packet::Packet for EntitySoundEffect {
8284 const ID: i32 = id::ENTITY_SOUND_EFFECT;
8285 const NAME: &'static str = "entity_sound_effect";
8286 const STATE: State = State::Play;
8287 const DIRECTION: Direction = Direction::Clientbound;
8288}
8289impl Decode for EntitySoundEffect {
8290 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8291 Ok({
8292 let v1000 = r.read_varint()?;
8293 let v1001 = r.read_varint()?;
8294 let v1002 = r.read_varint()?;
8295 let v1003 = r.read_f32()?;
8296 let v1004 = r.read_f32()?;
8297 EntitySoundEffect {
8298 sound_id: v1000,
8299 sound_category: v1001,
8300 entity_id: v1002,
8301 volume: v1003,
8302 pitch: v1004,
8303 }
8304 })
8305 }
8306}
8307impl Encode for EntitySoundEffect {
8308 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8309 w.put_varint((*self).sound_id);
8310 w.put_varint((*self).sound_category);
8311 w.put_varint((*self).entity_id);
8312 w.put_f32((*self).volume);
8313 w.put_f32((*self).pitch);
8314 Ok(())
8315 }
8316}
8317#[cfg(feature = "testgen")]
8318impl Generate for EntitySoundEffect {
8319 fn generate(g: &mut Gen) -> Self {
8320 {
8321 let v1005 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8322 let v1006 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8323 let v1007 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8324 let v1008 = g.f32();
8325 let v1009 = g.f32();
8326 EntitySoundEffect {
8327 sound_id: v1005,
8328 sound_category: v1006,
8329 entity_id: v1007,
8330 volume: v1008,
8331 pitch: v1009,
8332 }
8333 }
8334 }
8335}
8336impl From<EntitySoundEffect> for ClientboundPlayPacket {
8337 fn from(p: EntitySoundEffect) -> Self {
8338 Self::EntitySoundEffect(p)
8339 }
8340}
8341
8342#[derive(Debug, Clone, PartialEq)]
8344pub struct SoundEffect {
8345 pub sound_id: i32,
8347 pub sound_category: i32,
8349 pub x: i32,
8351 pub y: i32,
8353 pub z: i32,
8355 pub volume: f32,
8357 pub pitch: f32,
8359}
8360impl crate::packet::Packet for SoundEffect {
8361 const ID: i32 = id::SOUND_EFFECT;
8362 const NAME: &'static str = "sound_effect";
8363 const STATE: State = State::Play;
8364 const DIRECTION: Direction = Direction::Clientbound;
8365}
8366impl Decode for SoundEffect {
8367 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8368 Ok({
8369 let v1010 = r.read_varint()?;
8370 let v1011 = r.read_varint()?;
8371 let v1012 = r.read_i32()?;
8372 let v1013 = r.read_i32()?;
8373 let v1014 = r.read_i32()?;
8374 let v1015 = r.read_f32()?;
8375 let v1016 = r.read_f32()?;
8376 SoundEffect {
8377 sound_id: v1010,
8378 sound_category: v1011,
8379 x: v1012,
8380 y: v1013,
8381 z: v1014,
8382 volume: v1015,
8383 pitch: v1016,
8384 }
8385 })
8386 }
8387}
8388impl Encode for SoundEffect {
8389 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8390 w.put_varint((*self).sound_id);
8391 w.put_varint((*self).sound_category);
8392 w.put_i32((*self).x);
8393 w.put_i32((*self).y);
8394 w.put_i32((*self).z);
8395 w.put_f32((*self).volume);
8396 w.put_f32((*self).pitch);
8397 Ok(())
8398 }
8399}
8400#[cfg(feature = "testgen")]
8401impl Generate for SoundEffect {
8402 fn generate(g: &mut Gen) -> Self {
8403 {
8404 let v1017 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8405 let v1018 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8406 let v1019 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8407 let v1020 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8408 let v1021 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8409 let v1022 = g.f32();
8410 let v1023 = g.f32();
8411 SoundEffect {
8412 sound_id: v1017,
8413 sound_category: v1018,
8414 x: v1019,
8415 y: v1020,
8416 z: v1021,
8417 volume: v1022,
8418 pitch: v1023,
8419 }
8420 }
8421 }
8422}
8423impl From<SoundEffect> for ClientboundPlayPacket {
8424 fn from(p: SoundEffect) -> Self {
8425 Self::SoundEffect(p)
8426 }
8427}
8428
8429#[derive(Debug, Clone, PartialEq)]
8431pub struct StopSound {
8432 pub flags: i8,
8434 pub source: Option<i32>,
8436 pub sound: Option<ByteString>,
8438}
8439impl crate::packet::Packet for StopSound {
8440 const ID: i32 = id::STOP_SOUND;
8441 const NAME: &'static str = "stop_sound";
8442 const STATE: State = State::Play;
8443 const DIRECTION: Direction = Direction::Clientbound;
8444}
8445impl Decode for StopSound {
8446 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8447 Ok({
8448 let v1024 = r.read_i8()?;
8449 let v1025 = if (v1024 == 1) || (v1024 == 3) {
8450 Some(r.read_varint()?)
8451 } else {
8452 None
8453 };
8454 let v1026 = if (v1024 == 2) || (v1024 == 3) {
8455 Some(r.read_string()?)
8456 } else {
8457 None
8458 };
8459 StopSound {
8460 flags: v1024,
8461 source: v1025,
8462 sound: v1026,
8463 }
8464 })
8465 }
8466}
8467impl Encode for StopSound {
8468 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8469 w.put_i8((*self).flags);
8470 match (
8471 &(*self).source,
8472 ((*self).flags == 1) || ((*self).flags == 3),
8473 ) {
8474 (Some(v1027), true) => {
8475 w.put_varint((*v1027));
8476 }
8477 (None, false) => {}
8478 _ => {
8479 return Err(EncodeError::SwitchMismatch(
8480 "play.clientbound.stop_sound.source",
8481 ));
8482 }
8483 }
8484 match (&(*self).sound, ((*self).flags == 2) || ((*self).flags == 3)) {
8485 (Some(v1028), true) => {
8486 w.put_string(&(*v1028))?;
8487 }
8488 (None, false) => {}
8489 _ => {
8490 return Err(EncodeError::SwitchMismatch(
8491 "play.clientbound.stop_sound.sound",
8492 ));
8493 }
8494 }
8495 Ok(())
8496 }
8497}
8498#[cfg(feature = "testgen")]
8499impl Generate for StopSound {
8500 fn generate(g: &mut Gen) -> Self {
8501 {
8502 let v1029 = (g.int_in(-128, 127, &[1, 3, 2, 3]) as i8);
8503 let v1030 = if (v1029 == 1) || (v1029 == 3) {
8504 Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
8505 } else {
8506 None
8507 };
8508 let v1031 = if (v1029 == 2) || (v1029 == 3) {
8509 Some(g.string())
8510 } else {
8511 None
8512 };
8513 StopSound {
8514 flags: v1029,
8515 source: v1030,
8516 sound: v1031,
8517 }
8518 }
8519 }
8520}
8521impl From<StopSound> for ClientboundPlayPacket {
8522 fn from(p: StopSound) -> Self {
8523 Self::StopSound(p)
8524 }
8525}
8526
8527#[derive(Debug, Clone, PartialEq)]
8529pub struct PlayerlistHeader {
8530 pub header: ByteString,
8532 pub footer: ByteString,
8534}
8535impl crate::packet::Packet for PlayerlistHeader {
8536 const ID: i32 = id::PLAYERLIST_HEADER;
8537 const NAME: &'static str = "playerlist_header";
8538 const STATE: State = State::Play;
8539 const DIRECTION: Direction = Direction::Clientbound;
8540}
8541impl Decode for PlayerlistHeader {
8542 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8543 Ok({
8544 let v1032 = r.read_string()?;
8545 let v1033 = r.read_string()?;
8546 PlayerlistHeader {
8547 header: v1032,
8548 footer: v1033,
8549 }
8550 })
8551 }
8552}
8553impl Encode for PlayerlistHeader {
8554 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8555 w.put_string(&(*self).header)?;
8556 w.put_string(&(*self).footer)?;
8557 Ok(())
8558 }
8559}
8560#[cfg(feature = "testgen")]
8561impl Generate for PlayerlistHeader {
8562 fn generate(g: &mut Gen) -> Self {
8563 {
8564 let v1034 = g.string();
8565 let v1035 = g.string();
8566 PlayerlistHeader {
8567 header: v1034,
8568 footer: v1035,
8569 }
8570 }
8571 }
8572}
8573impl From<PlayerlistHeader> for ClientboundPlayPacket {
8574 fn from(p: PlayerlistHeader) -> Self {
8575 Self::PlayerlistHeader(p)
8576 }
8577}
8578
8579#[derive(Debug, Clone, PartialEq)]
8581pub struct NbtQueryResponse {
8582 pub transaction_id: i32,
8584 pub nbt: Option<RawNbt>,
8586}
8587impl crate::packet::Packet for NbtQueryResponse {
8588 const ID: i32 = id::NBT_QUERY_RESPONSE;
8589 const NAME: &'static str = "nbt_query_response";
8590 const STATE: State = State::Play;
8591 const DIRECTION: Direction = Direction::Clientbound;
8592}
8593impl Decode for NbtQueryResponse {
8594 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8595 Ok({
8596 let v1036 = r.read_varint()?;
8597 let v1037 = RawNbt::read_optional(r)?;
8598 NbtQueryResponse {
8599 transaction_id: v1036,
8600 nbt: v1037,
8601 }
8602 })
8603 }
8604}
8605impl Encode for NbtQueryResponse {
8606 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8607 w.put_varint((*self).transaction_id);
8608 RawNbt::write_optional(&(*self).nbt, w);
8609 Ok(())
8610 }
8611}
8612#[cfg(feature = "testgen")]
8613impl Generate for NbtQueryResponse {
8614 fn generate(g: &mut Gen) -> Self {
8615 {
8616 let v1038 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8617 let v1039 = g.opt_nbt();
8618 NbtQueryResponse {
8619 transaction_id: v1038,
8620 nbt: v1039,
8621 }
8622 }
8623 }
8624}
8625impl From<NbtQueryResponse> for ClientboundPlayPacket {
8626 fn from(p: NbtQueryResponse) -> Self {
8627 Self::NbtQueryResponse(p)
8628 }
8629}
8630
8631#[derive(Debug, Clone, PartialEq)]
8633pub struct Collect {
8634 pub collected_entity_id: i32,
8636 pub collector_entity_id: i32,
8638 pub pickup_item_count: i32,
8640}
8641impl crate::packet::Packet for Collect {
8642 const ID: i32 = id::COLLECT;
8643 const NAME: &'static str = "collect";
8644 const STATE: State = State::Play;
8645 const DIRECTION: Direction = Direction::Clientbound;
8646}
8647impl Decode for Collect {
8648 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8649 Ok({
8650 let v1040 = r.read_varint()?;
8651 let v1041 = r.read_varint()?;
8652 let v1042 = r.read_varint()?;
8653 Collect {
8654 collected_entity_id: v1040,
8655 collector_entity_id: v1041,
8656 pickup_item_count: v1042,
8657 }
8658 })
8659 }
8660}
8661impl Encode for Collect {
8662 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8663 w.put_varint((*self).collected_entity_id);
8664 w.put_varint((*self).collector_entity_id);
8665 w.put_varint((*self).pickup_item_count);
8666 Ok(())
8667 }
8668}
8669#[cfg(feature = "testgen")]
8670impl Generate for Collect {
8671 fn generate(g: &mut Gen) -> Self {
8672 {
8673 let v1043 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8674 let v1044 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8675 let v1045 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8676 Collect {
8677 collected_entity_id: v1043,
8678 collector_entity_id: v1044,
8679 pickup_item_count: v1045,
8680 }
8681 }
8682 }
8683}
8684impl From<Collect> for ClientboundPlayPacket {
8685 fn from(p: Collect) -> Self {
8686 Self::Collect(p)
8687 }
8688}
8689
8690#[derive(Debug, Clone, PartialEq)]
8692pub struct EntityTeleport {
8693 pub entity_id: i32,
8695 pub x: f64,
8697 pub y: f64,
8699 pub z: f64,
8701 pub yaw: i8,
8703 pub pitch: i8,
8705 pub on_ground: bool,
8707}
8708impl crate::packet::Packet for EntityTeleport {
8709 const ID: i32 = id::ENTITY_TELEPORT;
8710 const NAME: &'static str = "entity_teleport";
8711 const STATE: State = State::Play;
8712 const DIRECTION: Direction = Direction::Clientbound;
8713}
8714impl Decode for EntityTeleport {
8715 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8716 Ok({
8717 let v1046 = r.read_varint()?;
8718 let v1047 = r.read_f64()?;
8719 let v1048 = r.read_f64()?;
8720 let v1049 = r.read_f64()?;
8721 let v1050 = r.read_i8()?;
8722 let v1051 = r.read_i8()?;
8723 let v1052 = r.read_bool()?;
8724 EntityTeleport {
8725 entity_id: v1046,
8726 x: v1047,
8727 y: v1048,
8728 z: v1049,
8729 yaw: v1050,
8730 pitch: v1051,
8731 on_ground: v1052,
8732 }
8733 })
8734 }
8735}
8736impl Encode for EntityTeleport {
8737 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8738 w.put_varint((*self).entity_id);
8739 w.put_f64((*self).x);
8740 w.put_f64((*self).y);
8741 w.put_f64((*self).z);
8742 w.put_i8((*self).yaw);
8743 w.put_i8((*self).pitch);
8744 w.put_bool((*self).on_ground);
8745 Ok(())
8746 }
8747}
8748#[cfg(feature = "testgen")]
8749impl Generate for EntityTeleport {
8750 fn generate(g: &mut Gen) -> Self {
8751 {
8752 let v1053 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
8753 let v1054 = g.f64();
8754 let v1055 = g.f64();
8755 let v1056 = g.f64();
8756 let v1057 = (g.int_in(-128, 127, &[]) as i8);
8757 let v1058 = (g.int_in(-128, 127, &[]) as i8);
8758 let v1059 = g.bool();
8759 EntityTeleport {
8760 entity_id: v1053,
8761 x: v1054,
8762 y: v1055,
8763 z: v1056,
8764 yaw: v1057,
8765 pitch: v1058,
8766 on_ground: v1059,
8767 }
8768 }
8769 }
8770}
8771impl From<EntityTeleport> for ClientboundPlayPacket {
8772 fn from(p: EntityTeleport) -> Self {
8773 Self::EntityTeleport(p)
8774 }
8775}
8776
8777#[derive(Debug, Clone, PartialEq)]
8779pub struct Advancements {
8780 pub reset: bool,
8782 pub advancement_mapping: Vec<AdvancementsAdvancementMapping>,
8784 pub identifiers: Vec<ByteString>,
8786 pub progress_mapping: Vec<AdvancementsProgressMapping>,
8788}
8789impl crate::packet::Packet for Advancements {
8790 const ID: i32 = id::ADVANCEMENTS;
8791 const NAME: &'static str = "advancements";
8792 const STATE: State = State::Play;
8793 const DIRECTION: Direction = Direction::Clientbound;
8794}
8795impl Decode for Advancements {
8796 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
8797 Ok({
8798 let v1060 = r.read_bool()?;
8799 let v1061 = {
8800 let v1062 = {
8801 let c = r.read_varint()?;
8802 r.check_count(i64::from(c), 5)?
8803 };
8804 let mut v1063 = Vec::with_capacity(v1062.min(crate::codec::PREALLOC_LIMIT));
8805 for _ in 0..v1062 {
8806 v1063.push({
8807 let v1064 = r.read_string()?;
8808 let v1065 = {
8809 let v1066 = if r.read_bool()? {
8810 Some(r.read_string()?)
8811 } else {
8812 None
8813 };
8814 let v1067 = if r.read_bool()? {
8815 Some({
8816 let v1068 = r.read_string()?;
8817 let v1069 = r.read_string()?;
8818 let v1070 = <types::Slot as Decode>::decode(r)?;
8819 let v1071 = r.read_varint()?;
8820 let v1072 = {
8821 let v1073 = u64::from(r.read_i32()? as u32);
8822 AdvancementsAdvancementMappingValueDisplayDataFlags {
8823 _unused: (((v1073 >> 3) & 0x1fffffff) as u32),
8824 hidden: (((v1073 >> 2) & 0x1) as u8),
8825 show_toast: (((v1073 >> 1) & 0x1) as u8),
8826 has_background_texture: (((v1073 >> 0) & 0x1) as u8),
8827 }
8828 };
8829 let v1074 = if (v1072.has_background_texture == 1) {
8830 Some(r.read_string()?)
8831 } else {
8832 None
8833 };
8834 let v1075 = r.read_f32()?;
8835 let v1076 = r.read_f32()?;
8836 AdvancementsAdvancementMappingValueDisplayData {
8837 title: v1068,
8838 description: v1069,
8839 icon: v1070,
8840 frame_type: v1071,
8841 flags: v1072,
8842 background_texture: v1074,
8843 x_cord: v1075,
8844 y_cord: v1076,
8845 }
8846 })
8847 } else {
8848 None
8849 };
8850 let v1077 = {
8851 let v1078 = {
8852 let c = r.read_varint()?;
8853 r.check_count(i64::from(c), 1)?
8854 };
8855 let mut v1079 =
8856 Vec::with_capacity(v1078.min(crate::codec::PREALLOC_LIMIT));
8857 for _ in 0..v1078 {
8858 v1079.push({
8859 let v1080 = r.read_string()?;
8860 AdvancementsAdvancementMappingValueCriteria { key: v1080 }
8861 });
8862 }
8863 v1079
8864 };
8865 let v1082 = {
8866 let v1083 = {
8867 let c = r.read_varint()?;
8868 r.check_count(i64::from(c), 1)?
8869 };
8870 let mut v1084 =
8871 Vec::with_capacity(v1083.min(crate::codec::PREALLOC_LIMIT));
8872 for _ in 0..v1083 {
8873 v1084.push({
8874 let v1085 = {
8875 let c = r.read_varint()?;
8876 r.check_count(i64::from(c), 1)?
8877 };
8878 let mut v1086 = Vec::with_capacity(
8879 v1085.min(crate::codec::PREALLOC_LIMIT),
8880 );
8881 for _ in 0..v1085 {
8882 v1086.push(r.read_string()?);
8883 }
8884 v1086
8885 });
8886 }
8887 v1084
8888 };
8889 AdvancementsAdvancementMappingValue {
8890 parent_id: v1066,
8891 display_data: v1067,
8892 criteria: v1077,
8893 requirements: v1082,
8894 }
8895 };
8896 AdvancementsAdvancementMapping {
8897 key: v1064,
8898 value: v1065,
8899 }
8900 });
8901 }
8902 v1063
8903 };
8904 let v1087 = {
8905 let v1088 = {
8906 let c = r.read_varint()?;
8907 r.check_count(i64::from(c), 1)?
8908 };
8909 let mut v1089 = Vec::with_capacity(v1088.min(crate::codec::PREALLOC_LIMIT));
8910 for _ in 0..v1088 {
8911 v1089.push(r.read_string()?);
8912 }
8913 v1089
8914 };
8915 let v1090 = {
8916 let v1091 = {
8917 let c = r.read_varint()?;
8918 r.check_count(i64::from(c), 2)?
8919 };
8920 let mut v1092 = Vec::with_capacity(v1091.min(crate::codec::PREALLOC_LIMIT));
8921 for _ in 0..v1091 {
8922 v1092.push({
8923 let v1093 = r.read_string()?;
8924 let v1094 = {
8925 let v1095 = {
8926 let c = r.read_varint()?;
8927 r.check_count(i64::from(c), 2)?
8928 };
8929 let mut v1096 =
8930 Vec::with_capacity(v1095.min(crate::codec::PREALLOC_LIMIT));
8931 for _ in 0..v1095 {
8932 v1096.push({
8933 let v1097 = r.read_string()?;
8934 let v1098 = if r.read_bool()? {
8935 Some(r.read_i64()?)
8936 } else {
8937 None
8938 };
8939 AdvancementsProgressMappingValue {
8940 criterion_identifier: v1097,
8941 criterion_progress: v1098,
8942 }
8943 });
8944 }
8945 v1096
8946 };
8947 AdvancementsProgressMapping {
8948 key: v1093,
8949 value: v1094,
8950 }
8951 });
8952 }
8953 v1092
8954 };
8955 Advancements {
8956 reset: v1060,
8957 advancement_mapping: v1061,
8958 identifiers: v1087,
8959 progress_mapping: v1090,
8960 }
8961 })
8962 }
8963}
8964impl Encode for Advancements {
8965 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
8966 w.put_bool((*self).reset);
8967 w.put_len_varint((*self).advancement_mapping.len())?;
8968 for v1099 in (*self).advancement_mapping.iter() {
8969 w.put_string(&(*v1099).key)?;
8970 match &(*v1099).value.parent_id {
8971 Some(v1100) => {
8972 w.put_u8(1);
8973 w.put_string(&(*v1100))?;
8974 }
8975 None => w.put_u8(0),
8976 }
8977 match &(*v1099).value.display_data {
8978 Some(v1101) => {
8979 w.put_u8(1);
8980 w.put_string(&(*v1101).title)?;
8981 w.put_string(&(*v1101).description)?;
8982 (*v1101).icon.encode(w)?;
8983 w.put_varint((*v1101).frame_type);
8984 {
8985 let mut bits: u64 = 0;
8986 {
8987 let x = i128::from((*v1101).flags._unused);
8988 if x < 0 || x > 536870911 {
8989 return Err(EncodeError::OutOfRange("_unused"));
8990 }
8991 bits = (bits << 29) | ((x as u64) & 0x1fffffff);
8992 }
8993 {
8994 let x = i128::from((*v1101).flags.hidden);
8995 if x < 0 || x > 1 {
8996 return Err(EncodeError::OutOfRange("hidden"));
8997 }
8998 bits = (bits << 1) | ((x as u64) & 0x1);
8999 }
9000 {
9001 let x = i128::from((*v1101).flags.show_toast);
9002 if x < 0 || x > 1 {
9003 return Err(EncodeError::OutOfRange("show_toast"));
9004 }
9005 bits = (bits << 1) | ((x as u64) & 0x1);
9006 }
9007 {
9008 let x = i128::from((*v1101).flags.has_background_texture);
9009 if x < 0 || x > 1 {
9010 return Err(EncodeError::OutOfRange("has_background_texture"));
9011 }
9012 bits = (bits << 1) | ((x as u64) & 0x1);
9013 }
9014 w.put_u32(bits as u32);
9015 }
9016 match (
9017 &(*v1101).background_texture,
9018 ((*v1101).flags.has_background_texture == 1),
9019 ) {
9020 (Some(v1102), true) => {
9021 w.put_string(&(*v1102))?;
9022 }
9023 (None, false) => {}
9024 _ => {
9025 return Err(EncodeError::SwitchMismatch(
9026 "play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
9027 ));
9028 }
9029 }
9030 w.put_f32((*v1101).x_cord);
9031 w.put_f32((*v1101).y_cord);
9032 }
9033 None => w.put_u8(0),
9034 }
9035 w.put_len_varint((*v1099).value.criteria.len())?;
9036 for v1103 in (*v1099).value.criteria.iter() {
9037 w.put_string(&(*v1103).key)?;
9038 }
9039 w.put_len_varint((*v1099).value.requirements.len())?;
9040 for v1104 in (*v1099).value.requirements.iter() {
9041 w.put_len_varint((*v1104).len())?;
9042 for v1105 in (*v1104).iter() {
9043 w.put_string(&(*v1105))?;
9044 }
9045 }
9046 }
9047 w.put_len_varint((*self).identifiers.len())?;
9048 for v1106 in (*self).identifiers.iter() {
9049 w.put_string(&(*v1106))?;
9050 }
9051 w.put_len_varint((*self).progress_mapping.len())?;
9052 for v1107 in (*self).progress_mapping.iter() {
9053 w.put_string(&(*v1107).key)?;
9054 w.put_len_varint((*v1107).value.len())?;
9055 for v1108 in (*v1107).value.iter() {
9056 w.put_string(&(*v1108).criterion_identifier)?;
9057 match &(*v1108).criterion_progress {
9058 Some(v1109) => {
9059 w.put_u8(1);
9060 w.put_i64((*v1109));
9061 }
9062 None => w.put_u8(0),
9063 }
9064 }
9065 }
9066 Ok(())
9067 }
9068}
9069#[cfg(feature = "testgen")]
9070impl Generate for Advancements {
9071 fn generate(g: &mut Gen) -> Self {
9072 {
9073 let v1110 = g.bool();
9074 let v1111 = {
9075 let v1112 = g.count();
9076 let mut v1113 = Vec::with_capacity(v1112.min(crate::codec::PREALLOC_LIMIT));
9077 for _ in 0..v1112 {
9078 v1113.push({
9079 let v1114 = g.string();
9080 let v1115 = {
9081 let v1116 = if g.bool() { Some(g.string()) } else { None };
9082 let v1117 = if g.bool() {
9083 Some({
9084 let v1118 = g.string();
9085 let v1119 = g.string();
9086 let v1120 = <types::Slot as Generate>::generate(g);
9087 let v1121 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
9088 let v1122 = {
9089 AdvancementsAdvancementMappingValueDisplayDataFlags {
9090 _unused: (g.int_in(0, 536870911, &[]) as u32),
9091 hidden: (g.int_in(0, 1, &[]) as u8),
9092 show_toast: (g.int_in(0, 1, &[]) as u8),
9093 has_background_texture: (g.int_in(0, 1, &[1]) as u8),
9094 }
9095 };
9096 let v1124 = if (v1122.has_background_texture == 1) {
9097 Some(g.string())
9098 } else {
9099 None
9100 };
9101 let v1125 = g.f32();
9102 let v1126 = g.f32();
9103 AdvancementsAdvancementMappingValueDisplayData {
9104 title: v1118,
9105 description: v1119,
9106 icon: v1120,
9107 frame_type: v1121,
9108 flags: v1122,
9109 background_texture: v1124,
9110 x_cord: v1125,
9111 y_cord: v1126,
9112 }
9113 })
9114 } else {
9115 None
9116 };
9117 let v1127 = {
9118 let v1128 = g.count();
9119 let mut v1129 =
9120 Vec::with_capacity(v1128.min(crate::codec::PREALLOC_LIMIT));
9121 for _ in 0..v1128 {
9122 v1129.push({
9123 let v1130 = g.string();
9124 AdvancementsAdvancementMappingValueCriteria { key: v1130 }
9125 });
9126 }
9127 v1129
9128 };
9129 let v1132 = {
9130 let v1133 = g.count();
9131 let mut v1134 =
9132 Vec::with_capacity(v1133.min(crate::codec::PREALLOC_LIMIT));
9133 for _ in 0..v1133 {
9134 v1134.push({
9135 let v1135 = g.count();
9136 let mut v1136 = Vec::with_capacity(
9137 v1135.min(crate::codec::PREALLOC_LIMIT),
9138 );
9139 for _ in 0..v1135 {
9140 v1136.push(g.string());
9141 }
9142 v1136
9143 });
9144 }
9145 v1134
9146 };
9147 AdvancementsAdvancementMappingValue {
9148 parent_id: v1116,
9149 display_data: v1117,
9150 criteria: v1127,
9151 requirements: v1132,
9152 }
9153 };
9154 AdvancementsAdvancementMapping {
9155 key: v1114,
9156 value: v1115,
9157 }
9158 });
9159 }
9160 v1113
9161 };
9162 let v1137 = {
9163 let v1138 = g.count();
9164 let mut v1139 = Vec::with_capacity(v1138.min(crate::codec::PREALLOC_LIMIT));
9165 for _ in 0..v1138 {
9166 v1139.push(g.string());
9167 }
9168 v1139
9169 };
9170 let v1140 = {
9171 let v1141 = g.count();
9172 let mut v1142 = Vec::with_capacity(v1141.min(crate::codec::PREALLOC_LIMIT));
9173 for _ in 0..v1141 {
9174 v1142.push({
9175 let v1143 = g.string();
9176 let v1144 = {
9177 let v1145 = g.count();
9178 let mut v1146 =
9179 Vec::with_capacity(v1145.min(crate::codec::PREALLOC_LIMIT));
9180 for _ in 0..v1145 {
9181 v1146.push({
9182 let v1147 = g.string();
9183 let v1148 = if g.bool() { Some(g.i64()) } else { None };
9184 AdvancementsProgressMappingValue {
9185 criterion_identifier: v1147,
9186 criterion_progress: v1148,
9187 }
9188 });
9189 }
9190 v1146
9191 };
9192 AdvancementsProgressMapping {
9193 key: v1143,
9194 value: v1144,
9195 }
9196 });
9197 }
9198 v1142
9199 };
9200 Advancements {
9201 reset: v1110,
9202 advancement_mapping: v1111,
9203 identifiers: v1137,
9204 progress_mapping: v1140,
9205 }
9206 }
9207 }
9208}
9209impl From<Advancements> for ClientboundPlayPacket {
9210 fn from(p: Advancements) -> Self {
9211 Self::Advancements(p)
9212 }
9213}
9214
9215#[derive(Debug, Clone, PartialEq)]
9217pub struct EntityUpdateAttributes {
9218 pub entity_id: i32,
9220 pub properties: Vec<EntityUpdateAttributesProperties>,
9222}
9223impl crate::packet::Packet for EntityUpdateAttributes {
9224 const ID: i32 = id::ENTITY_UPDATE_ATTRIBUTES;
9225 const NAME: &'static str = "entity_update_attributes";
9226 const STATE: State = State::Play;
9227 const DIRECTION: Direction = Direction::Clientbound;
9228}
9229impl Decode for EntityUpdateAttributes {
9230 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
9231 Ok({
9232 let v1149 = r.read_varint()?;
9233 let v1150 = {
9234 let v1151 = {
9235 let c = r.read_i32()?;
9236 r.check_count(i64::from(c), 10)?
9237 };
9238 let mut v1152 = Vec::with_capacity(v1151.min(crate::codec::PREALLOC_LIMIT));
9239 for _ in 0..v1151 {
9240 v1152.push({
9241 let v1153 = r.read_string()?;
9242 let v1154 = r.read_f64()?;
9243 let v1155 = {
9244 let v1156 = {
9245 let c = r.read_varint()?;
9246 r.check_count(i64::from(c), 25)?
9247 };
9248 let mut v1157 =
9249 Vec::with_capacity(v1156.min(crate::codec::PREALLOC_LIMIT));
9250 for _ in 0..v1156 {
9251 v1157.push({
9252 let v1158 = r.read_uuid()?;
9253 let v1159 = r.read_f64()?;
9254 let v1160 = r.read_i8()?;
9255 EntityUpdateAttributesPropertiesModifiers {
9256 uuid: v1158,
9257 amount: v1159,
9258 operation: v1160,
9259 }
9260 });
9261 }
9262 v1157
9263 };
9264 EntityUpdateAttributesProperties {
9265 key: v1153,
9266 value: v1154,
9267 modifiers: v1155,
9268 }
9269 });
9270 }
9271 v1152
9272 };
9273 EntityUpdateAttributes {
9274 entity_id: v1149,
9275 properties: v1150,
9276 }
9277 })
9278 }
9279}
9280impl Encode for EntityUpdateAttributes {
9281 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
9282 w.put_varint((*self).entity_id);
9283 w.put_i32(crate::codec::count_i32((*self).properties.len())?);
9284 for v1161 in (*self).properties.iter() {
9285 w.put_string(&(*v1161).key)?;
9286 w.put_f64((*v1161).value);
9287 w.put_len_varint((*v1161).modifiers.len())?;
9288 for v1162 in (*v1161).modifiers.iter() {
9289 w.put_uuid(&(*v1162).uuid);
9290 w.put_f64((*v1162).amount);
9291 w.put_i8((*v1162).operation);
9292 }
9293 }
9294 Ok(())
9295 }
9296}
9297#[cfg(feature = "testgen")]
9298impl Generate for EntityUpdateAttributes {
9299 fn generate(g: &mut Gen) -> Self {
9300 {
9301 let v1163 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
9302 let v1164 = {
9303 let v1165 = g.count();
9304 let mut v1166 = Vec::with_capacity(v1165.min(crate::codec::PREALLOC_LIMIT));
9305 for _ in 0..v1165 {
9306 v1166.push({
9307 let v1167 = g.string();
9308 let v1168 = g.f64();
9309 let v1169 = {
9310 let v1170 = g.count();
9311 let mut v1171 =
9312 Vec::with_capacity(v1170.min(crate::codec::PREALLOC_LIMIT));
9313 for _ in 0..v1170 {
9314 v1171.push({
9315 let v1172 = g.uuid();
9316 let v1173 = g.f64();
9317 let v1174 = (g.int_in(-128, 127, &[]) as i8);
9318 EntityUpdateAttributesPropertiesModifiers {
9319 uuid: v1172,
9320 amount: v1173,
9321 operation: v1174,
9322 }
9323 });
9324 }
9325 v1171
9326 };
9327 EntityUpdateAttributesProperties {
9328 key: v1167,
9329 value: v1168,
9330 modifiers: v1169,
9331 }
9332 });
9333 }
9334 v1166
9335 };
9336 EntityUpdateAttributes {
9337 entity_id: v1163,
9338 properties: v1164,
9339 }
9340 }
9341 }
9342}
9343impl From<EntityUpdateAttributes> for ClientboundPlayPacket {
9344 fn from(p: EntityUpdateAttributes) -> Self {
9345 Self::EntityUpdateAttributes(p)
9346 }
9347}
9348
9349#[derive(Debug, Clone, PartialEq)]
9351pub struct EntityEffect {
9352 pub entity_id: i32,
9354 pub effect_id: i8,
9356 pub amplifier: i8,
9358 pub duration: i32,
9360 pub hide_particles: i8,
9362}
9363impl crate::packet::Packet for EntityEffect {
9364 const ID: i32 = id::ENTITY_EFFECT;
9365 const NAME: &'static str = "entity_effect";
9366 const STATE: State = State::Play;
9367 const DIRECTION: Direction = Direction::Clientbound;
9368}
9369impl Decode for EntityEffect {
9370 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
9371 Ok({
9372 let v1175 = r.read_varint()?;
9373 let v1176 = r.read_i8()?;
9374 let v1177 = r.read_i8()?;
9375 let v1178 = r.read_varint()?;
9376 let v1179 = r.read_i8()?;
9377 EntityEffect {
9378 entity_id: v1175,
9379 effect_id: v1176,
9380 amplifier: v1177,
9381 duration: v1178,
9382 hide_particles: v1179,
9383 }
9384 })
9385 }
9386}
9387impl Encode for EntityEffect {
9388 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
9389 w.put_varint((*self).entity_id);
9390 w.put_i8((*self).effect_id);
9391 w.put_i8((*self).amplifier);
9392 w.put_varint((*self).duration);
9393 w.put_i8((*self).hide_particles);
9394 Ok(())
9395 }
9396}
9397#[cfg(feature = "testgen")]
9398impl Generate for EntityEffect {
9399 fn generate(g: &mut Gen) -> Self {
9400 {
9401 let v1180 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
9402 let v1181 = (g.int_in(-128, 127, &[]) as i8);
9403 let v1182 = (g.int_in(-128, 127, &[]) as i8);
9404 let v1183 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
9405 let v1184 = (g.int_in(-128, 127, &[]) as i8);
9406 EntityEffect {
9407 entity_id: v1180,
9408 effect_id: v1181,
9409 amplifier: v1182,
9410 duration: v1183,
9411 hide_particles: v1184,
9412 }
9413 }
9414 }
9415}
9416impl From<EntityEffect> for ClientboundPlayPacket {
9417 fn from(p: EntityEffect) -> Self {
9418 Self::EntityEffect(p)
9419 }
9420}
9421
9422#[derive(Debug, Clone, PartialEq)]
9424pub struct DeclareRecipes {
9425 pub recipes: Vec<DeclareRecipesRecipes>,
9427}
9428impl crate::packet::Packet for DeclareRecipes {
9429 const ID: i32 = id::DECLARE_RECIPES;
9430 const NAME: &'static str = "declare_recipes";
9431 const STATE: State = State::Play;
9432 const DIRECTION: Direction = Direction::Clientbound;
9433}
9434impl Decode for DeclareRecipes {
9435 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
9436 Ok({
9437 let v1185 = {
9438 let v1186 = {
9439 let c = r.read_varint()?;
9440 r.check_count(i64::from(c), 2)?
9441 };
9442 let mut v1187 = Vec::with_capacity(v1186.min(crate::codec::PREALLOC_LIMIT));
9443 for _ in 0..v1186 {
9444 v1187.push({
9445 let v1188 = r.read_string()?;
9446 let v1189 = r.read_string()?;
9447 let v1190 = (if (&*v1188 == "minecraft:crafting_shapeless") {
9448 DeclareRecipesRecipesData::CraftingShapeless({
9449 let v1191 = r.read_string()?;
9450 let v1192 = {
9451 let v1193 = {
9452 let c = r.read_varint()?;
9453 r.check_count(i64::from(c), 1)?
9454 };
9455 let mut v1194 =
9456 Vec::with_capacity(v1193.min(crate::codec::PREALLOC_LIMIT));
9457 for _ in 0..v1193 {
9458 v1194.push({
9459 let v1195 = {
9460 let c = r.read_varint()?;
9461 r.check_count(i64::from(c), 1)?
9462 };
9463 let mut v1196 = Vec::with_capacity(
9464 v1195.min(crate::codec::PREALLOC_LIMIT),
9465 );
9466 for _ in 0..v1195 {
9467 v1196.push(<types::Slot as Decode>::decode(r)?);
9468 }
9469 v1196
9470 });
9471 }
9472 v1194
9473 };
9474 let v1197 = <types::Slot as Decode>::decode(r)?;
9475 DeclareRecipesRecipesDataCraftingShapeless {
9476 group: v1191,
9477 ingredients: v1192,
9478 result: v1197,
9479 }
9480 })
9481 } else if (&*v1188 == "minecraft:crafting_shaped") {
9482 DeclareRecipesRecipesData::CraftingShaped({
9483 let v1198 = r.read_varint()?;
9484 let v1199 = r.read_varint()?;
9485 let v1200 = r.read_string()?;
9486 let v1201 = {
9487 let v1202 = r.check_count(i64::from(v1199), 0)?;
9488 let mut v1203 =
9489 Vec::with_capacity(v1202.min(crate::codec::PREALLOC_LIMIT));
9490 for _ in 0..v1202 {
9491 v1203.push({
9492 let v1204 = r.check_count(i64::from(v1198), 1)?;
9493 let mut v1205 = Vec::with_capacity(
9494 v1204.min(crate::codec::PREALLOC_LIMIT),
9495 );
9496 for _ in 0..v1204 {
9497 v1205.push({
9498 let v1206 = {
9499 let c = r.read_varint()?;
9500 r.check_count(i64::from(c), 1)?
9501 };
9502 let mut v1207 = Vec::with_capacity(
9503 v1206.min(crate::codec::PREALLOC_LIMIT),
9504 );
9505 for _ in 0..v1206 {
9506 v1207.push(
9507 <types::Slot as Decode>::decode(r)?,
9508 );
9509 }
9510 v1207
9511 });
9512 }
9513 v1205
9514 });
9515 }
9516 v1203
9517 };
9518 let v1208 = <types::Slot as Decode>::decode(r)?;
9519 DeclareRecipesRecipesDataCraftingShaped {
9520 width: v1198,
9521 height: v1199,
9522 group: v1200,
9523 ingredients: v1201,
9524 result: v1208,
9525 }
9526 })
9527 } else if (&*v1188 == "minecraft:crafting_special_armordye") {
9528 DeclareRecipesRecipesData::CraftingSpecialArmordye
9529 } else if (&*v1188 == "minecraft:crafting_special_bookcloning") {
9530 DeclareRecipesRecipesData::CraftingSpecialBookcloning
9531 } else if (&*v1188 == "minecraft:crafting_special_mapcloning") {
9532 DeclareRecipesRecipesData::CraftingSpecialMapcloning
9533 } else if (&*v1188 == "minecraft:crafting_special_mapextending") {
9534 DeclareRecipesRecipesData::CraftingSpecialMapextending
9535 } else if (&*v1188 == "minecraft:crafting_special_firework_rocket") {
9536 DeclareRecipesRecipesData::CraftingSpecialFireworkRocket
9537 } else if (&*v1188 == "minecraft:crafting_special_firework_star") {
9538 DeclareRecipesRecipesData::CraftingSpecialFireworkStar
9539 } else if (&*v1188 == "minecraft:crafting_special_firework_star_fade") {
9540 DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade
9541 } else if (&*v1188 == "minecraft:crafting_special_repairitem") {
9542 DeclareRecipesRecipesData::CraftingSpecialRepairitem
9543 } else if (&*v1188 == "minecraft:crafting_special_tippedarrow") {
9544 DeclareRecipesRecipesData::CraftingSpecialTippedarrow
9545 } else if (&*v1188 == "minecraft:crafting_special_bannerduplicate") {
9546 DeclareRecipesRecipesData::CraftingSpecialBannerduplicate
9547 } else if (&*v1188 == "minecraft:crafting_special_banneraddpattern") {
9548 DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern
9549 } else if (&*v1188 == "minecraft:crafting_special_shielddecoration") {
9550 DeclareRecipesRecipesData::CraftingSpecialShielddecoration
9551 } else if (&*v1188 == "minecraft:crafting_special_shulkerboxcoloring") {
9552 DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring
9553 } else if (&*v1188 == "minecraft:crafting_special_suspiciousstew") {
9554 DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew
9555 } else if (&*v1188 == "minecraft:smelting") {
9556 DeclareRecipesRecipesData::Smelting(
9557 <types::MinecraftSmeltingFormat as Decode>::decode(r)?,
9558 )
9559 } else if (&*v1188 == "minecraft:blasting") {
9560 DeclareRecipesRecipesData::Blasting(
9561 <types::MinecraftSmeltingFormat as Decode>::decode(r)?,
9562 )
9563 } else if (&*v1188 == "minecraft:smoking") {
9564 DeclareRecipesRecipesData::Smoking(
9565 <types::MinecraftSmeltingFormat as Decode>::decode(r)?,
9566 )
9567 } else if (&*v1188 == "minecraft:campfire_cooking") {
9568 DeclareRecipesRecipesData::CampfireCooking(
9569 <types::MinecraftSmeltingFormat as Decode>::decode(r)?,
9570 )
9571 } else if (&*v1188 == "minecraft:stonecutting") {
9572 DeclareRecipesRecipesData::Stonecutting({
9573 let v1209 = r.read_string()?;
9574 let v1210 = {
9575 let v1211 = {
9576 let c = r.read_varint()?;
9577 r.check_count(i64::from(c), 1)?
9578 };
9579 let mut v1212 =
9580 Vec::with_capacity(v1211.min(crate::codec::PREALLOC_LIMIT));
9581 for _ in 0..v1211 {
9582 v1212.push(<types::Slot as Decode>::decode(r)?);
9583 }
9584 v1212
9585 };
9586 let v1213 = <types::Slot as Decode>::decode(r)?;
9587 DeclareRecipesRecipesDataStonecutting {
9588 group: v1209,
9589 ingredient: v1210,
9590 result: v1213,
9591 }
9592 })
9593 } else if (&*v1188 == "minecraft:smithing") {
9594 DeclareRecipesRecipesData::Smithing({
9595 let v1214 = {
9596 let v1215 = {
9597 let c = r.read_varint()?;
9598 r.check_count(i64::from(c), 1)?
9599 };
9600 let mut v1216 =
9601 Vec::with_capacity(v1215.min(crate::codec::PREALLOC_LIMIT));
9602 for _ in 0..v1215 {
9603 v1216.push(<types::Slot as Decode>::decode(r)?);
9604 }
9605 v1216
9606 };
9607 let v1217 = {
9608 let v1218 = {
9609 let c = r.read_varint()?;
9610 r.check_count(i64::from(c), 1)?
9611 };
9612 let mut v1219 =
9613 Vec::with_capacity(v1218.min(crate::codec::PREALLOC_LIMIT));
9614 for _ in 0..v1218 {
9615 v1219.push(<types::Slot as Decode>::decode(r)?);
9616 }
9617 v1219
9618 };
9619 let v1220 = <types::Slot as Decode>::decode(r)?;
9620 DeclareRecipesRecipesDataSmithing {
9621 base: v1214,
9622 addition: v1217,
9623 result: v1220,
9624 }
9625 })
9626 } else {
9627 DeclareRecipesRecipesData::Other
9628 });
9629 DeclareRecipesRecipes {
9630 r#type: v1188,
9631 recipe_id: v1189,
9632 data: v1190,
9633 }
9634 });
9635 }
9636 v1187
9637 };
9638 DeclareRecipes { recipes: v1185 }
9639 })
9640 }
9641}
9642impl Encode for DeclareRecipes {
9643 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
9644 w.put_len_varint((*self).recipes.len())?;
9645 for v1221 in (*self).recipes.iter() {
9646 w.put_string(&(*v1221).r#type)?;
9647 w.put_string(&(*v1221).recipe_id)?;
9648 match &(*v1221).data {
9649 DeclareRecipesRecipesData::CraftingShapeless(v1222) => {
9650 if !(&*(*v1221).r#type == "minecraft:crafting_shapeless") {
9651 return Err(EncodeError::SwitchMismatch(
9652 "play.clientbound.declare_recipes.recipes.data",
9653 ));
9654 }
9655 w.put_string(&(*v1222).group)?;
9656 w.put_len_varint((*v1222).ingredients.len())?;
9657 for v1223 in (*v1222).ingredients.iter() {
9658 w.put_len_varint((*v1223).len())?;
9659 for v1224 in (*v1223).iter() {
9660 (*v1224).encode(w)?;
9661 }
9662 }
9663 (*v1222).result.encode(w)?;
9664 }
9665 DeclareRecipesRecipesData::CraftingShaped(v1225) => {
9666 if !(&*(*v1221).r#type == "minecraft:crafting_shaped") {
9667 return Err(EncodeError::SwitchMismatch(
9668 "play.clientbound.declare_recipes.recipes.data",
9669 ));
9670 }
9671 w.put_varint((*v1225).width);
9672 w.put_varint((*v1225).height);
9673 w.put_string(&(*v1225).group)?;
9674 if usize::try_from((*v1225).height).ok() != Some((*v1225).ingredients.len()) {
9675 return Err(EncodeError::CountMismatch {
9676 field: "play.clientbound.declare_recipes.recipes.data.ingredients",
9677 expected: usize::try_from((*v1225).height).unwrap_or(0),
9678 actual: (*v1225).ingredients.len(),
9679 });
9680 }
9681 for v1226 in (*v1225).ingredients.iter() {
9682 if usize::try_from((*v1225).width).ok() != Some((*v1226).len()) {
9683 return Err(EncodeError::CountMismatch {
9684 field: "play.clientbound.declare_recipes.recipes.data.ingredients",
9685 expected: usize::try_from((*v1225).width).unwrap_or(0),
9686 actual: (*v1226).len(),
9687 });
9688 }
9689 for v1227 in (*v1226).iter() {
9690 w.put_len_varint((*v1227).len())?;
9691 for v1228 in (*v1227).iter() {
9692 (*v1228).encode(w)?;
9693 }
9694 }
9695 }
9696 (*v1225).result.encode(w)?;
9697 }
9698 DeclareRecipesRecipesData::CraftingSpecialArmordye => {
9699 if !(&*(*v1221).r#type == "minecraft:crafting_special_armordye") {
9700 return Err(EncodeError::SwitchMismatch(
9701 "play.clientbound.declare_recipes.recipes.data",
9702 ));
9703 }
9704 }
9705 DeclareRecipesRecipesData::CraftingSpecialBookcloning => {
9706 if !(&*(*v1221).r#type == "minecraft:crafting_special_bookcloning") {
9707 return Err(EncodeError::SwitchMismatch(
9708 "play.clientbound.declare_recipes.recipes.data",
9709 ));
9710 }
9711 }
9712 DeclareRecipesRecipesData::CraftingSpecialMapcloning => {
9713 if !(&*(*v1221).r#type == "minecraft:crafting_special_mapcloning") {
9714 return Err(EncodeError::SwitchMismatch(
9715 "play.clientbound.declare_recipes.recipes.data",
9716 ));
9717 }
9718 }
9719 DeclareRecipesRecipesData::CraftingSpecialMapextending => {
9720 if !(&*(*v1221).r#type == "minecraft:crafting_special_mapextending") {
9721 return Err(EncodeError::SwitchMismatch(
9722 "play.clientbound.declare_recipes.recipes.data",
9723 ));
9724 }
9725 }
9726 DeclareRecipesRecipesData::CraftingSpecialFireworkRocket => {
9727 if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_rocket") {
9728 return Err(EncodeError::SwitchMismatch(
9729 "play.clientbound.declare_recipes.recipes.data",
9730 ));
9731 }
9732 }
9733 DeclareRecipesRecipesData::CraftingSpecialFireworkStar => {
9734 if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_star") {
9735 return Err(EncodeError::SwitchMismatch(
9736 "play.clientbound.declare_recipes.recipes.data",
9737 ));
9738 }
9739 }
9740 DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade => {
9741 if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_star_fade") {
9742 return Err(EncodeError::SwitchMismatch(
9743 "play.clientbound.declare_recipes.recipes.data",
9744 ));
9745 }
9746 }
9747 DeclareRecipesRecipesData::CraftingSpecialRepairitem => {
9748 if !(&*(*v1221).r#type == "minecraft:crafting_special_repairitem") {
9749 return Err(EncodeError::SwitchMismatch(
9750 "play.clientbound.declare_recipes.recipes.data",
9751 ));
9752 }
9753 }
9754 DeclareRecipesRecipesData::CraftingSpecialTippedarrow => {
9755 if !(&*(*v1221).r#type == "minecraft:crafting_special_tippedarrow") {
9756 return Err(EncodeError::SwitchMismatch(
9757 "play.clientbound.declare_recipes.recipes.data",
9758 ));
9759 }
9760 }
9761 DeclareRecipesRecipesData::CraftingSpecialBannerduplicate => {
9762 if !(&*(*v1221).r#type == "minecraft:crafting_special_bannerduplicate") {
9763 return Err(EncodeError::SwitchMismatch(
9764 "play.clientbound.declare_recipes.recipes.data",
9765 ));
9766 }
9767 }
9768 DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern => {
9769 if !(&*(*v1221).r#type == "minecraft:crafting_special_banneraddpattern") {
9770 return Err(EncodeError::SwitchMismatch(
9771 "play.clientbound.declare_recipes.recipes.data",
9772 ));
9773 }
9774 }
9775 DeclareRecipesRecipesData::CraftingSpecialShielddecoration => {
9776 if !(&*(*v1221).r#type == "minecraft:crafting_special_shielddecoration") {
9777 return Err(EncodeError::SwitchMismatch(
9778 "play.clientbound.declare_recipes.recipes.data",
9779 ));
9780 }
9781 }
9782 DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring => {
9783 if !(&*(*v1221).r#type == "minecraft:crafting_special_shulkerboxcoloring") {
9784 return Err(EncodeError::SwitchMismatch(
9785 "play.clientbound.declare_recipes.recipes.data",
9786 ));
9787 }
9788 }
9789 DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew => {
9790 if !(&*(*v1221).r#type == "minecraft:crafting_special_suspiciousstew") {
9791 return Err(EncodeError::SwitchMismatch(
9792 "play.clientbound.declare_recipes.recipes.data",
9793 ));
9794 }
9795 }
9796 DeclareRecipesRecipesData::Smelting(v1229) => {
9797 if !(&*(*v1221).r#type == "minecraft:smelting") {
9798 return Err(EncodeError::SwitchMismatch(
9799 "play.clientbound.declare_recipes.recipes.data",
9800 ));
9801 }
9802 (*v1229).encode(w)?;
9803 }
9804 DeclareRecipesRecipesData::Blasting(v1230) => {
9805 if !(&*(*v1221).r#type == "minecraft:blasting") {
9806 return Err(EncodeError::SwitchMismatch(
9807 "play.clientbound.declare_recipes.recipes.data",
9808 ));
9809 }
9810 (*v1230).encode(w)?;
9811 }
9812 DeclareRecipesRecipesData::Smoking(v1231) => {
9813 if !(&*(*v1221).r#type == "minecraft:smoking") {
9814 return Err(EncodeError::SwitchMismatch(
9815 "play.clientbound.declare_recipes.recipes.data",
9816 ));
9817 }
9818 (*v1231).encode(w)?;
9819 }
9820 DeclareRecipesRecipesData::CampfireCooking(v1232) => {
9821 if !(&*(*v1221).r#type == "minecraft:campfire_cooking") {
9822 return Err(EncodeError::SwitchMismatch(
9823 "play.clientbound.declare_recipes.recipes.data",
9824 ));
9825 }
9826 (*v1232).encode(w)?;
9827 }
9828 DeclareRecipesRecipesData::Stonecutting(v1233) => {
9829 if !(&*(*v1221).r#type == "minecraft:stonecutting") {
9830 return Err(EncodeError::SwitchMismatch(
9831 "play.clientbound.declare_recipes.recipes.data",
9832 ));
9833 }
9834 w.put_string(&(*v1233).group)?;
9835 w.put_len_varint((*v1233).ingredient.len())?;
9836 for v1234 in (*v1233).ingredient.iter() {
9837 (*v1234).encode(w)?;
9838 }
9839 (*v1233).result.encode(w)?;
9840 }
9841 DeclareRecipesRecipesData::Smithing(v1235) => {
9842 if !(&*(*v1221).r#type == "minecraft:smithing") {
9843 return Err(EncodeError::SwitchMismatch(
9844 "play.clientbound.declare_recipes.recipes.data",
9845 ));
9846 }
9847 w.put_len_varint((*v1235).base.len())?;
9848 for v1236 in (*v1235).base.iter() {
9849 (*v1236).encode(w)?;
9850 }
9851 w.put_len_varint((*v1235).addition.len())?;
9852 for v1237 in (*v1235).addition.iter() {
9853 (*v1237).encode(w)?;
9854 }
9855 (*v1235).result.encode(w)?;
9856 }
9857 DeclareRecipesRecipesData::Other => {
9858 if !(!((&*(*v1221).r#type == "minecraft:crafting_shapeless")
9859 || (&*(*v1221).r#type == "minecraft:crafting_shaped")
9860 || (&*(*v1221).r#type == "minecraft:crafting_special_armordye")
9861 || (&*(*v1221).r#type == "minecraft:crafting_special_bookcloning")
9862 || (&*(*v1221).r#type == "minecraft:crafting_special_mapcloning")
9863 || (&*(*v1221).r#type == "minecraft:crafting_special_mapextending")
9864 || (&*(*v1221).r#type == "minecraft:crafting_special_firework_rocket")
9865 || (&*(*v1221).r#type == "minecraft:crafting_special_firework_star")
9866 || (&*(*v1221).r#type == "minecraft:crafting_special_firework_star_fade")
9867 || (&*(*v1221).r#type == "minecraft:crafting_special_repairitem")
9868 || (&*(*v1221).r#type == "minecraft:crafting_special_tippedarrow")
9869 || (&*(*v1221).r#type == "minecraft:crafting_special_bannerduplicate")
9870 || (&*(*v1221).r#type == "minecraft:crafting_special_banneraddpattern")
9871 || (&*(*v1221).r#type == "minecraft:crafting_special_shielddecoration")
9872 || (&*(*v1221).r#type == "minecraft:crafting_special_shulkerboxcoloring")
9873 || (&*(*v1221).r#type == "minecraft:crafting_special_suspiciousstew")
9874 || (&*(*v1221).r#type == "minecraft:smelting")
9875 || (&*(*v1221).r#type == "minecraft:blasting")
9876 || (&*(*v1221).r#type == "minecraft:smoking")
9877 || (&*(*v1221).r#type == "minecraft:campfire_cooking")
9878 || (&*(*v1221).r#type == "minecraft:stonecutting")
9879 || (&*(*v1221).r#type == "minecraft:smithing")))
9880 {
9881 return Err(EncodeError::SwitchMismatch(
9882 "play.clientbound.declare_recipes.recipes.data",
9883 ));
9884 }
9885 }
9886 }
9887 }
9888 Ok(())
9889 }
9890}
9891#[cfg(feature = "testgen")]
9892impl Generate for DeclareRecipes {
9893 fn generate(g: &mut Gen) -> Self {
9894 {
9895 let v1238 = {
9896 let v1239 = g.count();
9897 let mut v1240 = Vec::with_capacity(v1239.min(crate::codec::PREALLOC_LIMIT));
9898 for _ in 0..v1239 {
9899 v1240.push({
9900 let v1241 = g.string_in(&[
9901 "minecraft:crafting_shapeless",
9902 "minecraft:crafting_shaped",
9903 "minecraft:crafting_special_armordye",
9904 "minecraft:crafting_special_bookcloning",
9905 "minecraft:crafting_special_mapcloning",
9906 "minecraft:crafting_special_mapextending",
9907 "minecraft:crafting_special_firework_rocket",
9908 "minecraft:crafting_special_firework_star",
9909 "minecraft:crafting_special_firework_star_fade",
9910 "minecraft:crafting_special_repairitem",
9911 "minecraft:crafting_special_tippedarrow",
9912 "minecraft:crafting_special_bannerduplicate",
9913 "minecraft:crafting_special_banneraddpattern",
9914 "minecraft:crafting_special_shielddecoration",
9915 "minecraft:crafting_special_shulkerboxcoloring",
9916 "minecraft:crafting_special_suspiciousstew",
9917 "minecraft:smelting",
9918 "minecraft:blasting",
9919 "minecraft:smoking",
9920 "minecraft:campfire_cooking",
9921 "minecraft:stonecutting",
9922 "minecraft:smithing",
9923 ]);
9924 let v1242 = g.string();
9925 let v1243 = (if (&*v1241 == "minecraft:crafting_shapeless") {
9926 DeclareRecipesRecipesData::CraftingShapeless({
9927 let v1244 = g.string();
9928 let v1245 = {
9929 let v1246 = g.count();
9930 let mut v1247 =
9931 Vec::with_capacity(v1246.min(crate::codec::PREALLOC_LIMIT));
9932 for _ in 0..v1246 {
9933 v1247.push({
9934 let v1248 = g.count();
9935 let mut v1249 = Vec::with_capacity(
9936 v1248.min(crate::codec::PREALLOC_LIMIT),
9937 );
9938 for _ in 0..v1248 {
9939 v1249.push(<types::Slot as Generate>::generate(g));
9940 }
9941 v1249
9942 });
9943 }
9944 v1247
9945 };
9946 let v1250 = <types::Slot as Generate>::generate(g);
9947 DeclareRecipesRecipesDataCraftingShapeless {
9948 group: v1244,
9949 ingredients: v1245,
9950 result: v1250,
9951 }
9952 })
9953 } else if (&*v1241 == "minecraft:crafting_shaped") {
9954 DeclareRecipesRecipesData::CraftingShaped({
9955 let v1251 = (g.small_count() as i32);
9956 let v1252 = (g.small_count() as i32);
9957 let v1253 = g.string();
9958 let v1254 = {
9959 let v1255 = usize::try_from(v1252).unwrap_or(0);
9960 let mut v1256 =
9961 Vec::with_capacity(v1255.min(crate::codec::PREALLOC_LIMIT));
9962 for _ in 0..v1255 {
9963 v1256.push({
9964 let v1257 = usize::try_from(v1251).unwrap_or(0);
9965 let mut v1258 = Vec::with_capacity(
9966 v1257.min(crate::codec::PREALLOC_LIMIT),
9967 );
9968 for _ in 0..v1257 {
9969 v1258.push({
9970 let v1259 = g.count();
9971 let mut v1260 = Vec::with_capacity(
9972 v1259.min(crate::codec::PREALLOC_LIMIT),
9973 );
9974 for _ in 0..v1259 {
9975 v1260.push(
9976 <types::Slot as Generate>::generate(g),
9977 );
9978 }
9979 v1260
9980 });
9981 }
9982 v1258
9983 });
9984 }
9985 v1256
9986 };
9987 let v1261 = <types::Slot as Generate>::generate(g);
9988 DeclareRecipesRecipesDataCraftingShaped {
9989 width: v1251,
9990 height: v1252,
9991 group: v1253,
9992 ingredients: v1254,
9993 result: v1261,
9994 }
9995 })
9996 } else if (&*v1241 == "minecraft:crafting_special_armordye") {
9997 DeclareRecipesRecipesData::CraftingSpecialArmordye
9998 } else if (&*v1241 == "minecraft:crafting_special_bookcloning") {
9999 DeclareRecipesRecipesData::CraftingSpecialBookcloning
10000 } else if (&*v1241 == "minecraft:crafting_special_mapcloning") {
10001 DeclareRecipesRecipesData::CraftingSpecialMapcloning
10002 } else if (&*v1241 == "minecraft:crafting_special_mapextending") {
10003 DeclareRecipesRecipesData::CraftingSpecialMapextending
10004 } else if (&*v1241 == "minecraft:crafting_special_firework_rocket") {
10005 DeclareRecipesRecipesData::CraftingSpecialFireworkRocket
10006 } else if (&*v1241 == "minecraft:crafting_special_firework_star") {
10007 DeclareRecipesRecipesData::CraftingSpecialFireworkStar
10008 } else if (&*v1241 == "minecraft:crafting_special_firework_star_fade") {
10009 DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade
10010 } else if (&*v1241 == "minecraft:crafting_special_repairitem") {
10011 DeclareRecipesRecipesData::CraftingSpecialRepairitem
10012 } else if (&*v1241 == "minecraft:crafting_special_tippedarrow") {
10013 DeclareRecipesRecipesData::CraftingSpecialTippedarrow
10014 } else if (&*v1241 == "minecraft:crafting_special_bannerduplicate") {
10015 DeclareRecipesRecipesData::CraftingSpecialBannerduplicate
10016 } else if (&*v1241 == "minecraft:crafting_special_banneraddpattern") {
10017 DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern
10018 } else if (&*v1241 == "minecraft:crafting_special_shielddecoration") {
10019 DeclareRecipesRecipesData::CraftingSpecialShielddecoration
10020 } else if (&*v1241 == "minecraft:crafting_special_shulkerboxcoloring") {
10021 DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring
10022 } else if (&*v1241 == "minecraft:crafting_special_suspiciousstew") {
10023 DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew
10024 } else if (&*v1241 == "minecraft:smelting") {
10025 DeclareRecipesRecipesData::Smelting(
10026 <types::MinecraftSmeltingFormat as Generate>::generate(g),
10027 )
10028 } else if (&*v1241 == "minecraft:blasting") {
10029 DeclareRecipesRecipesData::Blasting(
10030 <types::MinecraftSmeltingFormat as Generate>::generate(g),
10031 )
10032 } else if (&*v1241 == "minecraft:smoking") {
10033 DeclareRecipesRecipesData::Smoking(
10034 <types::MinecraftSmeltingFormat as Generate>::generate(g),
10035 )
10036 } else if (&*v1241 == "minecraft:campfire_cooking") {
10037 DeclareRecipesRecipesData::CampfireCooking(
10038 <types::MinecraftSmeltingFormat as Generate>::generate(g),
10039 )
10040 } else if (&*v1241 == "minecraft:stonecutting") {
10041 DeclareRecipesRecipesData::Stonecutting({
10042 let v1262 = g.string();
10043 let v1263 = {
10044 let v1264 = g.count();
10045 let mut v1265 =
10046 Vec::with_capacity(v1264.min(crate::codec::PREALLOC_LIMIT));
10047 for _ in 0..v1264 {
10048 v1265.push(<types::Slot as Generate>::generate(g));
10049 }
10050 v1265
10051 };
10052 let v1266 = <types::Slot as Generate>::generate(g);
10053 DeclareRecipesRecipesDataStonecutting {
10054 group: v1262,
10055 ingredient: v1263,
10056 result: v1266,
10057 }
10058 })
10059 } else if (&*v1241 == "minecraft:smithing") {
10060 DeclareRecipesRecipesData::Smithing({
10061 let v1267 = {
10062 let v1268 = g.count();
10063 let mut v1269 =
10064 Vec::with_capacity(v1268.min(crate::codec::PREALLOC_LIMIT));
10065 for _ in 0..v1268 {
10066 v1269.push(<types::Slot as Generate>::generate(g));
10067 }
10068 v1269
10069 };
10070 let v1270 = {
10071 let v1271 = g.count();
10072 let mut v1272 =
10073 Vec::with_capacity(v1271.min(crate::codec::PREALLOC_LIMIT));
10074 for _ in 0..v1271 {
10075 v1272.push(<types::Slot as Generate>::generate(g));
10076 }
10077 v1272
10078 };
10079 let v1273 = <types::Slot as Generate>::generate(g);
10080 DeclareRecipesRecipesDataSmithing {
10081 base: v1267,
10082 addition: v1270,
10083 result: v1273,
10084 }
10085 })
10086 } else {
10087 DeclareRecipesRecipesData::Other
10088 });
10089 DeclareRecipesRecipes {
10090 r#type: v1241,
10091 recipe_id: v1242,
10092 data: v1243,
10093 }
10094 });
10095 }
10096 v1240
10097 };
10098 DeclareRecipes { recipes: v1238 }
10099 }
10100 }
10101}
10102impl From<DeclareRecipes> for ClientboundPlayPacket {
10103 fn from(p: DeclareRecipes) -> Self {
10104 Self::DeclareRecipes(p)
10105 }
10106}
10107
10108#[derive(Debug, Clone, PartialEq)]
10110pub struct Tags {
10111 pub block_tags: Vec<types::Tags>,
10113 pub item_tags: Vec<types::Tags>,
10115 pub fluid_tags: Vec<types::Tags>,
10117 pub entity_tags: Vec<types::Tags>,
10119}
10120impl crate::packet::Packet for Tags {
10121 const ID: i32 = id::TAGS;
10122 const NAME: &'static str = "tags";
10123 const STATE: State = State::Play;
10124 const DIRECTION: Direction = Direction::Clientbound;
10125}
10126impl Decode for Tags {
10127 fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
10128 Ok({
10129 let v1274 = {
10130 let v1275 = {
10131 let c = r.read_varint()?;
10132 r.check_count(i64::from(c), 2)?
10133 };
10134 let mut v1276 = Vec::with_capacity(v1275.min(crate::codec::PREALLOC_LIMIT));
10135 for _ in 0..v1275 {
10136 v1276.push({
10137 let v1277 = r.read_string()?;
10138 let v1278 = {
10139 let v1279 = {
10140 let c = r.read_varint()?;
10141 r.check_count(i64::from(c), 1)?
10142 };
10143 let mut v1280 =
10144 Vec::with_capacity(v1279.min(crate::codec::PREALLOC_LIMIT));
10145 for _ in 0..v1279 {
10146 v1280.push(r.read_varint()?);
10147 }
10148 v1280
10149 };
10150 types::Tags {
10151 tag_name: v1277,
10152 entries: v1278,
10153 }
10154 });
10155 }
10156 v1276
10157 };
10158 let v1281 = {
10159 let v1282 = {
10160 let c = r.read_varint()?;
10161 r.check_count(i64::from(c), 2)?
10162 };
10163 let mut v1283 = Vec::with_capacity(v1282.min(crate::codec::PREALLOC_LIMIT));
10164 for _ in 0..v1282 {
10165 v1283.push({
10166 let v1284 = r.read_string()?;
10167 let v1285 = {
10168 let v1286 = {
10169 let c = r.read_varint()?;
10170 r.check_count(i64::from(c), 1)?
10171 };
10172 let mut v1287 =
10173 Vec::with_capacity(v1286.min(crate::codec::PREALLOC_LIMIT));
10174 for _ in 0..v1286 {
10175 v1287.push(r.read_varint()?);
10176 }
10177 v1287
10178 };
10179 types::Tags {
10180 tag_name: v1284,
10181 entries: v1285,
10182 }
10183 });
10184 }
10185 v1283
10186 };
10187 let v1288 = {
10188 let v1289 = {
10189 let c = r.read_varint()?;
10190 r.check_count(i64::from(c), 2)?
10191 };
10192 let mut v1290 = Vec::with_capacity(v1289.min(crate::codec::PREALLOC_LIMIT));
10193 for _ in 0..v1289 {
10194 v1290.push({
10195 let v1291 = r.read_string()?;
10196 let v1292 = {
10197 let v1293 = {
10198 let c = r.read_varint()?;
10199 r.check_count(i64::from(c), 1)?
10200 };
10201 let mut v1294 =
10202 Vec::with_capacity(v1293.min(crate::codec::PREALLOC_LIMIT));
10203 for _ in 0..v1293 {
10204 v1294.push(r.read_varint()?);
10205 }
10206 v1294
10207 };
10208 types::Tags {
10209 tag_name: v1291,
10210 entries: v1292,
10211 }
10212 });
10213 }
10214 v1290
10215 };
10216 let v1295 = {
10217 let v1296 = {
10218 let c = r.read_varint()?;
10219 r.check_count(i64::from(c), 2)?
10220 };
10221 let mut v1297 = Vec::with_capacity(v1296.min(crate::codec::PREALLOC_LIMIT));
10222 for _ in 0..v1296 {
10223 v1297.push({
10224 let v1298 = r.read_string()?;
10225 let v1299 = {
10226 let v1300 = {
10227 let c = r.read_varint()?;
10228 r.check_count(i64::from(c), 1)?
10229 };
10230 let mut v1301 =
10231 Vec::with_capacity(v1300.min(crate::codec::PREALLOC_LIMIT));
10232 for _ in 0..v1300 {
10233 v1301.push(r.read_varint()?);
10234 }
10235 v1301
10236 };
10237 types::Tags {
10238 tag_name: v1298,
10239 entries: v1299,
10240 }
10241 });
10242 }
10243 v1297
10244 };
10245 Tags {
10246 block_tags: v1274,
10247 item_tags: v1281,
10248 fluid_tags: v1288,
10249 entity_tags: v1295,
10250 }
10251 })
10252 }
10253}
10254impl Encode for Tags {
10255 fn encode(&self, w: &mut BytesMut) -> EncodeResult {
10256 w.put_len_varint((*self).block_tags.len())?;
10257 for v1302 in (*self).block_tags.iter() {
10258 w.put_string(&(*v1302).tag_name)?;
10259 w.put_len_varint((*v1302).entries.len())?;
10260 for v1303 in (*v1302).entries.iter() {
10261 w.put_varint((*v1303));
10262 }
10263 }
10264 w.put_len_varint((*self).item_tags.len())?;
10265 for v1304 in (*self).item_tags.iter() {
10266 w.put_string(&(*v1304).tag_name)?;
10267 w.put_len_varint((*v1304).entries.len())?;
10268 for v1305 in (*v1304).entries.iter() {
10269 w.put_varint((*v1305));
10270 }
10271 }
10272 w.put_len_varint((*self).fluid_tags.len())?;
10273 for v1306 in (*self).fluid_tags.iter() {
10274 w.put_string(&(*v1306).tag_name)?;
10275 w.put_len_varint((*v1306).entries.len())?;
10276 for v1307 in (*v1306).entries.iter() {
10277 w.put_varint((*v1307));
10278 }
10279 }
10280 w.put_len_varint((*self).entity_tags.len())?;
10281 for v1308 in (*self).entity_tags.iter() {
10282 w.put_string(&(*v1308).tag_name)?;
10283 w.put_len_varint((*v1308).entries.len())?;
10284 for v1309 in (*v1308).entries.iter() {
10285 w.put_varint((*v1309));
10286 }
10287 }
10288 Ok(())
10289 }
10290}
10291#[cfg(feature = "testgen")]
10292impl Generate for Tags {
10293 fn generate(g: &mut Gen) -> Self {
10294 {
10295 let v1310 = {
10296 let v1311 = g.count();
10297 let mut v1312 = Vec::with_capacity(v1311.min(crate::codec::PREALLOC_LIMIT));
10298 for _ in 0..v1311 {
10299 v1312.push({
10300 let v1313 = g.string();
10301 let v1314 = {
10302 let v1315 = g.count();
10303 let mut v1316 =
10304 Vec::with_capacity(v1315.min(crate::codec::PREALLOC_LIMIT));
10305 for _ in 0..v1315 {
10306 v1316.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
10307 }
10308 v1316
10309 };
10310 types::Tags {
10311 tag_name: v1313,
10312 entries: v1314,
10313 }
10314 });
10315 }
10316 v1312
10317 };
10318 let v1317 = {
10319 let v1318 = g.count();
10320 let mut v1319 = Vec::with_capacity(v1318.min(crate::codec::PREALLOC_LIMIT));
10321 for _ in 0..v1318 {
10322 v1319.push({
10323 let v1320 = g.string();
10324 let v1321 = {
10325 let v1322 = g.count();
10326 let mut v1323 =
10327 Vec::with_capacity(v1322.min(crate::codec::PREALLOC_LIMIT));
10328 for _ in 0..v1322 {
10329 v1323.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
10330 }
10331 v1323
10332 };
10333 types::Tags {
10334 tag_name: v1320,
10335 entries: v1321,
10336 }
10337 });
10338 }
10339 v1319
10340 };
10341 let v1324 = {
10342 let v1325 = g.count();
10343 let mut v1326 = Vec::with_capacity(v1325.min(crate::codec::PREALLOC_LIMIT));
10344 for _ in 0..v1325 {
10345 v1326.push({
10346 let v1327 = g.string();
10347 let v1328 = {
10348 let v1329 = g.count();
10349 let mut v1330 =
10350 Vec::with_capacity(v1329.min(crate::codec::PREALLOC_LIMIT));
10351 for _ in 0..v1329 {
10352 v1330.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
10353 }
10354 v1330
10355 };
10356 types::Tags {
10357 tag_name: v1327,
10358 entries: v1328,
10359 }
10360 });
10361 }
10362 v1326
10363 };
10364 let v1331 = {
10365 let v1332 = g.count();
10366 let mut v1333 = Vec::with_capacity(v1332.min(crate::codec::PREALLOC_LIMIT));
10367 for _ in 0..v1332 {
10368 v1333.push({
10369 let v1334 = g.string();
10370 let v1335 = {
10371 let v1336 = g.count();
10372 let mut v1337 =
10373 Vec::with_capacity(v1336.min(crate::codec::PREALLOC_LIMIT));
10374 for _ in 0..v1336 {
10375 v1337.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
10376 }
10377 v1337
10378 };
10379 types::Tags {
10380 tag_name: v1334,
10381 entries: v1335,
10382 }
10383 });
10384 }
10385 v1333
10386 };
10387 Tags {
10388 block_tags: v1310,
10389 item_tags: v1317,
10390 fluid_tags: v1324,
10391 entity_tags: v1331,
10392 }
10393 }
10394 }
10395}
10396impl From<Tags> for ClientboundPlayPacket {
10397 fn from(p: Tags) -> Self {
10398 Self::Tags(p)
10399 }
10400}
10401
10402#[derive(Debug, Clone, PartialEq)]
10404pub enum ClientboundPlayPacket {
10405 SpawnEntity(SpawnEntity),
10407 SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
10409 SpawnEntityLiving(SpawnEntityLiving),
10411 SpawnEntityPainting(SpawnEntityPainting),
10413 NamedEntitySpawn(NamedEntitySpawn),
10415 Animation(Animation),
10417 Statistics(Statistics),
10419 AcknowledgePlayerDigging(AcknowledgePlayerDigging),
10421 BlockBreakAnimation(BlockBreakAnimation),
10423 TileEntityData(TileEntityData),
10425 BlockAction(BlockAction),
10427 BlockChange(BlockChange),
10429 BossBar(BossBar),
10431 Difficulty(Difficulty),
10433 Chat(Chat),
10435 TabComplete(TabComplete),
10437 DeclareCommands(DeclareCommands),
10439 Transaction(Transaction),
10441 CloseWindow(CloseWindow),
10443 WindowItems(WindowItems),
10445 CraftProgressBar(CraftProgressBar),
10447 SetSlot(SetSlot),
10449 SetCooldown(SetCooldown),
10451 CustomPayload(CustomPayload),
10453 NamedSoundEffect(NamedSoundEffect),
10455 KickDisconnect(KickDisconnect),
10457 EntityStatus(EntityStatus),
10459 Explosion(Explosion),
10461 UnloadChunk(UnloadChunk),
10463 GameStateChange(GameStateChange),
10465 OpenHorseWindow(OpenHorseWindow),
10467 KeepAlive(KeepAlive),
10469 MapChunk(MapChunk),
10471 WorldEvent(WorldEvent),
10473 WorldParticles(WorldParticles),
10475 UpdateLight(UpdateLight),
10477 Login(Login),
10479 Map(Map),
10481 TradeList(TradeList),
10483 RelEntityMove(RelEntityMove),
10485 EntityMoveLook(EntityMoveLook),
10487 EntityLook(EntityLook),
10489 Entity(Entity),
10491 VehicleMove(VehicleMove),
10493 OpenBook(OpenBook),
10495 OpenWindow(OpenWindow),
10497 OpenSignEntity(OpenSignEntity),
10499 CraftRecipeResponse(CraftRecipeResponse),
10501 Abilities(Abilities),
10503 CombatEvent(CombatEvent),
10505 PlayerInfo(PlayerInfo),
10507 FacePlayer(FacePlayer),
10509 Position(Position),
10511 UnlockRecipes(UnlockRecipes),
10513 EntityDestroy(EntityDestroy),
10515 RemoveEntityEffect(RemoveEntityEffect),
10517 ResourcePackSend(ResourcePackSend),
10519 Respawn(Respawn),
10521 EntityHeadRotation(EntityHeadRotation),
10523 MultiBlockChange(MultiBlockChange),
10525 SelectAdvancementTab(SelectAdvancementTab),
10527 WorldBorder(WorldBorder),
10529 Camera(Camera),
10531 HeldItemSlot(HeldItemSlot),
10533 UpdateViewPosition(UpdateViewPosition),
10535 UpdateViewDistance(UpdateViewDistance),
10537 SpawnPosition(SpawnPosition),
10539 ScoreboardDisplayObjective(ScoreboardDisplayObjective),
10541 EntityMetadata(EntityMetadata),
10543 AttachEntity(AttachEntity),
10545 EntityVelocity(EntityVelocity),
10547 EntityEquipment(EntityEquipment),
10549 Experience(Experience),
10551 UpdateHealth(UpdateHealth),
10553 ScoreboardObjective(ScoreboardObjective),
10555 SetPassengers(SetPassengers),
10557 Teams(Teams),
10559 ScoreboardScore(ScoreboardScore),
10561 UpdateTime(UpdateTime),
10563 Title(Title),
10565 EntitySoundEffect(EntitySoundEffect),
10567 SoundEffect(SoundEffect),
10569 StopSound(StopSound),
10571 PlayerlistHeader(PlayerlistHeader),
10573 NbtQueryResponse(NbtQueryResponse),
10575 Collect(Collect),
10577 EntityTeleport(EntityTeleport),
10579 Advancements(Advancements),
10581 EntityUpdateAttributes(EntityUpdateAttributes),
10583 EntityEffect(EntityEffect),
10585 DeclareRecipes(DeclareRecipes),
10587 Tags(Tags),
10589}
10590
10591impl PacketSet for ClientboundPlayPacket {
10592 const STATE: State = State::Play;
10593 const DIRECTION: Direction = Direction::Clientbound;
10594 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
10595 match raw.id {
10596 id::SPAWN_ENTITY => decode_exact(&raw.body).map(Self::SpawnEntity),
10597 id::SPAWN_ENTITY_EXPERIENCE_ORB => {
10598 decode_exact(&raw.body).map(Self::SpawnEntityExperienceOrb)
10599 }
10600 id::SPAWN_ENTITY_LIVING => decode_exact(&raw.body).map(Self::SpawnEntityLiving),
10601 id::SPAWN_ENTITY_PAINTING => decode_exact(&raw.body).map(Self::SpawnEntityPainting),
10602 id::NAMED_ENTITY_SPAWN => decode_exact(&raw.body).map(Self::NamedEntitySpawn),
10603 id::ANIMATION => decode_exact(&raw.body).map(Self::Animation),
10604 id::STATISTICS => decode_exact(&raw.body).map(Self::Statistics),
10605 id::ACKNOWLEDGE_PLAYER_DIGGING => {
10606 decode_exact(&raw.body).map(Self::AcknowledgePlayerDigging)
10607 }
10608 id::BLOCK_BREAK_ANIMATION => decode_exact(&raw.body).map(Self::BlockBreakAnimation),
10609 id::TILE_ENTITY_DATA => decode_exact(&raw.body).map(Self::TileEntityData),
10610 id::BLOCK_ACTION => decode_exact(&raw.body).map(Self::BlockAction),
10611 id::BLOCK_CHANGE => decode_exact(&raw.body).map(Self::BlockChange),
10612 id::BOSS_BAR => decode_exact(&raw.body).map(Self::BossBar),
10613 id::DIFFICULTY => decode_exact(&raw.body).map(Self::Difficulty),
10614 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
10615 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
10616 id::DECLARE_COMMANDS => decode_exact(&raw.body).map(Self::DeclareCommands),
10617 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
10618 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
10619 id::WINDOW_ITEMS => decode_exact(&raw.body).map(Self::WindowItems),
10620 id::CRAFT_PROGRESS_BAR => decode_exact(&raw.body).map(Self::CraftProgressBar),
10621 id::SET_SLOT => decode_exact(&raw.body).map(Self::SetSlot),
10622 id::SET_COOLDOWN => decode_exact(&raw.body).map(Self::SetCooldown),
10623 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
10624 id::NAMED_SOUND_EFFECT => decode_exact(&raw.body).map(Self::NamedSoundEffect),
10625 id::KICK_DISCONNECT => decode_exact(&raw.body).map(Self::KickDisconnect),
10626 id::ENTITY_STATUS => decode_exact(&raw.body).map(Self::EntityStatus),
10627 id::EXPLOSION => decode_exact(&raw.body).map(Self::Explosion),
10628 id::UNLOAD_CHUNK => decode_exact(&raw.body).map(Self::UnloadChunk),
10629 id::GAME_STATE_CHANGE => decode_exact(&raw.body).map(Self::GameStateChange),
10630 id::OPEN_HORSE_WINDOW => decode_exact(&raw.body).map(Self::OpenHorseWindow),
10631 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
10632 id::MAP_CHUNK => decode_exact(&raw.body).map(Self::MapChunk),
10633 id::WORLD_EVENT => decode_exact(&raw.body).map(Self::WorldEvent),
10634 id::WORLD_PARTICLES => decode_exact(&raw.body).map(Self::WorldParticles),
10635 id::UPDATE_LIGHT => decode_exact(&raw.body).map(Self::UpdateLight),
10636 id::LOGIN => decode_exact(&raw.body).map(Self::Login),
10637 id::MAP => decode_exact(&raw.body).map(Self::Map),
10638 id::TRADE_LIST => decode_exact(&raw.body).map(Self::TradeList),
10639 id::REL_ENTITY_MOVE => decode_exact(&raw.body).map(Self::RelEntityMove),
10640 id::ENTITY_MOVE_LOOK => decode_exact(&raw.body).map(Self::EntityMoveLook),
10641 id::ENTITY_LOOK => decode_exact(&raw.body).map(Self::EntityLook),
10642 id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
10643 id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
10644 id::OPEN_BOOK => decode_exact(&raw.body).map(Self::OpenBook),
10645 id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
10646 id::OPEN_SIGN_ENTITY => decode_exact(&raw.body).map(Self::OpenSignEntity),
10647 id::CRAFT_RECIPE_RESPONSE => decode_exact(&raw.body).map(Self::CraftRecipeResponse),
10648 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
10649 id::COMBAT_EVENT => decode_exact(&raw.body).map(Self::CombatEvent),
10650 id::PLAYER_INFO => decode_exact(&raw.body).map(Self::PlayerInfo),
10651 id::FACE_PLAYER => decode_exact(&raw.body).map(Self::FacePlayer),
10652 id::POSITION => decode_exact(&raw.body).map(Self::Position),
10653 id::UNLOCK_RECIPES => decode_exact(&raw.body).map(Self::UnlockRecipes),
10654 id::ENTITY_DESTROY => decode_exact(&raw.body).map(Self::EntityDestroy),
10655 id::REMOVE_ENTITY_EFFECT => decode_exact(&raw.body).map(Self::RemoveEntityEffect),
10656 id::RESOURCE_PACK_SEND => decode_exact(&raw.body).map(Self::ResourcePackSend),
10657 id::RESPAWN => decode_exact(&raw.body).map(Self::Respawn),
10658 id::ENTITY_HEAD_ROTATION => decode_exact(&raw.body).map(Self::EntityHeadRotation),
10659 id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
10660 id::SELECT_ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::SelectAdvancementTab),
10661 id::WORLD_BORDER => decode_exact(&raw.body).map(Self::WorldBorder),
10662 id::CAMERA => decode_exact(&raw.body).map(Self::Camera),
10663 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
10664 id::UPDATE_VIEW_POSITION => decode_exact(&raw.body).map(Self::UpdateViewPosition),
10665 id::UPDATE_VIEW_DISTANCE => decode_exact(&raw.body).map(Self::UpdateViewDistance),
10666 id::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
10667 id::SCOREBOARD_DISPLAY_OBJECTIVE => {
10668 decode_exact(&raw.body).map(Self::ScoreboardDisplayObjective)
10669 }
10670 id::ENTITY_METADATA => decode_exact(&raw.body).map(Self::EntityMetadata),
10671 id::ATTACH_ENTITY => decode_exact(&raw.body).map(Self::AttachEntity),
10672 id::ENTITY_VELOCITY => decode_exact(&raw.body).map(Self::EntityVelocity),
10673 id::ENTITY_EQUIPMENT => decode_exact(&raw.body).map(Self::EntityEquipment),
10674 id::EXPERIENCE => decode_exact(&raw.body).map(Self::Experience),
10675 id::UPDATE_HEALTH => decode_exact(&raw.body).map(Self::UpdateHealth),
10676 id::SCOREBOARD_OBJECTIVE => decode_exact(&raw.body).map(Self::ScoreboardObjective),
10677 id::SET_PASSENGERS => decode_exact(&raw.body).map(Self::SetPassengers),
10678 id::TEAMS => decode_exact(&raw.body).map(Self::Teams),
10679 id::SCOREBOARD_SCORE => decode_exact(&raw.body).map(Self::ScoreboardScore),
10680 id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
10681 id::TITLE => decode_exact(&raw.body).map(Self::Title),
10682 id::ENTITY_SOUND_EFFECT => decode_exact(&raw.body).map(Self::EntitySoundEffect),
10683 id::SOUND_EFFECT => decode_exact(&raw.body).map(Self::SoundEffect),
10684 id::STOP_SOUND => decode_exact(&raw.body).map(Self::StopSound),
10685 id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
10686 id::NBT_QUERY_RESPONSE => decode_exact(&raw.body).map(Self::NbtQueryResponse),
10687 id::COLLECT => decode_exact(&raw.body).map(Self::Collect),
10688 id::ENTITY_TELEPORT => decode_exact(&raw.body).map(Self::EntityTeleport),
10689 id::ADVANCEMENTS => decode_exact(&raw.body).map(Self::Advancements),
10690 id::ENTITY_UPDATE_ATTRIBUTES => {
10691 decode_exact(&raw.body).map(Self::EntityUpdateAttributes)
10692 }
10693 id::ENTITY_EFFECT => decode_exact(&raw.body).map(Self::EntityEffect),
10694 id::DECLARE_RECIPES => decode_exact(&raw.body).map(Self::DeclareRecipes),
10695 id::TAGS => decode_exact(&raw.body).map(Self::Tags),
10696 other => Err(DecodeError::UnknownPacketId(other)),
10697 }
10698 }
10699 fn id(&self) -> i32 {
10700 match *self {
10701 Self::SpawnEntity(_) => id::SPAWN_ENTITY,
10702 Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
10703 Self::SpawnEntityLiving(_) => id::SPAWN_ENTITY_LIVING,
10704 Self::SpawnEntityPainting(_) => id::SPAWN_ENTITY_PAINTING,
10705 Self::NamedEntitySpawn(_) => id::NAMED_ENTITY_SPAWN,
10706 Self::Animation(_) => id::ANIMATION,
10707 Self::Statistics(_) => id::STATISTICS,
10708 Self::AcknowledgePlayerDigging(_) => id::ACKNOWLEDGE_PLAYER_DIGGING,
10709 Self::BlockBreakAnimation(_) => id::BLOCK_BREAK_ANIMATION,
10710 Self::TileEntityData(_) => id::TILE_ENTITY_DATA,
10711 Self::BlockAction(_) => id::BLOCK_ACTION,
10712 Self::BlockChange(_) => id::BLOCK_CHANGE,
10713 Self::BossBar(_) => id::BOSS_BAR,
10714 Self::Difficulty(_) => id::DIFFICULTY,
10715 Self::Chat(_) => id::CHAT,
10716 Self::TabComplete(_) => id::TAB_COMPLETE,
10717 Self::DeclareCommands(_) => id::DECLARE_COMMANDS,
10718 Self::Transaction(_) => id::TRANSACTION,
10719 Self::CloseWindow(_) => id::CLOSE_WINDOW,
10720 Self::WindowItems(_) => id::WINDOW_ITEMS,
10721 Self::CraftProgressBar(_) => id::CRAFT_PROGRESS_BAR,
10722 Self::SetSlot(_) => id::SET_SLOT,
10723 Self::SetCooldown(_) => id::SET_COOLDOWN,
10724 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
10725 Self::NamedSoundEffect(_) => id::NAMED_SOUND_EFFECT,
10726 Self::KickDisconnect(_) => id::KICK_DISCONNECT,
10727 Self::EntityStatus(_) => id::ENTITY_STATUS,
10728 Self::Explosion(_) => id::EXPLOSION,
10729 Self::UnloadChunk(_) => id::UNLOAD_CHUNK,
10730 Self::GameStateChange(_) => id::GAME_STATE_CHANGE,
10731 Self::OpenHorseWindow(_) => id::OPEN_HORSE_WINDOW,
10732 Self::KeepAlive(_) => id::KEEP_ALIVE,
10733 Self::MapChunk(_) => id::MAP_CHUNK,
10734 Self::WorldEvent(_) => id::WORLD_EVENT,
10735 Self::WorldParticles(_) => id::WORLD_PARTICLES,
10736 Self::UpdateLight(_) => id::UPDATE_LIGHT,
10737 Self::Login(_) => id::LOGIN,
10738 Self::Map(_) => id::MAP,
10739 Self::TradeList(_) => id::TRADE_LIST,
10740 Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
10741 Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
10742 Self::EntityLook(_) => id::ENTITY_LOOK,
10743 Self::Entity(_) => id::ENTITY,
10744 Self::VehicleMove(_) => id::VEHICLE_MOVE,
10745 Self::OpenBook(_) => id::OPEN_BOOK,
10746 Self::OpenWindow(_) => id::OPEN_WINDOW,
10747 Self::OpenSignEntity(_) => id::OPEN_SIGN_ENTITY,
10748 Self::CraftRecipeResponse(_) => id::CRAFT_RECIPE_RESPONSE,
10749 Self::Abilities(_) => id::ABILITIES,
10750 Self::CombatEvent(_) => id::COMBAT_EVENT,
10751 Self::PlayerInfo(_) => id::PLAYER_INFO,
10752 Self::FacePlayer(_) => id::FACE_PLAYER,
10753 Self::Position(_) => id::POSITION,
10754 Self::UnlockRecipes(_) => id::UNLOCK_RECIPES,
10755 Self::EntityDestroy(_) => id::ENTITY_DESTROY,
10756 Self::RemoveEntityEffect(_) => id::REMOVE_ENTITY_EFFECT,
10757 Self::ResourcePackSend(_) => id::RESOURCE_PACK_SEND,
10758 Self::Respawn(_) => id::RESPAWN,
10759 Self::EntityHeadRotation(_) => id::ENTITY_HEAD_ROTATION,
10760 Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
10761 Self::SelectAdvancementTab(_) => id::SELECT_ADVANCEMENT_TAB,
10762 Self::WorldBorder(_) => id::WORLD_BORDER,
10763 Self::Camera(_) => id::CAMERA,
10764 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
10765 Self::UpdateViewPosition(_) => id::UPDATE_VIEW_POSITION,
10766 Self::UpdateViewDistance(_) => id::UPDATE_VIEW_DISTANCE,
10767 Self::SpawnPosition(_) => id::SPAWN_POSITION,
10768 Self::ScoreboardDisplayObjective(_) => id::SCOREBOARD_DISPLAY_OBJECTIVE,
10769 Self::EntityMetadata(_) => id::ENTITY_METADATA,
10770 Self::AttachEntity(_) => id::ATTACH_ENTITY,
10771 Self::EntityVelocity(_) => id::ENTITY_VELOCITY,
10772 Self::EntityEquipment(_) => id::ENTITY_EQUIPMENT,
10773 Self::Experience(_) => id::EXPERIENCE,
10774 Self::UpdateHealth(_) => id::UPDATE_HEALTH,
10775 Self::ScoreboardObjective(_) => id::SCOREBOARD_OBJECTIVE,
10776 Self::SetPassengers(_) => id::SET_PASSENGERS,
10777 Self::Teams(_) => id::TEAMS,
10778 Self::ScoreboardScore(_) => id::SCOREBOARD_SCORE,
10779 Self::UpdateTime(_) => id::UPDATE_TIME,
10780 Self::Title(_) => id::TITLE,
10781 Self::EntitySoundEffect(_) => id::ENTITY_SOUND_EFFECT,
10782 Self::SoundEffect(_) => id::SOUND_EFFECT,
10783 Self::StopSound(_) => id::STOP_SOUND,
10784 Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
10785 Self::NbtQueryResponse(_) => id::NBT_QUERY_RESPONSE,
10786 Self::Collect(_) => id::COLLECT,
10787 Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
10788 Self::Advancements(_) => id::ADVANCEMENTS,
10789 Self::EntityUpdateAttributes(_) => id::ENTITY_UPDATE_ATTRIBUTES,
10790 Self::EntityEffect(_) => id::ENTITY_EFFECT,
10791 Self::DeclareRecipes(_) => id::DECLARE_RECIPES,
10792 Self::Tags(_) => id::TAGS,
10793 }
10794 }
10795 fn name(&self) -> &'static str {
10796 match *self {
10797 Self::SpawnEntity(_) => "spawn_entity",
10798 Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
10799 Self::SpawnEntityLiving(_) => "spawn_entity_living",
10800 Self::SpawnEntityPainting(_) => "spawn_entity_painting",
10801 Self::NamedEntitySpawn(_) => "named_entity_spawn",
10802 Self::Animation(_) => "animation",
10803 Self::Statistics(_) => "statistics",
10804 Self::AcknowledgePlayerDigging(_) => "acknowledge_player_digging",
10805 Self::BlockBreakAnimation(_) => "block_break_animation",
10806 Self::TileEntityData(_) => "tile_entity_data",
10807 Self::BlockAction(_) => "block_action",
10808 Self::BlockChange(_) => "block_change",
10809 Self::BossBar(_) => "boss_bar",
10810 Self::Difficulty(_) => "difficulty",
10811 Self::Chat(_) => "chat",
10812 Self::TabComplete(_) => "tab_complete",
10813 Self::DeclareCommands(_) => "declare_commands",
10814 Self::Transaction(_) => "transaction",
10815 Self::CloseWindow(_) => "close_window",
10816 Self::WindowItems(_) => "window_items",
10817 Self::CraftProgressBar(_) => "craft_progress_bar",
10818 Self::SetSlot(_) => "set_slot",
10819 Self::SetCooldown(_) => "set_cooldown",
10820 Self::CustomPayload(_) => "custom_payload",
10821 Self::NamedSoundEffect(_) => "named_sound_effect",
10822 Self::KickDisconnect(_) => "kick_disconnect",
10823 Self::EntityStatus(_) => "entity_status",
10824 Self::Explosion(_) => "explosion",
10825 Self::UnloadChunk(_) => "unload_chunk",
10826 Self::GameStateChange(_) => "game_state_change",
10827 Self::OpenHorseWindow(_) => "open_horse_window",
10828 Self::KeepAlive(_) => "keep_alive",
10829 Self::MapChunk(_) => "map_chunk",
10830 Self::WorldEvent(_) => "world_event",
10831 Self::WorldParticles(_) => "world_particles",
10832 Self::UpdateLight(_) => "update_light",
10833 Self::Login(_) => "login",
10834 Self::Map(_) => "map",
10835 Self::TradeList(_) => "trade_list",
10836 Self::RelEntityMove(_) => "rel_entity_move",
10837 Self::EntityMoveLook(_) => "entity_move_look",
10838 Self::EntityLook(_) => "entity_look",
10839 Self::Entity(_) => "entity",
10840 Self::VehicleMove(_) => "vehicle_move",
10841 Self::OpenBook(_) => "open_book",
10842 Self::OpenWindow(_) => "open_window",
10843 Self::OpenSignEntity(_) => "open_sign_entity",
10844 Self::CraftRecipeResponse(_) => "craft_recipe_response",
10845 Self::Abilities(_) => "abilities",
10846 Self::CombatEvent(_) => "combat_event",
10847 Self::PlayerInfo(_) => "player_info",
10848 Self::FacePlayer(_) => "face_player",
10849 Self::Position(_) => "position",
10850 Self::UnlockRecipes(_) => "unlock_recipes",
10851 Self::EntityDestroy(_) => "entity_destroy",
10852 Self::RemoveEntityEffect(_) => "remove_entity_effect",
10853 Self::ResourcePackSend(_) => "resource_pack_send",
10854 Self::Respawn(_) => "respawn",
10855 Self::EntityHeadRotation(_) => "entity_head_rotation",
10856 Self::MultiBlockChange(_) => "multi_block_change",
10857 Self::SelectAdvancementTab(_) => "select_advancement_tab",
10858 Self::WorldBorder(_) => "world_border",
10859 Self::Camera(_) => "camera",
10860 Self::HeldItemSlot(_) => "held_item_slot",
10861 Self::UpdateViewPosition(_) => "update_view_position",
10862 Self::UpdateViewDistance(_) => "update_view_distance",
10863 Self::SpawnPosition(_) => "spawn_position",
10864 Self::ScoreboardDisplayObjective(_) => "scoreboard_display_objective",
10865 Self::EntityMetadata(_) => "entity_metadata",
10866 Self::AttachEntity(_) => "attach_entity",
10867 Self::EntityVelocity(_) => "entity_velocity",
10868 Self::EntityEquipment(_) => "entity_equipment",
10869 Self::Experience(_) => "experience",
10870 Self::UpdateHealth(_) => "update_health",
10871 Self::ScoreboardObjective(_) => "scoreboard_objective",
10872 Self::SetPassengers(_) => "set_passengers",
10873 Self::Teams(_) => "teams",
10874 Self::ScoreboardScore(_) => "scoreboard_score",
10875 Self::UpdateTime(_) => "update_time",
10876 Self::Title(_) => "title",
10877 Self::EntitySoundEffect(_) => "entity_sound_effect",
10878 Self::SoundEffect(_) => "sound_effect",
10879 Self::StopSound(_) => "stop_sound",
10880 Self::PlayerlistHeader(_) => "playerlist_header",
10881 Self::NbtQueryResponse(_) => "nbt_query_response",
10882 Self::Collect(_) => "collect",
10883 Self::EntityTeleport(_) => "entity_teleport",
10884 Self::Advancements(_) => "advancements",
10885 Self::EntityUpdateAttributes(_) => "entity_update_attributes",
10886 Self::EntityEffect(_) => "entity_effect",
10887 Self::DeclareRecipes(_) => "declare_recipes",
10888 Self::Tags(_) => "tags",
10889 }
10890 }
10891 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
10892 match *self {
10893 Self::SpawnEntity(ref p) => p.encode(w),
10894 Self::SpawnEntityExperienceOrb(ref p) => p.encode(w),
10895 Self::SpawnEntityLiving(ref p) => p.encode(w),
10896 Self::SpawnEntityPainting(ref p) => p.encode(w),
10897 Self::NamedEntitySpawn(ref p) => p.encode(w),
10898 Self::Animation(ref p) => p.encode(w),
10899 Self::Statistics(ref p) => p.encode(w),
10900 Self::AcknowledgePlayerDigging(ref p) => p.encode(w),
10901 Self::BlockBreakAnimation(ref p) => p.encode(w),
10902 Self::TileEntityData(ref p) => p.encode(w),
10903 Self::BlockAction(ref p) => p.encode(w),
10904 Self::BlockChange(ref p) => p.encode(w),
10905 Self::BossBar(ref p) => p.encode(w),
10906 Self::Difficulty(ref p) => p.encode(w),
10907 Self::Chat(ref p) => p.encode(w),
10908 Self::TabComplete(ref p) => p.encode(w),
10909 Self::DeclareCommands(ref p) => p.encode(w),
10910 Self::Transaction(ref p) => p.encode(w),
10911 Self::CloseWindow(ref p) => p.encode(w),
10912 Self::WindowItems(ref p) => p.encode(w),
10913 Self::CraftProgressBar(ref p) => p.encode(w),
10914 Self::SetSlot(ref p) => p.encode(w),
10915 Self::SetCooldown(ref p) => p.encode(w),
10916 Self::CustomPayload(ref p) => p.encode(w),
10917 Self::NamedSoundEffect(ref p) => p.encode(w),
10918 Self::KickDisconnect(ref p) => p.encode(w),
10919 Self::EntityStatus(ref p) => p.encode(w),
10920 Self::Explosion(ref p) => p.encode(w),
10921 Self::UnloadChunk(ref p) => p.encode(w),
10922 Self::GameStateChange(ref p) => p.encode(w),
10923 Self::OpenHorseWindow(ref p) => p.encode(w),
10924 Self::KeepAlive(ref p) => p.encode(w),
10925 Self::MapChunk(ref p) => p.encode(w),
10926 Self::WorldEvent(ref p) => p.encode(w),
10927 Self::WorldParticles(ref p) => p.encode(w),
10928 Self::UpdateLight(ref p) => p.encode(w),
10929 Self::Login(ref p) => p.encode(w),
10930 Self::Map(ref p) => p.encode(w),
10931 Self::TradeList(ref p) => p.encode(w),
10932 Self::RelEntityMove(ref p) => p.encode(w),
10933 Self::EntityMoveLook(ref p) => p.encode(w),
10934 Self::EntityLook(ref p) => p.encode(w),
10935 Self::Entity(ref p) => p.encode(w),
10936 Self::VehicleMove(ref p) => p.encode(w),
10937 Self::OpenBook(ref p) => p.encode(w),
10938 Self::OpenWindow(ref p) => p.encode(w),
10939 Self::OpenSignEntity(ref p) => p.encode(w),
10940 Self::CraftRecipeResponse(ref p) => p.encode(w),
10941 Self::Abilities(ref p) => p.encode(w),
10942 Self::CombatEvent(ref p) => p.encode(w),
10943 Self::PlayerInfo(ref p) => p.encode(w),
10944 Self::FacePlayer(ref p) => p.encode(w),
10945 Self::Position(ref p) => p.encode(w),
10946 Self::UnlockRecipes(ref p) => p.encode(w),
10947 Self::EntityDestroy(ref p) => p.encode(w),
10948 Self::RemoveEntityEffect(ref p) => p.encode(w),
10949 Self::ResourcePackSend(ref p) => p.encode(w),
10950 Self::Respawn(ref p) => p.encode(w),
10951 Self::EntityHeadRotation(ref p) => p.encode(w),
10952 Self::MultiBlockChange(ref p) => p.encode(w),
10953 Self::SelectAdvancementTab(ref p) => p.encode(w),
10954 Self::WorldBorder(ref p) => p.encode(w),
10955 Self::Camera(ref p) => p.encode(w),
10956 Self::HeldItemSlot(ref p) => p.encode(w),
10957 Self::UpdateViewPosition(ref p) => p.encode(w),
10958 Self::UpdateViewDistance(ref p) => p.encode(w),
10959 Self::SpawnPosition(ref p) => p.encode(w),
10960 Self::ScoreboardDisplayObjective(ref p) => p.encode(w),
10961 Self::EntityMetadata(ref p) => p.encode(w),
10962 Self::AttachEntity(ref p) => p.encode(w),
10963 Self::EntityVelocity(ref p) => p.encode(w),
10964 Self::EntityEquipment(ref p) => p.encode(w),
10965 Self::Experience(ref p) => p.encode(w),
10966 Self::UpdateHealth(ref p) => p.encode(w),
10967 Self::ScoreboardObjective(ref p) => p.encode(w),
10968 Self::SetPassengers(ref p) => p.encode(w),
10969 Self::Teams(ref p) => p.encode(w),
10970 Self::ScoreboardScore(ref p) => p.encode(w),
10971 Self::UpdateTime(ref p) => p.encode(w),
10972 Self::Title(ref p) => p.encode(w),
10973 Self::EntitySoundEffect(ref p) => p.encode(w),
10974 Self::SoundEffect(ref p) => p.encode(w),
10975 Self::StopSound(ref p) => p.encode(w),
10976 Self::PlayerlistHeader(ref p) => p.encode(w),
10977 Self::NbtQueryResponse(ref p) => p.encode(w),
10978 Self::Collect(ref p) => p.encode(w),
10979 Self::EntityTeleport(ref p) => p.encode(w),
10980 Self::Advancements(ref p) => p.encode(w),
10981 Self::EntityUpdateAttributes(ref p) => p.encode(w),
10982 Self::EntityEffect(ref p) => p.encode(w),
10983 Self::DeclareRecipes(ref p) => p.encode(w),
10984 Self::Tags(ref p) => p.encode(w),
10985 }
10986 }
10987 fn name_of(id: i32) -> Option<&'static str> {
10988 match id {
10989 id::SPAWN_ENTITY => Some("spawn_entity"),
10990 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some("spawn_entity_experience_orb"),
10991 id::SPAWN_ENTITY_LIVING => Some("spawn_entity_living"),
10992 id::SPAWN_ENTITY_PAINTING => Some("spawn_entity_painting"),
10993 id::NAMED_ENTITY_SPAWN => Some("named_entity_spawn"),
10994 id::ANIMATION => Some("animation"),
10995 id::STATISTICS => Some("statistics"),
10996 id::ACKNOWLEDGE_PLAYER_DIGGING => Some("acknowledge_player_digging"),
10997 id::BLOCK_BREAK_ANIMATION => Some("block_break_animation"),
10998 id::TILE_ENTITY_DATA => Some("tile_entity_data"),
10999 id::BLOCK_ACTION => Some("block_action"),
11000 id::BLOCK_CHANGE => Some("block_change"),
11001 id::BOSS_BAR => Some("boss_bar"),
11002 id::DIFFICULTY => Some("difficulty"),
11003 id::CHAT => Some("chat"),
11004 id::TAB_COMPLETE => Some("tab_complete"),
11005 id::DECLARE_COMMANDS => Some("declare_commands"),
11006 id::TRANSACTION => Some("transaction"),
11007 id::CLOSE_WINDOW => Some("close_window"),
11008 id::WINDOW_ITEMS => Some("window_items"),
11009 id::CRAFT_PROGRESS_BAR => Some("craft_progress_bar"),
11010 id::SET_SLOT => Some("set_slot"),
11011 id::SET_COOLDOWN => Some("set_cooldown"),
11012 id::CUSTOM_PAYLOAD => Some("custom_payload"),
11013 id::NAMED_SOUND_EFFECT => Some("named_sound_effect"),
11014 id::KICK_DISCONNECT => Some("kick_disconnect"),
11015 id::ENTITY_STATUS => Some("entity_status"),
11016 id::EXPLOSION => Some("explosion"),
11017 id::UNLOAD_CHUNK => Some("unload_chunk"),
11018 id::GAME_STATE_CHANGE => Some("game_state_change"),
11019 id::OPEN_HORSE_WINDOW => Some("open_horse_window"),
11020 id::KEEP_ALIVE => Some("keep_alive"),
11021 id::MAP_CHUNK => Some("map_chunk"),
11022 id::WORLD_EVENT => Some("world_event"),
11023 id::WORLD_PARTICLES => Some("world_particles"),
11024 id::UPDATE_LIGHT => Some("update_light"),
11025 id::LOGIN => Some("login"),
11026 id::MAP => Some("map"),
11027 id::TRADE_LIST => Some("trade_list"),
11028 id::REL_ENTITY_MOVE => Some("rel_entity_move"),
11029 id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
11030 id::ENTITY_LOOK => Some("entity_look"),
11031 id::ENTITY => Some("entity"),
11032 id::VEHICLE_MOVE => Some("vehicle_move"),
11033 id::OPEN_BOOK => Some("open_book"),
11034 id::OPEN_WINDOW => Some("open_window"),
11035 id::OPEN_SIGN_ENTITY => Some("open_sign_entity"),
11036 id::CRAFT_RECIPE_RESPONSE => Some("craft_recipe_response"),
11037 id::ABILITIES => Some("abilities"),
11038 id::COMBAT_EVENT => Some("combat_event"),
11039 id::PLAYER_INFO => Some("player_info"),
11040 id::FACE_PLAYER => Some("face_player"),
11041 id::POSITION => Some("position"),
11042 id::UNLOCK_RECIPES => Some("unlock_recipes"),
11043 id::ENTITY_DESTROY => Some("entity_destroy"),
11044 id::REMOVE_ENTITY_EFFECT => Some("remove_entity_effect"),
11045 id::RESOURCE_PACK_SEND => Some("resource_pack_send"),
11046 id::RESPAWN => Some("respawn"),
11047 id::ENTITY_HEAD_ROTATION => Some("entity_head_rotation"),
11048 id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
11049 id::SELECT_ADVANCEMENT_TAB => Some("select_advancement_tab"),
11050 id::WORLD_BORDER => Some("world_border"),
11051 id::CAMERA => Some("camera"),
11052 id::HELD_ITEM_SLOT => Some("held_item_slot"),
11053 id::UPDATE_VIEW_POSITION => Some("update_view_position"),
11054 id::UPDATE_VIEW_DISTANCE => Some("update_view_distance"),
11055 id::SPAWN_POSITION => Some("spawn_position"),
11056 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some("scoreboard_display_objective"),
11057 id::ENTITY_METADATA => Some("entity_metadata"),
11058 id::ATTACH_ENTITY => Some("attach_entity"),
11059 id::ENTITY_VELOCITY => Some("entity_velocity"),
11060 id::ENTITY_EQUIPMENT => Some("entity_equipment"),
11061 id::EXPERIENCE => Some("experience"),
11062 id::UPDATE_HEALTH => Some("update_health"),
11063 id::SCOREBOARD_OBJECTIVE => Some("scoreboard_objective"),
11064 id::SET_PASSENGERS => Some("set_passengers"),
11065 id::TEAMS => Some("teams"),
11066 id::SCOREBOARD_SCORE => Some("scoreboard_score"),
11067 id::UPDATE_TIME => Some("update_time"),
11068 id::TITLE => Some("title"),
11069 id::ENTITY_SOUND_EFFECT => Some("entity_sound_effect"),
11070 id::SOUND_EFFECT => Some("sound_effect"),
11071 id::STOP_SOUND => Some("stop_sound"),
11072 id::PLAYERLIST_HEADER => Some("playerlist_header"),
11073 id::NBT_QUERY_RESPONSE => Some("nbt_query_response"),
11074 id::COLLECT => Some("collect"),
11075 id::ENTITY_TELEPORT => Some("entity_teleport"),
11076 id::ADVANCEMENTS => Some("advancements"),
11077 id::ENTITY_UPDATE_ATTRIBUTES => Some("entity_update_attributes"),
11078 id::ENTITY_EFFECT => Some("entity_effect"),
11079 id::DECLARE_RECIPES => Some("declare_recipes"),
11080 id::TAGS => Some("tags"),
11081 _ => None,
11082 }
11083 }
11084}
11085
11086impl ClientboundPlayPacket {
11087 pub const IDS: &'static [i32] = &[
11089 id::SPAWN_ENTITY,
11090 id::SPAWN_ENTITY_EXPERIENCE_ORB,
11091 id::SPAWN_ENTITY_LIVING,
11092 id::SPAWN_ENTITY_PAINTING,
11093 id::NAMED_ENTITY_SPAWN,
11094 id::ANIMATION,
11095 id::STATISTICS,
11096 id::ACKNOWLEDGE_PLAYER_DIGGING,
11097 id::BLOCK_BREAK_ANIMATION,
11098 id::TILE_ENTITY_DATA,
11099 id::BLOCK_ACTION,
11100 id::BLOCK_CHANGE,
11101 id::BOSS_BAR,
11102 id::DIFFICULTY,
11103 id::CHAT,
11104 id::TAB_COMPLETE,
11105 id::DECLARE_COMMANDS,
11106 id::TRANSACTION,
11107 id::CLOSE_WINDOW,
11108 id::WINDOW_ITEMS,
11109 id::CRAFT_PROGRESS_BAR,
11110 id::SET_SLOT,
11111 id::SET_COOLDOWN,
11112 id::CUSTOM_PAYLOAD,
11113 id::NAMED_SOUND_EFFECT,
11114 id::KICK_DISCONNECT,
11115 id::ENTITY_STATUS,
11116 id::EXPLOSION,
11117 id::UNLOAD_CHUNK,
11118 id::GAME_STATE_CHANGE,
11119 id::OPEN_HORSE_WINDOW,
11120 id::KEEP_ALIVE,
11121 id::MAP_CHUNK,
11122 id::WORLD_EVENT,
11123 id::WORLD_PARTICLES,
11124 id::UPDATE_LIGHT,
11125 id::LOGIN,
11126 id::MAP,
11127 id::TRADE_LIST,
11128 id::REL_ENTITY_MOVE,
11129 id::ENTITY_MOVE_LOOK,
11130 id::ENTITY_LOOK,
11131 id::ENTITY,
11132 id::VEHICLE_MOVE,
11133 id::OPEN_BOOK,
11134 id::OPEN_WINDOW,
11135 id::OPEN_SIGN_ENTITY,
11136 id::CRAFT_RECIPE_RESPONSE,
11137 id::ABILITIES,
11138 id::COMBAT_EVENT,
11139 id::PLAYER_INFO,
11140 id::FACE_PLAYER,
11141 id::POSITION,
11142 id::UNLOCK_RECIPES,
11143 id::ENTITY_DESTROY,
11144 id::REMOVE_ENTITY_EFFECT,
11145 id::RESOURCE_PACK_SEND,
11146 id::RESPAWN,
11147 id::ENTITY_HEAD_ROTATION,
11148 id::MULTI_BLOCK_CHANGE,
11149 id::SELECT_ADVANCEMENT_TAB,
11150 id::WORLD_BORDER,
11151 id::CAMERA,
11152 id::HELD_ITEM_SLOT,
11153 id::UPDATE_VIEW_POSITION,
11154 id::UPDATE_VIEW_DISTANCE,
11155 id::SPAWN_POSITION,
11156 id::SCOREBOARD_DISPLAY_OBJECTIVE,
11157 id::ENTITY_METADATA,
11158 id::ATTACH_ENTITY,
11159 id::ENTITY_VELOCITY,
11160 id::ENTITY_EQUIPMENT,
11161 id::EXPERIENCE,
11162 id::UPDATE_HEALTH,
11163 id::SCOREBOARD_OBJECTIVE,
11164 id::SET_PASSENGERS,
11165 id::TEAMS,
11166 id::SCOREBOARD_SCORE,
11167 id::UPDATE_TIME,
11168 id::TITLE,
11169 id::ENTITY_SOUND_EFFECT,
11170 id::SOUND_EFFECT,
11171 id::STOP_SOUND,
11172 id::PLAYERLIST_HEADER,
11173 id::NBT_QUERY_RESPONSE,
11174 id::COLLECT,
11175 id::ENTITY_TELEPORT,
11176 id::ADVANCEMENTS,
11177 id::ENTITY_UPDATE_ATTRIBUTES,
11178 id::ENTITY_EFFECT,
11179 id::DECLARE_RECIPES,
11180 id::TAGS,
11181 ];
11182 #[cfg(feature = "testgen")]
11184 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
11185 match id {
11186 id::SPAWN_ENTITY => Some(Self::SpawnEntity(<SpawnEntity as Generate>::generate(g))),
11187 id::SPAWN_ENTITY_EXPERIENCE_ORB => Some(Self::SpawnEntityExperienceOrb(
11188 <SpawnEntityExperienceOrb as Generate>::generate(g),
11189 )),
11190 id::SPAWN_ENTITY_LIVING => Some(Self::SpawnEntityLiving(
11191 <SpawnEntityLiving as Generate>::generate(g),
11192 )),
11193 id::SPAWN_ENTITY_PAINTING => Some(Self::SpawnEntityPainting(
11194 <SpawnEntityPainting as Generate>::generate(g),
11195 )),
11196 id::NAMED_ENTITY_SPAWN => Some(Self::NamedEntitySpawn(
11197 <NamedEntitySpawn as Generate>::generate(g),
11198 )),
11199 id::ANIMATION => Some(Self::Animation(<Animation as Generate>::generate(g))),
11200 id::STATISTICS => Some(Self::Statistics(<Statistics as Generate>::generate(g))),
11201 id::ACKNOWLEDGE_PLAYER_DIGGING => Some(Self::AcknowledgePlayerDigging(
11202 <AcknowledgePlayerDigging as Generate>::generate(g),
11203 )),
11204 id::BLOCK_BREAK_ANIMATION => Some(Self::BlockBreakAnimation(
11205 <BlockBreakAnimation as Generate>::generate(g),
11206 )),
11207 id::TILE_ENTITY_DATA => Some(Self::TileEntityData(
11208 <TileEntityData as Generate>::generate(g),
11209 )),
11210 id::BLOCK_ACTION => Some(Self::BlockAction(<BlockAction as Generate>::generate(g))),
11211 id::BLOCK_CHANGE => Some(Self::BlockChange(<BlockChange as Generate>::generate(g))),
11212 id::BOSS_BAR => Some(Self::BossBar(<BossBar as Generate>::generate(g))),
11213 id::DIFFICULTY => Some(Self::Difficulty(<Difficulty as Generate>::generate(g))),
11214 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
11215 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
11216 id::DECLARE_COMMANDS => Some(Self::DeclareCommands(
11217 <DeclareCommands as Generate>::generate(g),
11218 )),
11219 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
11220 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
11221 id::WINDOW_ITEMS => Some(Self::WindowItems(<WindowItems as Generate>::generate(g))),
11222 id::CRAFT_PROGRESS_BAR => Some(Self::CraftProgressBar(
11223 <CraftProgressBar as Generate>::generate(g),
11224 )),
11225 id::SET_SLOT => Some(Self::SetSlot(<SetSlot as Generate>::generate(g))),
11226 id::SET_COOLDOWN => Some(Self::SetCooldown(<SetCooldown as Generate>::generate(g))),
11227 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
11228 g,
11229 ))),
11230 id::NAMED_SOUND_EFFECT => Some(Self::NamedSoundEffect(
11231 <NamedSoundEffect as Generate>::generate(g),
11232 )),
11233 id::KICK_DISCONNECT => Some(Self::KickDisconnect(
11234 <KickDisconnect as Generate>::generate(g),
11235 )),
11236 id::ENTITY_STATUS => Some(Self::EntityStatus(<EntityStatus as Generate>::generate(g))),
11237 id::EXPLOSION => Some(Self::Explosion(<Explosion as Generate>::generate(g))),
11238 id::UNLOAD_CHUNK => Some(Self::UnloadChunk(<UnloadChunk as Generate>::generate(g))),
11239 id::GAME_STATE_CHANGE => Some(Self::GameStateChange(
11240 <GameStateChange as Generate>::generate(g),
11241 )),
11242 id::OPEN_HORSE_WINDOW => Some(Self::OpenHorseWindow(
11243 <OpenHorseWindow as Generate>::generate(g),
11244 )),
11245 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
11246 id::MAP_CHUNK => Some(Self::MapChunk(<MapChunk as Generate>::generate(g))),
11247 id::WORLD_EVENT => Some(Self::WorldEvent(<WorldEvent as Generate>::generate(g))),
11248 id::WORLD_PARTICLES => Some(Self::WorldParticles(
11249 <WorldParticles as Generate>::generate(g),
11250 )),
11251 id::UPDATE_LIGHT => Some(Self::UpdateLight(<UpdateLight as Generate>::generate(g))),
11252 id::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
11253 id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
11254 id::TRADE_LIST => Some(Self::TradeList(<TradeList as Generate>::generate(g))),
11255 id::REL_ENTITY_MOVE => Some(Self::RelEntityMove(
11256 <RelEntityMove as Generate>::generate(g),
11257 )),
11258 id::ENTITY_MOVE_LOOK => Some(Self::EntityMoveLook(
11259 <EntityMoveLook as Generate>::generate(g),
11260 )),
11261 id::ENTITY_LOOK => Some(Self::EntityLook(<EntityLook as Generate>::generate(g))),
11262 id::ENTITY => Some(Self::Entity(<Entity as Generate>::generate(g))),
11263 id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
11264 id::OPEN_BOOK => Some(Self::OpenBook(<OpenBook as Generate>::generate(g))),
11265 id::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow as Generate>::generate(g))),
11266 id::OPEN_SIGN_ENTITY => Some(Self::OpenSignEntity(
11267 <OpenSignEntity as Generate>::generate(g),
11268 )),
11269 id::CRAFT_RECIPE_RESPONSE => Some(Self::CraftRecipeResponse(
11270 <CraftRecipeResponse as Generate>::generate(g),
11271 )),
11272 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
11273 id::COMBAT_EVENT => Some(Self::CombatEvent(<CombatEvent as Generate>::generate(g))),
11274 id::PLAYER_INFO => Some(Self::PlayerInfo(<PlayerInfo as Generate>::generate(g))),
11275 id::FACE_PLAYER => Some(Self::FacePlayer(<FacePlayer as Generate>::generate(g))),
11276 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
11277 id::UNLOCK_RECIPES => Some(Self::UnlockRecipes(<UnlockRecipes as Generate>::generate(
11278 g,
11279 ))),
11280 id::ENTITY_DESTROY => Some(Self::EntityDestroy(<EntityDestroy as Generate>::generate(
11281 g,
11282 ))),
11283 id::REMOVE_ENTITY_EFFECT => Some(Self::RemoveEntityEffect(
11284 <RemoveEntityEffect as Generate>::generate(g),
11285 )),
11286 id::RESOURCE_PACK_SEND => Some(Self::ResourcePackSend(
11287 <ResourcePackSend as Generate>::generate(g),
11288 )),
11289 id::RESPAWN => Some(Self::Respawn(<Respawn as Generate>::generate(g))),
11290 id::ENTITY_HEAD_ROTATION => Some(Self::EntityHeadRotation(
11291 <EntityHeadRotation as Generate>::generate(g),
11292 )),
11293 id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
11294 <MultiBlockChange as Generate>::generate(g),
11295 )),
11296 id::SELECT_ADVANCEMENT_TAB => Some(Self::SelectAdvancementTab(
11297 <SelectAdvancementTab as Generate>::generate(g),
11298 )),
11299 id::WORLD_BORDER => Some(Self::WorldBorder(<WorldBorder as Generate>::generate(g))),
11300 id::CAMERA => Some(Self::Camera(<Camera as Generate>::generate(g))),
11301 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
11302 id::UPDATE_VIEW_POSITION => Some(Self::UpdateViewPosition(
11303 <UpdateViewPosition as Generate>::generate(g),
11304 )),
11305 id::UPDATE_VIEW_DISTANCE => Some(Self::UpdateViewDistance(
11306 <UpdateViewDistance as Generate>::generate(g),
11307 )),
11308 id::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition as Generate>::generate(
11309 g,
11310 ))),
11311 id::SCOREBOARD_DISPLAY_OBJECTIVE => Some(Self::ScoreboardDisplayObjective(
11312 <ScoreboardDisplayObjective as Generate>::generate(g),
11313 )),
11314 id::ENTITY_METADATA => Some(Self::EntityMetadata(
11315 <EntityMetadata as Generate>::generate(g),
11316 )),
11317 id::ATTACH_ENTITY => Some(Self::AttachEntity(<AttachEntity as Generate>::generate(g))),
11318 id::ENTITY_VELOCITY => Some(Self::EntityVelocity(
11319 <EntityVelocity as Generate>::generate(g),
11320 )),
11321 id::ENTITY_EQUIPMENT => Some(Self::EntityEquipment(
11322 <EntityEquipment as Generate>::generate(g),
11323 )),
11324 id::EXPERIENCE => Some(Self::Experience(<Experience as Generate>::generate(g))),
11325 id::UPDATE_HEALTH => Some(Self::UpdateHealth(<UpdateHealth as Generate>::generate(g))),
11326 id::SCOREBOARD_OBJECTIVE => Some(Self::ScoreboardObjective(
11327 <ScoreboardObjective as Generate>::generate(g),
11328 )),
11329 id::SET_PASSENGERS => Some(Self::SetPassengers(<SetPassengers as Generate>::generate(
11330 g,
11331 ))),
11332 id::TEAMS => Some(Self::Teams(<Teams as Generate>::generate(g))),
11333 id::SCOREBOARD_SCORE => Some(Self::ScoreboardScore(
11334 <ScoreboardScore as Generate>::generate(g),
11335 )),
11336 id::UPDATE_TIME => Some(Self::UpdateTime(<UpdateTime as Generate>::generate(g))),
11337 id::TITLE => Some(Self::Title(<Title as Generate>::generate(g))),
11338 id::ENTITY_SOUND_EFFECT => Some(Self::EntitySoundEffect(
11339 <EntitySoundEffect as Generate>::generate(g),
11340 )),
11341 id::SOUND_EFFECT => Some(Self::SoundEffect(<SoundEffect as Generate>::generate(g))),
11342 id::STOP_SOUND => Some(Self::StopSound(<StopSound as Generate>::generate(g))),
11343 id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
11344 <PlayerlistHeader as Generate>::generate(g),
11345 )),
11346 id::NBT_QUERY_RESPONSE => Some(Self::NbtQueryResponse(
11347 <NbtQueryResponse as Generate>::generate(g),
11348 )),
11349 id::COLLECT => Some(Self::Collect(<Collect as Generate>::generate(g))),
11350 id::ENTITY_TELEPORT => Some(Self::EntityTeleport(
11351 <EntityTeleport as Generate>::generate(g),
11352 )),
11353 id::ADVANCEMENTS => Some(Self::Advancements(<Advancements as Generate>::generate(g))),
11354 id::ENTITY_UPDATE_ATTRIBUTES => Some(Self::EntityUpdateAttributes(
11355 <EntityUpdateAttributes as Generate>::generate(g),
11356 )),
11357 id::ENTITY_EFFECT => Some(Self::EntityEffect(<EntityEffect as Generate>::generate(g))),
11358 id::DECLARE_RECIPES => Some(Self::DeclareRecipes(
11359 <DeclareRecipes as Generate>::generate(g),
11360 )),
11361 id::TAGS => Some(Self::Tags(<Tags as Generate>::generate(g))),
11362 _ => None,
11363 }
11364 }
11365}