#![allow(
unused_imports,
unused_variables,
unused_mut,
unused_parens,
unused_braces,
clippy::all,
clippy::pedantic,
non_camel_case_types,
non_snake_case
)]
use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
use crate::error::{DecodeError, EncodeError};
use crate::nbt::{AnonNbt, RawNbt};
use crate::packet::{Direction, PacketSet, RawPacket, State};
#[cfg(feature = "testgen")]
use crate::testgen::{Gen, Generate};
use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
use bytes::{BufMut, Bytes, BytesMut};
pub mod id {
pub const TELEPORT_CONFIRM: i32 = 0x00;
pub const TAB_COMPLETE: i32 = 0x01;
pub const CHAT: i32 = 0x02;
pub const CLIENT_COMMAND: i32 = 0x03;
pub const SETTINGS: i32 = 0x04;
pub const TRANSACTION: i32 = 0x05;
pub const ENCHANT_ITEM: i32 = 0x06;
pub const WINDOW_CLICK: i32 = 0x07;
pub const CLOSE_WINDOW: i32 = 0x08;
pub const CUSTOM_PAYLOAD: i32 = 0x09;
pub const USE_ENTITY: i32 = 0x0a;
pub const KEEP_ALIVE: i32 = 0x0b;
pub const FLYING: i32 = 0x0c;
pub const POSITION: i32 = 0x0d;
pub const POSITION_LOOK: i32 = 0x0e;
pub const LOOK: i32 = 0x0f;
pub const VEHICLE_MOVE: i32 = 0x10;
pub const STEER_BOAT: i32 = 0x11;
pub const CRAFT_RECIPE_REQUEST: i32 = 0x12;
pub const ABILITIES: i32 = 0x13;
pub const BLOCK_DIG: i32 = 0x14;
pub const ENTITY_ACTION: i32 = 0x15;
pub const STEER_VEHICLE: i32 = 0x16;
pub const CRAFTING_BOOK_DATA: i32 = 0x17;
pub const RESOURCE_PACK_RECEIVE: i32 = 0x18;
pub const ADVANCEMENT_TAB: i32 = 0x19;
pub const HELD_ITEM_SLOT: i32 = 0x1a;
pub const SET_CREATIVE_SLOT: i32 = 0x1b;
pub const UPDATE_SIGN: i32 = 0x1c;
pub const ARM_ANIMATION: i32 = 0x1d;
pub const SPECTATE: i32 = 0x1e;
pub const BLOCK_PLACE: i32 = 0x1f;
pub const USE_ITEM: i32 = 0x20;
}
pub use crate::defs::p340::play::serverbound::ClientCommandActionId;
pub use crate::defs::p340::play::serverbound::CraftingBookDataBody;
pub use crate::defs::p340::play::serverbound::CraftingBookDataBodyCase0;
pub use crate::defs::p340::play::serverbound::CraftingBookDataBodyCase1;
pub use crate::defs::p340::play::serverbound::EntityActionActionId;
pub type TeleportConfirm = crate::defs::p340::play::serverbound::TeleportConfirm<340>;
impl crate::packet::Packet for TeleportConfirm {
const ID: i32 = id::TELEPORT_CONFIRM;
const NAME: &'static str = "teleport_confirm";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<TeleportConfirm> for ServerboundPlayPacket {
fn from(p: TeleportConfirm) -> Self {
Self::TeleportConfirm(p)
}
}
pub type TabComplete = crate::defs::p340::play::serverbound::TabComplete<340>;
impl crate::packet::Packet for TabComplete {
const ID: i32 = id::TAB_COMPLETE;
const NAME: &'static str = "tab_complete";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<TabComplete> for ServerboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(p)
}
}
pub type Chat = crate::defs::p47::play::serverbound::Chat<340>;
impl crate::packet::Packet for Chat {
const ID: i32 = id::CHAT;
const NAME: &'static str = "chat";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Chat> for ServerboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
pub type ClientCommand = crate::defs::p340::play::serverbound::ClientCommand<340>;
impl crate::packet::Packet for ClientCommand {
const ID: i32 = id::CLIENT_COMMAND;
const NAME: &'static str = "client_command";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<ClientCommand> for ServerboundPlayPacket {
fn from(p: ClientCommand) -> Self {
Self::ClientCommand(p)
}
}
pub type Settings = crate::defs::p340::play::serverbound::Settings<340>;
impl crate::packet::Packet for Settings {
const ID: i32 = id::SETTINGS;
const NAME: &'static str = "settings";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Settings> for ServerboundPlayPacket {
fn from(p: Settings) -> Self {
Self::Settings(p)
}
}
pub type Transaction = crate::defs::p47::play::serverbound::Transaction<340>;
impl crate::packet::Packet for Transaction {
const ID: i32 = id::TRANSACTION;
const NAME: &'static str = "transaction";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Transaction> for ServerboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(p)
}
}
pub type EnchantItem = crate::defs::p47::play::serverbound::EnchantItem<340>;
impl crate::packet::Packet for EnchantItem {
const ID: i32 = id::ENCHANT_ITEM;
const NAME: &'static str = "enchant_item";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<EnchantItem> for ServerboundPlayPacket {
fn from(p: EnchantItem) -> Self {
Self::EnchantItem(p)
}
}
pub type WindowClick = crate::defs::p47::play::serverbound::WindowClick<340>;
impl crate::packet::Packet for WindowClick {
const ID: i32 = id::WINDOW_CLICK;
const NAME: &'static str = "window_click";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<WindowClick> for ServerboundPlayPacket {
fn from(p: WindowClick) -> Self {
Self::WindowClick(p)
}
}
pub type CloseWindow = crate::defs::p47::play::serverbound::CloseWindow<340>;
impl crate::packet::Packet for CloseWindow {
const ID: i32 = id::CLOSE_WINDOW;
const NAME: &'static str = "close_window";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CloseWindow> for ServerboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(p)
}
}
pub type CustomPayload = crate::defs::p47::play::serverbound::CustomPayload<340>;
impl crate::packet::Packet for CustomPayload {
const ID: i32 = id::CUSTOM_PAYLOAD;
const NAME: &'static str = "custom_payload";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CustomPayload> for ServerboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
pub type UseEntity = crate::defs::p340::play::serverbound::UseEntity<340>;
impl crate::packet::Packet for UseEntity {
const ID: i32 = id::USE_ENTITY;
const NAME: &'static str = "use_entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<UseEntity> for ServerboundPlayPacket {
fn from(p: UseEntity) -> Self {
Self::UseEntity(p)
}
}
pub type KeepAlive = crate::defs::p340::play::serverbound::KeepAlive<340>;
impl crate::packet::Packet for KeepAlive {
const ID: i32 = id::KEEP_ALIVE;
const NAME: &'static str = "keep_alive";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<KeepAlive> for ServerboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
pub type Flying = crate::defs::p47::play::serverbound::Flying<340>;
impl crate::packet::Packet for Flying {
const ID: i32 = id::FLYING;
const NAME: &'static str = "flying";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Flying> for ServerboundPlayPacket {
fn from(p: Flying) -> Self {
Self::Flying(p)
}
}
pub type Position = crate::defs::p47::play::serverbound::Position<340>;
impl crate::packet::Packet for Position {
const ID: i32 = id::POSITION;
const NAME: &'static str = "position";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Position> for ServerboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(p)
}
}
pub type PositionLook = crate::defs::p47::play::serverbound::PositionLook<340>;
impl crate::packet::Packet for PositionLook {
const ID: i32 = id::POSITION_LOOK;
const NAME: &'static str = "position_look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<PositionLook> for ServerboundPlayPacket {
fn from(p: PositionLook) -> Self {
Self::PositionLook(p)
}
}
pub type Look = crate::defs::p47::play::serverbound::Look<340>;
impl crate::packet::Packet for Look {
const ID: i32 = id::LOOK;
const NAME: &'static str = "look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Look> for ServerboundPlayPacket {
fn from(p: Look) -> Self {
Self::Look(p)
}
}
pub type VehicleMove = crate::defs::p340::play::serverbound::VehicleMove<340>;
impl crate::packet::Packet for VehicleMove {
const ID: i32 = id::VEHICLE_MOVE;
const NAME: &'static str = "vehicle_move";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<VehicleMove> for ServerboundPlayPacket {
fn from(p: VehicleMove) -> Self {
Self::VehicleMove(p)
}
}
pub type SteerBoat = crate::defs::p340::play::serverbound::SteerBoat<340>;
impl crate::packet::Packet for SteerBoat {
const ID: i32 = id::STEER_BOAT;
const NAME: &'static str = "steer_boat";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<SteerBoat> for ServerboundPlayPacket {
fn from(p: SteerBoat) -> Self {
Self::SteerBoat(p)
}
}
pub type CraftRecipeRequest = crate::defs::p340::play::serverbound::CraftRecipeRequest<340>;
impl crate::packet::Packet for CraftRecipeRequest {
const ID: i32 = id::CRAFT_RECIPE_REQUEST;
const NAME: &'static str = "craft_recipe_request";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CraftRecipeRequest> for ServerboundPlayPacket {
fn from(p: CraftRecipeRequest) -> Self {
Self::CraftRecipeRequest(p)
}
}
pub type Abilities = crate::defs::p47::play::serverbound::Abilities<340>;
impl crate::packet::Packet for Abilities {
const ID: i32 = id::ABILITIES;
const NAME: &'static str = "abilities";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Abilities> for ServerboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(p)
}
}
pub type BlockDig = crate::defs::p47::play::serverbound::BlockDig<340>;
impl crate::packet::Packet for BlockDig {
const ID: i32 = id::BLOCK_DIG;
const NAME: &'static str = "block_dig";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<BlockDig> for ServerboundPlayPacket {
fn from(p: BlockDig) -> Self {
Self::BlockDig(p)
}
}
pub type EntityAction = crate::defs::p340::play::serverbound::EntityAction<340>;
impl crate::packet::Packet for EntityAction {
const ID: i32 = id::ENTITY_ACTION;
const NAME: &'static str = "entity_action";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<EntityAction> for ServerboundPlayPacket {
fn from(p: EntityAction) -> Self {
Self::EntityAction(p)
}
}
pub type SteerVehicle = crate::defs::p47::play::serverbound::SteerVehicle<340>;
impl crate::packet::Packet for SteerVehicle {
const ID: i32 = id::STEER_VEHICLE;
const NAME: &'static str = "steer_vehicle";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<SteerVehicle> for ServerboundPlayPacket {
fn from(p: SteerVehicle) -> Self {
Self::SteerVehicle(p)
}
}
pub type CraftingBookData = crate::defs::p340::play::serverbound::CraftingBookData<340>;
impl crate::packet::Packet for CraftingBookData {
const ID: i32 = id::CRAFTING_BOOK_DATA;
const NAME: &'static str = "crafting_book_data";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CraftingBookData> for ServerboundPlayPacket {
fn from(p: CraftingBookData) -> Self {
Self::CraftingBookData(p)
}
}
pub type ResourcePackReceive = crate::defs::p340::play::serverbound::ResourcePackReceive<340>;
impl crate::packet::Packet for ResourcePackReceive {
const ID: i32 = id::RESOURCE_PACK_RECEIVE;
const NAME: &'static str = "resource_pack_receive";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<ResourcePackReceive> for ServerboundPlayPacket {
fn from(p: ResourcePackReceive) -> Self {
Self::ResourcePackReceive(p)
}
}
pub type AdvancementTab = crate::defs::p340::play::serverbound::AdvancementTab<340>;
impl crate::packet::Packet for AdvancementTab {
const ID: i32 = id::ADVANCEMENT_TAB;
const NAME: &'static str = "advancement_tab";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<AdvancementTab> for ServerboundPlayPacket {
fn from(p: AdvancementTab) -> Self {
Self::AdvancementTab(p)
}
}
pub type HeldItemSlot = crate::defs::p47::play::serverbound::HeldItemSlot<340>;
impl crate::packet::Packet for HeldItemSlot {
const ID: i32 = id::HELD_ITEM_SLOT;
const NAME: &'static str = "held_item_slot";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<HeldItemSlot> for ServerboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(p)
}
}
pub type SetCreativeSlot = crate::defs::p47::play::serverbound::SetCreativeSlot<340>;
impl crate::packet::Packet for SetCreativeSlot {
const ID: i32 = id::SET_CREATIVE_SLOT;
const NAME: &'static str = "set_creative_slot";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<SetCreativeSlot> for ServerboundPlayPacket {
fn from(p: SetCreativeSlot) -> Self {
Self::SetCreativeSlot(p)
}
}
pub type UpdateSign = crate::defs::p47::play::serverbound::UpdateSign<340>;
impl crate::packet::Packet for UpdateSign {
const ID: i32 = id::UPDATE_SIGN;
const NAME: &'static str = "update_sign";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<UpdateSign> for ServerboundPlayPacket {
fn from(p: UpdateSign) -> Self {
Self::UpdateSign(p)
}
}
pub type ArmAnimation = crate::defs::p340::play::serverbound::ArmAnimation<340>;
impl crate::packet::Packet for ArmAnimation {
const ID: i32 = id::ARM_ANIMATION;
const NAME: &'static str = "arm_animation";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<ArmAnimation> for ServerboundPlayPacket {
fn from(p: ArmAnimation) -> Self {
Self::ArmAnimation(p)
}
}
pub type Spectate = crate::defs::p47::play::serverbound::Spectate<340>;
impl crate::packet::Packet for Spectate {
const ID: i32 = id::SPECTATE;
const NAME: &'static str = "spectate";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Spectate> for ServerboundPlayPacket {
fn from(p: Spectate) -> Self {
Self::Spectate(p)
}
}
pub type BlockPlace = crate::defs::p340::play::serverbound::BlockPlace<340>;
impl crate::packet::Packet for BlockPlace {
const ID: i32 = id::BLOCK_PLACE;
const NAME: &'static str = "block_place";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<BlockPlace> for ServerboundPlayPacket {
fn from(p: BlockPlace) -> Self {
Self::BlockPlace(p)
}
}
pub type UseItem = crate::defs::p340::play::serverbound::UseItem<340>;
impl crate::packet::Packet for UseItem {
const ID: i32 = id::USE_ITEM;
const NAME: &'static str = "use_item";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<UseItem> for ServerboundPlayPacket {
fn from(p: UseItem) -> Self {
Self::UseItem(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ServerboundPlayPacket {
TeleportConfirm(TeleportConfirm),
TabComplete(TabComplete),
Chat(Chat),
ClientCommand(ClientCommand),
Settings(Settings),
Transaction(Transaction),
EnchantItem(EnchantItem),
WindowClick(WindowClick),
CloseWindow(CloseWindow),
CustomPayload(CustomPayload),
UseEntity(UseEntity),
KeepAlive(KeepAlive),
Flying(Flying),
Position(Position),
PositionLook(PositionLook),
Look(Look),
VehicleMove(VehicleMove),
SteerBoat(SteerBoat),
CraftRecipeRequest(CraftRecipeRequest),
Abilities(Abilities),
BlockDig(BlockDig),
EntityAction(EntityAction),
SteerVehicle(SteerVehicle),
CraftingBookData(CraftingBookData),
ResourcePackReceive(ResourcePackReceive),
AdvancementTab(AdvancementTab),
HeldItemSlot(HeldItemSlot),
SetCreativeSlot(SetCreativeSlot),
UpdateSign(UpdateSign),
ArmAnimation(ArmAnimation),
Spectate(Spectate),
BlockPlace(BlockPlace),
UseItem(UseItem),
}
impl PacketSet for ServerboundPlayPacket {
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
match raw.id {
id::TELEPORT_CONFIRM => decode_exact(&raw.body).map(Self::TeleportConfirm),
id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::FLYING => decode_exact(&raw.body).map(Self::Flying),
id::POSITION => decode_exact(&raw.body).map(Self::Position),
id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
id::LOOK => decode_exact(&raw.body).map(Self::Look),
id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
id::STEER_BOAT => decode_exact(&raw.body).map(Self::SteerBoat),
id::CRAFT_RECIPE_REQUEST => decode_exact(&raw.body).map(Self::CraftRecipeRequest),
id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
id::CRAFTING_BOOK_DATA => decode_exact(&raw.body).map(Self::CraftingBookData),
id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
id::ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::AdvancementTab),
id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
id::USE_ITEM => decode_exact(&raw.body).map(Self::UseItem),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::TeleportConfirm(_) => id::TELEPORT_CONFIRM,
Self::TabComplete(_) => id::TAB_COMPLETE,
Self::Chat(_) => id::CHAT,
Self::ClientCommand(_) => id::CLIENT_COMMAND,
Self::Settings(_) => id::SETTINGS,
Self::Transaction(_) => id::TRANSACTION,
Self::EnchantItem(_) => id::ENCHANT_ITEM,
Self::WindowClick(_) => id::WINDOW_CLICK,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::UseEntity(_) => id::USE_ENTITY,
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::Flying(_) => id::FLYING,
Self::Position(_) => id::POSITION,
Self::PositionLook(_) => id::POSITION_LOOK,
Self::Look(_) => id::LOOK,
Self::VehicleMove(_) => id::VEHICLE_MOVE,
Self::SteerBoat(_) => id::STEER_BOAT,
Self::CraftRecipeRequest(_) => id::CRAFT_RECIPE_REQUEST,
Self::Abilities(_) => id::ABILITIES,
Self::BlockDig(_) => id::BLOCK_DIG,
Self::EntityAction(_) => id::ENTITY_ACTION,
Self::SteerVehicle(_) => id::STEER_VEHICLE,
Self::CraftingBookData(_) => id::CRAFTING_BOOK_DATA,
Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
Self::AdvancementTab(_) => id::ADVANCEMENT_TAB,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
Self::UpdateSign(_) => id::UPDATE_SIGN,
Self::ArmAnimation(_) => id::ARM_ANIMATION,
Self::Spectate(_) => id::SPECTATE,
Self::BlockPlace(_) => id::BLOCK_PLACE,
Self::UseItem(_) => id::USE_ITEM,
}
}
fn name(&self) -> &'static str {
match *self {
Self::TeleportConfirm(_) => "teleport_confirm",
Self::TabComplete(_) => "tab_complete",
Self::Chat(_) => "chat",
Self::ClientCommand(_) => "client_command",
Self::Settings(_) => "settings",
Self::Transaction(_) => "transaction",
Self::EnchantItem(_) => "enchant_item",
Self::WindowClick(_) => "window_click",
Self::CloseWindow(_) => "close_window",
Self::CustomPayload(_) => "custom_payload",
Self::UseEntity(_) => "use_entity",
Self::KeepAlive(_) => "keep_alive",
Self::Flying(_) => "flying",
Self::Position(_) => "position",
Self::PositionLook(_) => "position_look",
Self::Look(_) => "look",
Self::VehicleMove(_) => "vehicle_move",
Self::SteerBoat(_) => "steer_boat",
Self::CraftRecipeRequest(_) => "craft_recipe_request",
Self::Abilities(_) => "abilities",
Self::BlockDig(_) => "block_dig",
Self::EntityAction(_) => "entity_action",
Self::SteerVehicle(_) => "steer_vehicle",
Self::CraftingBookData(_) => "crafting_book_data",
Self::ResourcePackReceive(_) => "resource_pack_receive",
Self::AdvancementTab(_) => "advancement_tab",
Self::HeldItemSlot(_) => "held_item_slot",
Self::SetCreativeSlot(_) => "set_creative_slot",
Self::UpdateSign(_) => "update_sign",
Self::ArmAnimation(_) => "arm_animation",
Self::Spectate(_) => "spectate",
Self::BlockPlace(_) => "block_place",
Self::UseItem(_) => "use_item",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::TeleportConfirm(ref p) => p.encode(w),
Self::TabComplete(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::ClientCommand(ref p) => p.encode(w),
Self::Settings(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::EnchantItem(ref p) => p.encode(w),
Self::WindowClick(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::UseEntity(ref p) => p.encode(w),
Self::KeepAlive(ref p) => p.encode(w),
Self::Flying(ref p) => p.encode(w),
Self::Position(ref p) => p.encode(w),
Self::PositionLook(ref p) => p.encode(w),
Self::Look(ref p) => p.encode(w),
Self::VehicleMove(ref p) => p.encode(w),
Self::SteerBoat(ref p) => p.encode(w),
Self::CraftRecipeRequest(ref p) => p.encode(w),
Self::Abilities(ref p) => p.encode(w),
Self::BlockDig(ref p) => p.encode(w),
Self::EntityAction(ref p) => p.encode(w),
Self::SteerVehicle(ref p) => p.encode(w),
Self::CraftingBookData(ref p) => p.encode(w),
Self::ResourcePackReceive(ref p) => p.encode(w),
Self::AdvancementTab(ref p) => p.encode(w),
Self::HeldItemSlot(ref p) => p.encode(w),
Self::SetCreativeSlot(ref p) => p.encode(w),
Self::UpdateSign(ref p) => p.encode(w),
Self::ArmAnimation(ref p) => p.encode(w),
Self::Spectate(ref p) => p.encode(w),
Self::BlockPlace(ref p) => p.encode(w),
Self::UseItem(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::TELEPORT_CONFIRM => Some("teleport_confirm"),
id::TAB_COMPLETE => Some("tab_complete"),
id::CHAT => Some("chat"),
id::CLIENT_COMMAND => Some("client_command"),
id::SETTINGS => Some("settings"),
id::TRANSACTION => Some("transaction"),
id::ENCHANT_ITEM => Some("enchant_item"),
id::WINDOW_CLICK => Some("window_click"),
id::CLOSE_WINDOW => Some("close_window"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::USE_ENTITY => Some("use_entity"),
id::KEEP_ALIVE => Some("keep_alive"),
id::FLYING => Some("flying"),
id::POSITION => Some("position"),
id::POSITION_LOOK => Some("position_look"),
id::LOOK => Some("look"),
id::VEHICLE_MOVE => Some("vehicle_move"),
id::STEER_BOAT => Some("steer_boat"),
id::CRAFT_RECIPE_REQUEST => Some("craft_recipe_request"),
id::ABILITIES => Some("abilities"),
id::BLOCK_DIG => Some("block_dig"),
id::ENTITY_ACTION => Some("entity_action"),
id::STEER_VEHICLE => Some("steer_vehicle"),
id::CRAFTING_BOOK_DATA => Some("crafting_book_data"),
id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
id::ADVANCEMENT_TAB => Some("advancement_tab"),
id::HELD_ITEM_SLOT => Some("held_item_slot"),
id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
id::UPDATE_SIGN => Some("update_sign"),
id::ARM_ANIMATION => Some("arm_animation"),
id::SPECTATE => Some("spectate"),
id::BLOCK_PLACE => Some("block_place"),
id::USE_ITEM => Some("use_item"),
_ => None,
}
}
}
impl ServerboundPlayPacket {
pub const IDS: &'static [i32] = &[
id::TELEPORT_CONFIRM,
id::TAB_COMPLETE,
id::CHAT,
id::CLIENT_COMMAND,
id::SETTINGS,
id::TRANSACTION,
id::ENCHANT_ITEM,
id::WINDOW_CLICK,
id::CLOSE_WINDOW,
id::CUSTOM_PAYLOAD,
id::USE_ENTITY,
id::KEEP_ALIVE,
id::FLYING,
id::POSITION,
id::POSITION_LOOK,
id::LOOK,
id::VEHICLE_MOVE,
id::STEER_BOAT,
id::CRAFT_RECIPE_REQUEST,
id::ABILITIES,
id::BLOCK_DIG,
id::ENTITY_ACTION,
id::STEER_VEHICLE,
id::CRAFTING_BOOK_DATA,
id::RESOURCE_PACK_RECEIVE,
id::ADVANCEMENT_TAB,
id::HELD_ITEM_SLOT,
id::SET_CREATIVE_SLOT,
id::UPDATE_SIGN,
id::ARM_ANIMATION,
id::SPECTATE,
id::BLOCK_PLACE,
id::USE_ITEM,
];
#[cfg(feature = "testgen")]
pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
match id {
id::TELEPORT_CONFIRM => Some(Self::TeleportConfirm(
<TeleportConfirm as Generate>::generate(g),
)),
id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
g,
))),
id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
id::STEER_BOAT => Some(Self::SteerBoat(<SteerBoat as Generate>::generate(g))),
id::CRAFT_RECIPE_REQUEST => Some(Self::CraftRecipeRequest(
<CraftRecipeRequest as Generate>::generate(g),
)),
id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
id::CRAFTING_BOOK_DATA => Some(Self::CraftingBookData(
<CraftingBookData as Generate>::generate(g),
)),
id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
<ResourcePackReceive as Generate>::generate(g),
)),
id::ADVANCEMENT_TAB => Some(Self::AdvancementTab(
<AdvancementTab as Generate>::generate(g),
)),
id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
<SetCreativeSlot as Generate>::generate(g),
)),
id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
id::USE_ITEM => Some(Self::UseItem(<UseItem as Generate>::generate(g))),
_ => None,
}
}
}