1#![allow(
9 unused_imports,
10 unused_variables,
11 unused_mut,
12 unused_parens,
13 unused_braces,
14 clippy::all,
15 clippy::pedantic,
16 non_camel_case_types,
17 non_snake_case
18)]
19use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
20use crate::error::{DecodeError, EncodeError};
21use crate::nbt::{AnonNbt, RawNbt};
22use crate::packet::{Direction, PacketSet, RawPacket, State};
23#[cfg(feature = "testgen")]
24use crate::testgen::{Gen, Generate};
25use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
26use bytes::{BufMut, Bytes, BytesMut};
27
28pub mod id {
30 pub const KEEP_ALIVE: i32 = 0x00;
32 pub const CHAT: i32 = 0x01;
34 pub const USE_ENTITY: i32 = 0x02;
36 pub const FLYING: i32 = 0x03;
38 pub const POSITION: i32 = 0x04;
40 pub const LOOK: i32 = 0x05;
42 pub const POSITION_LOOK: i32 = 0x06;
44 pub const BLOCK_DIG: i32 = 0x07;
46 pub const BLOCK_PLACE: i32 = 0x08;
48 pub const HELD_ITEM_SLOT: i32 = 0x09;
50 pub const ARM_ANIMATION: i32 = 0x0a;
52 pub const ENTITY_ACTION: i32 = 0x0b;
54 pub const STEER_VEHICLE: i32 = 0x0c;
56 pub const CLOSE_WINDOW: i32 = 0x0d;
58 pub const WINDOW_CLICK: i32 = 0x0e;
60 pub const TRANSACTION: i32 = 0x0f;
62 pub const SET_CREATIVE_SLOT: i32 = 0x10;
64 pub const ENCHANT_ITEM: i32 = 0x11;
66 pub const UPDATE_SIGN: i32 = 0x12;
68 pub const ABILITIES: i32 = 0x13;
70 pub const TAB_COMPLETE: i32 = 0x14;
72 pub const SETTINGS: i32 = 0x15;
74 pub const CLIENT_COMMAND: i32 = 0x16;
76 pub const CUSTOM_PAYLOAD: i32 = 0x17;
78 pub const SPECTATE: i32 = 0x18;
80 pub const RESOURCE_PACK_RECEIVE: i32 = 0x19;
82}
83
84pub use crate::defs::p47::play::serverbound::ClientCommandPayload;
85pub use crate::defs::p47::play::serverbound::EntityActionActionId;
86
87pub type KeepAlive = crate::defs::p47::play::serverbound::KeepAlive<47>;
89impl crate::packet::Packet for KeepAlive {
90 const ID: i32 = id::KEEP_ALIVE;
91 const NAME: &'static str = "keep_alive";
92 const STATE: State = State::Play;
93 const DIRECTION: Direction = Direction::Serverbound;
94}
95impl From<KeepAlive> for ServerboundPlayPacket {
96 fn from(p: KeepAlive) -> Self {
97 Self::KeepAlive(p)
98 }
99}
100
101pub type Chat = crate::defs::p47::play::serverbound::Chat<47>;
103impl crate::packet::Packet for Chat {
104 const ID: i32 = id::CHAT;
105 const NAME: &'static str = "chat";
106 const STATE: State = State::Play;
107 const DIRECTION: Direction = Direction::Serverbound;
108}
109impl From<Chat> for ServerboundPlayPacket {
110 fn from(p: Chat) -> Self {
111 Self::Chat(p)
112 }
113}
114
115pub type UseEntity = crate::defs::p47::play::serverbound::UseEntity<47>;
117impl crate::packet::Packet for UseEntity {
118 const ID: i32 = id::USE_ENTITY;
119 const NAME: &'static str = "use_entity";
120 const STATE: State = State::Play;
121 const DIRECTION: Direction = Direction::Serverbound;
122}
123impl From<UseEntity> for ServerboundPlayPacket {
124 fn from(p: UseEntity) -> Self {
125 Self::UseEntity(p)
126 }
127}
128
129pub type Flying = crate::defs::p47::play::serverbound::Flying<47>;
131impl crate::packet::Packet for Flying {
132 const ID: i32 = id::FLYING;
133 const NAME: &'static str = "flying";
134 const STATE: State = State::Play;
135 const DIRECTION: Direction = Direction::Serverbound;
136}
137impl From<Flying> for ServerboundPlayPacket {
138 fn from(p: Flying) -> Self {
139 Self::Flying(p)
140 }
141}
142
143pub type Position = crate::defs::p47::play::serverbound::Position<47>;
145impl crate::packet::Packet for Position {
146 const ID: i32 = id::POSITION;
147 const NAME: &'static str = "position";
148 const STATE: State = State::Play;
149 const DIRECTION: Direction = Direction::Serverbound;
150}
151impl From<Position> for ServerboundPlayPacket {
152 fn from(p: Position) -> Self {
153 Self::Position(p)
154 }
155}
156
157pub type Look = crate::defs::p47::play::serverbound::Look<47>;
159impl crate::packet::Packet for Look {
160 const ID: i32 = id::LOOK;
161 const NAME: &'static str = "look";
162 const STATE: State = State::Play;
163 const DIRECTION: Direction = Direction::Serverbound;
164}
165impl From<Look> for ServerboundPlayPacket {
166 fn from(p: Look) -> Self {
167 Self::Look(p)
168 }
169}
170
171pub type PositionLook = crate::defs::p47::play::serverbound::PositionLook<47>;
173impl crate::packet::Packet for PositionLook {
174 const ID: i32 = id::POSITION_LOOK;
175 const NAME: &'static str = "position_look";
176 const STATE: State = State::Play;
177 const DIRECTION: Direction = Direction::Serverbound;
178}
179impl From<PositionLook> for ServerboundPlayPacket {
180 fn from(p: PositionLook) -> Self {
181 Self::PositionLook(p)
182 }
183}
184
185pub type BlockDig = crate::defs::p47::play::serverbound::BlockDig<47>;
187impl crate::packet::Packet for BlockDig {
188 const ID: i32 = id::BLOCK_DIG;
189 const NAME: &'static str = "block_dig";
190 const STATE: State = State::Play;
191 const DIRECTION: Direction = Direction::Serverbound;
192}
193impl From<BlockDig> for ServerboundPlayPacket {
194 fn from(p: BlockDig) -> Self {
195 Self::BlockDig(p)
196 }
197}
198
199pub type BlockPlace = crate::defs::p47::play::serverbound::BlockPlace<47>;
201impl crate::packet::Packet for BlockPlace {
202 const ID: i32 = id::BLOCK_PLACE;
203 const NAME: &'static str = "block_place";
204 const STATE: State = State::Play;
205 const DIRECTION: Direction = Direction::Serverbound;
206}
207impl From<BlockPlace> for ServerboundPlayPacket {
208 fn from(p: BlockPlace) -> Self {
209 Self::BlockPlace(p)
210 }
211}
212
213pub type HeldItemSlot = crate::defs::p47::play::serverbound::HeldItemSlot<47>;
215impl crate::packet::Packet for HeldItemSlot {
216 const ID: i32 = id::HELD_ITEM_SLOT;
217 const NAME: &'static str = "held_item_slot";
218 const STATE: State = State::Play;
219 const DIRECTION: Direction = Direction::Serverbound;
220}
221impl From<HeldItemSlot> for ServerboundPlayPacket {
222 fn from(p: HeldItemSlot) -> Self {
223 Self::HeldItemSlot(p)
224 }
225}
226
227pub type ArmAnimation = crate::defs::p47::play::serverbound::ArmAnimation<47>;
229impl crate::packet::Packet for ArmAnimation {
230 const ID: i32 = id::ARM_ANIMATION;
231 const NAME: &'static str = "arm_animation";
232 const STATE: State = State::Play;
233 const DIRECTION: Direction = Direction::Serverbound;
234}
235impl From<ArmAnimation> for ServerboundPlayPacket {
236 fn from(p: ArmAnimation) -> Self {
237 Self::ArmAnimation(p)
238 }
239}
240
241pub type EntityAction = crate::defs::p47::play::serverbound::EntityAction<47>;
243impl crate::packet::Packet for EntityAction {
244 const ID: i32 = id::ENTITY_ACTION;
245 const NAME: &'static str = "entity_action";
246 const STATE: State = State::Play;
247 const DIRECTION: Direction = Direction::Serverbound;
248}
249impl From<EntityAction> for ServerboundPlayPacket {
250 fn from(p: EntityAction) -> Self {
251 Self::EntityAction(p)
252 }
253}
254
255pub type SteerVehicle = crate::defs::p47::play::serverbound::SteerVehicle<47>;
257impl crate::packet::Packet for SteerVehicle {
258 const ID: i32 = id::STEER_VEHICLE;
259 const NAME: &'static str = "steer_vehicle";
260 const STATE: State = State::Play;
261 const DIRECTION: Direction = Direction::Serverbound;
262}
263impl From<SteerVehicle> for ServerboundPlayPacket {
264 fn from(p: SteerVehicle) -> Self {
265 Self::SteerVehicle(p)
266 }
267}
268
269pub type CloseWindow = crate::defs::p47::play::serverbound::CloseWindow<47>;
271impl crate::packet::Packet for CloseWindow {
272 const ID: i32 = id::CLOSE_WINDOW;
273 const NAME: &'static str = "close_window";
274 const STATE: State = State::Play;
275 const DIRECTION: Direction = Direction::Serverbound;
276}
277impl From<CloseWindow> for ServerboundPlayPacket {
278 fn from(p: CloseWindow) -> Self {
279 Self::CloseWindow(p)
280 }
281}
282
283pub type WindowClick = crate::defs::p47::play::serverbound::WindowClick<47>;
285impl crate::packet::Packet for WindowClick {
286 const ID: i32 = id::WINDOW_CLICK;
287 const NAME: &'static str = "window_click";
288 const STATE: State = State::Play;
289 const DIRECTION: Direction = Direction::Serverbound;
290}
291impl From<WindowClick> for ServerboundPlayPacket {
292 fn from(p: WindowClick) -> Self {
293 Self::WindowClick(p)
294 }
295}
296
297pub type Transaction = crate::defs::p47::play::serverbound::Transaction<47>;
299impl crate::packet::Packet for Transaction {
300 const ID: i32 = id::TRANSACTION;
301 const NAME: &'static str = "transaction";
302 const STATE: State = State::Play;
303 const DIRECTION: Direction = Direction::Serverbound;
304}
305impl From<Transaction> for ServerboundPlayPacket {
306 fn from(p: Transaction) -> Self {
307 Self::Transaction(p)
308 }
309}
310
311pub type SetCreativeSlot = crate::defs::p47::play::serverbound::SetCreativeSlot<47>;
313impl crate::packet::Packet for SetCreativeSlot {
314 const ID: i32 = id::SET_CREATIVE_SLOT;
315 const NAME: &'static str = "set_creative_slot";
316 const STATE: State = State::Play;
317 const DIRECTION: Direction = Direction::Serverbound;
318}
319impl From<SetCreativeSlot> for ServerboundPlayPacket {
320 fn from(p: SetCreativeSlot) -> Self {
321 Self::SetCreativeSlot(p)
322 }
323}
324
325pub type EnchantItem = crate::defs::p47::play::serverbound::EnchantItem<47>;
327impl crate::packet::Packet for EnchantItem {
328 const ID: i32 = id::ENCHANT_ITEM;
329 const NAME: &'static str = "enchant_item";
330 const STATE: State = State::Play;
331 const DIRECTION: Direction = Direction::Serverbound;
332}
333impl From<EnchantItem> for ServerboundPlayPacket {
334 fn from(p: EnchantItem) -> Self {
335 Self::EnchantItem(p)
336 }
337}
338
339pub type UpdateSign = crate::defs::p47::play::serverbound::UpdateSign<47>;
341impl crate::packet::Packet for UpdateSign {
342 const ID: i32 = id::UPDATE_SIGN;
343 const NAME: &'static str = "update_sign";
344 const STATE: State = State::Play;
345 const DIRECTION: Direction = Direction::Serverbound;
346}
347impl From<UpdateSign> for ServerboundPlayPacket {
348 fn from(p: UpdateSign) -> Self {
349 Self::UpdateSign(p)
350 }
351}
352
353pub type Abilities = crate::defs::p47::play::serverbound::Abilities<47>;
355impl crate::packet::Packet for Abilities {
356 const ID: i32 = id::ABILITIES;
357 const NAME: &'static str = "abilities";
358 const STATE: State = State::Play;
359 const DIRECTION: Direction = Direction::Serverbound;
360}
361impl From<Abilities> for ServerboundPlayPacket {
362 fn from(p: Abilities) -> Self {
363 Self::Abilities(p)
364 }
365}
366
367pub type TabComplete = crate::defs::p47::play::serverbound::TabComplete<47>;
369impl crate::packet::Packet for TabComplete {
370 const ID: i32 = id::TAB_COMPLETE;
371 const NAME: &'static str = "tab_complete";
372 const STATE: State = State::Play;
373 const DIRECTION: Direction = Direction::Serverbound;
374}
375impl From<TabComplete> for ServerboundPlayPacket {
376 fn from(p: TabComplete) -> Self {
377 Self::TabComplete(p)
378 }
379}
380
381pub type Settings = crate::defs::p47::play::serverbound::Settings<47>;
383impl crate::packet::Packet for Settings {
384 const ID: i32 = id::SETTINGS;
385 const NAME: &'static str = "settings";
386 const STATE: State = State::Play;
387 const DIRECTION: Direction = Direction::Serverbound;
388}
389impl From<Settings> for ServerboundPlayPacket {
390 fn from(p: Settings) -> Self {
391 Self::Settings(p)
392 }
393}
394
395pub type ClientCommand = crate::defs::p47::play::serverbound::ClientCommand<47>;
397impl crate::packet::Packet for ClientCommand {
398 const ID: i32 = id::CLIENT_COMMAND;
399 const NAME: &'static str = "client_command";
400 const STATE: State = State::Play;
401 const DIRECTION: Direction = Direction::Serverbound;
402}
403impl From<ClientCommand> for ServerboundPlayPacket {
404 fn from(p: ClientCommand) -> Self {
405 Self::ClientCommand(p)
406 }
407}
408
409pub type CustomPayload = crate::defs::p47::play::serverbound::CustomPayload<47>;
411impl crate::packet::Packet for CustomPayload {
412 const ID: i32 = id::CUSTOM_PAYLOAD;
413 const NAME: &'static str = "custom_payload";
414 const STATE: State = State::Play;
415 const DIRECTION: Direction = Direction::Serverbound;
416}
417impl From<CustomPayload> for ServerboundPlayPacket {
418 fn from(p: CustomPayload) -> Self {
419 Self::CustomPayload(p)
420 }
421}
422
423pub type Spectate = crate::defs::p47::play::serverbound::Spectate<47>;
425impl crate::packet::Packet for Spectate {
426 const ID: i32 = id::SPECTATE;
427 const NAME: &'static str = "spectate";
428 const STATE: State = State::Play;
429 const DIRECTION: Direction = Direction::Serverbound;
430}
431impl From<Spectate> for ServerboundPlayPacket {
432 fn from(p: Spectate) -> Self {
433 Self::Spectate(p)
434 }
435}
436
437pub type ResourcePackReceive = crate::defs::p47::play::serverbound::ResourcePackReceive<47>;
439impl crate::packet::Packet for ResourcePackReceive {
440 const ID: i32 = id::RESOURCE_PACK_RECEIVE;
441 const NAME: &'static str = "resource_pack_receive";
442 const STATE: State = State::Play;
443 const DIRECTION: Direction = Direction::Serverbound;
444}
445impl From<ResourcePackReceive> for ServerboundPlayPacket {
446 fn from(p: ResourcePackReceive) -> Self {
447 Self::ResourcePackReceive(p)
448 }
449}
450
451#[derive(Debug, Clone, PartialEq)]
453pub enum ServerboundPlayPacket {
454 KeepAlive(KeepAlive),
456 Chat(Chat),
458 UseEntity(UseEntity),
460 Flying(Flying),
462 Position(Position),
464 Look(Look),
466 PositionLook(PositionLook),
468 BlockDig(BlockDig),
470 BlockPlace(BlockPlace),
472 HeldItemSlot(HeldItemSlot),
474 ArmAnimation(ArmAnimation),
476 EntityAction(EntityAction),
478 SteerVehicle(SteerVehicle),
480 CloseWindow(CloseWindow),
482 WindowClick(WindowClick),
484 Transaction(Transaction),
486 SetCreativeSlot(SetCreativeSlot),
488 EnchantItem(EnchantItem),
490 UpdateSign(UpdateSign),
492 Abilities(Abilities),
494 TabComplete(TabComplete),
496 Settings(Settings),
498 ClientCommand(ClientCommand),
500 CustomPayload(CustomPayload),
502 Spectate(Spectate),
504 ResourcePackReceive(ResourcePackReceive),
506}
507
508impl PacketSet for ServerboundPlayPacket {
509 const STATE: State = State::Play;
510 const DIRECTION: Direction = Direction::Serverbound;
511 fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
512 match raw.id {
513 id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
514 id::CHAT => decode_exact(&raw.body).map(Self::Chat),
515 id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
516 id::FLYING => decode_exact(&raw.body).map(Self::Flying),
517 id::POSITION => decode_exact(&raw.body).map(Self::Position),
518 id::LOOK => decode_exact(&raw.body).map(Self::Look),
519 id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
520 id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
521 id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
522 id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
523 id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
524 id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
525 id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
526 id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
527 id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
528 id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
529 id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
530 id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
531 id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
532 id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
533 id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
534 id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
535 id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
536 id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
537 id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
538 id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
539 other => Err(DecodeError::UnknownPacketId(other)),
540 }
541 }
542 fn id(&self) -> i32 {
543 match *self {
544 Self::KeepAlive(_) => id::KEEP_ALIVE,
545 Self::Chat(_) => id::CHAT,
546 Self::UseEntity(_) => id::USE_ENTITY,
547 Self::Flying(_) => id::FLYING,
548 Self::Position(_) => id::POSITION,
549 Self::Look(_) => id::LOOK,
550 Self::PositionLook(_) => id::POSITION_LOOK,
551 Self::BlockDig(_) => id::BLOCK_DIG,
552 Self::BlockPlace(_) => id::BLOCK_PLACE,
553 Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
554 Self::ArmAnimation(_) => id::ARM_ANIMATION,
555 Self::EntityAction(_) => id::ENTITY_ACTION,
556 Self::SteerVehicle(_) => id::STEER_VEHICLE,
557 Self::CloseWindow(_) => id::CLOSE_WINDOW,
558 Self::WindowClick(_) => id::WINDOW_CLICK,
559 Self::Transaction(_) => id::TRANSACTION,
560 Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
561 Self::EnchantItem(_) => id::ENCHANT_ITEM,
562 Self::UpdateSign(_) => id::UPDATE_SIGN,
563 Self::Abilities(_) => id::ABILITIES,
564 Self::TabComplete(_) => id::TAB_COMPLETE,
565 Self::Settings(_) => id::SETTINGS,
566 Self::ClientCommand(_) => id::CLIENT_COMMAND,
567 Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
568 Self::Spectate(_) => id::SPECTATE,
569 Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
570 }
571 }
572 fn name(&self) -> &'static str {
573 match *self {
574 Self::KeepAlive(_) => "keep_alive",
575 Self::Chat(_) => "chat",
576 Self::UseEntity(_) => "use_entity",
577 Self::Flying(_) => "flying",
578 Self::Position(_) => "position",
579 Self::Look(_) => "look",
580 Self::PositionLook(_) => "position_look",
581 Self::BlockDig(_) => "block_dig",
582 Self::BlockPlace(_) => "block_place",
583 Self::HeldItemSlot(_) => "held_item_slot",
584 Self::ArmAnimation(_) => "arm_animation",
585 Self::EntityAction(_) => "entity_action",
586 Self::SteerVehicle(_) => "steer_vehicle",
587 Self::CloseWindow(_) => "close_window",
588 Self::WindowClick(_) => "window_click",
589 Self::Transaction(_) => "transaction",
590 Self::SetCreativeSlot(_) => "set_creative_slot",
591 Self::EnchantItem(_) => "enchant_item",
592 Self::UpdateSign(_) => "update_sign",
593 Self::Abilities(_) => "abilities",
594 Self::TabComplete(_) => "tab_complete",
595 Self::Settings(_) => "settings",
596 Self::ClientCommand(_) => "client_command",
597 Self::CustomPayload(_) => "custom_payload",
598 Self::Spectate(_) => "spectate",
599 Self::ResourcePackReceive(_) => "resource_pack_receive",
600 }
601 }
602 fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
603 match *self {
604 Self::KeepAlive(ref p) => p.encode(w),
605 Self::Chat(ref p) => p.encode(w),
606 Self::UseEntity(ref p) => p.encode(w),
607 Self::Flying(ref p) => p.encode(w),
608 Self::Position(ref p) => p.encode(w),
609 Self::Look(ref p) => p.encode(w),
610 Self::PositionLook(ref p) => p.encode(w),
611 Self::BlockDig(ref p) => p.encode(w),
612 Self::BlockPlace(ref p) => p.encode(w),
613 Self::HeldItemSlot(ref p) => p.encode(w),
614 Self::ArmAnimation(ref p) => p.encode(w),
615 Self::EntityAction(ref p) => p.encode(w),
616 Self::SteerVehicle(ref p) => p.encode(w),
617 Self::CloseWindow(ref p) => p.encode(w),
618 Self::WindowClick(ref p) => p.encode(w),
619 Self::Transaction(ref p) => p.encode(w),
620 Self::SetCreativeSlot(ref p) => p.encode(w),
621 Self::EnchantItem(ref p) => p.encode(w),
622 Self::UpdateSign(ref p) => p.encode(w),
623 Self::Abilities(ref p) => p.encode(w),
624 Self::TabComplete(ref p) => p.encode(w),
625 Self::Settings(ref p) => p.encode(w),
626 Self::ClientCommand(ref p) => p.encode(w),
627 Self::CustomPayload(ref p) => p.encode(w),
628 Self::Spectate(ref p) => p.encode(w),
629 Self::ResourcePackReceive(ref p) => p.encode(w),
630 }
631 }
632 fn name_of(id: i32) -> Option<&'static str> {
633 match id {
634 id::KEEP_ALIVE => Some("keep_alive"),
635 id::CHAT => Some("chat"),
636 id::USE_ENTITY => Some("use_entity"),
637 id::FLYING => Some("flying"),
638 id::POSITION => Some("position"),
639 id::LOOK => Some("look"),
640 id::POSITION_LOOK => Some("position_look"),
641 id::BLOCK_DIG => Some("block_dig"),
642 id::BLOCK_PLACE => Some("block_place"),
643 id::HELD_ITEM_SLOT => Some("held_item_slot"),
644 id::ARM_ANIMATION => Some("arm_animation"),
645 id::ENTITY_ACTION => Some("entity_action"),
646 id::STEER_VEHICLE => Some("steer_vehicle"),
647 id::CLOSE_WINDOW => Some("close_window"),
648 id::WINDOW_CLICK => Some("window_click"),
649 id::TRANSACTION => Some("transaction"),
650 id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
651 id::ENCHANT_ITEM => Some("enchant_item"),
652 id::UPDATE_SIGN => Some("update_sign"),
653 id::ABILITIES => Some("abilities"),
654 id::TAB_COMPLETE => Some("tab_complete"),
655 id::SETTINGS => Some("settings"),
656 id::CLIENT_COMMAND => Some("client_command"),
657 id::CUSTOM_PAYLOAD => Some("custom_payload"),
658 id::SPECTATE => Some("spectate"),
659 id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
660 _ => None,
661 }
662 }
663}
664
665impl ServerboundPlayPacket {
666 pub const IDS: &'static [i32] = &[
668 id::KEEP_ALIVE,
669 id::CHAT,
670 id::USE_ENTITY,
671 id::FLYING,
672 id::POSITION,
673 id::LOOK,
674 id::POSITION_LOOK,
675 id::BLOCK_DIG,
676 id::BLOCK_PLACE,
677 id::HELD_ITEM_SLOT,
678 id::ARM_ANIMATION,
679 id::ENTITY_ACTION,
680 id::STEER_VEHICLE,
681 id::CLOSE_WINDOW,
682 id::WINDOW_CLICK,
683 id::TRANSACTION,
684 id::SET_CREATIVE_SLOT,
685 id::ENCHANT_ITEM,
686 id::UPDATE_SIGN,
687 id::ABILITIES,
688 id::TAB_COMPLETE,
689 id::SETTINGS,
690 id::CLIENT_COMMAND,
691 id::CUSTOM_PAYLOAD,
692 id::SPECTATE,
693 id::RESOURCE_PACK_RECEIVE,
694 ];
695 #[cfg(feature = "testgen")]
697 pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
698 match id {
699 id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
700 id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
701 id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
702 id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
703 id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
704 id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
705 id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
706 id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
707 id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
708 id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
709 id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
710 id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
711 id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
712 id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
713 id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
714 id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
715 id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
716 <SetCreativeSlot as Generate>::generate(g),
717 )),
718 id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
719 id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
720 id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
721 id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
722 id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
723 id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
724 g,
725 ))),
726 id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
727 g,
728 ))),
729 id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
730 id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
731 <ResourcePackReceive as Generate>::generate(g),
732 )),
733 _ => None,
734 }
735 }
736}