Skip to main content

ghast_protocol/generated/v1_12_1/play/
serverbound.rs

1// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
2// (data/pc/1.12.1/protocol.json, Minecraft 1.12.1). Do not edit; run `cargo run -p ghast-codegen-protocol`.
3// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
4// in crates/ghast-protocol/src/generated/.
5
6//! Serverbound packets of the play state.
7
8#![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
28/// Packet ids.
29pub mod id {
30    /// `teleport_confirm`
31    pub const TELEPORT_CONFIRM: i32 = 0x00;
32    /// `tab_complete`
33    pub const TAB_COMPLETE: i32 = 0x01;
34    /// `chat`
35    pub const CHAT: i32 = 0x02;
36    /// `client_command`
37    pub const CLIENT_COMMAND: i32 = 0x03;
38    /// `settings`
39    pub const SETTINGS: i32 = 0x04;
40    /// `transaction`
41    pub const TRANSACTION: i32 = 0x05;
42    /// `enchant_item`
43    pub const ENCHANT_ITEM: i32 = 0x06;
44    /// `window_click`
45    pub const WINDOW_CLICK: i32 = 0x07;
46    /// `close_window`
47    pub const CLOSE_WINDOW: i32 = 0x08;
48    /// `custom_payload`
49    pub const CUSTOM_PAYLOAD: i32 = 0x09;
50    /// `use_entity`
51    pub const USE_ENTITY: i32 = 0x0a;
52    /// `keep_alive`
53    pub const KEEP_ALIVE: i32 = 0x0b;
54    /// `flying`
55    pub const FLYING: i32 = 0x0c;
56    /// `position`
57    pub const POSITION: i32 = 0x0d;
58    /// `position_look`
59    pub const POSITION_LOOK: i32 = 0x0e;
60    /// `look`
61    pub const LOOK: i32 = 0x0f;
62    /// `vehicle_move`
63    pub const VEHICLE_MOVE: i32 = 0x10;
64    /// `steer_boat`
65    pub const STEER_BOAT: i32 = 0x11;
66    /// `craft_recipe_request`
67    pub const CRAFT_RECIPE_REQUEST: i32 = 0x12;
68    /// `abilities`
69    pub const ABILITIES: i32 = 0x13;
70    /// `block_dig`
71    pub const BLOCK_DIG: i32 = 0x14;
72    /// `entity_action`
73    pub const ENTITY_ACTION: i32 = 0x15;
74    /// `steer_vehicle`
75    pub const STEER_VEHICLE: i32 = 0x16;
76    /// `crafting_book_data`
77    pub const CRAFTING_BOOK_DATA: i32 = 0x17;
78    /// `resource_pack_receive`
79    pub const RESOURCE_PACK_RECEIVE: i32 = 0x18;
80    /// `advancement_tab`
81    pub const ADVANCEMENT_TAB: i32 = 0x19;
82    /// `held_item_slot`
83    pub const HELD_ITEM_SLOT: i32 = 0x1a;
84    /// `set_creative_slot`
85    pub const SET_CREATIVE_SLOT: i32 = 0x1b;
86    /// `update_sign`
87    pub const UPDATE_SIGN: i32 = 0x1c;
88    /// `arm_animation`
89    pub const ARM_ANIMATION: i32 = 0x1d;
90    /// `spectate`
91    pub const SPECTATE: i32 = 0x1e;
92    /// `block_place`
93    pub const BLOCK_PLACE: i32 = 0x1f;
94    /// `use_item`
95    pub const USE_ITEM: i32 = 0x20;
96}
97
98pub use crate::defs::p340::play::serverbound::ClientCommandActionId;
99pub use crate::defs::p340::play::serverbound::CraftingBookDataBody;
100pub use crate::defs::p340::play::serverbound::CraftingBookDataBodyCase0;
101pub use crate::defs::p340::play::serverbound::CraftingBookDataBodyCase1;
102pub use crate::defs::p340::play::serverbound::EntityActionActionId;
103
104/// `teleport_confirm` (serverbound play, id 0x00).
105pub type TeleportConfirm = crate::defs::p340::play::serverbound::TeleportConfirm<338>;
106impl crate::packet::Packet for TeleportConfirm {
107    const ID: i32 = id::TELEPORT_CONFIRM;
108    const NAME: &'static str = "teleport_confirm";
109    const STATE: State = State::Play;
110    const DIRECTION: Direction = Direction::Serverbound;
111}
112impl From<TeleportConfirm> for ServerboundPlayPacket {
113    fn from(p: TeleportConfirm) -> Self {
114        Self::TeleportConfirm(p)
115    }
116}
117
118/// `tab_complete` (serverbound play, id 0x01).
119pub type TabComplete = crate::defs::p340::play::serverbound::TabComplete<338>;
120impl crate::packet::Packet for TabComplete {
121    const ID: i32 = id::TAB_COMPLETE;
122    const NAME: &'static str = "tab_complete";
123    const STATE: State = State::Play;
124    const DIRECTION: Direction = Direction::Serverbound;
125}
126impl From<TabComplete> for ServerboundPlayPacket {
127    fn from(p: TabComplete) -> Self {
128        Self::TabComplete(p)
129    }
130}
131
132/// `chat` (serverbound play, id 0x02).
133pub type Chat = crate::defs::p47::play::serverbound::Chat<338>;
134impl crate::packet::Packet for Chat {
135    const ID: i32 = id::CHAT;
136    const NAME: &'static str = "chat";
137    const STATE: State = State::Play;
138    const DIRECTION: Direction = Direction::Serverbound;
139}
140impl From<Chat> for ServerboundPlayPacket {
141    fn from(p: Chat) -> Self {
142        Self::Chat(p)
143    }
144}
145
146/// `client_command` (serverbound play, id 0x03).
147pub type ClientCommand = crate::defs::p340::play::serverbound::ClientCommand<338>;
148impl crate::packet::Packet for ClientCommand {
149    const ID: i32 = id::CLIENT_COMMAND;
150    const NAME: &'static str = "client_command";
151    const STATE: State = State::Play;
152    const DIRECTION: Direction = Direction::Serverbound;
153}
154impl From<ClientCommand> for ServerboundPlayPacket {
155    fn from(p: ClientCommand) -> Self {
156        Self::ClientCommand(p)
157    }
158}
159
160/// `settings` (serverbound play, id 0x04).
161pub type Settings = crate::defs::p340::play::serverbound::Settings<338>;
162impl crate::packet::Packet for Settings {
163    const ID: i32 = id::SETTINGS;
164    const NAME: &'static str = "settings";
165    const STATE: State = State::Play;
166    const DIRECTION: Direction = Direction::Serverbound;
167}
168impl From<Settings> for ServerboundPlayPacket {
169    fn from(p: Settings) -> Self {
170        Self::Settings(p)
171    }
172}
173
174/// `transaction` (serverbound play, id 0x05).
175pub type Transaction = crate::defs::p47::play::serverbound::Transaction<338>;
176impl crate::packet::Packet for Transaction {
177    const ID: i32 = id::TRANSACTION;
178    const NAME: &'static str = "transaction";
179    const STATE: State = State::Play;
180    const DIRECTION: Direction = Direction::Serverbound;
181}
182impl From<Transaction> for ServerboundPlayPacket {
183    fn from(p: Transaction) -> Self {
184        Self::Transaction(p)
185    }
186}
187
188/// `enchant_item` (serverbound play, id 0x06).
189pub type EnchantItem = crate::defs::p47::play::serverbound::EnchantItem<338>;
190impl crate::packet::Packet for EnchantItem {
191    const ID: i32 = id::ENCHANT_ITEM;
192    const NAME: &'static str = "enchant_item";
193    const STATE: State = State::Play;
194    const DIRECTION: Direction = Direction::Serverbound;
195}
196impl From<EnchantItem> for ServerboundPlayPacket {
197    fn from(p: EnchantItem) -> Self {
198        Self::EnchantItem(p)
199    }
200}
201
202/// `window_click` (serverbound play, id 0x07).
203pub type WindowClick = crate::defs::p47::play::serverbound::WindowClick<338>;
204impl crate::packet::Packet for WindowClick {
205    const ID: i32 = id::WINDOW_CLICK;
206    const NAME: &'static str = "window_click";
207    const STATE: State = State::Play;
208    const DIRECTION: Direction = Direction::Serverbound;
209}
210impl From<WindowClick> for ServerboundPlayPacket {
211    fn from(p: WindowClick) -> Self {
212        Self::WindowClick(p)
213    }
214}
215
216/// `close_window` (serverbound play, id 0x08).
217pub type CloseWindow = crate::defs::p47::play::serverbound::CloseWindow<338>;
218impl crate::packet::Packet for CloseWindow {
219    const ID: i32 = id::CLOSE_WINDOW;
220    const NAME: &'static str = "close_window";
221    const STATE: State = State::Play;
222    const DIRECTION: Direction = Direction::Serverbound;
223}
224impl From<CloseWindow> for ServerboundPlayPacket {
225    fn from(p: CloseWindow) -> Self {
226        Self::CloseWindow(p)
227    }
228}
229
230/// `custom_payload` (serverbound play, id 0x09).
231pub type CustomPayload = crate::defs::p47::play::serverbound::CustomPayload<338>;
232impl crate::packet::Packet for CustomPayload {
233    const ID: i32 = id::CUSTOM_PAYLOAD;
234    const NAME: &'static str = "custom_payload";
235    const STATE: State = State::Play;
236    const DIRECTION: Direction = Direction::Serverbound;
237}
238impl From<CustomPayload> for ServerboundPlayPacket {
239    fn from(p: CustomPayload) -> Self {
240        Self::CustomPayload(p)
241    }
242}
243
244/// `use_entity` (serverbound play, id 0x0a).
245pub type UseEntity = crate::defs::p340::play::serverbound::UseEntity<338>;
246impl crate::packet::Packet for UseEntity {
247    const ID: i32 = id::USE_ENTITY;
248    const NAME: &'static str = "use_entity";
249    const STATE: State = State::Play;
250    const DIRECTION: Direction = Direction::Serverbound;
251}
252impl From<UseEntity> for ServerboundPlayPacket {
253    fn from(p: UseEntity) -> Self {
254        Self::UseEntity(p)
255    }
256}
257
258/// `keep_alive` (serverbound play, id 0x0b).
259pub type KeepAlive = crate::defs::p47::play::serverbound::KeepAlive<338>;
260impl crate::packet::Packet for KeepAlive {
261    const ID: i32 = id::KEEP_ALIVE;
262    const NAME: &'static str = "keep_alive";
263    const STATE: State = State::Play;
264    const DIRECTION: Direction = Direction::Serverbound;
265}
266impl From<KeepAlive> for ServerboundPlayPacket {
267    fn from(p: KeepAlive) -> Self {
268        Self::KeepAlive(p)
269    }
270}
271
272/// `flying` (serverbound play, id 0x0c).
273pub type Flying = crate::defs::p47::play::serverbound::Flying<338>;
274impl crate::packet::Packet for Flying {
275    const ID: i32 = id::FLYING;
276    const NAME: &'static str = "flying";
277    const STATE: State = State::Play;
278    const DIRECTION: Direction = Direction::Serverbound;
279}
280impl From<Flying> for ServerboundPlayPacket {
281    fn from(p: Flying) -> Self {
282        Self::Flying(p)
283    }
284}
285
286/// `position` (serverbound play, id 0x0d).
287pub type Position = crate::defs::p47::play::serverbound::Position<338>;
288impl crate::packet::Packet for Position {
289    const ID: i32 = id::POSITION;
290    const NAME: &'static str = "position";
291    const STATE: State = State::Play;
292    const DIRECTION: Direction = Direction::Serverbound;
293}
294impl From<Position> for ServerboundPlayPacket {
295    fn from(p: Position) -> Self {
296        Self::Position(p)
297    }
298}
299
300/// `position_look` (serverbound play, id 0x0e).
301pub type PositionLook = crate::defs::p47::play::serverbound::PositionLook<338>;
302impl crate::packet::Packet for PositionLook {
303    const ID: i32 = id::POSITION_LOOK;
304    const NAME: &'static str = "position_look";
305    const STATE: State = State::Play;
306    const DIRECTION: Direction = Direction::Serverbound;
307}
308impl From<PositionLook> for ServerboundPlayPacket {
309    fn from(p: PositionLook) -> Self {
310        Self::PositionLook(p)
311    }
312}
313
314/// `look` (serverbound play, id 0x0f).
315pub type Look = crate::defs::p47::play::serverbound::Look<338>;
316impl crate::packet::Packet for Look {
317    const ID: i32 = id::LOOK;
318    const NAME: &'static str = "look";
319    const STATE: State = State::Play;
320    const DIRECTION: Direction = Direction::Serverbound;
321}
322impl From<Look> for ServerboundPlayPacket {
323    fn from(p: Look) -> Self {
324        Self::Look(p)
325    }
326}
327
328/// `vehicle_move` (serverbound play, id 0x10).
329pub type VehicleMove = crate::defs::p340::play::serverbound::VehicleMove<338>;
330impl crate::packet::Packet for VehicleMove {
331    const ID: i32 = id::VEHICLE_MOVE;
332    const NAME: &'static str = "vehicle_move";
333    const STATE: State = State::Play;
334    const DIRECTION: Direction = Direction::Serverbound;
335}
336impl From<VehicleMove> for ServerboundPlayPacket {
337    fn from(p: VehicleMove) -> Self {
338        Self::VehicleMove(p)
339    }
340}
341
342/// `steer_boat` (serverbound play, id 0x11).
343pub type SteerBoat = crate::defs::p340::play::serverbound::SteerBoat<338>;
344impl crate::packet::Packet for SteerBoat {
345    const ID: i32 = id::STEER_BOAT;
346    const NAME: &'static str = "steer_boat";
347    const STATE: State = State::Play;
348    const DIRECTION: Direction = Direction::Serverbound;
349}
350impl From<SteerBoat> for ServerboundPlayPacket {
351    fn from(p: SteerBoat) -> Self {
352        Self::SteerBoat(p)
353    }
354}
355
356/// `craft_recipe_request` (serverbound play, id 0x12).
357pub type CraftRecipeRequest = crate::defs::p340::play::serverbound::CraftRecipeRequest<338>;
358impl crate::packet::Packet for CraftRecipeRequest {
359    const ID: i32 = id::CRAFT_RECIPE_REQUEST;
360    const NAME: &'static str = "craft_recipe_request";
361    const STATE: State = State::Play;
362    const DIRECTION: Direction = Direction::Serverbound;
363}
364impl From<CraftRecipeRequest> for ServerboundPlayPacket {
365    fn from(p: CraftRecipeRequest) -> Self {
366        Self::CraftRecipeRequest(p)
367    }
368}
369
370/// `abilities` (serverbound play, id 0x13).
371pub type Abilities = crate::defs::p47::play::serverbound::Abilities<338>;
372impl crate::packet::Packet for Abilities {
373    const ID: i32 = id::ABILITIES;
374    const NAME: &'static str = "abilities";
375    const STATE: State = State::Play;
376    const DIRECTION: Direction = Direction::Serverbound;
377}
378impl From<Abilities> for ServerboundPlayPacket {
379    fn from(p: Abilities) -> Self {
380        Self::Abilities(p)
381    }
382}
383
384/// `block_dig` (serverbound play, id 0x14).
385pub type BlockDig = crate::defs::p47::play::serverbound::BlockDig<338>;
386impl crate::packet::Packet for BlockDig {
387    const ID: i32 = id::BLOCK_DIG;
388    const NAME: &'static str = "block_dig";
389    const STATE: State = State::Play;
390    const DIRECTION: Direction = Direction::Serverbound;
391}
392impl From<BlockDig> for ServerboundPlayPacket {
393    fn from(p: BlockDig) -> Self {
394        Self::BlockDig(p)
395    }
396}
397
398/// `entity_action` (serverbound play, id 0x15).
399pub type EntityAction = crate::defs::p340::play::serverbound::EntityAction<338>;
400impl crate::packet::Packet for EntityAction {
401    const ID: i32 = id::ENTITY_ACTION;
402    const NAME: &'static str = "entity_action";
403    const STATE: State = State::Play;
404    const DIRECTION: Direction = Direction::Serverbound;
405}
406impl From<EntityAction> for ServerboundPlayPacket {
407    fn from(p: EntityAction) -> Self {
408        Self::EntityAction(p)
409    }
410}
411
412/// `steer_vehicle` (serverbound play, id 0x16).
413pub type SteerVehicle = crate::defs::p47::play::serverbound::SteerVehicle<338>;
414impl crate::packet::Packet for SteerVehicle {
415    const ID: i32 = id::STEER_VEHICLE;
416    const NAME: &'static str = "steer_vehicle";
417    const STATE: State = State::Play;
418    const DIRECTION: Direction = Direction::Serverbound;
419}
420impl From<SteerVehicle> for ServerboundPlayPacket {
421    fn from(p: SteerVehicle) -> Self {
422        Self::SteerVehicle(p)
423    }
424}
425
426/// `crafting_book_data` (serverbound play, id 0x17).
427pub type CraftingBookData = crate::defs::p340::play::serverbound::CraftingBookData<338>;
428impl crate::packet::Packet for CraftingBookData {
429    const ID: i32 = id::CRAFTING_BOOK_DATA;
430    const NAME: &'static str = "crafting_book_data";
431    const STATE: State = State::Play;
432    const DIRECTION: Direction = Direction::Serverbound;
433}
434impl From<CraftingBookData> for ServerboundPlayPacket {
435    fn from(p: CraftingBookData) -> Self {
436        Self::CraftingBookData(p)
437    }
438}
439
440/// `resource_pack_receive` (serverbound play, id 0x18).
441pub type ResourcePackReceive = crate::defs::p340::play::serverbound::ResourcePackReceive<338>;
442impl crate::packet::Packet for ResourcePackReceive {
443    const ID: i32 = id::RESOURCE_PACK_RECEIVE;
444    const NAME: &'static str = "resource_pack_receive";
445    const STATE: State = State::Play;
446    const DIRECTION: Direction = Direction::Serverbound;
447}
448impl From<ResourcePackReceive> for ServerboundPlayPacket {
449    fn from(p: ResourcePackReceive) -> Self {
450        Self::ResourcePackReceive(p)
451    }
452}
453
454/// `advancement_tab` (serverbound play, id 0x19).
455pub type AdvancementTab = crate::defs::p340::play::serverbound::AdvancementTab<338>;
456impl crate::packet::Packet for AdvancementTab {
457    const ID: i32 = id::ADVANCEMENT_TAB;
458    const NAME: &'static str = "advancement_tab";
459    const STATE: State = State::Play;
460    const DIRECTION: Direction = Direction::Serverbound;
461}
462impl From<AdvancementTab> for ServerboundPlayPacket {
463    fn from(p: AdvancementTab) -> Self {
464        Self::AdvancementTab(p)
465    }
466}
467
468/// `held_item_slot` (serverbound play, id 0x1a).
469pub type HeldItemSlot = crate::defs::p47::play::serverbound::HeldItemSlot<338>;
470impl crate::packet::Packet for HeldItemSlot {
471    const ID: i32 = id::HELD_ITEM_SLOT;
472    const NAME: &'static str = "held_item_slot";
473    const STATE: State = State::Play;
474    const DIRECTION: Direction = Direction::Serverbound;
475}
476impl From<HeldItemSlot> for ServerboundPlayPacket {
477    fn from(p: HeldItemSlot) -> Self {
478        Self::HeldItemSlot(p)
479    }
480}
481
482/// `set_creative_slot` (serverbound play, id 0x1b).
483pub type SetCreativeSlot = crate::defs::p47::play::serverbound::SetCreativeSlot<338>;
484impl crate::packet::Packet for SetCreativeSlot {
485    const ID: i32 = id::SET_CREATIVE_SLOT;
486    const NAME: &'static str = "set_creative_slot";
487    const STATE: State = State::Play;
488    const DIRECTION: Direction = Direction::Serverbound;
489}
490impl From<SetCreativeSlot> for ServerboundPlayPacket {
491    fn from(p: SetCreativeSlot) -> Self {
492        Self::SetCreativeSlot(p)
493    }
494}
495
496/// `update_sign` (serverbound play, id 0x1c).
497pub type UpdateSign = crate::defs::p47::play::serverbound::UpdateSign<338>;
498impl crate::packet::Packet for UpdateSign {
499    const ID: i32 = id::UPDATE_SIGN;
500    const NAME: &'static str = "update_sign";
501    const STATE: State = State::Play;
502    const DIRECTION: Direction = Direction::Serverbound;
503}
504impl From<UpdateSign> for ServerboundPlayPacket {
505    fn from(p: UpdateSign) -> Self {
506        Self::UpdateSign(p)
507    }
508}
509
510/// `arm_animation` (serverbound play, id 0x1d).
511pub type ArmAnimation = crate::defs::p340::play::serverbound::ArmAnimation<338>;
512impl crate::packet::Packet for ArmAnimation {
513    const ID: i32 = id::ARM_ANIMATION;
514    const NAME: &'static str = "arm_animation";
515    const STATE: State = State::Play;
516    const DIRECTION: Direction = Direction::Serverbound;
517}
518impl From<ArmAnimation> for ServerboundPlayPacket {
519    fn from(p: ArmAnimation) -> Self {
520        Self::ArmAnimation(p)
521    }
522}
523
524/// `spectate` (serverbound play, id 0x1e).
525pub type Spectate = crate::defs::p47::play::serverbound::Spectate<338>;
526impl crate::packet::Packet for Spectate {
527    const ID: i32 = id::SPECTATE;
528    const NAME: &'static str = "spectate";
529    const STATE: State = State::Play;
530    const DIRECTION: Direction = Direction::Serverbound;
531}
532impl From<Spectate> for ServerboundPlayPacket {
533    fn from(p: Spectate) -> Self {
534        Self::Spectate(p)
535    }
536}
537
538/// `block_place` (serverbound play, id 0x1f).
539pub type BlockPlace = crate::defs::p340::play::serverbound::BlockPlace<338>;
540impl crate::packet::Packet for BlockPlace {
541    const ID: i32 = id::BLOCK_PLACE;
542    const NAME: &'static str = "block_place";
543    const STATE: State = State::Play;
544    const DIRECTION: Direction = Direction::Serverbound;
545}
546impl From<BlockPlace> for ServerboundPlayPacket {
547    fn from(p: BlockPlace) -> Self {
548        Self::BlockPlace(p)
549    }
550}
551
552/// `use_item` (serverbound play, id 0x20).
553pub type UseItem = crate::defs::p340::play::serverbound::UseItem<338>;
554impl crate::packet::Packet for UseItem {
555    const ID: i32 = id::USE_ITEM;
556    const NAME: &'static str = "use_item";
557    const STATE: State = State::Play;
558    const DIRECTION: Direction = Direction::Serverbound;
559}
560impl From<UseItem> for ServerboundPlayPacket {
561    fn from(p: UseItem) -> Self {
562        Self::UseItem(p)
563    }
564}
565
566/// Every Serverbound packet of the Play state.
567#[derive(Debug, Clone, PartialEq)]
568pub enum ServerboundPlayPacket {
569    /// `teleport_confirm`
570    TeleportConfirm(TeleportConfirm),
571    /// `tab_complete`
572    TabComplete(TabComplete),
573    /// `chat`
574    Chat(Chat),
575    /// `client_command`
576    ClientCommand(ClientCommand),
577    /// `settings`
578    Settings(Settings),
579    /// `transaction`
580    Transaction(Transaction),
581    /// `enchant_item`
582    EnchantItem(EnchantItem),
583    /// `window_click`
584    WindowClick(WindowClick),
585    /// `close_window`
586    CloseWindow(CloseWindow),
587    /// `custom_payload`
588    CustomPayload(CustomPayload),
589    /// `use_entity`
590    UseEntity(UseEntity),
591    /// `keep_alive`
592    KeepAlive(KeepAlive),
593    /// `flying`
594    Flying(Flying),
595    /// `position`
596    Position(Position),
597    /// `position_look`
598    PositionLook(PositionLook),
599    /// `look`
600    Look(Look),
601    /// `vehicle_move`
602    VehicleMove(VehicleMove),
603    /// `steer_boat`
604    SteerBoat(SteerBoat),
605    /// `craft_recipe_request`
606    CraftRecipeRequest(CraftRecipeRequest),
607    /// `abilities`
608    Abilities(Abilities),
609    /// `block_dig`
610    BlockDig(BlockDig),
611    /// `entity_action`
612    EntityAction(EntityAction),
613    /// `steer_vehicle`
614    SteerVehicle(SteerVehicle),
615    /// `crafting_book_data`
616    CraftingBookData(CraftingBookData),
617    /// `resource_pack_receive`
618    ResourcePackReceive(ResourcePackReceive),
619    /// `advancement_tab`
620    AdvancementTab(AdvancementTab),
621    /// `held_item_slot`
622    HeldItemSlot(HeldItemSlot),
623    /// `set_creative_slot`
624    SetCreativeSlot(SetCreativeSlot),
625    /// `update_sign`
626    UpdateSign(UpdateSign),
627    /// `arm_animation`
628    ArmAnimation(ArmAnimation),
629    /// `spectate`
630    Spectate(Spectate),
631    /// `block_place`
632    BlockPlace(BlockPlace),
633    /// `use_item`
634    UseItem(UseItem),
635}
636
637impl PacketSet for ServerboundPlayPacket {
638    const STATE: State = State::Play;
639    const DIRECTION: Direction = Direction::Serverbound;
640    fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
641        match raw.id {
642            id::TELEPORT_CONFIRM => decode_exact(&raw.body).map(Self::TeleportConfirm),
643            id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
644            id::CHAT => decode_exact(&raw.body).map(Self::Chat),
645            id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
646            id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
647            id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
648            id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
649            id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
650            id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
651            id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
652            id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
653            id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
654            id::FLYING => decode_exact(&raw.body).map(Self::Flying),
655            id::POSITION => decode_exact(&raw.body).map(Self::Position),
656            id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
657            id::LOOK => decode_exact(&raw.body).map(Self::Look),
658            id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
659            id::STEER_BOAT => decode_exact(&raw.body).map(Self::SteerBoat),
660            id::CRAFT_RECIPE_REQUEST => decode_exact(&raw.body).map(Self::CraftRecipeRequest),
661            id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
662            id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
663            id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
664            id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
665            id::CRAFTING_BOOK_DATA => decode_exact(&raw.body).map(Self::CraftingBookData),
666            id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
667            id::ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::AdvancementTab),
668            id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
669            id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
670            id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
671            id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
672            id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
673            id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
674            id::USE_ITEM => decode_exact(&raw.body).map(Self::UseItem),
675            other => Err(DecodeError::UnknownPacketId(other)),
676        }
677    }
678    fn id(&self) -> i32 {
679        match *self {
680            Self::TeleportConfirm(_) => id::TELEPORT_CONFIRM,
681            Self::TabComplete(_) => id::TAB_COMPLETE,
682            Self::Chat(_) => id::CHAT,
683            Self::ClientCommand(_) => id::CLIENT_COMMAND,
684            Self::Settings(_) => id::SETTINGS,
685            Self::Transaction(_) => id::TRANSACTION,
686            Self::EnchantItem(_) => id::ENCHANT_ITEM,
687            Self::WindowClick(_) => id::WINDOW_CLICK,
688            Self::CloseWindow(_) => id::CLOSE_WINDOW,
689            Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
690            Self::UseEntity(_) => id::USE_ENTITY,
691            Self::KeepAlive(_) => id::KEEP_ALIVE,
692            Self::Flying(_) => id::FLYING,
693            Self::Position(_) => id::POSITION,
694            Self::PositionLook(_) => id::POSITION_LOOK,
695            Self::Look(_) => id::LOOK,
696            Self::VehicleMove(_) => id::VEHICLE_MOVE,
697            Self::SteerBoat(_) => id::STEER_BOAT,
698            Self::CraftRecipeRequest(_) => id::CRAFT_RECIPE_REQUEST,
699            Self::Abilities(_) => id::ABILITIES,
700            Self::BlockDig(_) => id::BLOCK_DIG,
701            Self::EntityAction(_) => id::ENTITY_ACTION,
702            Self::SteerVehicle(_) => id::STEER_VEHICLE,
703            Self::CraftingBookData(_) => id::CRAFTING_BOOK_DATA,
704            Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
705            Self::AdvancementTab(_) => id::ADVANCEMENT_TAB,
706            Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
707            Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
708            Self::UpdateSign(_) => id::UPDATE_SIGN,
709            Self::ArmAnimation(_) => id::ARM_ANIMATION,
710            Self::Spectate(_) => id::SPECTATE,
711            Self::BlockPlace(_) => id::BLOCK_PLACE,
712            Self::UseItem(_) => id::USE_ITEM,
713        }
714    }
715    fn name(&self) -> &'static str {
716        match *self {
717            Self::TeleportConfirm(_) => "teleport_confirm",
718            Self::TabComplete(_) => "tab_complete",
719            Self::Chat(_) => "chat",
720            Self::ClientCommand(_) => "client_command",
721            Self::Settings(_) => "settings",
722            Self::Transaction(_) => "transaction",
723            Self::EnchantItem(_) => "enchant_item",
724            Self::WindowClick(_) => "window_click",
725            Self::CloseWindow(_) => "close_window",
726            Self::CustomPayload(_) => "custom_payload",
727            Self::UseEntity(_) => "use_entity",
728            Self::KeepAlive(_) => "keep_alive",
729            Self::Flying(_) => "flying",
730            Self::Position(_) => "position",
731            Self::PositionLook(_) => "position_look",
732            Self::Look(_) => "look",
733            Self::VehicleMove(_) => "vehicle_move",
734            Self::SteerBoat(_) => "steer_boat",
735            Self::CraftRecipeRequest(_) => "craft_recipe_request",
736            Self::Abilities(_) => "abilities",
737            Self::BlockDig(_) => "block_dig",
738            Self::EntityAction(_) => "entity_action",
739            Self::SteerVehicle(_) => "steer_vehicle",
740            Self::CraftingBookData(_) => "crafting_book_data",
741            Self::ResourcePackReceive(_) => "resource_pack_receive",
742            Self::AdvancementTab(_) => "advancement_tab",
743            Self::HeldItemSlot(_) => "held_item_slot",
744            Self::SetCreativeSlot(_) => "set_creative_slot",
745            Self::UpdateSign(_) => "update_sign",
746            Self::ArmAnimation(_) => "arm_animation",
747            Self::Spectate(_) => "spectate",
748            Self::BlockPlace(_) => "block_place",
749            Self::UseItem(_) => "use_item",
750        }
751    }
752    fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
753        match *self {
754            Self::TeleportConfirm(ref p) => p.encode(w),
755            Self::TabComplete(ref p) => p.encode(w),
756            Self::Chat(ref p) => p.encode(w),
757            Self::ClientCommand(ref p) => p.encode(w),
758            Self::Settings(ref p) => p.encode(w),
759            Self::Transaction(ref p) => p.encode(w),
760            Self::EnchantItem(ref p) => p.encode(w),
761            Self::WindowClick(ref p) => p.encode(w),
762            Self::CloseWindow(ref p) => p.encode(w),
763            Self::CustomPayload(ref p) => p.encode(w),
764            Self::UseEntity(ref p) => p.encode(w),
765            Self::KeepAlive(ref p) => p.encode(w),
766            Self::Flying(ref p) => p.encode(w),
767            Self::Position(ref p) => p.encode(w),
768            Self::PositionLook(ref p) => p.encode(w),
769            Self::Look(ref p) => p.encode(w),
770            Self::VehicleMove(ref p) => p.encode(w),
771            Self::SteerBoat(ref p) => p.encode(w),
772            Self::CraftRecipeRequest(ref p) => p.encode(w),
773            Self::Abilities(ref p) => p.encode(w),
774            Self::BlockDig(ref p) => p.encode(w),
775            Self::EntityAction(ref p) => p.encode(w),
776            Self::SteerVehicle(ref p) => p.encode(w),
777            Self::CraftingBookData(ref p) => p.encode(w),
778            Self::ResourcePackReceive(ref p) => p.encode(w),
779            Self::AdvancementTab(ref p) => p.encode(w),
780            Self::HeldItemSlot(ref p) => p.encode(w),
781            Self::SetCreativeSlot(ref p) => p.encode(w),
782            Self::UpdateSign(ref p) => p.encode(w),
783            Self::ArmAnimation(ref p) => p.encode(w),
784            Self::Spectate(ref p) => p.encode(w),
785            Self::BlockPlace(ref p) => p.encode(w),
786            Self::UseItem(ref p) => p.encode(w),
787        }
788    }
789    fn name_of(id: i32) -> Option<&'static str> {
790        match id {
791            id::TELEPORT_CONFIRM => Some("teleport_confirm"),
792            id::TAB_COMPLETE => Some("tab_complete"),
793            id::CHAT => Some("chat"),
794            id::CLIENT_COMMAND => Some("client_command"),
795            id::SETTINGS => Some("settings"),
796            id::TRANSACTION => Some("transaction"),
797            id::ENCHANT_ITEM => Some("enchant_item"),
798            id::WINDOW_CLICK => Some("window_click"),
799            id::CLOSE_WINDOW => Some("close_window"),
800            id::CUSTOM_PAYLOAD => Some("custom_payload"),
801            id::USE_ENTITY => Some("use_entity"),
802            id::KEEP_ALIVE => Some("keep_alive"),
803            id::FLYING => Some("flying"),
804            id::POSITION => Some("position"),
805            id::POSITION_LOOK => Some("position_look"),
806            id::LOOK => Some("look"),
807            id::VEHICLE_MOVE => Some("vehicle_move"),
808            id::STEER_BOAT => Some("steer_boat"),
809            id::CRAFT_RECIPE_REQUEST => Some("craft_recipe_request"),
810            id::ABILITIES => Some("abilities"),
811            id::BLOCK_DIG => Some("block_dig"),
812            id::ENTITY_ACTION => Some("entity_action"),
813            id::STEER_VEHICLE => Some("steer_vehicle"),
814            id::CRAFTING_BOOK_DATA => Some("crafting_book_data"),
815            id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
816            id::ADVANCEMENT_TAB => Some("advancement_tab"),
817            id::HELD_ITEM_SLOT => Some("held_item_slot"),
818            id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
819            id::UPDATE_SIGN => Some("update_sign"),
820            id::ARM_ANIMATION => Some("arm_animation"),
821            id::SPECTATE => Some("spectate"),
822            id::BLOCK_PLACE => Some("block_place"),
823            id::USE_ITEM => Some("use_item"),
824            _ => None,
825        }
826    }
827}
828
829impl ServerboundPlayPacket {
830    /// All packet ids of this set, ascending.
831    pub const IDS: &'static [i32] = &[
832        id::TELEPORT_CONFIRM,
833        id::TAB_COMPLETE,
834        id::CHAT,
835        id::CLIENT_COMMAND,
836        id::SETTINGS,
837        id::TRANSACTION,
838        id::ENCHANT_ITEM,
839        id::WINDOW_CLICK,
840        id::CLOSE_WINDOW,
841        id::CUSTOM_PAYLOAD,
842        id::USE_ENTITY,
843        id::KEEP_ALIVE,
844        id::FLYING,
845        id::POSITION,
846        id::POSITION_LOOK,
847        id::LOOK,
848        id::VEHICLE_MOVE,
849        id::STEER_BOAT,
850        id::CRAFT_RECIPE_REQUEST,
851        id::ABILITIES,
852        id::BLOCK_DIG,
853        id::ENTITY_ACTION,
854        id::STEER_VEHICLE,
855        id::CRAFTING_BOOK_DATA,
856        id::RESOURCE_PACK_RECEIVE,
857        id::ADVANCEMENT_TAB,
858        id::HELD_ITEM_SLOT,
859        id::SET_CREATIVE_SLOT,
860        id::UPDATE_SIGN,
861        id::ARM_ANIMATION,
862        id::SPECTATE,
863        id::BLOCK_PLACE,
864        id::USE_ITEM,
865    ];
866    /// Generates a random packet with the given id (test support).
867    #[cfg(feature = "testgen")]
868    pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
869        match id {
870            id::TELEPORT_CONFIRM => Some(Self::TeleportConfirm(
871                <TeleportConfirm as Generate>::generate(g),
872            )),
873            id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
874            id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
875            id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
876                g,
877            ))),
878            id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
879            id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
880            id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
881            id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
882            id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
883            id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
884                g,
885            ))),
886            id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
887            id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
888            id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
889            id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
890            id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
891            id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
892            id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
893            id::STEER_BOAT => Some(Self::SteerBoat(<SteerBoat as Generate>::generate(g))),
894            id::CRAFT_RECIPE_REQUEST => Some(Self::CraftRecipeRequest(
895                <CraftRecipeRequest as Generate>::generate(g),
896            )),
897            id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
898            id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
899            id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
900            id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
901            id::CRAFTING_BOOK_DATA => Some(Self::CraftingBookData(
902                <CraftingBookData as Generate>::generate(g),
903            )),
904            id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
905                <ResourcePackReceive as Generate>::generate(g),
906            )),
907            id::ADVANCEMENT_TAB => Some(Self::AdvancementTab(
908                <AdvancementTab as Generate>::generate(g),
909            )),
910            id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
911            id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
912                <SetCreativeSlot as Generate>::generate(g),
913            )),
914            id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
915            id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
916            id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
917            id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
918            id::USE_ITEM => Some(Self::UseItem(<UseItem as Generate>::generate(g))),
919            _ => None,
920        }
921    }
922}