#![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(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CookieRequest<const V: i32> {
pub cookie: ByteString,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CookieRequest<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
Self { cookie: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CookieRequest<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).cookie)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CookieRequest<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
Self { cookie: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomPayload<const V: i32> {
pub channel: ByteString,
pub data: Bytes,
}
#[cfg(feature = "v26_1")]
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(feature = "v26_1")]
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(feature = "v26_1")]
#[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(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct Disconnect<const V: i32> {
pub reason: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Disconnect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
Self { reason: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Disconnect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).reason.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Disconnect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { reason: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct FinishConfiguration<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for FinishConfiguration<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for FinishConfiguration<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for FinishConfiguration<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive<const V: i32> {
pub keep_alive_id: i64,
}
#[cfg(feature = "v26_1")]
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(feature = "v26_1")]
impl<const V: i32> Encode for KeepAlive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).keep_alive_id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[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(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct Ping<const V: i32> {
pub id: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Ping<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
Self { id: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Ping<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Ping<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { id: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct ResetChat<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ResetChat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ResetChat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ResetChat<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct RegistryDataEntries {
pub key: ByteString,
pub value: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct RegistryData<const V: i32> {
pub id: ByteString,
pub entries: Vec<crate::defs::p775::configuration::clientbound::RegistryDataEntries>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RegistryData<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = r.read_string()?;
let v6 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
crate::defs::p775::configuration::clientbound::RegistryDataEntries {
key: v5,
value: v6,
}
});
}
v4
};
Self {
id: v1,
entries: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RegistryData<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).id)?;
w.put_len_varint((*self).entries.len())?;
for v1 in (*self).entries.iter() {
w.put_string(&(*v1).key)?;
match &(*v1).value {
Some(v2) => {
w.put_u8(1);
(*v2).write(w);
}
None => w.put_u8(0),
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RegistryData<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = g.string();
let v6 = if g.bool() { Some(g.anon_nbt()) } else { None };
crate::defs::p775::configuration::clientbound::RegistryDataEntries {
key: v5,
value: v6,
}
});
}
v4
};
Self {
id: v1,
entries: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct RemoveResourcePack<const V: i32> {
pub uuid: Option<Uuid>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RemoveResourcePack<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
};
Self { uuid: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RemoveResourcePack<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).uuid {
Some(v1) => {
w.put_u8(1);
w.put_uuid(&(*v1));
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RemoveResourcePack<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = if g.bool() { Some(g.uuid()) } else { None };
Self { uuid: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct AddResourcePack<const V: i32> {
pub uuid: Uuid,
pub url: ByteString,
pub hash: ByteString,
pub forced: bool,
pub prompt_message: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for AddResourcePack<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
let v2 = r.read_string()?;
let v3 = r.read_string()?;
let v4 = r.read_bool()?;
let v5 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
Self {
uuid: v1,
url: v2,
hash: v3,
forced: v4,
prompt_message: v5,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for AddResourcePack<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).uuid);
w.put_string(&(*self).url)?;
w.put_string(&(*self).hash)?;
w.put_bool((*self).forced);
match &(*self).prompt_message {
Some(v1) => {
w.put_u8(1);
(*v1).write(w);
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AddResourcePack<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
let v2 = g.string();
let v3 = g.string();
let v4 = g.bool();
let v5 = if g.bool() { Some(g.anon_nbt()) } else { None };
Self {
uuid: v1,
url: v2,
hash: v3,
forced: v4,
prompt_message: v5,
}
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct StoreCookie<const V: i32> {
pub key: ByteString,
pub value: Bytes,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for StoreCookie<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_byte_array()?;
Self { key: v1, value: v2 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for StoreCookie<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).key)?;
w.put_byte_array(&(*self).value)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for StoreCookie<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.bytes();
Self { key: v1, value: v2 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct Transfer<const V: i32> {
pub host: ByteString,
pub port: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Transfer<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_varint()?;
Self { host: v1, port: v2 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Transfer<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).host)?;
w.put_varint((*self).port);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Transfer<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { host: v1, port: v2 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct FeatureFlags<const V: i32> {
pub features: Vec<ByteString>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for FeatureFlags<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(r.read_string()?);
}
v3
};
Self { features: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for FeatureFlags<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).features.len())?;
for v1 in (*self).features.iter() {
w.put_string(&(*v1))?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for FeatureFlags<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(g.string());
}
v3
};
Self { features: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct TagsTags {
pub tag_type: ByteString,
pub tags: Vec<crate::defs::p754::types::Tags>,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct Tags<const V: i32> {
pub tags: Vec<crate::defs::p775::configuration::clientbound::TagsTags>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Tags<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
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 = {
let v6 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push({
let v8 = r.read_string()?;
let v9 = {
let v10 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v11 = Vec::with_capacity(
v10.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v10 {
v11.push(r.read_varint()?);
}
v11
};
crate::defs::p754::types::Tags {
tag_name: v8,
entries: v9,
}
});
}
v7
};
crate::defs::p775::configuration::clientbound::TagsTags {
tag_type: v4,
tags: v5,
}
});
}
v3
};
Self { tags: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Tags<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).tags.len())?;
for v1 in (*self).tags.iter() {
w.put_string(&(*v1).tag_type)?;
w.put_len_varint((*v1).tags.len())?;
for v2 in (*v1).tags.iter() {
w.put_string(&(*v2).tag_name)?;
w.put_len_varint((*v2).entries.len())?;
for v3 in (*v2).entries.iter() {
w.put_varint((*v3));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Tags<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 = {
let v6 = g.count();
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push({
let v8 = g.string();
let v9 = {
let v10 = g.count();
let mut v11 = Vec::with_capacity(
v10.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v10 {
v11.push(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
);
}
v11
};
crate::defs::p754::types::Tags {
tag_name: v8,
entries: v9,
}
});
}
v7
};
crate::defs::p775::configuration::clientbound::TagsTags {
tag_type: v4,
tags: v5,
}
});
}
v3
};
Self { tags: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct SelectKnownPacksPacks {
pub namespace: ByteString,
pub id: ByteString,
pub version: ByteString,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct SelectKnownPacks<const V: i32> {
pub packs: Vec<crate::defs::p775::configuration::clientbound::SelectKnownPacksPacks>,
}
#[cfg(feature = "v26_1")]
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::clientbound::SelectKnownPacksPacks {
namespace: v4,
id: v5,
version: v6,
}
});
}
v3
};
Self { packs: v1 }
})
}
}
#[cfg(feature = "v26_1")]
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(feature = "v26_1")]
#[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::clientbound::SelectKnownPacksPacks {
namespace: v4,
id: v5,
version: v6,
}
});
}
v3
};
Self { packs: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomReportDetailsDetails {
pub key: ByteString,
pub value: ByteString,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomReportDetails<const V: i32> {
pub details: Vec<crate::defs::p775::configuration::clientbound::CustomReportDetailsDetails>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CustomReportDetails<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
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()?;
crate::defs::p775::configuration::clientbound::CustomReportDetailsDetails {
key: v4,
value: v5,
}
});
}
v3
};
Self { details: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CustomReportDetails<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).details.len())?;
for v1 in (*self).details.iter() {
w.put_string(&(*v1).key)?;
w.put_string(&(*v1).value)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CustomReportDetails<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();
crate::defs::p775::configuration::clientbound::CustomReportDetailsDetails {
key: v4,
value: v5,
}
});
}
v3
};
Self { details: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct ServerLinksLinks {
pub has_known_type: bool,
pub known_type: Option<crate::defs::p775::types::ServerLinkType>,
pub unknown_type: Option<AnonNbt>,
pub link: ByteString,
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct ServerLinks<const V: i32> {
pub links: Vec<crate::defs::p775::configuration::clientbound::ServerLinksLinks>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ServerLinks<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = r.read_bool()?;
let v5 = if v4 {
Some(crate::defs::p775::types::ServerLinkType(r.read_varint()?))
} else {
None
};
let v6 = if (!v4) { Some(AnonNbt::read(r)?) } else { None };
let v7 = r.read_string()?;
crate::defs::p775::configuration::clientbound::ServerLinksLinks {
has_known_type: v4,
known_type: v5,
unknown_type: v6,
link: v7,
}
});
}
v3
};
Self { links: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ServerLinks<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).links.len())?;
for v1 in (*self).links.iter() {
w.put_bool((*v1).has_known_type);
match (&(*v1).known_type, (*v1).has_known_type) {
(Some(v2), true) => {
w.put_varint((*v2).0);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"configuration.clientbound.server_links.links.knownType",
));
}
}
match (&(*v1).unknown_type, (!(*v1).has_known_type)) {
(Some(v3), true) => {
(*v3).write(w);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"configuration.clientbound.server_links.links.unknownType",
));
}
}
w.put_string(&(*v1).link)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ServerLinks<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.bool();
let v5 = if v4 {
Some(crate::defs::p775::types::ServerLinkType(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
)
as i32))
} else {
None
};
let v6 = if (!v4) { Some(g.anon_nbt()) } else { None };
let v7 = g.string();
crate::defs::p775::configuration::clientbound::ServerLinksLinks {
has_known_type: v4,
known_type: v5,
unknown_type: v6,
link: v7,
}
});
}
v3
};
Self { links: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct ClearDialog<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ClearDialog<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ClearDialog<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ClearDialog<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct ShowDialog<const V: i32> {
pub dialog: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ShowDialog<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
Self { dialog: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ShowDialog<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).dialog.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ShowDialog<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { dialog: v1 }
}
}
}
#[cfg(feature = "v26_1")]
#[derive(Debug, Clone, PartialEq)]
pub struct CodeOfConduct<const V: i32> {
pub contents: ByteString,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CodeOfConduct<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
Self { contents: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CodeOfConduct<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).contents)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CodeOfConduct<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
Self { contents: v1 }
}
}
}