// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/26.1/protocol.json). Do not edit; run `cargo run -p ghast-codegen-protocol`.
// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
// in crates/ghast-protocol/src/generated/.
//! Clientbound packets of the play state.
#![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")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct ChatTypeParameterType(pub i32);
#[cfg(feature = "v26_1")]
impl ChatTypeParameterType {
/// `content`
pub const CONTENT: Self = Self(0);
/// `sender`
pub const SENDER: Self = Self(1);
/// `target`
pub const TARGET: Self = Self(2);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("content"),
1 => Some("sender"),
2 => Some("target"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for ChatTypeParameterType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "ChatTypeParameterType::{n}"),
None => write!(f, "ChatTypeParameterType({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `ChatType`.
#[derive(Debug, Clone, PartialEq)]
pub struct ChatType {
/// `translationKey`
pub translation_key: ByteString,
/// `parameters`
pub parameters: Vec<crate::defs::p775::play::clientbound::ChatTypeParameterType>,
/// `style`
pub style: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl Decode for ChatType {
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), 1)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(crate::defs::p775::play::clientbound::ChatTypeParameterType(
r.read_varint()?,
));
}
v4
};
let v5 = AnonNbt::read(r)?;
Self {
translation_key: v1,
parameters: v2,
style: v5,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for ChatType {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).translation_key)?;
w.put_len_varint((*self).parameters.len())?;
for v1 in (*self).parameters.iter() {
w.put_varint((*v1).0);
}
(*self).style.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for ChatType {
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(crate::defs::p775::play::clientbound::ChatTypeParameterType(
g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32,
));
}
v4
};
let v5 = g.anon_nbt();
Self {
translation_key: v1,
parameters: v2,
style: v5,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `ChatTypes`.
#[derive(Debug, Clone, PartialEq)]
pub struct ChatTypes {
/// `chat`
pub chat: crate::defs::p775::play::clientbound::ChatType,
/// `narration`
pub narration: crate::defs::p775::play::clientbound::ChatType,
}
#[cfg(feature = "v26_1")]
impl Decode for ChatTypes {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::play::clientbound::ChatType as Decode>::decode(r)?;
let v2 = <crate::defs::p775::play::clientbound::ChatType as Decode>::decode(r)?;
Self {
chat: v1,
narration: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for ChatTypes {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).chat.encode(w)?;
(*self).narration.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for ChatTypes {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::play::clientbound::ChatType as Generate>::generate(g);
let v2 = <crate::defs::p775::play::clientbound::ChatType as Generate>::generate(g);
Self {
chat: v1,
narration: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `ExplosionParticleEntry`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleEntry {
/// `data`
pub data: crate::defs::p775::play::clientbound::ExplosionParticleInfo,
/// `weight`
pub weight: i32,
}
#[cfg(feature = "v26_1")]
impl Decode for ExplosionParticleEntry {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 =
<crate::defs::p775::play::clientbound::ExplosionParticleInfo as Decode>::decode(r)?;
let v2 = r.read_varint()?;
Self {
data: v1,
weight: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for ExplosionParticleEntry {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).data.encode(w)?;
w.put_varint((*self).weight);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleEntry {
fn generate(g: &mut Gen) -> Self {
{
let v1 =
<crate::defs::p775::play::clientbound::ExplosionParticleInfo as Generate>::generate(
g,
);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
data: v1,
weight: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `ExplosionParticleInfo`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleInfo {
/// `particle`
pub particle: crate::defs::p775::types::Particle,
/// `scaling`
pub scaling: f32,
/// `speed`
pub speed: f32,
}
#[cfg(feature = "v26_1")]
impl Decode for ExplosionParticleInfo {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::Particle as Decode>::decode(r)?;
let v2 = r.read_f32()?;
let v3 = r.read_f32()?;
Self {
particle: v1,
scaling: v2,
speed: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for ExplosionParticleInfo {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).particle.encode(w)?;
w.put_f32((*self).scaling);
w.put_f32((*self).speed);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleInfo {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::Particle as Generate>::generate(g);
let v2 = g.f32();
let v3 = g.f32();
Self {
particle: v1,
scaling: v2,
speed: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `RecipeBookSetting`.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookSetting {
/// `open`
pub open: bool,
/// `filtering`
pub filtering: bool,
}
#[cfg(feature = "v26_1")]
impl Decode for RecipeBookSetting {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
let v2 = r.read_bool()?;
Self {
open: v1,
filtering: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for RecipeBookSetting {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).open);
w.put_bool((*self).filtering);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for RecipeBookSetting {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
let v2 = g.bool();
Self {
open: v1,
filtering: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct RecipeDisplayType(pub i32);
#[cfg(feature = "v26_1")]
impl RecipeDisplayType {
/// `crafting_shapeless`
pub const CRAFTING_SHAPELESS: Self = Self(0);
/// `crafting_shaped`
pub const CRAFTING_SHAPED: Self = Self(1);
/// `furnace`
pub const FURNACE: Self = Self(2);
/// `stonecutter`
pub const STONECUTTER: Self = Self(3);
/// `smithing`
pub const SMITHING: Self = Self(4);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("crafting_shapeless"),
1 => Some("crafting_shaped"),
2 => Some("furnace"),
3 => Some("stonecutter"),
4 => Some("smithing"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for RecipeDisplayType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "RecipeDisplayType::{n}"),
None => write!(f, "RecipeDisplayType({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShapeless {
/// `ingredients`
pub ingredients: Vec<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p775::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p775::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShaped {
/// `width`
pub width: i32,
/// `height`
pub height: i32,
/// `ingredients`
pub ingredients: Vec<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p775::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p775::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataFurnace {
/// `ingredient`
pub ingredient: crate::defs::p775::play::clientbound::SlotDisplay,
/// `fuel`
pub fuel: crate::defs::p775::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p775::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p775::play::clientbound::SlotDisplay,
/// `duration`
pub duration: i32,
/// `experience`
pub experience: f32,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataStonecutter {
/// `ingredient`
pub ingredient: crate::defs::p775::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p775::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p775::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataSmithing {
/// `template`
pub template: crate::defs::p775::play::clientbound::SlotDisplay,
/// `base`
pub base: crate::defs::p775::play::clientbound::SlotDisplay,
/// `addition`
pub addition: crate::defs::p775::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p775::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p775::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_1")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
pub enum RecipeDisplayData {
/// Case(s) `crafting_shapeless`.
CraftingShapeless(crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShapeless),
/// Case(s) `crafting_shaped`.
CraftingShaped(crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShaped),
/// Case(s) `furnace`.
Furnace(crate::defs::p775::play::clientbound::RecipeDisplayDataFurnace),
/// Case(s) `stonecutter`.
Stonecutter(crate::defs::p775::play::clientbound::RecipeDisplayDataStonecutter),
/// Case(s) `smithing`.
Smithing(crate::defs::p775::play::clientbound::RecipeDisplayDataSmithing),
/// Any other value.
Other,
}
#[cfg(feature = "v26_1")]
/// Named type `RecipeDisplay`.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplay {
/// `type`
pub r#type: crate::defs::p775::play::clientbound::RecipeDisplayType,
/// `data`
pub data: crate::defs::p775::play::clientbound::RecipeDisplayData,
}
#[cfg(feature = "v26_1")]
impl Decode for RecipeDisplay {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::RecipeDisplayType(r.read_varint()?);
let v2 = (if (v1.0 == 0) {
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShapeless({
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v5
};
let v6 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v7 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShaped({
let v8 = r.read_varint()?;
let v9 = r.read_varint()?;
let v10 = {
let v11 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v12
};
let v13 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v14 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v16 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v17 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v18 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v19 = r.read_varint()?;
let v20 = r.read_f32()?;
crate::defs::p775::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v22 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v23 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p775::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v25 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v26 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v27 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v28 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p775::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p775::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for RecipeDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShapeless(v1) => {
if !((*self).r#type.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
w.put_len_varint((*v1).ingredients.len())?;
for v2 in (*v1).ingredients.iter() {
(*v2).encode(w)?;
}
(*v1).result.encode(w)?;
(*v1).crafting_station.encode(w)?;
}
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShaped(v3) => {
if !((*self).r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
w.put_varint((*v3).width);
w.put_varint((*v3).height);
w.put_len_varint((*v3).ingredients.len())?;
for v4 in (*v3).ingredients.iter() {
(*v4).encode(w)?;
}
(*v3).result.encode(w)?;
(*v3).crafting_station.encode(w)?;
}
crate::defs::p775::play::clientbound::RecipeDisplayData::Furnace(v5) => {
if !((*self).r#type.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
(*v5).ingredient.encode(w)?;
(*v5).fuel.encode(w)?;
(*v5).result.encode(w)?;
(*v5).crafting_station.encode(w)?;
w.put_varint((*v5).duration);
w.put_f32((*v5).experience);
}
crate::defs::p775::play::clientbound::RecipeDisplayData::Stonecutter(v6) => {
if !((*self).r#type.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
(*v6).ingredient.encode(w)?;
(*v6).result.encode(w)?;
(*v6).crafting_station.encode(w)?;
}
crate::defs::p775::play::clientbound::RecipeDisplayData::Smithing(v7) => {
if !((*self).r#type.0 == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
(*v7).template.encode(w)?;
(*v7).base.encode(w)?;
(*v7).addition.encode(w)?;
(*v7).result.encode(w)?;
(*v7).crafting_station.encode(w)?;
}
crate::defs::p775::play::clientbound::RecipeDisplayData::Other => {
if !(!(((*self).r#type.0 == 0)
|| ((*self).r#type.0 == 1)
|| ((*self).r#type.0 == 2)
|| ((*self).r#type.0 == 3)
|| ((*self).r#type.0 == 4)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.RecipeDisplay.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for RecipeDisplay {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::RecipeDisplayType(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4],
) as i32);
let v2 = (if (v1.0 == 0) {
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShapeless({
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v5
};
let v6 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v7 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p775::play::clientbound::RecipeDisplayData::CraftingShaped({
let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v10 = {
let v11 = g.count();
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v12
};
let v13 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v14 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p775::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v16 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v17 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v18 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v20 = g.f32();
crate::defs::p775::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v22 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v23 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p775::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p775::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v25 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v26 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v27 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v28 =
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p775::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p775::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct SlotDisplayType(pub i32);
#[cfg(feature = "v26_1")]
impl SlotDisplayType {
/// `empty`
pub const EMPTY: Self = Self(0);
/// `any_fuel`
pub const ANY_FUEL: Self = Self(1);
/// `with_any_potion`
pub const WITH_ANY_POTION: Self = Self(2);
/// `only_with_component`
pub const ONLY_WITH_COMPONENT: Self = Self(3);
/// `item`
pub const ITEM: Self = Self(4);
/// `item_stack`
pub const ITEM_STACK: Self = Self(5);
/// `tag`
pub const TAG: Self = Self(6);
/// `dyed_slot_demo`
pub const DYED_SLOT_DEMO: Self = Self(7);
/// `smithing_trim`
pub const SMITHING_TRIM: Self = Self(8);
/// `with_remainder`
pub const WITH_REMAINDER: Self = Self(9);
/// `composite`
pub const COMPOSITE: Self = Self(10);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("empty"),
1 => Some("any_fuel"),
2 => Some("with_any_potion"),
3 => Some("only_with_component"),
4 => Some("item"),
5 => Some("item_stack"),
6 => Some("tag"),
7 => Some("dyed_slot_demo"),
8 => Some("smithing_trim"),
9 => Some("with_remainder"),
10 => Some("composite"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for SlotDisplayType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SlotDisplayType::{n}"),
None => write!(f, "SlotDisplayType({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithAnyPotion {
/// `base`
pub base: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataOnlyWithComponent {
/// `source`
pub source: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `component`
pub component: crate::defs::p775::types::SlotComponentType,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataDyedSlotDemo {
/// `dye`
pub dye: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `target`
pub target: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataSmithingTrim {
/// `base`
pub base: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `material`
pub material: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `pattern`
pub pattern: Holder<crate::defs::p775::types::ArmorTrimPattern>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithRemainder {
/// `input`
pub input: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
/// `remainder`
pub remainder: Box<crate::defs::p775::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_1")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
pub enum SlotDisplayData {
/// Case(s) `empty`.
Empty,
/// Case(s) `any_fuel`.
AnyFuel,
/// Case(s) `with_any_potion`.
WithAnyPotion(crate::defs::p775::play::clientbound::SlotDisplayDataWithAnyPotion),
/// Case(s) `only_with_component`.
OnlyWithComponent(crate::defs::p775::play::clientbound::SlotDisplayDataOnlyWithComponent),
/// Case(s) `item`.
Item(i32),
/// Case(s) `item_stack`.
ItemStack(crate::defs::p775::types::ItemStackTemplate),
/// Case(s) `tag`.
Tag(ByteString),
/// Case(s) `dyed_slot_demo`.
DyedSlotDemo(crate::defs::p775::play::clientbound::SlotDisplayDataDyedSlotDemo),
/// Case(s) `smithing_trim`.
SmithingTrim(crate::defs::p775::play::clientbound::SlotDisplayDataSmithingTrim),
/// Case(s) `with_remainder`.
WithRemainder(crate::defs::p775::play::clientbound::SlotDisplayDataWithRemainder),
/// Case(s) `composite`.
Composite(Vec<crate::defs::p775::play::clientbound::SlotDisplay>),
/// Any other value.
Other,
}
#[cfg(feature = "v26_1")]
/// Named type `SlotDisplay`.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplay {
/// `type`
pub r#type: crate::defs::p775::play::clientbound::SlotDisplayType,
/// `data`
pub data: crate::defs::p775::play::clientbound::SlotDisplayData,
}
#[cfg(feature = "v26_1")]
impl Decode for SlotDisplay {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::SlotDisplayType(r.read_varint()?);
let v2 = (if (v1.0 == 0) {
crate::defs::p775::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p775::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p775::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p775::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p775::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v5 = crate::defs::p775::types::SlotComponentType(r.read_varint()?);
crate::defs::p775::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p775::play::clientbound::SlotDisplayData::Item(r.read_varint()?)
} else if (v1.0 == 5) {
crate::defs::p775::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p775::types::ItemStackTemplate as Decode>::decode(r)?,
)
} else if (v1.0 == 6) {
crate::defs::p775::play::clientbound::SlotDisplayData::Tag(r.read_string()?)
} else if (v1.0 == 7) {
crate::defs::p775::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v7 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p775::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p775::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v9 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v10 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(
<crate::defs::p775::types::ArmorTrimPattern as Decode>::decode(r)?,
)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
crate::defs::p775::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p775::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v12 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p775::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p775::play::clientbound::SlotDisplayData::Composite({
let v13 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push(
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?,
);
}
v14
})
} else {
crate::defs::p775::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for SlotDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p775::play::clientbound::SlotDisplayData::Empty => {
if !((*self).r#type.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p775::play::clientbound::SlotDisplayData::AnyFuel => {
if !((*self).r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p775::play::clientbound::SlotDisplayData::WithAnyPotion(v1) => {
if !((*self).r#type.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*(*v1).base).encode(w)?;
}
crate::defs::p775::play::clientbound::SlotDisplayData::OnlyWithComponent(v2) => {
if !((*self).r#type.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*(*v2).source).encode(w)?;
w.put_varint((*v2).component.0);
}
crate::defs::p775::play::clientbound::SlotDisplayData::Item(v3) => {
if !((*self).r#type.0 == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
w.put_varint((*v3));
}
crate::defs::p775::play::clientbound::SlotDisplayData::ItemStack(v4) => {
if !((*self).r#type.0 == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*v4).encode(w)?;
}
crate::defs::p775::play::clientbound::SlotDisplayData::Tag(v5) => {
if !((*self).r#type.0 == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
w.put_string(&(*v5))?;
}
crate::defs::p775::play::clientbound::SlotDisplayData::DyedSlotDemo(v6) => {
if !((*self).r#type.0 == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*(*v6).dye).encode(w)?;
(*(*v6).target).encode(w)?;
}
crate::defs::p775::play::clientbound::SlotDisplayData::SmithingTrim(v7) => {
if !((*self).r#type.0 == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*(*v7).base).encode(w)?;
(*(*v7).material).encode(w)?;
match &(*v7).pattern {
Holder::Id(v9) => {
if *v9 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v9.wrapping_add(1));
}
Holder::Inline(v8) => {
w.put_varint(0);
(*v8).encode(w)?;
}
}
}
crate::defs::p775::play::clientbound::SlotDisplayData::WithRemainder(v10) => {
if !((*self).r#type.0 == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*(*v10).input).encode(w)?;
(*(*v10).remainder).encode(w)?;
}
crate::defs::p775::play::clientbound::SlotDisplayData::Composite(v11) => {
if !((*self).r#type.0 == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
w.put_len_varint((*v11).len())?;
for v12 in (*v11).iter() {
(*v12).encode(w)?;
}
}
crate::defs::p775::play::clientbound::SlotDisplayData::Other => {
if !(!(((*self).r#type.0 == 0)
|| ((*self).r#type.0 == 1)
|| ((*self).r#type.0 == 2)
|| ((*self).r#type.0 == 3)
|| ((*self).r#type.0 == 4)
|| ((*self).r#type.0 == 5)
|| ((*self).r#type.0 == 6)
|| ((*self).r#type.0 == 7)
|| ((*self).r#type.0 == 8)
|| ((*self).r#type.0 == 9)
|| ((*self).r#type.0 == 10)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for SlotDisplay {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::SlotDisplayType(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
) as i32);
let v2 = (if (v1.0 == 0) {
crate::defs::p775::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p775::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p775::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p775::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p775::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v5 = crate::defs::p775::types::SlotComponentType(g.int_in(
-2147483648,
2147483647,
&[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109,
],
)
as i32);
crate::defs::p775::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p775::play::clientbound::SlotDisplayData::Item(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v1.0 == 5) {
crate::defs::p775::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p775::types::ItemStackTemplate as Generate>::generate(g),
)
} else if (v1.0 == 6) {
crate::defs::p775::play::clientbound::SlotDisplayData::Tag(g.string())
} else if (v1.0 == 7) {
crate::defs::p775::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v7 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p775::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p775::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v9 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v10 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(
<crate::defs::p775::types::ArmorTrimPattern as Generate>::generate(g),
)
};
crate::defs::p775::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p775::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v12 = Box::new(
<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p775::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p775::play::clientbound::SlotDisplayData::Composite({
let v13 = g.count();
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push(<crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v14
})
} else {
crate::defs::p775::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct SpawnInfoGamemode(pub i8);
#[cfg(feature = "v26_1")]
impl SpawnInfoGamemode {
/// `survival`
pub const SURVIVAL: Self = Self(0);
/// `creative`
pub const CREATIVE: Self = Self(1);
/// `adventure`
pub const ADVENTURE: Self = Self(2);
/// `spectator`
pub const SPECTATOR: Self = Self(3);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("survival"),
1 => Some("creative"),
2 => Some("adventure"),
3 => Some("spectator"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for SpawnInfoGamemode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SpawnInfoGamemode::{n}"),
None => write!(f, "SpawnInfoGamemode({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Named type `SpawnInfo`.
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnInfo {
/// `dimension`
pub dimension: i32,
/// `name`
pub name: ByteString,
/// `hashedSeed`
pub hashed_seed: i64,
/// `gamemode`
pub gamemode: crate::defs::p775::play::clientbound::SpawnInfoGamemode,
/// `previousGamemode`
pub previous_gamemode: u8,
/// `isDebug`
pub is_debug: bool,
/// `isFlat`
pub is_flat: bool,
/// `death`
pub death: Option<crate::defs::p775::types::GlobalPos>,
/// `portalCooldown`
pub portal_cooldown: i32,
/// `seaLevel`
pub sea_level: i32,
}
#[cfg(feature = "v26_1")]
impl Decode for SpawnInfo {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_string()?;
let v3 = r.read_i64()?;
let v4 = crate::defs::p775::play::clientbound::SpawnInfoGamemode(r.read_i8()?);
let v5 = r.read_u8()?;
let v6 = r.read_bool()?;
let v7 = r.read_bool()?;
let v8 = if r.read_bool()? {
Some(<crate::defs::p775::types::GlobalPos as Decode>::decode(r)?)
} else {
None
};
let v9 = r.read_varint()?;
let v10 = r.read_varint()?;
Self {
dimension: v1,
name: v2,
hashed_seed: v3,
gamemode: v4,
previous_gamemode: v5,
is_debug: v6,
is_flat: v7,
death: v8,
portal_cooldown: v9,
sea_level: v10,
}
})
}
}
#[cfg(feature = "v26_1")]
impl Encode for SpawnInfo {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).dimension);
w.put_string(&(*self).name)?;
w.put_i64((*self).hashed_seed);
w.put_i8((*self).gamemode.0);
w.put_u8((*self).previous_gamemode);
w.put_bool((*self).is_debug);
w.put_bool((*self).is_flat);
match &(*self).death {
Some(v1) => {
w.put_u8(1);
(*v1).encode(w)?;
}
None => w.put_u8(0),
}
w.put_varint((*self).portal_cooldown);
w.put_varint((*self).sea_level);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl Generate for SpawnInfo {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.string();
let v3 = g.i64();
let v4 = crate::defs::p775::play::clientbound::SpawnInfoGamemode(g.int_in(
-128,
127,
&[0, 1, 2, 3],
) as i8);
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = g.bool();
let v7 = g.bool();
let v8 = if g.bool() {
Some(<crate::defs::p775::types::GlobalPos as Generate>::generate(
g,
))
} else {
None
};
let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
dimension: v1,
name: v2,
hashed_seed: v3,
gamemode: v4,
previous_gamemode: v5,
is_debug: v6,
is_flat: v7,
death: v8,
portal_cooldown: v9,
sea_level: v10,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `bundle_delimiter` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BundleDelimiter<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for BundleDelimiter<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for BundleDelimiter<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BundleDelimiter<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
/// `spawn_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `objectUUID`
pub object_uuid: Uuid,
/// `type`
pub r#type: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `velocity`
pub velocity: LpVec3,
/// `pitch`
pub pitch: i8,
/// `yaw`
pub yaw: i8,
/// `headPitch`
pub head_pitch: i8,
/// `objectData`
pub object_data: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SpawnEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_varint()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = LpVec3::read(r)?;
let v8 = r.read_i8()?;
let v9 = r.read_i8()?;
let v10 = r.read_i8()?;
let v11 = r.read_varint()?;
Self {
entity_id: v1,
object_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
velocity: v7,
pitch: v8,
yaw: v9,
head_pitch: v10,
object_data: v11,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SpawnEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).object_uuid);
w.put_varint((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
(*self).velocity.write(w);
w.put_i8((*self).pitch);
w.put_i8((*self).yaw);
w.put_i8((*self).head_pitch);
w.put_varint((*self).object_data);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = <LpVec3 as Generate>::generate(g);
let v8 = (g.int_in(-128, 127, &[]) as i8);
let v9 = (g.int_in(-128, 127, &[]) as i8);
let v10 = (g.int_in(-128, 127, &[]) as i8);
let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
entity_id: v1,
object_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
velocity: v7,
pitch: v8,
yaw: v9,
head_pitch: v10,
object_data: v11,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `acknowledge_player_digging` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct AcknowledgePlayerDigging<const V: i32> {
/// `sequenceId`
pub sequence_id: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for AcknowledgePlayerDigging<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { sequence_id: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for AcknowledgePlayerDigging<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).sequence_id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AcknowledgePlayerDigging<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { sequence_id: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `tile_entity_data` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TileEntityData<const V: i32> {
/// `location`
pub location: BlockPos,
/// `action`
pub action: i32,
/// `nbtData`
pub nbt_data: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for TileEntityData<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_varint()?;
let v3 = AnonNbt::read_optional(r)?;
Self {
location: v1,
action: v2,
nbt_data: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for TileEntityData<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).action);
AnonNbt::write_optional(&(*self).nbt_data, w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TileEntityData<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.anon_opt_nbt();
Self {
location: v1,
action: v2,
nbt_data: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `boss_bar` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BossBar<const V: i32> {
/// `entityUUID`
pub entity_uuid: Uuid,
/// `action`
pub action: i32,
/// `title`
pub title: Option<AnonNbt>,
/// `health`
pub health: Option<f32>,
/// `color`
pub color: Option<i32>,
/// `dividers`
pub dividers: Option<i32>,
/// `flags`
pub flags: Option<u8>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for BossBar<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
let v2 = r.read_varint()?;
let v3 = if (v2 == 0) || (v2 == 3) {
Some(AnonNbt::read(r)?)
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 5) {
Some(r.read_u8()?)
} else {
None
};
Self {
entity_uuid: v1,
action: v2,
title: v3,
health: v4,
color: v5,
dividers: v6,
flags: v7,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for BossBar<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).action);
match (
&(*self).title,
((*self).action == 0) || ((*self).action == 3),
) {
(Some(v1), true) => {
(*v1).write(w);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.title",
));
}
}
match (
&(*self).health,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v2), true) => {
w.put_f32((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.health",
));
}
}
match (
&(*self).color,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v3), true) => {
w.put_varint((*v3));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.color",
));
}
}
match (
&(*self).dividers,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v4), true) => {
w.put_varint((*v4));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.dividers",
));
}
}
match (
&(*self).flags,
((*self).action == 0) || ((*self).action == 5),
) {
(Some(v5), true) => {
w.put_u8((*v5));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.flags",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BossBar<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
let v2 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
let v3 = if (v2 == 0) || (v2 == 3) {
Some(g.anon_nbt())
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(g.f32())
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 5) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
Self {
entity_uuid: v1,
action: v2,
title: v3,
health: v4,
color: v5,
dividers: v6,
flags: v7,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct DifficultyDifficulty(pub i32);
#[cfg(feature = "v26_1")]
impl DifficultyDifficulty {
/// `peaceful`
pub const PEACEFUL: Self = Self(0);
/// `easy`
pub const EASY: Self = Self(1);
/// `normal`
pub const NORMAL: Self = Self(2);
/// `hard`
pub const HARD: Self = Self(3);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("peaceful"),
1 => Some("easy"),
2 => Some("normal"),
3 => Some("hard"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for DifficultyDifficulty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "DifficultyDifficulty::{n}"),
None => write!(f, "DifficultyDifficulty({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// `difficulty` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Difficulty<const V: i32> {
/// `difficulty`
pub difficulty: crate::defs::p775::play::clientbound::DifficultyDifficulty,
/// `difficultyLocked`
pub difficulty_locked: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Difficulty<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::DifficultyDifficulty(r.read_varint()?);
let v2 = r.read_bool()?;
Self {
difficulty: v1,
difficulty_locked: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Difficulty<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).difficulty.0);
w.put_bool((*self).difficulty_locked);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Difficulty<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::DifficultyDifficulty(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3],
)
as i32);
let v2 = g.bool();
Self {
difficulty: v1,
difficulty_locked: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `chunk_batch_finished` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ChunkBatchFinished<const V: i32> {
/// `batchSize`
pub batch_size: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ChunkBatchFinished<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { batch_size: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ChunkBatchFinished<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).batch_size);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ChunkBatchFinished<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { batch_size: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `chunk_batch_start` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ChunkBatchStart<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ChunkBatchStart<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ChunkBatchStart<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ChunkBatchStart<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct ChunkBiomesBiomes {
/// `position`
pub position: crate::defs::p775::types::PackedChunkPos,
/// `data`
pub data: Bytes,
}
#[cfg(feature = "v26_1")]
/// `chunk_biomes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ChunkBiomes<const V: i32> {
/// `biomes`
pub biomes: Vec<crate::defs::p775::play::clientbound::ChunkBiomesBiomes>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ChunkBiomes<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 9)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = <crate::defs::p775::types::PackedChunkPos as Decode>::decode(r)?;
let v5 = r.read_byte_array()?;
crate::defs::p775::play::clientbound::ChunkBiomesBiomes {
position: v4,
data: v5,
}
});
}
v3
};
Self { biomes: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ChunkBiomes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).biomes.len())?;
for v1 in (*self).biomes.iter() {
(*v1).position.encode(w)?;
w.put_byte_array(&(*v1).data)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ChunkBiomes<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 =
<crate::defs::p775::types::PackedChunkPos as Generate>::generate(g);
let v5 = g.bytes();
crate::defs::p775::play::clientbound::ChunkBiomesBiomes {
position: v4,
data: v5,
}
});
}
v3
};
Self { biomes: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `clear_titles` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ClearTitles<const V: i32> {
/// `reset`
pub reset: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ClearTitles<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
Self { reset: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ClearTitles<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).reset);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ClearTitles<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
Self { reset: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TabCompleteMatches {
/// `match`
pub r#match: ByteString,
/// `tooltip`
pub tooltip: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
/// `tab_complete` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete<const V: i32> {
/// `transactionId`
pub transaction_id: i32,
/// `start`
pub start: i32,
/// `length`
pub length: i32,
/// `matches`
pub matches: Vec<crate::defs::p775::play::clientbound::TabCompleteMatches>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for TabComplete<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = {
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = r.read_string()?;
let v8 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
crate::defs::p775::play::clientbound::TabCompleteMatches {
r#match: v7,
tooltip: v8,
}
});
}
v6
};
Self {
transaction_id: v1,
start: v2,
length: v3,
matches: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for TabComplete<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
w.put_varint((*self).start);
w.put_varint((*self).length);
w.put_len_varint((*self).matches.len())?;
for v1 in (*self).matches.iter() {
w.put_string(&(*v1).r#match)?;
match &(*v1).tooltip {
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 TabComplete<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = {
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = g.string();
let v8 = if g.bool() { Some(g.anon_nbt()) } else { None };
crate::defs::p775::play::clientbound::TabCompleteMatches {
r#match: v7,
tooltip: v8,
}
});
}
v6
};
Self {
transaction_id: v1,
start: v2,
length: v3,
matches: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `declare_commands` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareCommands<const V: i32> {
/// `nodes`
pub nodes: Vec<crate::defs::p775::types::CommandNode>,
/// `rootIndex`
pub root_index: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DeclareCommands<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(<crate::defs::p775::types::CommandNode as Decode>::decode(
r,
)?);
}
v3
};
let v4 = r.read_varint()?;
Self {
nodes: v1,
root_index: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DeclareCommands<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).nodes.len())?;
for v1 in (*self).nodes.iter() {
(*v1).encode(w)?;
}
w.put_varint((*self).root_index);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DeclareCommands<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(<crate::defs::p775::types::CommandNode as Generate>::generate(g));
}
v3
};
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
nodes: v1,
root_index: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `close_window` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CloseWindow<const V: i32> {
/// `windowId`
pub window_id: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CloseWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { window_id: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CloseWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CloseWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { window_id: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `window_items` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WindowItems<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `stateId`
pub state_id: i32,
/// `items`
pub items: Vec<crate::defs::p775::types::Slot>,
/// `carriedItem`
pub carried_item: crate::defs::p775::types::Slot,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WindowItems<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(<crate::defs::p775::types::Slot as Decode>::decode(r)?);
}
v5
};
let v6 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WindowItems<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).state_id);
w.put_len_varint((*self).items.len())?;
for v1 in (*self).items.iter() {
(*v1).encode(w)?;
}
(*self).carried_item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WindowItems<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(<crate::defs::p775::types::Slot as Generate>::generate(g));
}
v5
};
let v6 = <crate::defs::p775::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `craft_progress_bar` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftProgressBar<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `property`
pub property: i16,
/// `value`
pub value: i16,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CraftProgressBar<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i16()?;
let v3 = r.read_i16()?;
Self {
window_id: v1,
property: v2,
value: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CraftProgressBar<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_i16((*self).property);
w.put_i16((*self).value);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CraftProgressBar<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-32768, 32767, &[]) as i16);
let v3 = (g.int_in(-32768, 32767, &[]) as i16);
Self {
window_id: v1,
property: v2,
value: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `set_slot` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetSlot<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `stateId`
pub state_id: i32,
/// `slot`
pub slot: i16,
/// `item`
pub item: crate::defs::p775::types::Slot,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetSlot<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_i16()?;
let v4 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetSlot<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).state_id);
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetSlot<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-32768, 32767, &[]) as i16);
let v4 = <crate::defs::p775::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `cookie_request` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CookieRequest<const V: i32> {
/// `cookie`
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")]
/// `set_cooldown` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCooldown<const V: i32> {
/// `cooldownGroup`
pub cooldown_group: ByteString,
/// `cooldownTicks`
pub cooldown_ticks: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetCooldown<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_varint()?;
Self {
cooldown_group: v1,
cooldown_ticks: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetCooldown<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).cooldown_group)?;
w.put_varint((*self).cooldown_ticks);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCooldown<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
cooldown_group: v1,
cooldown_ticks: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `chat_suggestions` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ChatSuggestions<const V: i32> {
/// `action`
pub action: i32,
/// `entries`
pub entries: Vec<ByteString>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ChatSuggestions<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(r.read_string()?);
}
v4
};
Self {
action: v1,
entries: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ChatSuggestions<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
w.put_len_varint((*self).entries.len())?;
for v1 in (*self).entries.iter() {
w.put_string(&(*v1))?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ChatSuggestions<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(g.string());
}
v4
};
Self {
action: v1,
entries: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `damage_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DamageEvent<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `sourceTypeId`
pub source_type_id: i32,
/// `sourceCauseId`
pub source_cause_id: i32,
/// `sourceDirectId`
pub source_direct_id: i32,
/// `sourcePosition`
pub source_position: Option<crate::defs::p775::types::Vec3f64>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DamageEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = r.read_varint()?;
let v5 = if r.read_bool()? {
Some(<crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?)
} else {
None
};
Self {
entity_id: v1,
source_type_id: v2,
source_cause_id: v3,
source_direct_id: v4,
source_position: v5,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DamageEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).source_type_id);
w.put_varint((*self).source_cause_id);
w.put_varint((*self).source_direct_id);
match &(*self).source_position {
Some(v1) => {
w.put_u8(1);
(*v1).encode(w)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DamageEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = if g.bool() {
Some(<crate::defs::p775::types::Vec3f64 as Generate>::generate(g))
} else {
None
};
Self {
entity_id: v1,
source_type_id: v2,
source_cause_id: v3,
source_direct_id: v4,
source_position: v5,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `debug_block_value` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugBlockValue<const V: i32> {
/// `blockPos`
pub block_pos: BlockPos,
/// `update`
pub update: crate::defs::p775::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DebugBlockValue<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
block_pos: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DebugBlockValue<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).block_pos.write(w, PositionLayout::Xzy)?;
(*self).update.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugBlockValue<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
block_pos: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `debug_chunk_value` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugChunkValue<const V: i32> {
/// `chunkPos`
pub chunk_pos: crate::defs::p775::types::PackedChunkPos,
/// `update`
pub update: crate::defs::p775::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DebugChunkValue<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::PackedChunkPos as Decode>::decode(r)?;
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
chunk_pos: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DebugChunkValue<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).chunk_pos.encode(w)?;
(*self).update.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugChunkValue<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::PackedChunkPos as Generate>::generate(g);
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
chunk_pos: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `debug_entity_value` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugEntityValue<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `update`
pub update: crate::defs::p775::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DebugEntityValue<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
entity_id: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DebugEntityValue<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).update.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugEntityValue<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <crate::defs::p775::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
entity_id: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `debug_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugEvent<const V: i32> {
/// `event`
pub event: crate::defs::p775::types::DebugSubscriptionEvent,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DebugEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::DebugSubscriptionEvent as Decode>::decode(r)?;
Self { event: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DebugEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).event.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::DebugSubscriptionEvent as Generate>::generate(g);
Self { event: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `debug_sample` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugSample<const V: i32> {
/// `sample`
pub sample: Vec<i64>,
/// `type`
pub r#type: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DebugSample<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(r.read_i64()?);
}
v3
};
let v4 = r.read_varint()?;
Self {
sample: v1,
r#type: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DebugSample<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).sample.len())?;
for v1 in (*self).sample.iter() {
w.put_i64((*v1));
}
w.put_varint((*self).r#type);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugSample<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.i64());
}
v3
};
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
sample: v1,
r#type: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `hide_message` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct HideMessage<const V: i32> {
/// `id`
pub id: i32,
/// `signature`
pub signature: Option<Bytes>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for HideMessage<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = if (v1 == 0) {
Some(r.read_bytes(256)?)
} else {
None
};
Self {
id: v1,
signature: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for HideMessage<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).id);
match (&(*self).signature, ((*self).id == 0)) {
(Some(v1), true) => {
if (*v1).len() != 256 {
return Err(EncodeError::CountMismatch {
field: "fixed buffer",
expected: 256,
actual: (*v1).len(),
});
}
w.put_slice(&(*v1));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.hide_message.signature",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for HideMessage<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
let v2 = if (v1 == 0) {
Some(g.fixed_bytes(256))
} else {
None
};
Self {
id: v1,
signature: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `kick_disconnect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct KickDisconnect<const V: i32> {
/// `reason`
pub reason: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for KickDisconnect<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 KickDisconnect<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 KickDisconnect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { reason: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `profileless_chat` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ProfilelessChat<const V: i32> {
/// `message`
pub message: AnonNbt,
/// `type`
pub r#type: Holder<crate::defs::p775::play::clientbound::ChatTypes>,
/// `name`
pub name: AnonNbt,
/// `target`
pub target: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ProfilelessChat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
let v2 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(
<crate::defs::p775::play::clientbound::ChatTypes as Decode>::decode(r)?,
)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
let v3 = AnonNbt::read(r)?;
let v4 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
Self {
message: v1,
r#type: v2,
name: v3,
target: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ProfilelessChat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).message.write(w);
match &(*self).r#type {
Holder::Id(v2) => {
if *v2 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v2.wrapping_add(1));
}
Holder::Inline(v1) => {
w.put_varint(0);
(*v1).encode(w)?;
}
}
(*self).name.write(w);
match &(*self).target {
Some(v3) => {
w.put_u8(1);
(*v3).write(w);
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ProfilelessChat<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
let v2 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(
<crate::defs::p775::play::clientbound::ChatTypes as Generate>::generate(g),
)
};
let v3 = g.anon_nbt();
let v4 = if g.bool() { Some(g.anon_nbt()) } else { None };
Self {
message: v1,
r#type: v2,
name: v3,
target: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `sync_entity_position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SyncEntityPosition<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `dx`
pub dx: f64,
/// `dy`
pub dy: f64,
/// `dz`
pub dz: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `onGround`
pub on_ground: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SyncEntityPosition<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_f64()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = r.read_bool()?;
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
on_ground: v10,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SyncEntityPosition<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f64((*self).dx);
w.put_f64((*self).dy);
w.put_f64((*self).dz);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SyncEntityPosition<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = g.f64();
let v8 = g.f32();
let v9 = g.f32();
let v10 = g.bool();
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
on_ground: v10,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `explosion` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Explosion<const V: i32> {
/// `center`
pub center: crate::defs::p775::types::Vec3f64,
/// `radius`
pub radius: f32,
/// `blockCount`
pub block_count: i32,
/// `playerKnockback`
pub player_knockback: Option<crate::defs::p775::types::Vec3f64>,
/// `explosionParticle`
pub explosion_particle: crate::defs::p775::types::Particle,
/// `sound`
pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
/// `blockParticles`
pub block_particles: Vec<crate::defs::p775::play::clientbound::ExplosionParticleEntry>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Explosion<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?;
let v2 = r.read_f32()?;
let v3 = r.read_i32()?;
let v4 = if r.read_bool()? {
Some(<crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?)
} else {
None
};
let v5 = <crate::defs::p775::types::Particle as Decode>::decode(r)?;
let v6 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Decode>::decode(r)?)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
let v7 = {
let v8 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 10)?
};
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push(<crate::defs::p775::play::clientbound::ExplosionParticleEntry as Decode>::decode(r)?);
}
v9
};
Self {
center: v1,
radius: v2,
block_count: v3,
player_knockback: v4,
explosion_particle: v5,
sound: v6,
block_particles: v7,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Explosion<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).center.encode(w)?;
w.put_f32((*self).radius);
w.put_i32((*self).block_count);
match &(*self).player_knockback {
Some(v1) => {
w.put_u8(1);
(*v1).encode(w)?;
}
None => w.put_u8(0),
}
(*self).explosion_particle.encode(w)?;
match &(*self).sound {
Holder::Id(v3) => {
if *v3 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v3.wrapping_add(1));
}
Holder::Inline(v2) => {
w.put_varint(0);
(*v2).encode(w)?;
}
}
w.put_len_varint((*self).block_particles.len())?;
for v4 in (*self).block_particles.iter() {
(*v4).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Explosion<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::Vec3f64 as Generate>::generate(g);
let v2 = g.f32();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = if g.bool() {
Some(<crate::defs::p775::types::Vec3f64 as Generate>::generate(g))
} else {
None
};
let v5 = <crate::defs::p775::types::Particle as Generate>::generate(g);
let v6 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Generate>::generate(g))
};
let v7 = {
let v8 = g.count();
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push(<crate::defs::p775::play::clientbound::ExplosionParticleEntry as Generate>::generate(g));
}
v9
};
Self {
center: v1,
radius: v2,
block_count: v3,
player_knockback: v4,
explosion_particle: v5,
sound: v6,
block_particles: v7,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `unload_chunk` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UnloadChunk<const V: i32> {
/// `chunkZ`
pub chunk_z: i32,
/// `chunkX`
pub chunk_x: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for UnloadChunk<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_i32()?;
Self {
chunk_z: v1,
chunk_x: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for UnloadChunk<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).chunk_z);
w.put_i32((*self).chunk_x);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UnloadChunk<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
chunk_z: v1,
chunk_x: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `u8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct GameStateChangeReason(pub u8);
#[cfg(feature = "v26_1")]
impl GameStateChangeReason {
/// `no_respawn_block_available`
pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
/// `start_raining`
pub const START_RAINING: Self = Self(1);
/// `stop_raining`
pub const STOP_RAINING: Self = Self(2);
/// `change_game_mode`
pub const CHANGE_GAME_MODE: Self = Self(3);
/// `win_game`
pub const WIN_GAME: Self = Self(4);
/// `demo_event`
pub const DEMO_EVENT: Self = Self(5);
/// `play_arrow_hit_sound`
pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
/// `rain_level_change`
pub const RAIN_LEVEL_CHANGE: Self = Self(7);
/// `thunder_level_change`
pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
/// `puffer_fish_sting`
pub const PUFFER_FISH_STING: Self = Self(9);
/// `guardian_elder_effect`
pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
/// `immediate_respawn`
pub const IMMEDIATE_RESPAWN: Self = Self(11);
/// `limited_crafting`
pub const LIMITED_CRAFTING: Self = Self(12);
/// `level_chunks_load_start`
pub const LEVEL_CHUNKS_LOAD_START: Self = Self(13);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("no_respawn_block_available"),
1 => Some("start_raining"),
2 => Some("stop_raining"),
3 => Some("change_game_mode"),
4 => Some("win_game"),
5 => Some("demo_event"),
6 => Some("play_arrow_hit_sound"),
7 => Some("rain_level_change"),
8 => Some("thunder_level_change"),
9 => Some("puffer_fish_sting"),
10 => Some("guardian_elder_effect"),
11 => Some("immediate_respawn"),
12 => Some("limited_crafting"),
13 => Some("level_chunks_load_start"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for GameStateChangeReason {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "GameStateChangeReason::{n}"),
None => write!(f, "GameStateChangeReason({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// `game_state_change` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct GameStateChange<const V: i32> {
/// `reason`
pub reason: crate::defs::p775::play::clientbound::GameStateChangeReason,
/// `gameMode`
pub game_mode: f32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for GameStateChange<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::GameStateChangeReason(r.read_u8()?);
let v2 = r.read_f32()?;
Self {
reason: v1,
game_mode: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for GameStateChange<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).reason.0);
w.put_f32((*self).game_mode);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for GameStateChange<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::GameStateChangeReason(g.int_in(
0,
255,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
)
as u8);
let v2 = g.f32();
Self {
reason: v1,
game_mode: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `game_rule_values` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct GameRuleValues<const V: i32> {
/// `values`
pub values: Vec<crate::defs::p775::types::GameRule>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for GameRuleValues<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(<crate::defs::p775::types::GameRule as Decode>::decode(r)?);
}
v3
};
Self { values: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for GameRuleValues<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).values.len())?;
for v1 in (*self).values.iter() {
(*v1).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for GameRuleValues<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(<crate::defs::p775::types::GameRule as Generate>::generate(
g,
));
}
v3
};
Self { values: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `game_test_highlight_pos` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct GameTestHighlightPos<const V: i32> {
/// `absolutePos`
pub absolute_pos: BlockPos,
/// `relativePos`
pub relative_pos: BlockPos,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for GameTestHighlightPos<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
Self {
absolute_pos: v1,
relative_pos: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for GameTestHighlightPos<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).absolute_pos.write(w, PositionLayout::Xzy)?;
(*self).relative_pos.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for GameTestHighlightPos<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = g.position();
Self {
absolute_pos: v1,
relative_pos: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `open_horse_window` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenHorseWindow<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `nbSlots`
pub nb_slots: i32,
/// `entityId`
pub entity_id: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for OpenHorseWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_i32()?;
Self {
window_id: v1,
nb_slots: v2,
entity_id: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for OpenHorseWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).nb_slots);
w.put_i32((*self).entity_id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenHorseWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
window_id: v1,
nb_slots: v2,
entity_id: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `hurt_animation` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct HurtAnimation<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `yaw`
pub yaw: f32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for HurtAnimation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f32()?;
Self {
entity_id: v1,
yaw: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for HurtAnimation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f32((*self).yaw);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for HurtAnimation<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f32();
Self {
entity_id: v1,
yaw: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `initialize_world_border` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct InitializeWorldBorder<const V: i32> {
/// `x`
pub x: f64,
/// `z`
pub z: f64,
/// `oldDiameter`
pub old_diameter: f64,
/// `newDiameter`
pub new_diameter: f64,
/// `speed`
pub speed: i64,
/// `portalTeleportBoundary`
pub portal_teleport_boundary: i32,
/// `warningBlocks`
pub warning_blocks: i32,
/// `warningTime`
pub warning_time: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for InitializeWorldBorder<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_varlong()?;
let v6 = r.read_varint()?;
let v7 = r.read_varint()?;
let v8 = r.read_varint()?;
Self {
x: v1,
z: v2,
old_diameter: v3,
new_diameter: v4,
speed: v5,
portal_teleport_boundary: v6,
warning_blocks: v7,
warning_time: v8,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for InitializeWorldBorder<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).z);
w.put_f64((*self).old_diameter);
w.put_f64((*self).new_diameter);
w.put_varlong((*self).speed);
w.put_varint((*self).portal_teleport_boundary);
w.put_varint((*self).warning_blocks);
w.put_varint((*self).warning_time);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for InitializeWorldBorder<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.varlong();
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
x: v1,
z: v2,
old_diameter: v3,
new_diameter: v4,
speed: v5,
portal_teleport_boundary: v6,
warning_blocks: v7,
warning_time: v8,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct MapChunkHeightmapsType(pub i32);
#[cfg(feature = "v26_1")]
impl MapChunkHeightmapsType {
/// `world_surface_wg`
pub const WORLD_SURFACE_WG: Self = Self(0);
/// `world_surface`
pub const WORLD_SURFACE: Self = Self(1);
/// `ocean_floor_wg`
pub const OCEAN_FLOOR_WG: Self = Self(2);
/// `ocean_floor`
pub const OCEAN_FLOOR: Self = Self(3);
/// `motion_blocking`
pub const MOTION_BLOCKING: Self = Self(4);
/// `motion_blocking_no_leaves`
pub const MOTION_BLOCKING_NO_LEAVES: Self = Self(5);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("world_surface_wg"),
1 => Some("world_surface"),
2 => Some("ocean_floor_wg"),
3 => Some("ocean_floor"),
4 => Some("motion_blocking"),
5 => Some("motion_blocking_no_leaves"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for MapChunkHeightmapsType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "MapChunkHeightmapsType::{n}"),
None => write!(f, "MapChunkHeightmapsType({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunkHeightmaps {
/// `type`
pub r#type: crate::defs::p775::play::clientbound::MapChunkHeightmapsType,
/// `data`
pub data: Vec<i64>,
}
#[cfg(feature = "v26_1")]
/// `map_chunk` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunk<const V: i32> {
/// `x`
pub x: i32,
/// `z`
pub z: i32,
/// `heightmaps`
pub heightmaps: Vec<crate::defs::p775::play::clientbound::MapChunkHeightmaps>,
/// `chunkData`
pub chunk_data: Bytes,
/// `blockEntities`
pub block_entities: Vec<crate::defs::p775::types::ChunkBlockEntity>,
/// `skyLightMask`
pub sky_light_mask: Vec<i64>,
/// `blockLightMask`
pub block_light_mask: Vec<i64>,
/// `emptySkyLightMask`
pub empty_sky_light_mask: Vec<i64>,
/// `emptyBlockLightMask`
pub empty_block_light_mask: Vec<i64>,
/// `skyLight`
pub sky_light: Vec<Vec<u8>>,
/// `blockLight`
pub block_light: Vec<Vec<u8>>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for MapChunk<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_i32()?;
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push({
let v6 = crate::defs::p775::play::clientbound::MapChunkHeightmapsType(
r.read_varint()?,
);
let v7 = {
let v8 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push(r.read_i64()?);
}
v9
};
crate::defs::p775::play::clientbound::MapChunkHeightmaps {
r#type: v6,
data: v7,
}
});
}
v5
};
let v10 = r.read_byte_array()?;
let v11 = {
let v12 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v12 {
v13.push(<crate::defs::p775::types::ChunkBlockEntity as Decode>::decode(r)?);
}
v13
};
let v14 = {
let v15 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v16 = Vec::with_capacity(v15.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v15 {
v16.push(r.read_i64()?);
}
v16
};
let v17 = {
let v18 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v18 {
v19.push(r.read_i64()?);
}
v19
};
let v20 = {
let v21 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v21 {
v22.push(r.read_i64()?);
}
v22
};
let v23 = {
let v24 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v24 {
v25.push(r.read_i64()?);
}
v25
};
let v26 = {
let v27 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v27 {
v28.push({
let v29 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v29 {
v30.push(r.read_u8()?);
}
v30
});
}
v28
};
let v31 = {
let v32 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v32 {
v33.push({
let v34 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v34 {
v35.push(r.read_u8()?);
}
v35
});
}
v33
};
Self {
x: v1,
z: v2,
heightmaps: v3,
chunk_data: v10,
block_entities: v11,
sky_light_mask: v14,
block_light_mask: v17,
empty_sky_light_mask: v20,
empty_block_light_mask: v23,
sky_light: v26,
block_light: v31,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for MapChunk<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).x);
w.put_i32((*self).z);
w.put_len_varint((*self).heightmaps.len())?;
for v1 in (*self).heightmaps.iter() {
w.put_varint((*v1).r#type.0);
w.put_len_varint((*v1).data.len())?;
for v2 in (*v1).data.iter() {
w.put_i64((*v2));
}
}
w.put_byte_array(&(*self).chunk_data)?;
w.put_len_varint((*self).block_entities.len())?;
for v3 in (*self).block_entities.iter() {
(*v3).encode(w)?;
}
w.put_len_varint((*self).sky_light_mask.len())?;
for v4 in (*self).sky_light_mask.iter() {
w.put_i64((*v4));
}
w.put_len_varint((*self).block_light_mask.len())?;
for v5 in (*self).block_light_mask.iter() {
w.put_i64((*v5));
}
w.put_len_varint((*self).empty_sky_light_mask.len())?;
for v6 in (*self).empty_sky_light_mask.iter() {
w.put_i64((*v6));
}
w.put_len_varint((*self).empty_block_light_mask.len())?;
for v7 in (*self).empty_block_light_mask.iter() {
w.put_i64((*v7));
}
w.put_len_varint((*self).sky_light.len())?;
for v8 in (*self).sky_light.iter() {
w.put_len_varint((*v8).len())?;
for v9 in (*v8).iter() {
w.put_u8((*v9));
}
}
w.put_len_varint((*self).block_light.len())?;
for v10 in (*self).block_light.iter() {
w.put_len_varint((*v10).len())?;
for v11 in (*v10).iter() {
w.put_u8((*v11));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for MapChunk<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push({
let v6 = crate::defs::p775::play::clientbound::MapChunkHeightmapsType(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5]) as i32,
);
let v7 = {
let v8 = g.count();
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push(g.i64());
}
v9
};
crate::defs::p775::play::clientbound::MapChunkHeightmaps {
r#type: v6,
data: v7,
}
});
}
v5
};
let v10 = g.bytes();
let v11 = {
let v12 = g.count();
let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v12 {
v13.push(<crate::defs::p775::types::ChunkBlockEntity as Generate>::generate(g));
}
v13
};
let v14 = {
let v15 = g.count();
let mut v16 = Vec::with_capacity(v15.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v15 {
v16.push(g.i64());
}
v16
};
let v17 = {
let v18 = g.count();
let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v18 {
v19.push(g.i64());
}
v19
};
let v20 = {
let v21 = g.count();
let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v21 {
v22.push(g.i64());
}
v22
};
let v23 = {
let v24 = g.count();
let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v24 {
v25.push(g.i64());
}
v25
};
let v26 = {
let v27 = g.count();
let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v27 {
v28.push({
let v29 = g.count();
let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v29 {
v30.push((g.int_in(0, 255, &[]) as u8));
}
v30
});
}
v28
};
let v31 = {
let v32 = g.count();
let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v32 {
v33.push({
let v34 = g.count();
let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v34 {
v35.push((g.int_in(0, 255, &[]) as u8));
}
v35
});
}
v33
};
Self {
x: v1,
z: v2,
heightmaps: v3,
chunk_data: v10,
block_entities: v11,
sky_light_mask: v14,
block_light_mask: v17,
empty_sky_light_mask: v20,
empty_block_light_mask: v23,
sky_light: v26,
block_light: v31,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `world_particles` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldParticles<const V: i32> {
/// `longDistance`
pub long_distance: bool,
/// `alwaysShow`
pub always_show: bool,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `offsetX`
pub offset_x: f32,
/// `offsetY`
pub offset_y: f32,
/// `offsetZ`
pub offset_z: f32,
/// `velocityOffset`
pub velocity_offset: f32,
/// `amount`
pub amount: i32,
/// `particle`
pub particle: crate::defs::p775::types::Particle,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldParticles<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
let v2 = r.read_bool()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f32()?;
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = r.read_i32()?;
let v11 = <crate::defs::p775::types::Particle as Decode>::decode(r)?;
Self {
long_distance: v1,
always_show: v2,
x: v3,
y: v4,
z: v5,
offset_x: v6,
offset_y: v7,
offset_z: v8,
velocity_offset: v9,
amount: v10,
particle: v11,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldParticles<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).long_distance);
w.put_bool((*self).always_show);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).offset_x);
w.put_f32((*self).offset_y);
w.put_f32((*self).offset_z);
w.put_f32((*self).velocity_offset);
w.put_i32((*self).amount);
(*self).particle.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldParticles<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
let v2 = g.bool();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f32();
let v7 = g.f32();
let v8 = g.f32();
let v9 = g.f32();
let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v11 = <crate::defs::p775::types::Particle as Generate>::generate(g);
Self {
long_distance: v1,
always_show: v2,
x: v3,
y: v4,
z: v5,
offset_x: v6,
offset_y: v7,
offset_z: v8,
velocity_offset: v9,
amount: v10,
particle: v11,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `update_light` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateLight<const V: i32> {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
/// `skyLightMask`
pub sky_light_mask: Vec<i64>,
/// `blockLightMask`
pub block_light_mask: Vec<i64>,
/// `emptySkyLightMask`
pub empty_sky_light_mask: Vec<i64>,
/// `emptyBlockLightMask`
pub empty_block_light_mask: Vec<i64>,
/// `skyLight`
pub sky_light: Vec<Vec<u8>>,
/// `blockLight`
pub block_light: Vec<Vec<u8>>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for UpdateLight<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(r.read_i64()?);
}
v5
};
let v6 = {
let v7 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v7 {
v8.push(r.read_i64()?);
}
v8
};
let v9 = {
let v10 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v10 {
v11.push(r.read_i64()?);
}
v11
};
let v12 = {
let v13 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push(r.read_i64()?);
}
v14
};
let v15 = {
let v16 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push({
let v18 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v18 {
v19.push(r.read_u8()?);
}
v19
});
}
v17
};
let v20 = {
let v21 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v21 {
v22.push({
let v23 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v23 {
v24.push(r.read_u8()?);
}
v24
});
}
v22
};
Self {
chunk_x: v1,
chunk_z: v2,
sky_light_mask: v3,
block_light_mask: v6,
empty_sky_light_mask: v9,
empty_block_light_mask: v12,
sky_light: v15,
block_light: v20,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for UpdateLight<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).chunk_x);
w.put_varint((*self).chunk_z);
w.put_len_varint((*self).sky_light_mask.len())?;
for v1 in (*self).sky_light_mask.iter() {
w.put_i64((*v1));
}
w.put_len_varint((*self).block_light_mask.len())?;
for v2 in (*self).block_light_mask.iter() {
w.put_i64((*v2));
}
w.put_len_varint((*self).empty_sky_light_mask.len())?;
for v3 in (*self).empty_sky_light_mask.iter() {
w.put_i64((*v3));
}
w.put_len_varint((*self).empty_block_light_mask.len())?;
for v4 in (*self).empty_block_light_mask.iter() {
w.put_i64((*v4));
}
w.put_len_varint((*self).sky_light.len())?;
for v5 in (*self).sky_light.iter() {
w.put_len_varint((*v5).len())?;
for v6 in (*v5).iter() {
w.put_u8((*v6));
}
}
w.put_len_varint((*self).block_light.len())?;
for v7 in (*self).block_light.iter() {
w.put_len_varint((*v7).len())?;
for v8 in (*v7).iter() {
w.put_u8((*v8));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateLight<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(g.i64());
}
v5
};
let v6 = {
let v7 = g.count();
let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v7 {
v8.push(g.i64());
}
v8
};
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.i64());
}
v11
};
let v12 = {
let v13 = g.count();
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push(g.i64());
}
v14
};
let v15 = {
let v16 = g.count();
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push({
let v18 = g.count();
let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v18 {
v19.push((g.int_in(0, 255, &[]) as u8));
}
v19
});
}
v17
};
let v20 = {
let v21 = g.count();
let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v21 {
v22.push({
let v23 = g.count();
let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v23 {
v24.push((g.int_in(0, 255, &[]) as u8));
}
v24
});
}
v22
};
Self {
chunk_x: v1,
chunk_z: v2,
sky_light_mask: v3,
block_light_mask: v6,
empty_sky_light_mask: v9,
empty_block_light_mask: v12,
sky_light: v15,
block_light: v20,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `login` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Login<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `isHardcore`
pub is_hardcore: bool,
/// `worldNames`
pub world_names: Vec<ByteString>,
/// `maxPlayers`
pub max_players: i32,
/// `viewDistance`
pub view_distance: i32,
/// `simulationDistance`
pub simulation_distance: i32,
/// `reducedDebugInfo`
pub reduced_debug_info: bool,
/// `enableRespawnScreen`
pub enable_respawn_screen: bool,
/// `doLimitedCrafting`
pub do_limited_crafting: bool,
/// `worldState`
pub world_state: crate::defs::p775::play::clientbound::SpawnInfo,
/// `enforcesSecureChat`
pub enforces_secure_chat: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Login<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_bool()?;
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(r.read_string()?);
}
v5
};
let v6 = r.read_varint()?;
let v7 = r.read_varint()?;
let v8 = r.read_varint()?;
let v9 = r.read_bool()?;
let v10 = r.read_bool()?;
let v11 = r.read_bool()?;
let v12 = <crate::defs::p775::play::clientbound::SpawnInfo as Decode>::decode(r)?;
let v13 = r.read_bool()?;
Self {
entity_id: v1,
is_hardcore: v2,
world_names: v3,
max_players: v6,
view_distance: v7,
simulation_distance: v8,
reduced_debug_info: v9,
enable_respawn_screen: v10,
do_limited_crafting: v11,
world_state: v12,
enforces_secure_chat: v13,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Login<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_bool((*self).is_hardcore);
w.put_len_varint((*self).world_names.len())?;
for v1 in (*self).world_names.iter() {
w.put_string(&(*v1))?;
}
w.put_varint((*self).max_players);
w.put_varint((*self).view_distance);
w.put_varint((*self).simulation_distance);
w.put_bool((*self).reduced_debug_info);
w.put_bool((*self).enable_respawn_screen);
w.put_bool((*self).do_limited_crafting);
(*self).world_state.encode(w)?;
w.put_bool((*self).enforces_secure_chat);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Login<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.bool();
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(g.string());
}
v5
};
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v9 = g.bool();
let v10 = g.bool();
let v11 = g.bool();
let v12 = <crate::defs::p775::play::clientbound::SpawnInfo as Generate>::generate(g);
let v13 = g.bool();
Self {
entity_id: v1,
is_hardcore: v2,
world_names: v3,
max_players: v6,
view_distance: v7,
simulation_distance: v8,
reduced_debug_info: v9,
enable_respawn_screen: v10,
do_limited_crafting: v11,
world_state: v12,
enforces_secure_chat: v13,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `low_disk_space_warning` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct LowDiskSpaceWarning<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for LowDiskSpaceWarning<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for LowDiskSpaceWarning<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for LowDiskSpaceWarning<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MapIcons {
/// `type`
pub r#type: i32,
/// `x`
pub x: i8,
/// `z`
pub z: i8,
/// `direction`
pub direction: u8,
/// `displayName`
pub display_name: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
/// `map` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Map<const V: i32> {
/// `itemDamage`
pub item_damage: i32,
/// `scale`
pub scale: i8,
/// `locked`
pub locked: bool,
/// `icons`
pub icons: Option<Vec<crate::defs::p775::play::clientbound::MapIcons>>,
/// `columns`
pub columns: u8,
/// `rows`
pub rows: Option<u8>,
/// `x`
pub x: Option<u8>,
/// `y`
pub y: Option<u8>,
/// `data`
pub data: Option<Bytes>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Map<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i8()?;
let v3 = r.read_bool()?;
let v4 = if r.read_bool()? {
Some({
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = r.read_varint()?;
let v8 = r.read_i8()?;
let v9 = r.read_i8()?;
let v10 = r.read_u8()?;
let v11 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
crate::defs::p775::play::clientbound::MapIcons {
r#type: v7,
x: v8,
z: v9,
direction: v10,
display_name: v11,
}
});
}
v6
})
} else {
None
};
let v12 = r.read_u8()?;
let v13 = if !(v12 == 0) {
Some(r.read_u8()?)
} else {
None
};
let v14 = if !(v12 == 0) {
Some(r.read_u8()?)
} else {
None
};
let v15 = if !(v12 == 0) {
Some(r.read_u8()?)
} else {
None
};
let v16 = if !(v12 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Self {
item_damage: v1,
scale: v2,
locked: v3,
icons: v4,
columns: v12,
rows: v13,
x: v14,
y: v15,
data: v16,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Map<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_damage);
w.put_i8((*self).scale);
w.put_bool((*self).locked);
match &(*self).icons {
Some(v1) => {
w.put_u8(1);
w.put_len_varint((*v1).len())?;
for v2 in (*v1).iter() {
w.put_varint((*v2).r#type);
w.put_i8((*v2).x);
w.put_i8((*v2).z);
w.put_u8((*v2).direction);
match &(*v2).display_name {
Some(v3) => {
w.put_u8(1);
(*v3).write(w);
}
None => w.put_u8(0),
}
}
}
None => w.put_u8(0),
}
w.put_u8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v4), true) => {
w.put_u8((*v4));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v5), true) => {
w.put_u8((*v5));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v6), true) => {
w.put_u8((*v6));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v7), true) => {
w.put_byte_array(&(*v7))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Map<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = g.bool();
let v4 = if g.bool() {
Some({
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v8 = (g.int_in(-128, 127, &[]) as i8);
let v9 = (g.int_in(-128, 127, &[]) as i8);
let v10 = (g.int_in(0, 255, &[]) as u8);
let v11 = if g.bool() { Some(g.anon_nbt()) } else { None };
crate::defs::p775::play::clientbound::MapIcons {
r#type: v7,
x: v8,
z: v9,
direction: v10,
display_name: v11,
}
});
}
v6
})
} else {
None
};
let v12 = (g.int_in(0, 255, &[0, 0, 0, 0]) as u8);
let v13 = if !(v12 == 0) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
let v14 = if !(v12 == 0) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
let v15 = if !(v12 == 0) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
let v16 = if !(v12 == 0) { Some(g.bytes()) } else { None };
Self {
item_damage: v1,
scale: v2,
locked: v3,
icons: v4,
columns: v12,
rows: v13,
x: v14,
y: v15,
data: v16,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTradesInputItem1 {
/// `itemId`
pub item_id: i32,
/// `itemCount`
pub item_count: i32,
/// `components`
pub components: Vec<crate::defs::p775::types::SlotComponent>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTradesInputItem2 {
/// `itemId`
pub item_id: i32,
/// `itemCount`
pub item_count: i32,
/// `components`
pub components: Vec<crate::defs::p775::types::SlotComponent>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTrades {
/// `inputItem1`
pub input_item1: crate::defs::p775::play::clientbound::TradeListTradesInputItem1,
/// `outputItem`
pub output_item: crate::defs::p775::types::Slot,
/// `inputItem2`
pub input_item2: Option<crate::defs::p775::play::clientbound::TradeListTradesInputItem2>,
/// `tradeDisabled`
pub trade_disabled: bool,
/// `nbTradeUses`
pub nb_trade_uses: i32,
/// `maximumNbTradeUses`
pub maximum_nb_trade_uses: i32,
/// `xp`
pub xp: i32,
/// `specialPrice`
pub special_price: i32,
/// `priceMultiplier`
pub price_multiplier: f32,
/// `demand`
pub demand: i32,
}
#[cfg(feature = "v26_1")]
/// `trade_list` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TradeList<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `trades`
pub trades: Vec<crate::defs::p775::play::clientbound::TradeListTrades>,
/// `villagerLevel`
pub villager_level: i32,
/// `experience`
pub experience: i32,
/// `isRegularVillager`
pub is_regular_villager: bool,
/// `canRestock`
pub can_restock: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for TradeList<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 30)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = { let v6 = r.read_varint()?;let v7 = r.read_varint()?;let v8 = { let v9 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push(<crate::defs::p775::types::SlotComponent as Decode>::decode(r)?); } v10 }; crate::defs::p775::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;let v12 = if r.read_bool()? { Some({ let v13 = r.read_varint()?;let v14 = r.read_varint()?;let v15 = { let v16 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v16 { v17.push(<crate::defs::p775::types::SlotComponent as Decode>::decode(r)?); } v17 }; crate::defs::p775::play::clientbound::TradeListTradesInputItem2 { item_id: v13, item_count: v14, components: v15 } }) } else { None };let v18 = r.read_bool()?;let v19 = r.read_i32()?;let v20 = r.read_i32()?;let v21 = r.read_i32()?;let v22 = r.read_i32()?;let v23 = r.read_f32()?;let v24 = r.read_i32()?; crate::defs::p775::play::clientbound::TradeListTrades { input_item1: v5, output_item: v11, input_item2: v12, trade_disabled: v18, nb_trade_uses: v19, maximum_nb_trade_uses: v20, xp: v21, special_price: v22, price_multiplier: v23, demand: v24 } });
}
v4
};
let v25 = r.read_varint()?;
let v26 = r.read_varint()?;
let v27 = r.read_bool()?;
let v28 = r.read_bool()?;
Self {
window_id: v1,
trades: v2,
villager_level: v25,
experience: v26,
is_regular_villager: v27,
can_restock: v28,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for TradeList<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_len_varint((*self).trades.len())?;
for v1 in (*self).trades.iter() {
w.put_varint((*v1).input_item1.item_id);
w.put_varint((*v1).input_item1.item_count);
w.put_len_varint((*v1).input_item1.components.len())?;
for v2 in (*v1).input_item1.components.iter() {
(*v2).encode(w)?;
}
(*v1).output_item.encode(w)?;
match &(*v1).input_item2 {
Some(v3) => {
w.put_u8(1);
w.put_varint((*v3).item_id);
w.put_varint((*v3).item_count);
w.put_len_varint((*v3).components.len())?;
for v4 in (*v3).components.iter() {
(*v4).encode(w)?;
}
}
None => w.put_u8(0),
}
w.put_bool((*v1).trade_disabled);
w.put_i32((*v1).nb_trade_uses);
w.put_i32((*v1).maximum_nb_trade_uses);
w.put_i32((*v1).xp);
w.put_i32((*v1).special_price);
w.put_f32((*v1).price_multiplier);
w.put_i32((*v1).demand);
}
w.put_varint((*self).villager_level);
w.put_varint((*self).experience);
w.put_bool((*self).is_regular_villager);
w.put_bool((*self).can_restock);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TradeList<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
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 = { let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v8 = { let v9 = g.count(); let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push(<crate::defs::p775::types::SlotComponent as Generate>::generate(g)); } v10 }; crate::defs::p775::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p775::types::Slot as Generate>::generate(g);let v12 = if g.bool() { Some({ let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v14 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v15 = { let v16 = g.count(); let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v16 { v17.push(<crate::defs::p775::types::SlotComponent as Generate>::generate(g)); } v17 }; crate::defs::p775::play::clientbound::TradeListTradesInputItem2 { item_id: v13, item_count: v14, components: v15 } }) } else { None };let v18 = g.bool();let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v20 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v21 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v22 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v23 = g.f32();let v24 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p775::play::clientbound::TradeListTrades { input_item1: v5, output_item: v11, input_item2: v12, trade_disabled: v18, nb_trade_uses: v19, maximum_nb_trade_uses: v20, xp: v21, special_price: v22, price_multiplier: v23, demand: v24 } });
}
v4
};
let v25 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v26 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v27 = g.bool();
let v28 = g.bool();
Self {
window_id: v1,
trades: v2,
villager_level: v25,
experience: v26,
is_regular_villager: v27,
can_restock: v28,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MoveMinecartSteps {
/// `position`
pub position: crate::defs::p775::types::Vec3f,
/// `velocity`
pub velocity: crate::defs::p775::types::Vec3f,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `weight`
pub weight: f32,
}
#[cfg(feature = "v26_1")]
/// `move_minecart` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct MoveMinecart<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `steps`
pub steps: Vec<crate::defs::p775::play::clientbound::MoveMinecartSteps>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for MoveMinecart<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 36)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = <crate::defs::p775::types::Vec3f as Decode>::decode(r)?;
let v6 = <crate::defs::p775::types::Vec3f as Decode>::decode(r)?;
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
crate::defs::p775::play::clientbound::MoveMinecartSteps {
position: v5,
velocity: v6,
yaw: v7,
pitch: v8,
weight: v9,
}
});
}
v4
};
Self {
entity_id: v1,
steps: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for MoveMinecart<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_len_varint((*self).steps.len())?;
for v1 in (*self).steps.iter() {
(*v1).position.encode(w)?;
(*v1).velocity.encode(w)?;
w.put_f32((*v1).yaw);
w.put_f32((*v1).pitch);
w.put_f32((*v1).weight);
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for MoveMinecart<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
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 = <crate::defs::p775::types::Vec3f as Generate>::generate(g);
let v6 = <crate::defs::p775::types::Vec3f as Generate>::generate(g);
let v7 = g.f32();
let v8 = g.f32();
let v9 = g.f32();
crate::defs::p775::play::clientbound::MoveMinecartSteps {
position: v5,
velocity: v6,
yaw: v7,
pitch: v8,
weight: v9,
}
});
}
v4
};
Self {
entity_id: v1,
steps: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct OpenBookHand(pub i32);
#[cfg(feature = "v26_1")]
impl OpenBookHand {
/// `main_hand`
pub const MAIN_HAND: Self = Self(0);
/// `off_hand`
pub const OFF_HAND: Self = Self(1);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("main_hand"),
1 => Some("off_hand"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for OpenBookHand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "OpenBookHand::{n}"),
None => write!(f, "OpenBookHand({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// `open_book` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenBook<const V: i32> {
/// `hand`
pub hand: crate::defs::p775::play::clientbound::OpenBookHand,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for OpenBook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::OpenBookHand(r.read_varint()?);
Self { hand: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for OpenBook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand.0);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenBook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::OpenBookHand(g.int_in(
-2147483648,
2147483647,
&[0, 1],
) as i32);
Self { hand: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `open_window` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenWindow<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `inventoryType`
pub inventory_type: i32,
/// `windowTitle`
pub window_title: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for OpenWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = AnonNbt::read(r)?;
Self {
window_id: v1,
inventory_type: v2,
window_title: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for OpenWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).inventory_type);
(*self).window_title.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.anon_nbt();
Self {
window_id: v1,
inventory_type: v2,
window_title: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `open_sign_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenSignEntity<const V: i32> {
/// `location`
pub location: BlockPos,
/// `isFrontText`
pub is_front_text: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for OpenSignEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_bool()?;
Self {
location: v1,
is_front_text: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for OpenSignEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_bool((*self).is_front_text);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenSignEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = g.bool();
Self {
location: v1,
is_front_text: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `ping` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Ping<const V: i32> {
/// `id`
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")]
/// `ping_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PingResponse<const V: i32> {
/// `id`
pub id: i64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PingResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i64()?;
Self { id: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PingResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PingResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.i64();
Self { id: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `craft_recipe_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeResponse<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `recipeDisplay`
pub recipe_display: crate::defs::p775::play::clientbound::RecipeDisplay,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for CraftRecipeResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = <crate::defs::p775::play::clientbound::RecipeDisplay as Decode>::decode(r)?;
Self {
window_id: v1,
recipe_display: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for CraftRecipeResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
(*self).recipe_display.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CraftRecipeResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <crate::defs::p775::play::clientbound::RecipeDisplay as Generate>::generate(g);
Self {
window_id: v1,
recipe_display: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `player_chat` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerChat<const V: i32> {
/// `globalIndex`
pub global_index: i32,
/// `senderUuid`
pub sender_uuid: Uuid,
/// `index`
pub index: i32,
/// `signature`
pub signature: Option<Bytes>,
/// `plainMessage`
pub plain_message: ByteString,
/// `timestamp`
pub timestamp: i64,
/// `salt`
pub salt: i64,
/// `previousMessages`
pub previous_messages: Vec<crate::defs::p775::types::PreviousMessages>,
/// `unsignedChatContent`
pub unsigned_chat_content: Option<AnonNbt>,
/// `filterType`
pub filter_type: i32,
/// `filterTypeMask`
pub filter_type_mask: Option<Vec<i64>>,
/// `type`
pub r#type: Holder<crate::defs::p775::play::clientbound::ChatTypes>,
/// `networkName`
pub network_name: AnonNbt,
/// `networkTargetName`
pub network_target_name: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PlayerChat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_varint()?;
let v4 = if r.read_bool()? {
Some(r.read_bytes(256)?)
} else {
None
};
let v5 = r.read_string()?;
let v6 = r.read_i64()?;
let v7 = r.read_i64()?;
let v8 = {
let v9 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({
let v11 = r.read_varint()?;
let v12 = if (v11 == 0) {
Some(r.read_bytes(256)?)
} else {
None
};
crate::defs::p775::types::PreviousMessages {
id: v11,
signature: v12,
}
});
}
v10
};
let v13 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
let v14 = r.read_varint()?;
let v15 = if (v14 == 2) {
Some({
let v16 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 8)?
};
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push(r.read_i64()?);
}
v17
})
} else {
None
};
let v18 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(
<crate::defs::p775::play::clientbound::ChatTypes as Decode>::decode(r)?,
)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
let v19 = AnonNbt::read(r)?;
let v20 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
Self {
global_index: v1,
sender_uuid: v2,
index: v3,
signature: v4,
plain_message: v5,
timestamp: v6,
salt: v7,
previous_messages: v8,
unsigned_chat_content: v13,
filter_type: v14,
filter_type_mask: v15,
r#type: v18,
network_name: v19,
network_target_name: v20,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PlayerChat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).global_index);
w.put_uuid(&(*self).sender_uuid);
w.put_varint((*self).index);
match &(*self).signature {
Some(v1) => {
w.put_u8(1);
if (*v1).len() != 256 {
return Err(EncodeError::CountMismatch {
field: "fixed buffer",
expected: 256,
actual: (*v1).len(),
});
}
w.put_slice(&(*v1));
}
None => w.put_u8(0),
}
w.put_string(&(*self).plain_message)?;
w.put_i64((*self).timestamp);
w.put_i64((*self).salt);
w.put_len_varint((*self).previous_messages.len())?;
for v2 in (*self).previous_messages.iter() {
w.put_varint((*v2).id);
match (&(*v2).signature, ((*v2).id == 0)) {
(Some(v3), true) => {
if (*v3).len() != 256 {
return Err(EncodeError::CountMismatch {
field: "fixed buffer",
expected: 256,
actual: (*v3).len(),
});
}
w.put_slice(&(*v3));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_chat.previousMessages.signature",
));
}
}
}
match &(*self).unsigned_chat_content {
Some(v4) => {
w.put_u8(1);
(*v4).write(w);
}
None => w.put_u8(0),
}
w.put_varint((*self).filter_type);
match (&(*self).filter_type_mask, ((*self).filter_type == 2)) {
(Some(v5), true) => {
w.put_len_varint((*v5).len())?;
for v6 in (*v5).iter() {
w.put_i64((*v6));
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_chat.filterTypeMask",
));
}
}
match &(*self).r#type {
Holder::Id(v8) => {
if *v8 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v8.wrapping_add(1));
}
Holder::Inline(v7) => {
w.put_varint(0);
(*v7).encode(w)?;
}
}
(*self).network_name.write(w);
match &(*self).network_target_name {
Some(v9) => {
w.put_u8(1);
(*v9).write(w);
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PlayerChat<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = if g.bool() {
Some(g.fixed_bytes(256))
} else {
None
};
let v5 = g.string();
let v6 = g.i64();
let v7 = g.i64();
let v8 = {
let v9 = g.count();
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({
let v11 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
let v12 = if (v11 == 0) {
Some(g.fixed_bytes(256))
} else {
None
};
crate::defs::p775::types::PreviousMessages {
id: v11,
signature: v12,
}
});
}
v10
};
let v13 = if g.bool() { Some(g.anon_nbt()) } else { None };
let v14 = (g.int_in(-2147483648, 2147483647, &[2]) as i32);
let v15 = if (v14 == 2) {
Some({
let v16 = g.count();
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push(g.i64());
}
v17
})
} else {
None
};
let v18 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(
<crate::defs::p775::play::clientbound::ChatTypes as Generate>::generate(g),
)
};
let v19 = g.anon_nbt();
let v20 = if g.bool() { Some(g.anon_nbt()) } else { None };
Self {
global_index: v1,
sender_uuid: v2,
index: v3,
signature: v4,
plain_message: v5,
timestamp: v6,
salt: v7,
previous_messages: v8,
unsigned_chat_content: v13,
filter_type: v14,
filter_type_mask: v15,
r#type: v18,
network_name: v19,
network_target_name: v20,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `end_combat_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EndCombatEvent<const V: i32> {
/// `duration`
pub duration: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EndCombatEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { duration: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EndCombatEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).duration);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EndCombatEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { duration: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `enter_combat_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EnterCombatEvent<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EnterCombatEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EnterCombatEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EnterCombatEvent<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
/// `death_combat_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeathCombatEvent<const V: i32> {
/// `playerId`
pub player_id: i32,
/// `message`
pub message: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DeathCombatEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = AnonNbt::read(r)?;
Self {
player_id: v1,
message: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DeathCombatEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).player_id);
(*self).message.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DeathCombatEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.anon_nbt();
Self {
player_id: v1,
message: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `player_remove` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerRemove<const V: i32> {
/// `players`
pub players: Vec<Uuid>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PlayerRemove<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 16)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(r.read_uuid()?);
}
v3
};
Self { players: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PlayerRemove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).players.len())?;
for v1 in (*self).players.iter() {
w.put_uuid(&(*v1));
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PlayerRemove<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.uuid());
}
v3
};
Self { players: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// Bit flags in a `u8`; unknown bits are kept as-is.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct PlayerInfoAction(pub u8);
#[cfg(feature = "v26_1")]
impl PlayerInfoAction {
/// `add_player`
pub const ADD_PLAYER: Self = Self(1 << 0);
/// `initialize_chat`
pub const INITIALIZE_CHAT: Self = Self(1 << 1);
/// `update_game_mode`
pub const UPDATE_GAME_MODE: Self = Self(1 << 2);
/// `update_listed`
pub const UPDATE_LISTED: Self = Self(1 << 3);
/// `update_latency`
pub const UPDATE_LATENCY: Self = Self(1 << 4);
/// `update_display_name`
pub const UPDATE_DISPLAY_NAME: Self = Self(1 << 5);
/// `update_list_order`
pub const UPDATE_LIST_ORDER: Self = Self(1 << 6);
/// `update_hat`
pub const UPDATE_HAT: Self = Self(1 << 7);
/// Whether every bit of `f` is set.
#[inline]
pub const fn contains(self, f: Self) -> bool {
self.0 & f.0 == f.0
}
/// The union of both sets of bits.
#[inline]
#[must_use]
pub const fn with(self, f: Self) -> Self {
Self(self.0 | f.0)
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoData {
/// `uuid`
pub uuid: Uuid,
/// `player`
pub player: Option<crate::defs::p775::types::GameProfileNameProp>,
/// `chatSession`
pub chat_session: Option<Option<crate::defs::p775::types::ChatSession>>,
/// `gamemode`
pub gamemode: Option<i32>,
/// `listed`
pub listed: Option<bool>,
/// `latency`
pub latency: Option<i32>,
/// `displayName`
pub display_name: Option<Option<AnonNbt>>,
/// `listPriority`
pub list_priority: Option<i32>,
/// `showHat`
pub show_hat: Option<bool>,
}
#[cfg(feature = "v26_1")]
/// `player_info` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfo<const V: i32> {
/// `action`
pub action: crate::defs::p775::play::clientbound::PlayerInfoAction,
/// `data`
pub data: Vec<crate::defs::p775::play::clientbound::PlayerInfoData>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PlayerInfo<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p775::play::clientbound::PlayerInfoAction(r.read_u8()?);
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 16)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = r.read_uuid()?;
let v6 = if ((v1.0 >> 0) & 1 != 0) {
Some(
<crate::defs::p775::types::GameProfileNameProp as Decode>::decode(
r,
)?,
)
} else {
None
};
let v7 = if ((v1.0 >> 1) & 1 != 0) {
Some(if r.read_bool()? {
Some({
let v8 = r.read_uuid()?;
let v9 = {
let v10 = r.read_i64()?;
let v11 = r.read_byte_array()?;
let v12 = r.read_byte_array()?;
crate::defs::p775::types::ChatSessionPublicKey {
expire_time: v10,
key_bytes: v11,
key_signature: v12,
}
};
crate::defs::p775::types::ChatSession {
uuid: v8,
public_key: v9,
}
})
} else {
None
})
} else {
None
};
let v13 = if ((v1.0 >> 2) & 1 != 0) {
Some(r.read_varint()?)
} else {
None
};
let v14 = if ((v1.0 >> 3) & 1 != 0) {
Some(r.read_bool()?)
} else {
None
};
let v15 = if ((v1.0 >> 4) & 1 != 0) {
Some(r.read_varint()?)
} else {
None
};
let v16 = if ((v1.0 >> 5) & 1 != 0) {
Some(if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
})
} else {
None
};
let v17 = if ((v1.0 >> 6) & 1 != 0) {
Some(r.read_varint()?)
} else {
None
};
let v18 = if ((v1.0 >> 7) & 1 != 0) {
Some(r.read_bool()?)
} else {
None
};
crate::defs::p775::play::clientbound::PlayerInfoData {
uuid: v5,
player: v6,
chat_session: v7,
gamemode: v13,
listed: v14,
latency: v15,
display_name: v16,
list_priority: v17,
show_hat: v18,
}
});
}
v4
};
Self {
action: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PlayerInfo<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).action.0);
w.put_len_varint((*self).data.len())?;
for v1 in (*self).data.iter() {
w.put_uuid(&(*v1).uuid);
match (&(*v1).player, (((*self).action.0 >> 0) & 1 != 0)) {
(Some(v2), true) => {
(*v2).encode(w)?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.player",
));
}
}
match (&(*v1).chat_session, (((*self).action.0 >> 1) & 1 != 0)) {
(Some(v3), true) => match &(*v3) {
Some(v4) => {
w.put_u8(1);
w.put_uuid(&(*v4).uuid);
w.put_i64((*v4).public_key.expire_time);
w.put_byte_array(&(*v4).public_key.key_bytes)?;
w.put_byte_array(&(*v4).public_key.key_signature)?;
}
None => w.put_u8(0),
},
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.chatSession",
));
}
}
match (&(*v1).gamemode, (((*self).action.0 >> 2) & 1 != 0)) {
(Some(v5), true) => {
w.put_varint((*v5));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.gamemode",
));
}
}
match (&(*v1).listed, (((*self).action.0 >> 3) & 1 != 0)) {
(Some(v6), true) => {
w.put_bool((*v6));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.listed",
));
}
}
match (&(*v1).latency, (((*self).action.0 >> 4) & 1 != 0)) {
(Some(v7), true) => {
w.put_varint((*v7));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.latency",
));
}
}
match (&(*v1).display_name, (((*self).action.0 >> 5) & 1 != 0)) {
(Some(v8), true) => match &(*v8) {
Some(v9) => {
w.put_u8(1);
(*v9).write(w);
}
None => w.put_u8(0),
},
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.displayName",
));
}
}
match (&(*v1).list_priority, (((*self).action.0 >> 6) & 1 != 0)) {
(Some(v10), true) => {
w.put_varint((*v10));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.listPriority",
));
}
}
match (&(*v1).show_hat, (((*self).action.0 >> 7) & 1 != 0)) {
(Some(v11), true) => {
w.put_bool((*v11));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.showHat",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PlayerInfo<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 =
crate::defs::p775::play::clientbound::PlayerInfoAction(g.int_in(0, 255, &[]) as u8);
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.uuid();let v6 = if ((v1.0 >> 0) & 1 != 0) { Some(<crate::defs::p775::types::GameProfileNameProp as Generate>::generate(g)) } else { None };let v7 = if ((v1.0 >> 1) & 1 != 0) { Some(if g.bool() { Some({ let v8 = g.uuid();let v9 = { let v10 = g.i64();let v11 = g.bytes();let v12 = g.bytes(); crate::defs::p775::types::ChatSessionPublicKey { expire_time: v10, key_bytes: v11, key_signature: v12 } }; crate::defs::p775::types::ChatSession { uuid: v8, public_key: v9 } }) } else { None }) } else { None };let v13 = if ((v1.0 >> 2) & 1 != 0) { Some((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else { None };let v14 = if ((v1.0 >> 3) & 1 != 0) { Some(g.bool()) } else { None };let v15 = if ((v1.0 >> 4) & 1 != 0) { Some((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else { None };let v16 = if ((v1.0 >> 5) & 1 != 0) { Some(if g.bool() { Some(g.anon_nbt()) } else { None }) } else { None };let v17 = if ((v1.0 >> 6) & 1 != 0) { Some((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else { None };let v18 = if ((v1.0 >> 7) & 1 != 0) { Some(g.bool()) } else { None }; crate::defs::p775::play::clientbound::PlayerInfoData { uuid: v5, player: v6, chat_session: v7, gamemode: v13, listed: v14, latency: v15, display_name: v16, list_priority: v17, show_hat: v18 } });
}
v4
};
Self {
action: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `face_player` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct FacePlayer<const V: i32> {
/// `feet_eyes`
pub feet_eyes: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `isEntity`
pub is_entity: bool,
/// `entityId`
pub entity_id: Option<i32>,
/// `entity_feet_eyes`
pub entity_feet_eyes: Option<i32>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for FacePlayer<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_bool()?;
let v6 = if v5 { Some(r.read_varint()?) } else { None };
let v7 = if v5 { Some(r.read_varint()?) } else { None };
Self {
feet_eyes: v1,
x: v2,
y: v3,
z: v4,
is_entity: v5,
entity_id: v6,
entity_feet_eyes: v7,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for FacePlayer<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).feet_eyes);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_bool((*self).is_entity);
match (&(*self).entity_id, (*self).is_entity) {
(Some(v1), true) => {
w.put_varint((*v1));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entityId",
));
}
}
match (&(*self).entity_feet_eyes, (*self).is_entity) {
(Some(v2), true) => {
w.put_varint((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entity_feet_eyes",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for FacePlayer<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.bool();
let v6 = if v5 {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v7 = if v5 {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Self {
feet_eyes: v1,
x: v2,
y: v3,
z: v4,
is_entity: v5,
entity_id: v6,
entity_feet_eyes: v7,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Bit flags in a `u32`; unknown bits are kept as-is.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct PositionUpdateRelatives(pub u32);
#[cfg(feature = "v26_1")]
impl PositionUpdateRelatives {
/// `x`
pub const X: Self = Self(1 << 0);
/// `y`
pub const Y: Self = Self(1 << 1);
/// `z`
pub const Z: Self = Self(1 << 2);
/// `yaw`
pub const YAW: Self = Self(1 << 3);
/// `pitch`
pub const PITCH: Self = Self(1 << 4);
/// `dx`
pub const DX: Self = Self(1 << 5);
/// `dy`
pub const DY: Self = Self(1 << 6);
/// `dz`
pub const DZ: Self = Self(1 << 7);
/// `yawDelta`
pub const YAW_DELTA: Self = Self(1 << 8);
/// Whether every bit of `f` is set.
#[inline]
pub const fn contains(self, f: Self) -> bool {
self.0 & f.0 == f.0
}
/// The union of both sets of bits.
#[inline]
#[must_use]
pub const fn with(self, f: Self) -> Self {
Self(self.0 | f.0)
}
}
#[cfg(feature = "v26_1")]
/// `position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Position<const V: i32> {
/// `teleportId`
pub teleport_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `dx`
pub dx: f64,
/// `dy`
pub dy: f64,
/// `dz`
pub dz: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::PositionUpdateRelatives,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Position<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_f64()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = crate::defs::p775::play::clientbound::PositionUpdateRelatives(r.read_u32()?);
Self {
teleport_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
flags: v10,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Position<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).teleport_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f64((*self).dx);
w.put_f64((*self).dy);
w.put_f64((*self).dz);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_u32((*self).flags.0);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Position<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = g.f64();
let v8 = g.f32();
let v9 = g.f32();
let v10 = crate::defs::p775::play::clientbound::PositionUpdateRelatives(g.int_in(
0,
4294967295,
&[],
)
as u32);
Self {
teleport_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
flags: v10,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `player_rotation` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerRotation<const V: i32> {
/// `yaw`
pub yaw: f32,
/// `relativeYaw`
pub relative_yaw: bool,
/// `pitch`
pub pitch: f32,
/// `relativePitch`
pub relative_pitch: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PlayerRotation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f32()?;
let v2 = r.read_bool()?;
let v3 = r.read_f32()?;
let v4 = r.read_bool()?;
Self {
yaw: v1,
relative_yaw: v2,
pitch: v3,
relative_pitch: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PlayerRotation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).yaw);
w.put_bool((*self).relative_yaw);
w.put_f32((*self).pitch);
w.put_bool((*self).relative_pitch);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PlayerRotation<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f32();
let v2 = g.bool();
let v3 = g.f32();
let v4 = g.bool();
Self {
yaw: v1,
relative_yaw: v2,
pitch: v3,
relative_pitch: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct RecipeBookAddEntriesRecipeCategory(pub i32);
#[cfg(feature = "v26_1")]
impl RecipeBookAddEntriesRecipeCategory {
/// `crafting_building_blocks`
pub const CRAFTING_BUILDING_BLOCKS: Self = Self(0);
/// `crafting_redstone`
pub const CRAFTING_REDSTONE: Self = Self(1);
/// `crafting_equipment`
pub const CRAFTING_EQUIPMENT: Self = Self(2);
/// `crafting_misc`
pub const CRAFTING_MISC: Self = Self(3);
/// `furnace_food`
pub const FURNACE_FOOD: Self = Self(4);
/// `furnace_blocks`
pub const FURNACE_BLOCKS: Self = Self(5);
/// `furnace_misc`
pub const FURNACE_MISC: Self = Self(6);
/// `blast_furnace_blocks`
pub const BLAST_FURNACE_BLOCKS: Self = Self(7);
/// `blast_furnace_misc`
pub const BLAST_FURNACE_MISC: Self = Self(8);
/// `smoker_food`
pub const SMOKER_FOOD: Self = Self(9);
/// `stonecutter`
pub const STONECUTTER: Self = Self(10);
/// `smithing`
pub const SMITHING: Self = Self(11);
/// `campfire`
pub const CAMPFIRE: Self = Self(12);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("crafting_building_blocks"),
1 => Some("crafting_redstone"),
2 => Some("crafting_equipment"),
3 => Some("crafting_misc"),
4 => Some("furnace_food"),
5 => Some("furnace_blocks"),
6 => Some("furnace_misc"),
7 => Some("blast_furnace_blocks"),
8 => Some("blast_furnace_misc"),
9 => Some("smoker_food"),
10 => Some("stonecutter"),
11 => Some("smithing"),
12 => Some("campfire"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for RecipeBookAddEntriesRecipeCategory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "RecipeBookAddEntriesRecipeCategory::{n}"),
None => write!(f, "RecipeBookAddEntriesRecipeCategory({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntriesRecipe {
/// `displayId`
pub display_id: i32,
/// `display`
pub display: crate::defs::p775::play::clientbound::RecipeDisplay,
/// `group`
pub group: i32,
/// `category`
pub category: crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory,
/// `craftingRequirements`
pub crafting_requirements: Option<Vec<HolderSet>>,
}
#[cfg(feature = "v26_1")]
/// Bit flags in a `u8`; unknown bits are kept as-is.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct RecipeBookAddEntriesFlags(pub u8);
#[cfg(feature = "v26_1")]
impl RecipeBookAddEntriesFlags {
/// `notification`
pub const NOTIFICATION: Self = Self(1 << 0);
/// `highlight`
pub const HIGHLIGHT: Self = Self(1 << 1);
/// Whether every bit of `f` is set.
#[inline]
pub const fn contains(self, f: Self) -> bool {
self.0 & f.0 == f.0
}
/// The union of both sets of bits.
#[inline]
#[must_use]
pub const fn with(self, f: Self) -> Self {
Self(self.0 | f.0)
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntries {
/// `recipe`
pub recipe: crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipe,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags,
}
#[cfg(feature = "v26_1")]
/// `recipe_book_add` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAdd<const V: i32> {
/// `entries`
pub entries: Vec<crate::defs::p775::play::clientbound::RecipeBookAddEntries>,
/// `replace`
pub replace: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RecipeBookAdd<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 6)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({ let v4 = { let v5 = r.read_varint()?;let v6 = <crate::defs::p775::play::clientbound::RecipeDisplay as Decode>::decode(r)?;let v7 = r.read_varint()?;let v8 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory(r.read_varint()?);let v9 = if r.read_bool()? { Some({ 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(<HolderSet as Decode>::decode(r)?); } v11 }) } else { None }; crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipe { display_id: v5, display: v6, group: v7, category: v8, crafting_requirements: v9 } };let v12 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags(r.read_u8()?); crate::defs::p775::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = r.read_bool()?;
Self {
entries: v1,
replace: v13,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RecipeBookAdd<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entries.len())?;
for v1 in (*self).entries.iter() {
w.put_varint((*v1).recipe.display_id);
(*v1).recipe.display.encode(w)?;
w.put_varint((*v1).recipe.group);
w.put_varint((*v1).recipe.category.0);
match &(*v1).recipe.crafting_requirements {
Some(v2) => {
w.put_u8(1);
w.put_len_varint((*v2).len())?;
for v3 in (*v2).iter() {
(*v3).encode(w)?;
}
}
None => w.put_u8(0),
}
w.put_u8((*v1).flags.0);
}
w.put_bool((*self).replace);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RecipeBookAdd<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 = { let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v6 = <crate::defs::p775::play::clientbound::RecipeDisplay as Generate>::generate(g);let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v8 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipeCategory(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) as i32);let v9 = if g.bool() { Some({ let v10 = g.count(); let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v10 { v11.push(<HolderSet as Generate>::generate(g)); } v11 }) } else { None }; crate::defs::p775::play::clientbound::RecipeBookAddEntriesRecipe { display_id: v5, display: v6, group: v7, category: v8, crafting_requirements: v9 } };let v12 = crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags(g.int_in(0, 255, &[]) as u8); crate::defs::p775::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = g.bool();
Self {
entries: v1,
replace: v13,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `recipe_book_remove` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookRemove<const V: i32> {
/// `recipeIds`
pub recipe_ids: Vec<i32>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RecipeBookRemove<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_varint()?);
}
v3
};
Self { recipe_ids: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RecipeBookRemove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).recipe_ids.len())?;
for v1 in (*self).recipe_ids.iter() {
w.put_varint((*v1));
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RecipeBookRemove<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.int_in(-2147483648, 2147483647, &[]) as i32));
}
v3
};
Self { recipe_ids: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `recipe_book_settings` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookSettings<const V: i32> {
/// `crafting`
pub crafting: crate::defs::p775::play::clientbound::RecipeBookSetting,
/// `furnace`
pub furnace: crate::defs::p775::play::clientbound::RecipeBookSetting,
/// `blast`
pub blast: crate::defs::p775::play::clientbound::RecipeBookSetting,
/// `smoker`
pub smoker: crate::defs::p775::play::clientbound::RecipeBookSetting,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RecipeBookSettings<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Decode>::decode(r)?;
let v2 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Decode>::decode(r)?;
let v3 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Decode>::decode(r)?;
let v4 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Decode>::decode(r)?;
Self {
crafting: v1,
furnace: v2,
blast: v3,
smoker: v4,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RecipeBookSettings<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).crafting.encode(w)?;
(*self).furnace.encode(w)?;
(*self).blast.encode(w)?;
(*self).smoker.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RecipeBookSettings<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Generate>::generate(g);
let v2 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Generate>::generate(g);
let v3 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Generate>::generate(g);
let v4 =
<crate::defs::p775::play::clientbound::RecipeBookSetting as Generate>::generate(g);
Self {
crafting: v1,
furnace: v2,
blast: v3,
smoker: v4,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `remove_entity_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RemoveEntityEffect<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `effectId`
pub effect_id: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for RemoveEntityEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
Self {
entity_id: v1,
effect_id: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for RemoveEntityEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).effect_id);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RemoveEntityEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
entity_id: v1,
effect_id: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `reset_score` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ResetScore<const V: i32> {
/// `entity_name`
pub entity_name: ByteString,
/// `objective_name`
pub objective_name: Option<ByteString>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ResetScore<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
Self {
entity_name: v1,
objective_name: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ResetScore<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).entity_name)?;
match &(*self).objective_name {
Some(v1) => {
w.put_u8(1);
w.put_string(&(*v1))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ResetScore<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = if g.bool() { Some(g.string()) } else { None };
Self {
entity_name: v1,
objective_name: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `remove_resource_pack` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RemoveResourcePack<const V: i32> {
/// `uuid`
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")]
/// `add_resource_pack` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct AddResourcePack<const V: i32> {
/// `uuid`
pub uuid: Uuid,
/// `url`
pub url: ByteString,
/// `hash`
pub hash: ByteString,
/// `forced`
pub forced: bool,
/// `promptMessage`
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")]
/// `respawn` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Respawn<const V: i32> {
/// `worldState`
pub world_state: crate::defs::p775::play::clientbound::SpawnInfo,
/// `copyMetadata`
pub copy_metadata: u8,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Respawn<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::play::clientbound::SpawnInfo as Decode>::decode(r)?;
let v2 = r.read_u8()?;
Self {
world_state: v1,
copy_metadata: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Respawn<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).world_state.encode(w)?;
w.put_u8((*self).copy_metadata);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Respawn<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::play::clientbound::SpawnInfo as Generate>::generate(g);
let v2 = (g.int_in(0, 255, &[]) as u8);
Self {
world_state: v1,
copy_metadata: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Packed bit field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct MultiBlockChangeChunkCoordinates {
/// `x` (22 bits)
pub x: i32,
/// `z` (22 bits)
pub z: i32,
/// `y` (20 bits)
pub y: i32,
}
#[cfg(feature = "v26_1")]
/// `multi_block_change` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct MultiBlockChange<const V: i32> {
/// `chunkCoordinates`
pub chunk_coordinates: crate::defs::p775::play::clientbound::MultiBlockChangeChunkCoordinates,
/// `records`
pub records: Vec<i64>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for MultiBlockChange<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = r.read_u64()?;
crate::defs::p775::play::clientbound::MultiBlockChangeChunkCoordinates {
x: ((((((v2 >> 42) & 0x3fffff) << 42) as i64) >> 42) as i32),
z: ((((((v2 >> 20) & 0x3fffff) << 42) as i64) >> 42) as i32),
y: ((((((v2 >> 0) & 0xfffff) << 44) as i64) >> 44) as i32),
}
};
let v3 = {
let v4 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(r.read_varlong()?);
}
v5
};
Self {
chunk_coordinates: v1,
records: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for MultiBlockChange<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
{
let mut bits: u64 = 0;
{
let x = i128::from((*self).chunk_coordinates.x);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("x"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.z);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("z"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.y);
if x < -524288 || x > 524287 {
return Err(EncodeError::OutOfRange("y"));
}
bits = (bits << 20) | ((x as u64) & 0xfffff);
}
w.put_u64(bits);
}
w.put_len_varint((*self).records.len())?;
for v1 in (*self).records.iter() {
w.put_varlong((*v1));
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for MultiBlockChange<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
crate::defs::p775::play::clientbound::MultiBlockChangeChunkCoordinates {
x: (g.int_in(-2097152, 2097151, &[]) as i32),
z: (g.int_in(-2097152, 2097151, &[]) as i32),
y: (g.int_in(-524288, 524287, &[]) as i32),
}
};
let v3 = {
let v4 = g.count();
let mut v5 = Vec::with_capacity(v4.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v4 {
v5.push(g.varlong());
}
v5
};
Self {
chunk_coordinates: v1,
records: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `server_data` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ServerData<const V: i32> {
/// `motd`
pub motd: AnonNbt,
/// `iconBytes`
pub icon_bytes: Option<Bytes>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ServerData<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
let v2 = if r.read_bool()? {
Some(r.read_byte_array()?)
} else {
None
};
Self {
motd: v1,
icon_bytes: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ServerData<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).motd.write(w);
match &(*self).icon_bytes {
Some(v1) => {
w.put_u8(1);
w.put_byte_array(&(*v1))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ServerData<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
let v2 = if g.bool() { Some(g.bytes()) } else { None };
Self {
motd: v1,
icon_bytes: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `action_bar` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ActionBar<const V: i32> {
/// `text`
pub text: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ActionBar<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
Self { text: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ActionBar<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).text.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ActionBar<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { text: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `world_border_center` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorderCenter<const V: i32> {
/// `x`
pub x: f64,
/// `z`
pub z: f64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldBorderCenter<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
Self { x: v1, z: v2 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldBorderCenter<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).z);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldBorderCenter<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
Self { x: v1, z: v2 }
}
}
}
#[cfg(feature = "v26_1")]
/// `world_border_lerp_size` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorderLerpSize<const V: i32> {
/// `oldDiameter`
pub old_diameter: f64,
/// `newDiameter`
pub new_diameter: f64,
/// `speed`
pub speed: i64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldBorderLerpSize<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_varlong()?;
Self {
old_diameter: v1,
new_diameter: v2,
speed: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldBorderLerpSize<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).old_diameter);
w.put_f64((*self).new_diameter);
w.put_varlong((*self).speed);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldBorderLerpSize<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.varlong();
Self {
old_diameter: v1,
new_diameter: v2,
speed: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `world_border_size` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorderSize<const V: i32> {
/// `diameter`
pub diameter: f64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldBorderSize<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
Self { diameter: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldBorderSize<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).diameter);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldBorderSize<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
Self { diameter: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `world_border_warning_delay` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorderWarningDelay<const V: i32> {
/// `warningTime`
pub warning_time: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldBorderWarningDelay<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { warning_time: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldBorderWarningDelay<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).warning_time);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldBorderWarningDelay<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { warning_time: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `world_border_warning_reach` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorderWarningReach<const V: i32> {
/// `warningBlocks`
pub warning_blocks: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for WorldBorderWarningReach<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { warning_blocks: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for WorldBorderWarningReach<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).warning_blocks);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldBorderWarningReach<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { warning_blocks: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `set_cursor_item` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCursorItem<const V: i32> {
/// `contents`
pub contents: crate::defs::p775::types::Slot,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetCursorItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;
Self { contents: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetCursorItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).contents.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCursorItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::Slot as Generate>::generate(g);
Self { contents: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `spawn_position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnPosition<const V: i32> {
/// `globalPos`
pub global_pos: crate::defs::p775::types::GlobalPos,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SpawnPosition<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p775::types::GlobalPos as Decode>::decode(r)?;
let v2 = r.read_f32()?;
let v3 = r.read_f32()?;
Self {
global_pos: v1,
yaw: v2,
pitch: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SpawnPosition<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).global_pos.encode(w)?;
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnPosition<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p775::types::GlobalPos as Generate>::generate(g);
let v2 = g.f32();
let v3 = g.f32();
Self {
global_pos: v1,
yaw: v2,
pitch: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `scoreboard_display_objective` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardDisplayObjective<const V: i32> {
/// `position`
pub position: i32,
/// `name`
pub name: ByteString,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ScoreboardDisplayObjective<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_string()?;
Self {
position: v1,
name: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ScoreboardDisplayObjective<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).position);
w.put_string(&(*self).name)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ScoreboardDisplayObjective<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.string();
Self {
position: v1,
name: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `entity_metadata` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMetadata<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `metadata`
pub metadata: Vec<crate::defs::p775::types::EntityMetadataEntry>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityMetadata<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let mut v3 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v3.push(<crate::defs::p775::types::EntityMetadataEntry as Decode>::decode(r)?);
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityMetadata<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
for v1 in (*self).metadata.iter() {
let v2 = w.len();
(*v1).encode(w)?;
if w.get(v2) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_metadata.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityMetadata<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let n = g.count();
let mut v3 = Vec::with_capacity(n);
for _ in 0..n {
v3.push(loop {
let v4 =
<crate::defs::p775::types::EntityMetadataEntry as Generate>::generate(
g,
);
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
v4.encode(w)?;
Ok(())
},
|b| b != 255,
) {
break v4;
}
});
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `entity_velocity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityVelocity<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `velocity`
pub velocity: LpVec3,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityVelocity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = LpVec3::read(r)?;
Self {
entity_id: v1,
velocity: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityVelocity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).velocity.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityVelocity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <LpVec3 as Generate>::generate(g);
Self {
entity_id: v1,
velocity: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipmentEquipments {
/// `slot`
pub slot: i8,
/// `item`
pub item: crate::defs::p775::types::Slot,
}
#[cfg(feature = "v26_1")]
/// `entity_equipment` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `equipments`
pub equipments: Vec<crate::defs::p775::play::clientbound::EntityEquipmentEquipments>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityEquipment<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let mut v3 = Vec::new();
loop {
let v4 = r.read_u8()?;
v3.push({
let v5 = ((v4 & 0x7f) as i8);
let v6 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;
crate::defs::p775::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
});
if v4 & 0x80 == 0 {
break;
}
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityEquipment<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
if (*self).equipments.is_empty() {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.entity_equipment.equipments",
expected: 1,
actual: 0,
});
}
for (v2, v1) in (*self).equipments.iter().enumerate() {
let v3 = w.len();
w.put_i8((*v1).slot);
(*v1).item.encode(w)?;
match w.get_mut(v3) {
Some(b) if *b & 0x80 == 0 => {
if v2 + 1 < (*self).equipments.len() {
*b |= 0x80;
}
}
_ => {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_equipment.equipments",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityEquipment<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let n = 1 + g.count();
let mut v3 = Vec::with_capacity(n);
for _ in 0..n {
v3.push(loop {
let v4 = {
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = <crate::defs::p775::types::Slot as Generate>::generate(g);
crate::defs::p775::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_i8(v4.slot);
v4.item.encode(w)?;
Ok(())
},
|b| b & 0x80 == 0,
) {
break v4;
}
});
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `held_item_slot` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct HeldItemSlot<const V: i32> {
/// `slot`
pub slot: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for HeldItemSlot<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { slot: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for HeldItemSlot<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).slot);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for HeldItemSlot<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { slot: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `scoreboard_objective` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardObjective<const V: i32> {
/// `name`
pub name: ByteString,
/// `action`
pub action: i8,
/// `displayText`
pub display_text: Option<AnonNbt>,
/// `type`
pub r#type: Option<i32>,
/// `number_format`
pub number_format: Option<Option<i32>>,
/// `styling`
pub styling: Option<Option<AnonNbt>>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ScoreboardObjective<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = if (v2 == 0) || (v2 == 2) {
Some(AnonNbt::read(r)?)
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 2) {
Some(if r.read_bool()? {
Some(r.read_varint()?)
} else {
None
})
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 2) {
Some(if (v5 == Some(Some(1))) || (v5 == Some(Some(2))) {
Some(AnonNbt::read(r)?)
} else {
None
})
} else {
None
};
Self {
name: v1,
action: v2,
display_text: v3,
r#type: v4,
number_format: v5,
styling: v6,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ScoreboardObjective<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).name)?;
w.put_i8((*self).action);
match (
&(*self).display_text,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v1), true) => {
(*v1).write(w);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.displayText",
));
}
}
match (
&(*self).r#type,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v2), true) => {
w.put_varint((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.type",
));
}
}
match (
&(*self).number_format,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v3), true) => match &(*v3) {
Some(v4) => {
w.put_u8(1);
w.put_varint((*v4));
}
None => w.put_u8(0),
},
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.number_format",
));
}
}
match (
&(*self).styling,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v5), true) => {
match (
&(*v5),
((*self).number_format == Some(Some(1)))
|| ((*self).number_format == Some(Some(2))),
) {
(Some(v6), true) => {
(*v6).write(w);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.styling",
));
}
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.styling",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ScoreboardObjective<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-128, 127, &[0, 2, 0, 2, 0, 2, 0, 2]) as i8);
let v3 = if (v2 == 0) || (v2 == 2) {
Some(g.anon_nbt())
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 2) {
Some(if g.bool() {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
})
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 2) {
Some(if (v5 == Some(Some(1))) || (v5 == Some(Some(2))) {
Some(g.anon_nbt())
} else {
None
})
} else {
None
};
Self {
name: v1,
action: v2,
display_text: v3,
r#type: v4,
number_format: v5,
styling: v6,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `set_player_inventory` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetPlayerInventory<const V: i32> {
/// `slotId`
pub slot_id: i32,
/// `contents`
pub contents: crate::defs::p775::types::Slot,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetPlayerInventory<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = <crate::defs::p775::types::Slot as Decode>::decode(r)?;
Self {
slot_id: v1,
contents: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetPlayerInventory<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).slot_id);
(*self).contents.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetPlayerInventory<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <crate::defs::p775::types::Slot as Generate>::generate(g);
Self {
slot_id: v1,
contents: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TeamsMode(pub i8);
#[cfg(feature = "v26_1")]
impl TeamsMode {
/// `add`
pub const ADD: Self = Self(0);
/// `remove`
pub const REMOVE: Self = Self(1);
/// `change`
pub const CHANGE: Self = Self(2);
/// `join`
pub const JOIN: Self = Self(3);
/// `leave`
pub const LEAVE: Self = Self(4);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("add"),
1 => Some("remove"),
2 => Some("change"),
3 => Some("join"),
4 => Some("leave"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for TeamsMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "TeamsMode::{n}"),
None => write!(f, "TeamsMode({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Bit flags in a `u8`; unknown bits are kept as-is.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TeamsBodyAddFlags(pub u8);
#[cfg(feature = "v26_1")]
impl TeamsBodyAddFlags {
/// `friendly_fire`
pub const FRIENDLY_FIRE: Self = Self(1 << 0);
/// `see_friendly_invisible`
pub const SEE_FRIENDLY_INVISIBLE: Self = Self(1 << 1);
/// Whether every bit of `f` is set.
#[inline]
pub const fn contains(self, f: Self) -> bool {
self.0 & f.0 == f.0
}
/// The union of both sets of bits.
#[inline]
#[must_use]
pub const fn with(self, f: Self) -> Self {
Self(self.0 | f.0)
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TeamsBodyAddNameTagVisibility(pub i32);
#[cfg(feature = "v26_1")]
impl TeamsBodyAddNameTagVisibility {
/// `always`
pub const ALWAYS: Self = Self(0);
/// `never`
pub const NEVER: Self = Self(1);
/// `hide_for_other_teams`
pub const HIDE_FOR_OTHER_TEAMS: Self = Self(2);
/// `hide_for_own_team`
pub const HIDE_FOR_OWN_TEAM: Self = Self(3);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("always"),
1 => Some("never"),
2 => Some("hide_for_other_teams"),
3 => Some("hide_for_own_team"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for TeamsBodyAddNameTagVisibility {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "TeamsBodyAddNameTagVisibility::{n}"),
None => write!(f, "TeamsBodyAddNameTagVisibility({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TeamsBodyAddCollisionRule(pub i32);
#[cfg(feature = "v26_1")]
impl TeamsBodyAddCollisionRule {
/// `always`
pub const ALWAYS: Self = Self(0);
/// `never`
pub const NEVER: Self = Self(1);
/// `push_other_teams`
pub const PUSH_OTHER_TEAMS: Self = Self(2);
/// `push_own_team`
pub const PUSH_OWN_TEAM: Self = Self(3);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("always"),
1 => Some("never"),
2 => Some("push_other_teams"),
3 => Some("push_own_team"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for TeamsBodyAddCollisionRule {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "TeamsBodyAddCollisionRule::{n}"),
None => write!(f, "TeamsBodyAddCollisionRule({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TeamsBodyAdd {
/// `name`
pub name: AnonNbt,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::TeamsBodyAddFlags,
/// `nameTagVisibility`
pub name_tag_visibility: crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility,
/// `collisionRule`
pub collision_rule: crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule,
/// `formatting`
pub formatting: i32,
/// `prefix`
pub prefix: AnonNbt,
/// `suffix`
pub suffix: AnonNbt,
}
#[cfg(feature = "v26_1")]
/// `teams` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Teams<const V: i32> {
/// `team`
pub team: ByteString,
/// `mode`
pub mode: crate::defs::p775::play::clientbound::TeamsMode,
/// Anonymous switch
pub body: Option<crate::defs::p775::play::clientbound::TeamsBodyAdd>,
/// `players`
pub players: Option<Vec<ByteString>>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Teams<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = crate::defs::p775::play::clientbound::TeamsMode(r.read_i8()?);
let v3 = if (v2.0 == 0) || (v2.0 == 2) {
Some({
let v4 = AnonNbt::read(r)?;
let v5 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(r.read_u8()?);
let v6 = crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
r.read_varint()?,
);
let v7 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
r.read_varint()?,
);
let v8 = r.read_varint()?;
let v9 = AnonNbt::read(r)?;
let v10 = AnonNbt::read(r)?;
crate::defs::p775::play::clientbound::TeamsBodyAdd {
name: v4,
flags: v5,
name_tag_visibility: v6,
collision_rule: v7,
formatting: v8,
prefix: v9,
suffix: v10,
}
})
} else {
None
};
let v11 = if (v2.0 == 0) || (v2.0 == 3) || (v2.0 == 4) {
Some({
let v12 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v12 {
v13.push(r.read_string()?);
}
v13
})
} else {
None
};
Self {
team: v1,
mode: v2,
body: v3,
players: v11,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Teams<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).team)?;
w.put_i8((*self).mode.0);
match (
&(*self).body,
((*self).mode.0 == 0) || ((*self).mode.0 == 2),
) {
(Some(v1), true) => {
(*v1).name.write(w);
w.put_u8((*v1).flags.0);
w.put_varint((*v1).name_tag_visibility.0);
w.put_varint((*v1).collision_rule.0);
w.put_varint((*v1).formatting);
(*v1).prefix.write(w);
(*v1).suffix.write(w);
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.body")),
}
match (
&(*self).players,
((*self).mode.0 == 0) || ((*self).mode.0 == 3) || ((*self).mode.0 == 4),
) {
(Some(v2), true) => {
w.put_len_varint((*v2).len())?;
for v3 in (*v2).iter() {
w.put_string(&(*v3))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.players",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Teams<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = crate::defs::p775::play::clientbound::TeamsMode(g.int_in(
-128,
127,
&[0, 1, 2, 3, 4],
) as i8);
let v3 = if (v2.0 == 0) || (v2.0 == 2) {
Some({
let v4 = g.anon_nbt();
let v5 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(g.int_in(
0,
255,
&[],
)
as u8);
let v6 = crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
);
let v7 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
);
let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v9 = g.anon_nbt();
let v10 = g.anon_nbt();
crate::defs::p775::play::clientbound::TeamsBodyAdd {
name: v4,
flags: v5,
name_tag_visibility: v6,
collision_rule: v7,
formatting: v8,
prefix: v9,
suffix: v10,
}
})
} else {
None
};
let v11 = if (v2.0 == 0) || (v2.0 == 3) || (v2.0 == 4) {
Some({
let v12 = g.count();
let mut v13 = Vec::with_capacity(v12.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v12 {
v13.push(g.string());
}
v13
})
} else {
None
};
Self {
team: v1,
mode: v2,
body: v3,
players: v11,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `scoreboard_score` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardScore<const V: i32> {
/// `itemName`
pub item_name: ByteString,
/// `scoreName`
pub score_name: ByteString,
/// `value`
pub value: i32,
/// `display_name`
pub display_name: Option<AnonNbt>,
/// `number_format`
pub number_format: Option<i32>,
/// `styling`
pub styling: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ScoreboardScore<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_string()?;
let v3 = r.read_varint()?;
let v4 = if r.read_bool()? {
Some(AnonNbt::read(r)?)
} else {
None
};
let v5 = if r.read_bool()? {
Some(r.read_varint()?)
} else {
None
};
let v6 = if (v5 == Some(1)) || (v5 == Some(2)) {
Some(AnonNbt::read(r)?)
} else {
None
};
Self {
item_name: v1,
score_name: v2,
value: v3,
display_name: v4,
number_format: v5,
styling: v6,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ScoreboardScore<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).item_name)?;
w.put_string(&(*self).score_name)?;
w.put_varint((*self).value);
match &(*self).display_name {
Some(v1) => {
w.put_u8(1);
(*v1).write(w);
}
None => w.put_u8(0),
}
match &(*self).number_format {
Some(v2) => {
w.put_u8(1);
w.put_varint((*v2));
}
None => w.put_u8(0),
}
match (
&(*self).styling,
((*self).number_format == Some(1)) || ((*self).number_format == Some(2)),
) {
(Some(v3), true) => {
(*v3).write(w);
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_score.styling",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ScoreboardScore<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.string();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = if g.bool() { Some(g.anon_nbt()) } else { None };
let v5 = if g.bool() {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v6 = if (v5 == Some(1)) || (v5 == Some(2)) {
Some(g.anon_nbt())
} else {
None
};
Self {
item_name: v1,
score_name: v2,
value: v3,
display_name: v4,
number_format: v5,
styling: v6,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `simulation_distance` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SimulationDistance<const V: i32> {
/// `distance`
pub distance: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SimulationDistance<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { distance: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SimulationDistance<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).distance);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SimulationDistance<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { distance: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `set_title_subtitle` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetTitleSubtitle<const V: i32> {
/// `text`
pub text: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetTitleSubtitle<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
Self { text: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetTitleSubtitle<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).text.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetTitleSubtitle<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { text: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateTimeClockUpdates {
/// `id`
pub id: i32,
/// `totalTicks`
pub total_ticks: i64,
/// `partialTick`
pub partial_tick: f32,
/// `rate`
pub rate: f32,
}
#[cfg(feature = "v26_1")]
/// `update_time` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateTime<const V: i32> {
/// `age`
pub age: i64,
/// `clockUpdates`
pub clock_updates: Vec<crate::defs::p775::play::clientbound::UpdateTimeClockUpdates>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for UpdateTime<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i64()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 10)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = r.read_varint()?;
let v6 = r.read_varlong()?;
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
crate::defs::p775::play::clientbound::UpdateTimeClockUpdates {
id: v5,
total_ticks: v6,
partial_tick: v7,
rate: v8,
}
});
}
v4
};
Self {
age: v1,
clock_updates: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for UpdateTime<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).age);
w.put_len_varint((*self).clock_updates.len())?;
for v1 in (*self).clock_updates.iter() {
w.put_varint((*v1).id);
w.put_varlong((*v1).total_ticks);
w.put_f32((*v1).partial_tick);
w.put_f32((*v1).rate);
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateTime<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.i64();
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.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = g.varlong();
let v7 = g.f32();
let v8 = g.f32();
crate::defs::p775::play::clientbound::UpdateTimeClockUpdates {
id: v5,
total_ticks: v6,
partial_tick: v7,
rate: v8,
}
});
}
v4
};
Self {
age: v1,
clock_updates: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `set_title_text` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetTitleText<const V: i32> {
/// `text`
pub text: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetTitleText<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
Self { text: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetTitleText<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).text.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetTitleText<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
Self { text: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `set_title_time` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetTitleTime<const V: i32> {
/// `fadeIn`
pub fade_in: i32,
/// `stay`
pub stay: i32,
/// `fadeOut`
pub fade_out: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetTitleTime<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_i32()?;
let v3 = r.read_i32()?;
Self {
fade_in: v1,
stay: v2,
fade_out: v3,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetTitleTime<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).fade_in);
w.put_i32((*self).stay);
w.put_i32((*self).fade_out);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetTitleTime<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
fade_in: v1,
stay: v2,
fade_out: v3,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `entity_sound_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntitySoundEffect<const V: i32> {
/// `sound`
pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
/// `soundCategory`
pub sound_category: crate::defs::p775::types::SoundSource,
/// `entityId`
pub entity_id: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: f32,
/// `seed`
pub seed: i64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntitySoundEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Decode>::decode(r)?)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
let v2 = crate::defs::p775::types::SoundSource(r.read_varint()?);
let v3 = r.read_varint()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
let v6 = r.read_i64()?;
Self {
sound: v1,
sound_category: v2,
entity_id: v3,
volume: v4,
pitch: v5,
seed: v6,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntitySoundEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).sound {
Holder::Id(v2) => {
if *v2 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v2.wrapping_add(1));
}
Holder::Inline(v1) => {
w.put_varint(0);
(*v1).encode(w)?;
}
}
w.put_varint((*self).sound_category.0);
w.put_varint((*self).entity_id);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
w.put_i64((*self).seed);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntitySoundEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Generate>::generate(g))
};
let v2 = crate::defs::p775::types::SoundSource(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.f32();
let v5 = g.f32();
let v6 = g.i64();
Self {
sound: v1,
sound_category: v2,
entity_id: v3,
volume: v4,
pitch: v5,
seed: v6,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `sound_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SoundEffect<const V: i32> {
/// `sound`
pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
/// `soundCategory`
pub sound_category: crate::defs::p775::types::SoundSource,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: f32,
/// `seed`
pub seed: i64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SoundEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Decode>::decode(r)?)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
let v2 = crate::defs::p775::types::SoundSource(r.read_varint()?);
let v3 = r.read_i32()?;
let v4 = r.read_i32()?;
let v5 = r.read_i32()?;
let v6 = r.read_f32()?;
let v7 = r.read_f32()?;
let v8 = r.read_i64()?;
Self {
sound: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
seed: v8,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SoundEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).sound {
Holder::Id(v2) => {
if *v2 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v2.wrapping_add(1));
}
Holder::Inline(v1) => {
w.put_varint(0);
(*v1).encode(w)?;
}
}
w.put_varint((*self).sound_category.0);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
w.put_i64((*self).seed);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SoundEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(<crate::defs::p775::types::ItemSoundEvent as Generate>::generate(g))
};
let v2 = crate::defs::p775::types::SoundSource(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = g.f32();
let v7 = g.f32();
let v8 = g.i64();
Self {
sound: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
seed: v8,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `start_configuration` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct StartConfiguration<const V: i32> {}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for StartConfiguration<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for StartConfiguration<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for StartConfiguration<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v26_1")]
/// `store_cookie` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct StoreCookie<const V: i32> {
/// `key`
pub key: ByteString,
/// `value`
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")]
/// `system_chat` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SystemChat<const V: i32> {
/// `content`
pub content: AnonNbt,
/// `isActionBar`
pub is_action_bar: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SystemChat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
let v2 = r.read_bool()?;
Self {
content: v1,
is_action_bar: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SystemChat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).content.write(w);
w.put_bool((*self).is_action_bar);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SystemChat<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
let v2 = g.bool();
Self {
content: v1,
is_action_bar: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `playerlist_header` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerlistHeader<const V: i32> {
/// `header`
pub header: AnonNbt,
/// `footer`
pub footer: AnonNbt,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for PlayerlistHeader<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
let v2 = AnonNbt::read(r)?;
Self {
header: v1,
footer: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for PlayerlistHeader<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).header.write(w);
(*self).footer.write(w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PlayerlistHeader<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
let v2 = g.anon_nbt();
Self {
header: v1,
footer: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `nbt_query_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct NbtQueryResponse<const V: i32> {
/// `transactionId`
pub transaction_id: i32,
/// `nbt`
pub nbt: Option<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for NbtQueryResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = AnonNbt::read_optional(r)?;
Self {
transaction_id: v1,
nbt: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for NbtQueryResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
AnonNbt::write_optional(&(*self).nbt, w);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for NbtQueryResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.anon_opt_nbt();
Self {
transaction_id: v1,
nbt: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `entity_teleport` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityTeleport<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `dx`
pub dx: f64,
/// `dy`
pub dy: f64,
/// `dz`
pub dz: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::PositionUpdateRelatives,
/// `onGround`
pub on_ground: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityTeleport<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_f64()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = crate::defs::p775::play::clientbound::PositionUpdateRelatives(r.read_u32()?);
let v11 = r.read_bool()?;
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
flags: v10,
on_ground: v11,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityTeleport<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f64((*self).dx);
w.put_f64((*self).dy);
w.put_f64((*self).dz);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_u32((*self).flags.0);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityTeleport<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = g.f64();
let v8 = g.f32();
let v9 = g.f32();
let v10 = crate::defs::p775::play::clientbound::PositionUpdateRelatives(g.int_in(
0,
4294967295,
&[],
)
as u32);
let v11 = g.bool();
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
dx: v5,
dy: v6,
dz: v7,
yaw: v8,
pitch: v9,
flags: v10,
on_ground: v11,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `test_instance_block_status` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TestInstanceBlockStatus<const V: i32> {
/// `status`
pub status: AnonNbt,
/// `size`
pub size: Option<crate::defs::p775::types::Vec3i>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for TestInstanceBlockStatus<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = AnonNbt::read(r)?;
let v2 = if r.read_bool()? {
Some(<crate::defs::p775::types::Vec3i as Decode>::decode(r)?)
} else {
None
};
Self {
status: v1,
size: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for TestInstanceBlockStatus<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).status.write(w);
match &(*self).size {
Some(v1) => {
w.put_u8(1);
(*v1).encode(w)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TestInstanceBlockStatus<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.anon_nbt();
let v2 = if g.bool() {
Some(<crate::defs::p775::types::Vec3i as Generate>::generate(g))
} else {
None
};
Self {
status: v1,
size: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `set_ticking_state` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetTickingState<const V: i32> {
/// `tick_rate`
pub tick_rate: f32,
/// `is_frozen`
pub is_frozen: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetTickingState<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f32()?;
let v2 = r.read_bool()?;
Self {
tick_rate: v1,
is_frozen: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetTickingState<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).tick_rate);
w.put_bool((*self).is_frozen);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetTickingState<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f32();
let v2 = g.bool();
Self {
tick_rate: v1,
is_frozen: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `step_tick` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct StepTick<const V: i32> {
/// `tick_steps`
pub tick_steps: i32,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for StepTick<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { tick_steps: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for StepTick<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).tick_steps);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for StepTick<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { tick_steps: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `transfer` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Transfer<const V: i32> {
/// `host`
pub host: ByteString,
/// `port`
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")]
/// Packed bit field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
/// `unused` (29 bits)
pub unused: u32,
/// `hidden` (1 bits)
pub hidden: u8,
/// `show_toast` (1 bits)
pub show_toast: u8,
/// `has_background_texture` (1 bits)
pub has_background_texture: u8,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: AnonNbt,
/// `description`
pub description: AnonNbt,
/// `icon`
pub icon: crate::defs::p775::types::ItemStackTemplate,
/// `frameType`
pub frame_type: i32,
/// `flags`
pub flags:
crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags,
/// `backgroundTexture`
pub background_texture: Option<ByteString>,
/// `xCord`
pub x_cord: f32,
/// `yCord`
pub y_cord: f32,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<
crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
/// `sendsTelemtryData`
pub sends_telemtry_data: bool,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValue,
}
#[cfg(feature = "v26_1")]
/// `advancements` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements<const V: i32> {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping:
Vec<crate::defs::p775::play::clientbound::AdvancementsAdvancementMapping>,
/// `identifiers`
pub identifiers: Vec<ByteString>,
/// `progressMapping`
pub progress_mapping: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMapping>,
/// `showAdvancements`
pub show_advancements: bool,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for Advancements<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
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 = { let v7 = if r.read_bool()? { Some(r.read_string()?) } else { None };let v8 = if r.read_bool()? { Some({ let v9 = AnonNbt::read(r)?;let v10 = AnonNbt::read(r)?;let v11 = <crate::defs::p775::types::ItemStackTemplate as Decode>::decode(r)?;let v12 = r.read_varint()?;let v13 = { let v14 = u64::from(r.read_i32()? as u32); crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { unused: (((v14 >> 3) & 0x1fffffff) as u32), hidden: (((v14 >> 2) & 0x1) as u8), show_toast: (((v14 >> 1) & 0x1) as u8), has_background_texture: (((v14 >> 0) & 0x1) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(r.read_string()?) } else { None };let v16 = r.read_f32()?;let v17 = r.read_f32()?; crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v21 { v22.push(r.read_string()?); } v22 }); } v20 };let v23 = r.read_bool()?; crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p775::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
}
v4
};
let v24 = {
let v25 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v26 = Vec::with_capacity(v25.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v25 {
v26.push(r.read_string()?);
}
v26
};
let v27 = {
let v28 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v29 = Vec::with_capacity(v28.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v28 {
v29.push({ let v30 = r.read_string()?;let v31 = { let v32 = { let c = r.read_varint()?; r.check_count(i64::from(c), 2)? }; let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v32 { v33.push({ let v34 = r.read_string()?;let v35 = if r.read_bool()? { Some(r.read_i64()?) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v34, criterion_progress: v35 } }); } v33 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v30, value: v31 } });
}
v29
};
let v36 = r.read_bool()?;
Self {
reset: v1,
advancement_mapping: v2,
identifiers: v24,
progress_mapping: v27,
show_advancements: v36,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for Advancements<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).reset);
w.put_len_varint((*self).advancement_mapping.len())?;
for v1 in (*self).advancement_mapping.iter() {
w.put_string(&(*v1).key)?;
match &(*v1).value.parent_id {
Some(v2) => {
w.put_u8(1);
w.put_string(&(*v2))?;
}
None => w.put_u8(0),
}
match &(*v1).value.display_data {
Some(v3) => {
w.put_u8(1);
(*v3).title.write(w);
(*v3).description.write(w);
(*v3).icon.encode(w)?;
w.put_varint((*v3).frame_type);
{
let mut bits: u64 = 0;
{
let x = i128::from((*v3).flags.unused);
if x < 0 || x > 536870911 {
return Err(EncodeError::OutOfRange("unused"));
}
bits = (bits << 29) | ((x as u64) & 0x1fffffff);
}
{
let x = i128::from((*v3).flags.hidden);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("hidden"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v3).flags.show_toast);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("show_toast"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v3).flags.has_background_texture);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("has_background_texture"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
w.put_u32(bits as u32);
}
match (
&(*v3).background_texture,
((*v3).flags.has_background_texture == 1),
) {
(Some(v4), true) => {
w.put_string(&(*v4))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
));
}
}
w.put_f32((*v3).x_cord);
w.put_f32((*v3).y_cord);
}
None => w.put_u8(0),
}
w.put_len_varint((*v1).value.requirements.len())?;
for v5 in (*v1).value.requirements.iter() {
w.put_len_varint((*v5).len())?;
for v6 in (*v5).iter() {
w.put_string(&(*v6))?;
}
}
w.put_bool((*v1).value.sends_telemtry_data);
}
w.put_len_varint((*self).identifiers.len())?;
for v7 in (*self).identifiers.iter() {
w.put_string(&(*v7))?;
}
w.put_len_varint((*self).progress_mapping.len())?;
for v8 in (*self).progress_mapping.iter() {
w.put_string(&(*v8).key)?;
w.put_len_varint((*v8).value.len())?;
for v9 in (*v8).value.iter() {
w.put_string(&(*v9).criterion_identifier)?;
match &(*v9).criterion_progress {
Some(v10) => {
w.put_u8(1);
w.put_i64((*v10));
}
None => w.put_u8(0),
}
}
}
w.put_bool((*self).show_advancements);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Advancements<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
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 = { let v7 = if g.bool() { Some(g.string()) } else { None };let v8 = if g.bool() { Some({ let v9 = g.anon_nbt();let v10 = g.anon_nbt();let v11 = <crate::defs::p775::types::ItemStackTemplate as Generate>::generate(g);let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v13 = { crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { unused: (g.int_in(0, 536870911, &[]) as u32), hidden: (g.int_in(0, 1, &[]) as u8), show_toast: (g.int_in(0, 1, &[]) as u8), has_background_texture: (g.int_in(0, 1, &[1]) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(g.string()) } else { None };let v16 = g.f32();let v17 = g.f32(); crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = g.count(); let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = g.count(); let mut v22 = Vec::with_capacity(v21.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v21 { v22.push(g.string()); } v22 }); } v20 };let v23 = g.bool(); crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p775::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
}
v4
};
let v24 = {
let v25 = g.count();
let mut v26 = Vec::with_capacity(v25.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v25 {
v26.push(g.string());
}
v26
};
let v27 = {
let v28 = g.count();
let mut v29 = Vec::with_capacity(v28.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v28 {
v29.push({ let v30 = g.string();let v31 = { let v32 = g.count(); let mut v33 = Vec::with_capacity(v32.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v32 { v33.push({ let v34 = g.string();let v35 = if g.bool() { Some(g.i64()) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v34, criterion_progress: v35 } }); } v33 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v30, value: v31 } });
}
v29
};
let v36 = g.bool();
Self {
reset: v1,
advancement_mapping: v2,
identifiers: v24,
progress_mapping: v27,
show_advancements: v36,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct EntityUpdateAttributesPropertiesKey(pub i32);
#[cfg(feature = "v26_1")]
impl EntityUpdateAttributesPropertiesKey {
/// `generic.armor`
pub const GENERIC_ARMOR: Self = Self(0);
/// `generic.armor_toughness`
pub const GENERIC_ARMOR_TOUGHNESS: Self = Self(1);
/// `generic.attack_damage`
pub const GENERIC_ATTACK_DAMAGE: Self = Self(2);
/// `generic.attack_knockback`
pub const GENERIC_ATTACK_KNOCKBACK: Self = Self(3);
/// `generic.attack_speed`
pub const GENERIC_ATTACK_SPEED: Self = Self(4);
/// `player.block_break_speed`
pub const PLAYER_BLOCK_BREAK_SPEED: Self = Self(5);
/// `player.block_interaction_range`
pub const PLAYER_BLOCK_INTERACTION_RANGE: Self = Self(6);
/// `burning_time`
pub const BURNING_TIME: Self = Self(7);
/// `camera_distance`
pub const CAMERA_DISTANCE: Self = Self(8);
/// `explosion_knockback_resistance`
pub const EXPLOSION_KNOCKBACK_RESISTANCE: Self = Self(9);
/// `player.entity_interaction_range`
pub const PLAYER_ENTITY_INTERACTION_RANGE: Self = Self(10);
/// `generic.fall_damage_multiplier`
pub const GENERIC_FALL_DAMAGE_MULTIPLIER: Self = Self(11);
/// `generic.flying_speed`
pub const GENERIC_FLYING_SPEED: Self = Self(12);
/// `generic.follow_range`
pub const GENERIC_FOLLOW_RANGE: Self = Self(13);
/// `generic.gravity`
pub const GENERIC_GRAVITY: Self = Self(14);
/// `generic.jump_strength`
pub const GENERIC_JUMP_STRENGTH: Self = Self(15);
/// `generic.knockback_resistance`
pub const GENERIC_KNOCKBACK_RESISTANCE: Self = Self(16);
/// `generic.luck`
pub const GENERIC_LUCK: Self = Self(17);
/// `generic.max_absorption`
pub const GENERIC_MAX_ABSORPTION: Self = Self(18);
/// `generic.max_health`
pub const GENERIC_MAX_HEALTH: Self = Self(19);
/// `mining_efficiency`
pub const MINING_EFFICIENCY: Self = Self(20);
/// `movement_efficiency`
pub const MOVEMENT_EFFICIENCY: Self = Self(21);
/// `generic.movement_speed`
pub const GENERIC_MOVEMENT_SPEED: Self = Self(22);
/// `oxygen_bonus`
pub const OXYGEN_BONUS: Self = Self(23);
/// `generic.safe_fall_distance`
pub const GENERIC_SAFE_FALL_DISTANCE: Self = Self(24);
/// `generic.scale`
pub const GENERIC_SCALE: Self = Self(25);
/// `sneaking_speed`
pub const SNEAKING_SPEED: Self = Self(26);
/// `zombie.spawn_reinforcements`
pub const ZOMBIE_SPAWN_REINFORCEMENTS: Self = Self(27);
/// `generic.step_height`
pub const GENERIC_STEP_HEIGHT: Self = Self(28);
/// `submerged_mining_speed`
pub const SUBMERGED_MINING_SPEED: Self = Self(29);
/// `sweeping_damage_ratio`
pub const SWEEPING_DAMAGE_RATIO: Self = Self(30);
/// `tempt_range`
pub const TEMPT_RANGE: Self = Self(31);
/// `water_movement_efficiency`
pub const WATER_MOVEMENT_EFFICIENCY: Self = Self(32);
/// `waypoint_transmit_range`
pub const WAYPOINT_TRANSMIT_RANGE: Self = Self(33);
/// `waypoint_receive_range`
pub const WAYPOINT_RECEIVE_RANGE: Self = Self(34);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("generic.armor"),
1 => Some("generic.armor_toughness"),
2 => Some("generic.attack_damage"),
3 => Some("generic.attack_knockback"),
4 => Some("generic.attack_speed"),
5 => Some("player.block_break_speed"),
6 => Some("player.block_interaction_range"),
7 => Some("burning_time"),
8 => Some("camera_distance"),
9 => Some("explosion_knockback_resistance"),
10 => Some("player.entity_interaction_range"),
11 => Some("generic.fall_damage_multiplier"),
12 => Some("generic.flying_speed"),
13 => Some("generic.follow_range"),
14 => Some("generic.gravity"),
15 => Some("generic.jump_strength"),
16 => Some("generic.knockback_resistance"),
17 => Some("generic.luck"),
18 => Some("generic.max_absorption"),
19 => Some("generic.max_health"),
20 => Some("mining_efficiency"),
21 => Some("movement_efficiency"),
22 => Some("generic.movement_speed"),
23 => Some("oxygen_bonus"),
24 => Some("generic.safe_fall_distance"),
25 => Some("generic.scale"),
26 => Some("sneaking_speed"),
27 => Some("zombie.spawn_reinforcements"),
28 => Some("generic.step_height"),
29 => Some("submerged_mining_speed"),
30 => Some("sweeping_damage_ratio"),
31 => Some("tempt_range"),
32 => Some("water_movement_efficiency"),
33 => Some("waypoint_transmit_range"),
34 => Some("waypoint_receive_range"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for EntityUpdateAttributesPropertiesKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "EntityUpdateAttributesPropertiesKey::{n}"),
None => write!(f, "EntityUpdateAttributesPropertiesKey({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesPropertiesModifiers {
/// `uuid`
pub uuid: ByteString,
/// `amount`
pub amount: f64,
/// `operation`
pub operation: i8,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesProperties {
/// `key`
pub key: crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesKey,
/// `value`
pub value: f64,
/// `modifiers`
pub modifiers:
Vec<crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers>,
}
#[cfg(feature = "v26_1")]
/// `entity_update_attributes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributes<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `properties`
pub properties: Vec<crate::defs::p775::play::clientbound::EntityUpdateAttributesProperties>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityUpdateAttributes<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 10)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesKey(r.read_varint()?);let v6 = r.read_f64()?;let v7 = { let v8 = { let c = r.read_varint()?; r.check_count(i64::from(c), 10)? }; let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = r.read_string()?;let v11 = r.read_f64()?;let v12 = r.read_i8()?; crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p775::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityUpdateAttributes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_len_varint((*self).properties.len())?;
for v1 in (*self).properties.iter() {
w.put_varint((*v1).key.0);
w.put_f64((*v1).value);
w.put_len_varint((*v1).modifiers.len())?;
for v2 in (*v1).modifiers.iter() {
w.put_string(&(*v2).uuid)?;
w.put_f64((*v2).amount);
w.put_i8((*v2).operation);
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityUpdateAttributes<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
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 = crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesKey(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) as i32);let v6 = g.f64();let v7 = { let v8 = g.count(); let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = g.string();let v11 = g.f64();let v12 = (g.int_in(-128, 127, &[]) as i8); crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p775::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `entity_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEffect<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `effectId`
pub effect_id: i32,
/// `amplifier`
pub amplifier: i32,
/// `duration`
pub duration: i32,
/// `flags`
pub flags: u8,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for EntityEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = r.read_varint()?;
let v5 = r.read_u8()?;
Self {
entity_id: v1,
effect_id: v2,
amplifier: v3,
duration: v4,
flags: v5,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for EntityEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).effect_id);
w.put_varint((*self).amplifier);
w.put_varint((*self).duration);
w.put_u8((*self).flags);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(0, 255, &[]) as u8);
Self {
entity_id: v1,
effect_id: v2,
amplifier: v3,
duration: v4,
flags: v5,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipes {
/// `name`
pub name: ByteString,
/// `items`
pub items: Vec<i32>,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesStoneCutterRecipes {
/// `input`
pub input: HolderSet,
/// `slotDisplay`
pub slot_display: crate::defs::p775::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_1")]
/// `declare_recipes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipes<const V: i32> {
/// `recipes`
pub recipes: Vec<crate::defs::p775::play::clientbound::DeclareRecipesRecipes>,
/// `stoneCutterRecipes`
pub stone_cutter_recipes:
Vec<crate::defs::p775::play::clientbound::DeclareRecipesStoneCutterRecipes>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for DeclareRecipes<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), 1)?
};
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push(r.read_varint()?);
}
v7
};
crate::defs::p775::play::clientbound::DeclareRecipesRecipes {
name: v4,
items: v5,
}
});
}
v3
};
let v8 = {
let v9 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({
let v11 = <HolderSet as Decode>::decode(r)?;
let v12 =
<crate::defs::p775::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?;
crate::defs::p775::play::clientbound::DeclareRecipesStoneCutterRecipes {
input: v11,
slot_display: v12,
}
});
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for DeclareRecipes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).recipes.len())?;
for v1 in (*self).recipes.iter() {
w.put_string(&(*v1).name)?;
w.put_len_varint((*v1).items.len())?;
for v2 in (*v1).items.iter() {
w.put_varint((*v2));
}
}
w.put_len_varint((*self).stone_cutter_recipes.len())?;
for v3 in (*self).stone_cutter_recipes.iter() {
(*v3).input.encode(w)?;
(*v3).slot_display.encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DeclareRecipes<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((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v7
};
crate::defs::p775::play::clientbound::DeclareRecipesRecipes {
name: v4,
items: v5,
}
});
}
v3
};
let v8 = {
let v9 = g.count();
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({ let v11 = <HolderSet as Generate>::generate(g);let v12 = <crate::defs::p775::play::clientbound::SlotDisplay as Generate>::generate(g); crate::defs::p775::play::clientbound::DeclareRecipesStoneCutterRecipes { input: v11, slot_display: v12 } });
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TagsTags {
/// `tagType`
pub tag_type: ByteString,
/// `tags`
pub tags: Vec<crate::defs::p754::types::Tags>,
}
#[cfg(feature = "v26_1")]
/// `tags` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Tags<const V: i32> {
/// `tags`
pub tags: Vec<crate::defs::p775::play::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::play::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::play::clientbound::TagsTags {
tag_type: v4,
tags: v5,
}
});
}
v3
};
Self { tags: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// `set_projectile_power` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetProjectilePower<const V: i32> {
/// `id`
pub id: i32,
/// `accelerationPower`
pub acceleration_power: f64,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for SetProjectilePower<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
Self {
id: v1,
acceleration_power: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for SetProjectilePower<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).id);
w.put_f64((*self).acceleration_power);
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetProjectilePower<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
Self {
id: v1,
acceleration_power: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct CustomReportDetailsDetails {
/// `key`
pub key: ByteString,
/// `value`
pub value: ByteString,
}
#[cfg(feature = "v26_1")]
/// `custom_report_details` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CustomReportDetails<const V: i32> {
/// `details`
pub details: Vec<crate::defs::p775::play::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::play::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::play::clientbound::CustomReportDetailsDetails {
key: v4,
value: v5,
}
});
}
v3
};
Self { details: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct ServerLinksLinks {
/// `hasKnownType`
pub has_known_type: bool,
/// `knownType`
pub known_type: Option<crate::defs::p775::types::ServerLinkType>,
/// `unknownType`
pub unknown_type: Option<AnonNbt>,
/// `link`
pub link: ByteString,
}
#[cfg(feature = "v26_1")]
/// `server_links` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ServerLinks<const V: i32> {
/// `links`
pub links: Vec<crate::defs::p775::play::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::play::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(
"play.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(
"play.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::play::clientbound::ServerLinksLinks {
has_known_type: v4,
known_type: v5,
unknown_type: v6,
link: v7,
}
});
}
v3
};
Self { links: v1 }
}
}
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TrackedWaypointOperation(pub i32);
#[cfg(feature = "v26_1")]
impl TrackedWaypointOperation {
/// `track`
pub const TRACK: Self = Self(0);
/// `untrack`
pub const UNTRACK: Self = Self(1);
/// `update`
pub const UPDATE: Self = Self(2);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("track"),
1 => Some("untrack"),
2 => Some("update"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for TrackedWaypointOperation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "TrackedWaypointOperation::{n}"),
None => write!(f, "TrackedWaypointOperation({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypointBodyTrue {
/// `uuid`
pub uuid: Uuid,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypointBodyFalse {
/// `id`
pub id: ByteString,
}
#[cfg(feature = "v26_1")]
/// Switch on `hasUUID`.
#[derive(Debug, Clone, PartialEq)]
pub enum TrackedWaypointWaypointBody {
/// Case(s) `true`.
True(crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyTrue),
/// Case(s) `false`.
False(crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyFalse),
/// Any other value.
Other,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypointIconColor {
/// `red`
pub red: u8,
/// `green`
pub green: u8,
/// `blue`
pub blue: u8,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypointIcon {
/// `style`
pub style: ByteString,
/// `color`
pub color: Option<crate::defs::p775::play::clientbound::TrackedWaypointWaypointIconColor>,
}
#[cfg(feature = "v26_1")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct TrackedWaypointWaypointType(pub i32);
#[cfg(feature = "v26_1")]
impl TrackedWaypointWaypointType {
/// `empty`
pub const EMPTY: Self = Self(0);
/// `vec3i`
pub const VEC3I: Self = Self(1);
/// `chunk`
pub const CHUNK: Self = Self(2);
/// `azimuth`
pub const AZIMUTH: Self = Self(3);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("empty"),
1 => Some("vec3i"),
2 => Some("chunk"),
3 => Some("azimuth"),
_ => None,
}
}
}
#[cfg(feature = "v26_1")]
impl std::fmt::Debug for TrackedWaypointWaypointType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "TrackedWaypointWaypointType::{n}"),
None => write!(f, "TrackedWaypointWaypointType({})", self.0),
}
}
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypointDataChunk {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
}
#[cfg(feature = "v26_1")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
pub enum TrackedWaypointWaypointData {
/// Case(s) `vec3i`.
Vec3i(crate::defs::p775::types::Vec3i),
/// Case(s) `chunk`.
Chunk(crate::defs::p775::play::clientbound::TrackedWaypointWaypointDataChunk),
/// Case(s) `azimuth`.
Azimuth(f32),
/// Any other value.
Other,
}
#[cfg(feature = "v26_1")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypointWaypoint {
/// `hasUUID`
pub has_uuid: bool,
/// Anonymous switch
pub body: crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody,
/// `icon`
pub icon: crate::defs::p775::play::clientbound::TrackedWaypointWaypointIcon,
/// `type`
pub r#type: crate::defs::p775::play::clientbound::TrackedWaypointWaypointType,
/// `data`
pub data: crate::defs::p775::play::clientbound::TrackedWaypointWaypointData,
}
#[cfg(feature = "v26_1")]
/// `tracked_waypoint` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TrackedWaypoint<const V: i32> {
/// `operation`
pub operation: crate::defs::p775::play::clientbound::TrackedWaypointOperation,
/// `waypoint`
pub waypoint: crate::defs::p775::play::clientbound::TrackedWaypointWaypoint,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for TrackedWaypoint<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 =
crate::defs::p775::play::clientbound::TrackedWaypointOperation(r.read_varint()?);
let v2 = {
let v3 = r.read_bool()?;
let v4 = (if v3 {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::True({
let v5 = r.read_uuid()?;
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyTrue {
uuid: v5,
}
})
} else if (!v3) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::False({
let v6 = r.read_string()?;
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyFalse {
id: v6,
}
})
} else {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::Other
});
let v7 = {
let v8 = r.read_string()?;
let v9 = if r.read_bool()? {
Some({
let v10 = r.read_u8()?;
let v11 = r.read_u8()?;
let v12 = r.read_u8()?;
crate::defs::p775::play::clientbound::TrackedWaypointWaypointIconColor {
red: v10,
green: v11,
blue: v12,
}
})
} else {
None
};
crate::defs::p775::play::clientbound::TrackedWaypointWaypointIcon {
style: v8,
color: v9,
}
};
let v13 = crate::defs::p775::play::clientbound::TrackedWaypointWaypointType(
r.read_varint()?,
);
let v14 = (if (v13.0 == 1) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Vec3i(
<crate::defs::p775::types::Vec3i as Decode>::decode(r)?,
)
} else if (v13.0 == 2) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Chunk({
let v15 = r.read_varint()?;
let v16 = r.read_varint()?;
crate::defs::p775::play::clientbound::TrackedWaypointWaypointDataChunk {
chunk_x: v15,
chunk_z: v16,
}
})
} else if (v13.0 == 3) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Azimuth(
r.read_f32()?,
)
} else {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Other
});
crate::defs::p775::play::clientbound::TrackedWaypointWaypoint {
has_uuid: v3,
body: v4,
icon: v7,
r#type: v13,
data: v14,
}
};
Self {
operation: v1,
waypoint: v2,
}
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for TrackedWaypoint<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).operation.0);
w.put_bool((*self).waypoint.has_uuid);
match &(*self).waypoint.body {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::True(v1) => {
if !((*self).waypoint.has_uuid) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.body",
));
}
w.put_uuid(&(*v1).uuid);
}
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::False(v2) => {
if !(!(*self).waypoint.has_uuid) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.body",
));
}
w.put_string(&(*v2).id)?;
}
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::Other => {
if !(!((*self).waypoint.has_uuid || (!(*self).waypoint.has_uuid))) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.body",
));
}
}
}
w.put_string(&(*self).waypoint.icon.style)?;
match &(*self).waypoint.icon.color {
Some(v3) => {
w.put_u8(1);
w.put_u8((*v3).red);
w.put_u8((*v3).green);
w.put_u8((*v3).blue);
}
None => w.put_u8(0),
}
w.put_varint((*self).waypoint.r#type.0);
match &(*self).waypoint.data {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Vec3i(v4) => {
if !((*self).waypoint.r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.data",
));
}
(*v4).encode(w)?;
}
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Chunk(v5) => {
if !((*self).waypoint.r#type.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.data",
));
}
w.put_varint((*v5).chunk_x);
w.put_varint((*v5).chunk_z);
}
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Azimuth(v6) => {
if !((*self).waypoint.r#type.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.data",
));
}
w.put_f32((*v6));
}
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Other => {
if !(!(((*self).waypoint.r#type.0 == 1)
|| ((*self).waypoint.r#type.0 == 2)
|| ((*self).waypoint.r#type.0 == 3)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.tracked_waypoint.waypoint.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v26_1")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TrackedWaypoint<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p775::play::clientbound::TrackedWaypointOperation(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2],
)
as i32);
let v2 = {
let v3 = g.bool();
let v4 = (if v3 {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::True({
let v5 = g.uuid();
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyTrue {
uuid: v5,
}
})
} else if (!v3) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::False({
let v6 = g.string();
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBodyFalse {
id: v6,
}
})
} else {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointBody::Other
});
let v7 = {
let v8 = g.string();
let v9 = if g.bool() {
Some({
let v10 = (g.int_in(0, 255, &[]) as u8);
let v11 = (g.int_in(0, 255, &[]) as u8);
let v12 = (g.int_in(0, 255, &[]) as u8);
crate::defs::p775::play::clientbound::TrackedWaypointWaypointIconColor {
red: v10,
green: v11,
blue: v12,
}
})
} else {
None
};
crate::defs::p775::play::clientbound::TrackedWaypointWaypointIcon {
style: v8,
color: v9,
}
};
let v13 = crate::defs::p775::play::clientbound::TrackedWaypointWaypointType(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
);
let v14 = (if (v13.0 == 1) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Vec3i(
<crate::defs::p775::types::Vec3i as Generate>::generate(g),
)
} else if (v13.0 == 2) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Chunk({
let v15 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v16 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p775::play::clientbound::TrackedWaypointWaypointDataChunk {
chunk_x: v15,
chunk_z: v16,
}
})
} else if (v13.0 == 3) {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Azimuth(
g.f32(),
)
} else {
crate::defs::p775::play::clientbound::TrackedWaypointWaypointData::Other
});
crate::defs::p775::play::clientbound::TrackedWaypointWaypoint {
has_uuid: v3,
body: v4,
icon: v7,
r#type: v13,
data: v14,
}
};
Self {
operation: v1,
waypoint: v2,
}
}
}
}
#[cfg(feature = "v26_1")]
/// `clear_dialog` (clientbound play).
#[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")]
/// `show_dialog` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ShowDialog<const V: i32> {
/// `dialog`
pub dialog: Holder<AnonNbt>,
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Decode for ShowDialog<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let id = r.read_varint()?;
if id == 0 {
Holder::Inline(AnonNbt::read(r)?)
} else {
Holder::Id(id.wrapping_sub(1))
}
};
Self { dialog: v1 }
})
}
}
#[cfg(feature = "v26_1")]
impl<const V: i32> Encode for ShowDialog<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).dialog {
Holder::Id(v2) => {
if *v2 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v2.wrapping_add(1));
}
Holder::Inline(v1) => {
w.put_varint(0);
(*v1).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 = if g.bool() {
Holder::Id(match g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32 {
-1 => 0,
v => v,
})
} else {
Holder::Inline(g.anon_nbt())
};
Self { dialog: v1 }
}
}
}