#![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};
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct SettingsParticleStatus(pub i32);
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl SettingsParticleStatus {
pub const ALL: Self = Self(0);
pub const DECREASED: Self = Self(1);
pub const MINIMAL: Self = Self(2);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("all"),
1 => Some("decreased"),
2 => Some("minimal"),
_ => None,
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl std::fmt::Debug for SettingsParticleStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SettingsParticleStatus::{n}"),
None => write!(f, "SettingsParticleStatus({})", self.0),
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Settings<const V: i32> {
pub locale: ByteString,
pub view_distance: i8,
pub chat_flags: i32,
pub chat_colors: bool,
pub skin_parts: u8,
pub main_hand: i32,
pub enable_text_filtering: bool,
pub enable_server_listing: bool,
pub particle_status: crate::defs::p775::configuration::serverbound::SettingsParticleStatus,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for Settings<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = r.read_varint()?;
let v4 = r.read_bool()?;
let v5 = r.read_u8()?;
let v6 = r.read_varint()?;
let v7 = r.read_bool()?;
let v8 = r.read_bool()?;
let v9 = crate::defs::p775::configuration::serverbound::SettingsParticleStatus(
r.read_varint()?,
);
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
main_hand: v6,
enable_text_filtering: v7,
enable_server_listing: v8,
particle_status: v9,
}
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for Settings<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).locale)?;
w.put_i8((*self).view_distance);
w.put_varint((*self).chat_flags);
w.put_bool((*self).chat_colors);
w.put_u8((*self).skin_parts);
w.put_varint((*self).main_hand);
w.put_bool((*self).enable_text_filtering);
w.put_bool((*self).enable_server_listing);
w.put_varint((*self).particle_status.0);
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Settings<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.bool();
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v7 = g.bool();
let v8 = g.bool();
let v9 = crate::defs::p775::configuration::serverbound::SettingsParticleStatus(
g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32,
);
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
main_hand: v6,
enable_text_filtering: v7,
enable_server_listing: v8,
particle_status: v9,
}
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct CookieResponse<const V: i32> {
pub key: ByteString,
pub value: Option<Bytes>,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for CookieResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = if r.read_bool()? {
Some(r.read_byte_array()?)
} else {
None
};
Self { key: v1, value: v2 }
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for CookieResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).key)?;
match &(*self).value {
Some(v1) => {
w.put_u8(1);
w.put_byte_array(&(*v1))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CookieResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = if g.bool() { Some(g.bytes()) } else { None };
Self { key: v1, value: v2 }
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomPayload<const V: i32> {
pub channel: ByteString,
pub data: Bytes,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for CustomPayload<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_rest();
Self {
channel: v1,
data: v2,
}
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for CustomPayload<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).channel)?;
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CustomPayload<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.bytes();
Self {
channel: v1,
data: v2,
}
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct FinishConfiguration<const V: i32> {}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for FinishConfiguration<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for FinishConfiguration<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for FinishConfiguration<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive<const V: i32> {
pub keep_alive_id: i64,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for KeepAlive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i64()?;
Self { keep_alive_id: v1 }
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for KeepAlive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).keep_alive_id);
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for KeepAlive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.i64();
Self { keep_alive_id: v1 }
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Pong<const V: i32> {
pub id: i32,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for Pong<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
Self { id: v1 }
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for Pong<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).id);
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Pong<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { id: v1 }
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackReceive<const V: i32> {
pub uuid: Uuid,
pub result: i32,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for ResourcePackReceive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
let v2 = r.read_varint()?;
Self {
uuid: v1,
result: v2,
}
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for ResourcePackReceive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).uuid);
w.put_varint((*self).result);
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ResourcePackReceive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
uuid: v1,
result: v2,
}
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SelectKnownPacksPacks {
pub namespace: ByteString,
pub id: ByteString,
pub version: ByteString,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SelectKnownPacks<const V: i32> {
pub packs: Vec<crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks>,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for SelectKnownPacks<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = r.read_string()?;
let v5 = r.read_string()?;
let v6 = r.read_string()?;
crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks {
namespace: v4,
id: v5,
version: v6,
}
});
}
v3
};
Self { packs: v1 }
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for SelectKnownPacks<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).packs.len())?;
for v1 in (*self).packs.iter() {
w.put_string(&(*v1).namespace)?;
w.put_string(&(*v1).id)?;
w.put_string(&(*v1).version)?;
}
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SelectKnownPacks<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = g.string();
let v5 = g.string();
let v6 = g.string();
crate::defs::p775::configuration::serverbound::SelectKnownPacksPacks {
namespace: v4,
id: v5,
version: v6,
}
});
}
v3
};
Self { packs: v1 }
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomClickAction<const V: i32> {
pub id: ByteString,
pub nbt: Option<AnonNbt>,
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for CustomClickAction<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
Self { id: v1, nbt: v2 }
})
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for CustomClickAction<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).id)?;
match &(*self).nbt {
Some(v1) => {
w.put_u8(1);
(*v1).write(w);
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CustomClickAction<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = if g.bool() { Some(g.anon_nbt()) } else { None };
Self { id: v1, nbt: v2 }
}
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct AcceptCodeOfConduct<const V: i32> {}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for AcceptCodeOfConduct<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for AcceptCodeOfConduct<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(any(feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AcceptCodeOfConduct<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}