#![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 SETTINGS: i32 = 0x00;
pub const COOKIE_RESPONSE: i32 = 0x01;
pub const CUSTOM_PAYLOAD: i32 = 0x02;
pub const FINISH_CONFIGURATION: i32 = 0x03;
pub const KEEP_ALIVE: i32 = 0x04;
pub const PONG: i32 = 0x05;
pub const RESOURCE_PACK_RECEIVE: i32 = 0x06;
pub const SELECT_KNOWN_PACKS: i32 = 0x07;
pub const CUSTOM_CLICK_ACTION: i32 = 0x08;
pub const ACCEPT_CODE_OF_CONDUCT: i32 = 0x09;
}
pub use crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks;
pub use crate::defs::p775::configuration::serverbound::SettingsParticleStatus;
pub type Settings = crate::defs::p775::configuration::serverbound::Settings<775>;
impl crate::packet::Packet for Settings {
const ID: i32 = id::SETTINGS;
const NAME: &'static str = "settings";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Settings> for ServerboundConfigurationPacket {
fn from(p: Settings) -> Self {
Self::Settings(p)
}
}
pub type CookieResponse = crate::defs::p775::configuration::serverbound::CookieResponse<775>;
impl crate::packet::Packet for CookieResponse {
const ID: i32 = id::COOKIE_RESPONSE;
const NAME: &'static str = "cookie_response";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CookieResponse> for ServerboundConfigurationPacket {
fn from(p: CookieResponse) -> Self {
Self::CookieResponse(p)
}
}
pub type CustomPayload = crate::defs::p775::configuration::serverbound::CustomPayload<775>;
impl crate::packet::Packet for CustomPayload {
const ID: i32 = id::CUSTOM_PAYLOAD;
const NAME: &'static str = "custom_payload";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CustomPayload> for ServerboundConfigurationPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
pub type FinishConfiguration =
crate::defs::p775::configuration::serverbound::FinishConfiguration<775>;
impl crate::packet::Packet for FinishConfiguration {
const ID: i32 = id::FINISH_CONFIGURATION;
const NAME: &'static str = "finish_configuration";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<FinishConfiguration> for ServerboundConfigurationPacket {
fn from(p: FinishConfiguration) -> Self {
Self::FinishConfiguration(p)
}
}
pub type KeepAlive = crate::defs::p775::configuration::serverbound::KeepAlive<775>;
impl crate::packet::Packet for KeepAlive {
const ID: i32 = id::KEEP_ALIVE;
const NAME: &'static str = "keep_alive";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<KeepAlive> for ServerboundConfigurationPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
pub type Pong = crate::defs::p775::configuration::serverbound::Pong<775>;
impl crate::packet::Packet for Pong {
const ID: i32 = id::PONG;
const NAME: &'static str = "pong";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<Pong> for ServerboundConfigurationPacket {
fn from(p: Pong) -> Self {
Self::Pong(p)
}
}
pub type ResourcePackReceive =
crate::defs::p775::configuration::serverbound::ResourcePackReceive<775>;
impl crate::packet::Packet for ResourcePackReceive {
const ID: i32 = id::RESOURCE_PACK_RECEIVE;
const NAME: &'static str = "resource_pack_receive";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<ResourcePackReceive> for ServerboundConfigurationPacket {
fn from(p: ResourcePackReceive) -> Self {
Self::ResourcePackReceive(p)
}
}
pub type SelectKnownPacks = crate::defs::p775::configuration::serverbound::SelectKnownPacks<775>;
impl crate::packet::Packet for SelectKnownPacks {
const ID: i32 = id::SELECT_KNOWN_PACKS;
const NAME: &'static str = "select_known_packs";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<SelectKnownPacks> for ServerboundConfigurationPacket {
fn from(p: SelectKnownPacks) -> Self {
Self::SelectKnownPacks(p)
}
}
pub type CustomClickAction = crate::defs::p775::configuration::serverbound::CustomClickAction<775>;
impl crate::packet::Packet for CustomClickAction {
const ID: i32 = id::CUSTOM_CLICK_ACTION;
const NAME: &'static str = "custom_click_action";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<CustomClickAction> for ServerboundConfigurationPacket {
fn from(p: CustomClickAction) -> Self {
Self::CustomClickAction(p)
}
}
pub type AcceptCodeOfConduct =
crate::defs::p775::configuration::serverbound::AcceptCodeOfConduct<775>;
impl crate::packet::Packet for AcceptCodeOfConduct {
const ID: i32 = id::ACCEPT_CODE_OF_CONDUCT;
const NAME: &'static str = "accept_code_of_conduct";
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
}
impl From<AcceptCodeOfConduct> for ServerboundConfigurationPacket {
fn from(p: AcceptCodeOfConduct) -> Self {
Self::AcceptCodeOfConduct(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ServerboundConfigurationPacket {
Settings(Settings),
CookieResponse(CookieResponse),
CustomPayload(CustomPayload),
FinishConfiguration(FinishConfiguration),
KeepAlive(KeepAlive),
Pong(Pong),
ResourcePackReceive(ResourcePackReceive),
SelectKnownPacks(SelectKnownPacks),
CustomClickAction(CustomClickAction),
AcceptCodeOfConduct(AcceptCodeOfConduct),
}
impl PacketSet for ServerboundConfigurationPacket {
const STATE: State = State::Configuration;
const DIRECTION: Direction = Direction::Serverbound;
fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
match raw.id {
id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
id::COOKIE_RESPONSE => decode_exact(&raw.body).map(Self::CookieResponse),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::FINISH_CONFIGURATION => decode_exact(&raw.body).map(Self::FinishConfiguration),
id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::PONG => decode_exact(&raw.body).map(Self::Pong),
id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
id::SELECT_KNOWN_PACKS => decode_exact(&raw.body).map(Self::SelectKnownPacks),
id::CUSTOM_CLICK_ACTION => decode_exact(&raw.body).map(Self::CustomClickAction),
id::ACCEPT_CODE_OF_CONDUCT => decode_exact(&raw.body).map(Self::AcceptCodeOfConduct),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::Settings(_) => id::SETTINGS,
Self::CookieResponse(_) => id::COOKIE_RESPONSE,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::FinishConfiguration(_) => id::FINISH_CONFIGURATION,
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::Pong(_) => id::PONG,
Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
Self::SelectKnownPacks(_) => id::SELECT_KNOWN_PACKS,
Self::CustomClickAction(_) => id::CUSTOM_CLICK_ACTION,
Self::AcceptCodeOfConduct(_) => id::ACCEPT_CODE_OF_CONDUCT,
}
}
fn name(&self) -> &'static str {
match *self {
Self::Settings(_) => "settings",
Self::CookieResponse(_) => "cookie_response",
Self::CustomPayload(_) => "custom_payload",
Self::FinishConfiguration(_) => "finish_configuration",
Self::KeepAlive(_) => "keep_alive",
Self::Pong(_) => "pong",
Self::ResourcePackReceive(_) => "resource_pack_receive",
Self::SelectKnownPacks(_) => "select_known_packs",
Self::CustomClickAction(_) => "custom_click_action",
Self::AcceptCodeOfConduct(_) => "accept_code_of_conduct",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::Settings(ref p) => p.encode(w),
Self::CookieResponse(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::FinishConfiguration(ref p) => p.encode(w),
Self::KeepAlive(ref p) => p.encode(w),
Self::Pong(ref p) => p.encode(w),
Self::ResourcePackReceive(ref p) => p.encode(w),
Self::SelectKnownPacks(ref p) => p.encode(w),
Self::CustomClickAction(ref p) => p.encode(w),
Self::AcceptCodeOfConduct(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::SETTINGS => Some("settings"),
id::COOKIE_RESPONSE => Some("cookie_response"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::FINISH_CONFIGURATION => Some("finish_configuration"),
id::KEEP_ALIVE => Some("keep_alive"),
id::PONG => Some("pong"),
id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
id::SELECT_KNOWN_PACKS => Some("select_known_packs"),
id::CUSTOM_CLICK_ACTION => Some("custom_click_action"),
id::ACCEPT_CODE_OF_CONDUCT => Some("accept_code_of_conduct"),
_ => None,
}
}
}
impl ServerboundConfigurationPacket {
pub const IDS: &'static [i32] = &[
id::SETTINGS,
id::COOKIE_RESPONSE,
id::CUSTOM_PAYLOAD,
id::FINISH_CONFIGURATION,
id::KEEP_ALIVE,
id::PONG,
id::RESOURCE_PACK_RECEIVE,
id::SELECT_KNOWN_PACKS,
id::CUSTOM_CLICK_ACTION,
id::ACCEPT_CODE_OF_CONDUCT,
];
#[cfg(feature = "testgen")]
pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
match id {
id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
id::COOKIE_RESPONSE => Some(Self::CookieResponse(
<CookieResponse as Generate>::generate(g),
)),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::FINISH_CONFIGURATION => Some(Self::FinishConfiguration(
<FinishConfiguration as Generate>::generate(g),
)),
id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
id::PONG => Some(Self::Pong(<Pong as Generate>::generate(g))),
id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
<ResourcePackReceive as Generate>::generate(g),
)),
id::SELECT_KNOWN_PACKS => Some(Self::SelectKnownPacks(
<SelectKnownPacks as Generate>::generate(g),
)),
id::CUSTOM_CLICK_ACTION => Some(Self::CustomClickAction(
<CustomClickAction as Generate>::generate(g),
)),
id::ACCEPT_CODE_OF_CONDUCT => Some(Self::AcceptCodeOfConduct(
<AcceptCodeOfConduct as Generate>::generate(g),
)),
_ => None,
}
}
}