// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/26.1/protocol.json + codegen/protocol/delta/776.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_2")]
/// Named type `ExplosionParticleEntry`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleEntry {
/// `data`
pub data: crate::defs::p776::play::clientbound::ExplosionParticleInfo,
/// `weight`
pub weight: i32,
}
#[cfg(feature = "v26_2")]
impl Decode for ExplosionParticleEntry {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 =
<crate::defs::p776::play::clientbound::ExplosionParticleInfo as Decode>::decode(r)?;
let v2 = r.read_varint()?;
Self {
data: v1,
weight: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
impl Encode for ExplosionParticleEntry {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).data.encode(w)?;
w.put_varint((*self).weight);
Ok(())
}
}
#[cfg(feature = "v26_2")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleEntry {
fn generate(g: &mut Gen) -> Self {
{
let v1 =
<crate::defs::p776::play::clientbound::ExplosionParticleInfo as Generate>::generate(
g,
);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
data: v1,
weight: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Named type `ExplosionParticleInfo`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleInfo {
/// `particle`
pub particle: crate::defs::p776::types::Particle,
/// `scaling`
pub scaling: f32,
/// `speed`
pub speed: f32,
}
#[cfg(feature = "v26_2")]
impl Decode for ExplosionParticleInfo {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p776::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_2")]
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_2")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleInfo {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p776::types::Particle as Generate>::generate(g);
let v2 = g.f32();
let v3 = g.f32();
Self {
particle: v1,
scaling: v2,
speed: v3,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShapeless {
/// `ingredients`
pub ingredients: Vec<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p776::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShaped {
/// `width`
pub width: i32,
/// `height`
pub height: i32,
/// `ingredients`
pub ingredients: Vec<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p776::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataFurnace {
/// `ingredient`
pub ingredient: crate::defs::p776::play::clientbound::SlotDisplay,
/// `fuel`
pub fuel: crate::defs::p776::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p776::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
/// `duration`
pub duration: i32,
/// `experience`
pub experience: f32,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataStonecutter {
/// `ingredient`
pub ingredient: crate::defs::p776::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p776::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataSmithing {
/// `template`
pub template: crate::defs::p776::play::clientbound::SlotDisplay,
/// `base`
pub base: crate::defs::p776::play::clientbound::SlotDisplay,
/// `addition`
pub addition: crate::defs::p776::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p776::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p776::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_2")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum RecipeDisplayData {
/// Case(s) `crafting_shapeless`.
CraftingShapeless(crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless),
/// Case(s) `crafting_shaped`.
CraftingShaped(crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped),
/// Case(s) `furnace`.
Furnace(crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace),
/// Case(s) `stonecutter`.
Stonecutter(crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter),
/// Case(s) `smithing`.
Smithing(crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing),
/// Any other value.
Other,
}
#[cfg(feature = "v26_2")]
/// 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::p776::play::clientbound::RecipeDisplayData,
}
#[cfg(feature = "v26_2")]
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::p776::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::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v5
};
let v6 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v7 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p776::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::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v12
};
let v13 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v14 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v16 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v17 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v18 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v19 = r.read_varint()?;
let v20 = r.read_f32()?;
crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v22 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v23 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v25 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v26 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v27 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v28 =
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p776::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
impl Encode for RecipeDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p776::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::p776::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::p776::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::p776::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::p776::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::p776::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_2")]
#[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::p776::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::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v5
};
let v6 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v7 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p776::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::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v12
};
let v13 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v14 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p776::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v16 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v17 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v18 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v20 = g.f32();
crate::defs::p776::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v22 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v23 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p776::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p776::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v25 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v26 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v27 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v28 =
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p776::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p776::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithAnyPotion {
/// `base`
pub base: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataOnlyWithComponent {
/// `source`
pub source: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `component`
pub component: crate::defs::p776::types::SlotComponentType,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataDyedSlotDemo {
/// `dye`
pub dye: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `target`
pub target: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataSmithingTrim {
/// `base`
pub base: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `material`
pub material: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `pattern`
pub pattern: Holder<crate::defs::p775::types::ArmorTrimPattern>,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithRemainder {
/// `input`
pub input: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
/// `remainder`
pub remainder: Box<crate::defs::p776::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_2")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum SlotDisplayData {
/// Case(s) `empty`.
Empty,
/// Case(s) `any_fuel`.
AnyFuel,
/// Case(s) `with_any_potion`.
WithAnyPotion(crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion),
/// Case(s) `only_with_component`.
OnlyWithComponent(crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent),
/// Case(s) `item`.
Item(i32),
/// Case(s) `item_stack`.
ItemStack(crate::defs::p776::types::ItemStackTemplate),
/// Case(s) `tag`.
Tag(ByteString),
/// Case(s) `dyed_slot_demo`.
DyedSlotDemo(crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo),
/// Case(s) `smithing_trim`.
SmithingTrim(crate::defs::p776::play::clientbound::SlotDisplayDataSmithingTrim),
/// Case(s) `with_remainder`.
WithRemainder(crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder),
/// Case(s) `composite`.
Composite(Vec<crate::defs::p776::play::clientbound::SlotDisplay>),
/// Any other value.
Other,
}
#[cfg(feature = "v26_2")]
/// 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::p776::play::clientbound::SlotDisplayData,
}
#[cfg(feature = "v26_2")]
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::p776::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p776::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p776::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v5 = crate::defs::p776::types::SlotComponentType(r.read_varint()?);
crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p776::play::clientbound::SlotDisplayData::Item(r.read_varint()?)
} else if (v1.0 == 5) {
crate::defs::p776::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p776::types::ItemStackTemplate as Decode>::decode(r)?,
)
} else if (v1.0 == 6) {
crate::defs::p776::play::clientbound::SlotDisplayData::Tag(r.read_string()?)
} else if (v1.0 == 7) {
crate::defs::p776::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v7 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p776::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v9 = Box::new(
<crate::defs::p776::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::p776::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p776::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v12 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p776::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::p776::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?,
);
}
v14
})
} else {
crate::defs::p776::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
impl Encode for SlotDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p776::play::clientbound::SlotDisplayData::Empty => {
if !((*self).r#type.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel => {
if !((*self).r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p776::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::p776::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::p776::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::p776::play::clientbound::SlotDisplayData::ItemStack(v4) => {
if !((*self).r#type.0 == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*v4).encode(w)?;
}
crate::defs::p776::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::p776::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::p776::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::p776::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::p776::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::p776::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_2")]
#[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::p776::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p776::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p776::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p776::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p776::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v5 = crate::defs::p776::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, 110,
],
)
as i32);
crate::defs::p776::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p776::play::clientbound::SlotDisplayData::Item(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v1.0 == 5) {
crate::defs::p776::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p776::types::ItemStackTemplate as Generate>::generate(g),
)
} else if (v1.0 == 6) {
crate::defs::p776::play::clientbound::SlotDisplayData::Tag(g.string())
} else if (v1.0 == 7) {
crate::defs::p776::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v7 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p776::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p776::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v9 = Box::new(
<crate::defs::p776::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::p776::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p776::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v12 = Box::new(
<crate::defs::p776::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p776::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p776::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::p776::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v14
})
} else {
crate::defs::p776::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// `declare_commands` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareCommands<const V: i32> {
/// `nodes`
pub nodes: Vec<crate::defs::p776::types::CommandNode>,
/// `rootIndex`
pub root_index: i32,
}
#[cfg(feature = "v26_2")]
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::p776::types::CommandNode as Decode>::decode(
r,
)?);
}
v3
};
let v4 = r.read_varint()?;
Self {
nodes: v1,
root_index: v4,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::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_2")]
/// `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::p776::types::Slot>,
/// `carriedItem`
pub carried_item: crate::defs::p776::types::Slot,
}
#[cfg(feature = "v26_2")]
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::p776::types::Slot as Decode>::decode(r)?);
}
v5
};
let v6 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::types::Slot as Generate>::generate(g));
}
v5
};
let v6 = <crate::defs::p776::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
}
}
}
#[cfg(feature = "v26_2")]
/// `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::p776::types::Slot,
}
#[cfg(feature = "v26_2")]
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::p776::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
}
}
}
#[cfg(feature = "v26_2")]
/// `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::p776::types::Particle,
/// `sound`
pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
/// `blockParticles`
pub block_particles: Vec<crate::defs::p776::play::clientbound::ExplosionParticleEntry>,
}
#[cfg(feature = "v26_2")]
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::p776::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::p776::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_2")]
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_2")]
#[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::p776::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::p776::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_2")]
/// `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::p776::types::Particle,
}
#[cfg(feature = "v26_2")]
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::p776::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_2")]
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_2")]
#[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::p776::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_2")]
/// `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,
/// `onlineMode`
pub online_mode: bool,
/// `enforcesSecureChat`
pub enforces_secure_chat: bool,
}
#[cfg(feature = "v26_2")]
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()?;
let v14 = 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,
online_mode: v13,
enforces_secure_chat: v14,
}
})
}
}
#[cfg(feature = "v26_2")]
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).online_mode);
w.put_bool((*self).enforces_secure_chat);
Ok(())
}
}
#[cfg(feature = "v26_2")]
#[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();
let v14 = 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,
online_mode: v13,
enforces_secure_chat: v14,
}
}
}
}
#[cfg(feature = "v26_2")]
/// 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::p776::types::SlotComponent>,
}
#[cfg(feature = "v26_2")]
/// 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::p776::types::SlotComponent>,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTrades {
/// `inputItem1`
pub input_item1: crate::defs::p776::play::clientbound::TradeListTradesInputItem1,
/// `outputItem`
pub output_item: crate::defs::p776::types::Slot,
/// `inputItem2`
pub input_item2: Option<crate::defs::p776::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_2")]
/// `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::p776::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_2")]
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::p776::types::SlotComponent as Decode>::decode(r)?); } v10 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p776::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::p776::types::SlotComponent as Decode>::decode(r)?); } v17 }; crate::defs::p776::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::p776::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_2")]
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_2")]
#[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::p776::types::SlotComponent as Generate>::generate(g)); } v10 }; crate::defs::p776::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p776::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::p776::types::SlotComponent as Generate>::generate(g)); } v17 }; crate::defs::p776::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::p776::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_2")]
/// `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::p776::play::clientbound::RecipeDisplay,
}
#[cfg(feature = "v26_2")]
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::p776::play::clientbound::RecipeDisplay as Decode>::decode(r)?;
Self {
window_id: v1,
recipe_display: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::play::clientbound::RecipeDisplay as Generate>::generate(g);
Self {
window_id: v1,
recipe_display: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntriesRecipe {
/// `displayId`
pub display_id: i32,
/// `display`
pub display: crate::defs::p776::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_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntries {
/// `recipe`
pub recipe: crate::defs::p776::play::clientbound::RecipeBookAddEntriesRecipe,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags,
}
#[cfg(feature = "v26_2")]
/// `recipe_book_add` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAdd<const V: i32> {
/// `entries`
pub entries: Vec<crate::defs::p776::play::clientbound::RecipeBookAddEntries>,
/// `replace`
pub replace: bool,
}
#[cfg(feature = "v26_2")]
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::p776::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::p776::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::p776::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = r.read_bool()?;
Self {
entries: v1,
replace: v13,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::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::p776::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::p776::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = g.bool();
Self {
entries: v1,
replace: v13,
}
}
}
}
#[cfg(feature = "v26_2")]
/// `set_cursor_item` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCursorItem<const V: i32> {
/// `contents`
pub contents: crate::defs::p776::types::Slot,
}
#[cfg(feature = "v26_2")]
impl<const V: i32> Decode for SetCursorItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p776::types::Slot as Decode>::decode(r)?;
Self { contents: v1 }
})
}
}
#[cfg(feature = "v26_2")]
impl<const V: i32> Encode for SetCursorItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).contents.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCursorItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p776::types::Slot as Generate>::generate(g);
Self { contents: v1 }
}
}
}
#[cfg(feature = "v26_2")]
/// `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::p776::types::EntityMetadataEntry>,
}
#[cfg(feature = "v26_2")]
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::p776::types::EntityMetadataEntry as Decode>::decode(r)?);
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::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_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipmentEquipments {
/// `slot`
pub slot: i8,
/// `item`
pub item: crate::defs::p776::types::Slot,
}
#[cfg(feature = "v26_2")]
/// `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::p776::play::clientbound::EntityEquipmentEquipments>,
}
#[cfg(feature = "v26_2")]
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::p776::types::Slot as Decode>::decode(r)?;
crate::defs::p776::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
});
if v4 & 0x80 == 0 {
break;
}
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::types::Slot as Generate>::generate(g);
crate::defs::p776::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_2")]
/// `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::p776::types::Slot,
}
#[cfg(feature = "v26_2")]
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::p776::types::Slot as Decode>::decode(r)?;
Self {
slot_id: v1,
contents: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::types::Slot as Generate>::generate(g);
Self {
slot_id: v1,
contents: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TeamsBodyAdd {
/// `name`
pub name: AnonNbt,
/// `prefix`
pub prefix: AnonNbt,
/// `suffix`
pub suffix: AnonNbt,
/// `nameTagVisibility`
pub name_tag_visibility: crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility,
/// `collisionRule`
pub collision_rule: crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule,
/// `color`
pub color: Option<i32>,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::TeamsBodyAddFlags,
}
#[cfg(feature = "v26_2")]
/// `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::p776::play::clientbound::TeamsBodyAdd>,
/// `players`
pub players: Option<Vec<ByteString>>,
}
#[cfg(feature = "v26_2")]
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 = AnonNbt::read(r)?;
let v6 = AnonNbt::read(r)?;
let v7 = crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
r.read_varint()?,
);
let v8 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
r.read_varint()?,
);
let v9 = if r.read_bool()? {
Some(r.read_varint()?)
} else {
None
};
let v10 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(r.read_u8()?);
crate::defs::p776::play::clientbound::TeamsBodyAdd {
name: v4,
prefix: v5,
suffix: v6,
name_tag_visibility: v7,
collision_rule: v8,
color: v9,
flags: 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_2")]
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);
(*v1).prefix.write(w);
(*v1).suffix.write(w);
w.put_varint((*v1).name_tag_visibility.0);
w.put_varint((*v1).collision_rule.0);
match &(*v1).color {
Some(v2) => {
w.put_u8(1);
w.put_varint((*v2));
}
None => w.put_u8(0),
}
w.put_u8((*v1).flags.0);
}
(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(v3), true) => {
w.put_len_varint((*v3).len())?;
for v4 in (*v3).iter() {
w.put_string(&(*v4))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.players",
));
}
}
Ok(())
}
}
#[cfg(feature = "v26_2")]
#[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 = g.anon_nbt();
let v6 = g.anon_nbt();
let v7 =
crate::defs::p775::play::clientbound::TeamsBodyAddNameTagVisibility(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
);
let v8 = crate::defs::p775::play::clientbound::TeamsBodyAddCollisionRule(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3]) as i32,
);
let v9 = if g.bool() {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v10 = crate::defs::p775::play::clientbound::TeamsBodyAddFlags(
g.int_in(0, 255, &[]) as u8,
);
crate::defs::p776::play::clientbound::TeamsBodyAdd {
name: v4,
prefix: v5,
suffix: v6,
name_tag_visibility: v7,
collision_rule: v8,
color: v9,
flags: 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_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: AnonNbt,
/// `description`
pub description: AnonNbt,
/// `icon`
pub icon: crate::defs::p776::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_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<
crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
/// `sendsTelemtryData`
pub sends_telemtry_data: bool,
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: crate::defs::p776::play::clientbound::AdvancementsAdvancementMappingValue,
}
#[cfg(feature = "v26_2")]
/// `advancements` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements<const V: i32> {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping:
Vec<crate::defs::p776::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_2")]
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::p776::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::p776::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::p776::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p776::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_2")]
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_2")]
#[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::p776::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::p776::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::p776::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v18, sends_telemtry_data: v23 } }; crate::defs::p776::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_2")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct EntityUpdateAttributesPropertiesKey(pub i32);
#[cfg(feature = "v26_2")]
impl EntityUpdateAttributesPropertiesKey {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `air_drag_modifier`
pub const AIR_DRAG_MODIFIER: Self = Self(0);
/// `generic.armor`
pub const GENERIC_ARMOR: Self = Self(1);
/// `generic.armor_toughness`
pub const GENERIC_ARMOR_TOUGHNESS: Self = Self(2);
/// `generic.attack_damage`
pub const GENERIC_ATTACK_DAMAGE: Self = Self(3);
/// `generic.attack_knockback`
pub const GENERIC_ATTACK_KNOCKBACK: Self = Self(4);
/// `generic.attack_speed`
pub const GENERIC_ATTACK_SPEED: Self = Self(5);
/// `below_name_distance`
pub const BELOW_NAME_DISTANCE: Self = Self(6);
/// `player.block_break_speed`
pub const PLAYER_BLOCK_BREAK_SPEED: Self = Self(7);
/// `player.block_interaction_range`
pub const PLAYER_BLOCK_INTERACTION_RANGE: Self = Self(8);
/// `bounciness`
pub const BOUNCINESS: Self = Self(9);
/// `burning_time`
pub const BURNING_TIME: Self = Self(10);
/// `camera_distance`
pub const CAMERA_DISTANCE: Self = Self(11);
/// `explosion_knockback_resistance`
pub const EXPLOSION_KNOCKBACK_RESISTANCE: Self = Self(12);
/// `player.entity_interaction_range`
pub const PLAYER_ENTITY_INTERACTION_RANGE: Self = Self(13);
/// `generic.fall_damage_multiplier`
pub const GENERIC_FALL_DAMAGE_MULTIPLIER: Self = Self(14);
/// `generic.flying_speed`
pub const GENERIC_FLYING_SPEED: Self = Self(15);
/// `generic.follow_range`
pub const GENERIC_FOLLOW_RANGE: Self = Self(16);
/// `friction_modifier`
pub const FRICTION_MODIFIER: Self = Self(17);
/// `generic.gravity`
pub const GENERIC_GRAVITY: Self = Self(18);
/// `generic.jump_strength`
pub const GENERIC_JUMP_STRENGTH: Self = Self(19);
/// `generic.knockback_resistance`
pub const GENERIC_KNOCKBACK_RESISTANCE: Self = Self(20);
/// `generic.luck`
pub const GENERIC_LUCK: Self = Self(21);
/// `generic.max_absorption`
pub const GENERIC_MAX_ABSORPTION: Self = Self(22);
/// `generic.max_health`
pub const GENERIC_MAX_HEALTH: Self = Self(23);
/// `mining_efficiency`
pub const MINING_EFFICIENCY: Self = Self(24);
/// `movement_efficiency`
pub const MOVEMENT_EFFICIENCY: Self = Self(25);
/// `generic.movement_speed`
pub const GENERIC_MOVEMENT_SPEED: Self = Self(26);
/// `name_tag_distance`
pub const NAME_TAG_DISTANCE: Self = Self(27);
/// `oxygen_bonus`
pub const OXYGEN_BONUS: Self = Self(28);
/// `generic.safe_fall_distance`
pub const GENERIC_SAFE_FALL_DISTANCE: Self = Self(29);
/// `generic.scale`
pub const GENERIC_SCALE: Self = Self(30);
/// `sneaking_speed`
pub const SNEAKING_SPEED: Self = Self(31);
/// `zombie.spawn_reinforcements`
pub const ZOMBIE_SPAWN_REINFORCEMENTS: Self = Self(32);
/// `generic.step_height`
pub const GENERIC_STEP_HEIGHT: Self = Self(33);
/// `submerged_mining_speed`
pub const SUBMERGED_MINING_SPEED: Self = Self(34);
/// `sweeping_damage_ratio`
pub const SWEEPING_DAMAGE_RATIO: Self = Self(35);
/// `tempt_range`
pub const TEMPT_RANGE: Self = Self(36);
/// `water_movement_efficiency`
pub const WATER_MOVEMENT_EFFICIENCY: Self = Self(37);
/// `waypoint_transmit_range`
pub const WAYPOINT_TRANSMIT_RANGE: Self = Self(38);
/// `waypoint_receive_range`
pub const WAYPOINT_RECEIVE_RANGE: Self = Self(39);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("air_drag_modifier"),
1 => Some("generic.armor"),
2 => Some("generic.armor_toughness"),
3 => Some("generic.attack_damage"),
4 => Some("generic.attack_knockback"),
5 => Some("generic.attack_speed"),
6 => Some("below_name_distance"),
7 => Some("player.block_break_speed"),
8 => Some("player.block_interaction_range"),
9 => Some("bounciness"),
10 => Some("burning_time"),
11 => Some("camera_distance"),
12 => Some("explosion_knockback_resistance"),
13 => Some("player.entity_interaction_range"),
14 => Some("generic.fall_damage_multiplier"),
15 => Some("generic.flying_speed"),
16 => Some("generic.follow_range"),
17 => Some("friction_modifier"),
18 => Some("generic.gravity"),
19 => Some("generic.jump_strength"),
20 => Some("generic.knockback_resistance"),
21 => Some("generic.luck"),
22 => Some("generic.max_absorption"),
23 => Some("generic.max_health"),
24 => Some("mining_efficiency"),
25 => Some("movement_efficiency"),
26 => Some("generic.movement_speed"),
27 => Some("name_tag_distance"),
28 => Some("oxygen_bonus"),
29 => Some("generic.safe_fall_distance"),
30 => Some("generic.scale"),
31 => Some("sneaking_speed"),
32 => Some("zombie.spawn_reinforcements"),
33 => Some("generic.step_height"),
34 => Some("submerged_mining_speed"),
35 => Some("sweeping_damage_ratio"),
36 => Some("tempt_range"),
37 => Some("water_movement_efficiency"),
38 => Some("waypoint_transmit_range"),
39 => Some("waypoint_receive_range"),
_ => None,
}
}
}
#[cfg(feature = "v26_2")]
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_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesProperties {
/// `key`
pub key: crate::defs::p776::play::clientbound::EntityUpdateAttributesPropertiesKey,
/// `value`
pub value: f64,
/// `modifiers`
pub modifiers:
Vec<crate::defs::p775::play::clientbound::EntityUpdateAttributesPropertiesModifiers>,
}
#[cfg(feature = "v26_2")]
/// `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::p776::play::clientbound::EntityUpdateAttributesProperties>,
}
#[cfg(feature = "v26_2")]
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::p776::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::p776::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::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, 35, 36, 37, 38, 39]) 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::p776::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
}
}
}
#[cfg(feature = "v26_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesStoneCutterRecipes {
/// `input`
pub input: HolderSet,
/// `slotDisplay`
pub slot_display: crate::defs::p776::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_2")]
/// `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::p776::play::clientbound::DeclareRecipesStoneCutterRecipes>,
}
#[cfg(feature = "v26_2")]
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::p776::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?;
crate::defs::p776::play::clientbound::DeclareRecipesStoneCutterRecipes {
input: v11,
slot_display: v12,
}
});
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
})
}
}
#[cfg(feature = "v26_2")]
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_2")]
#[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::p776::play::clientbound::SlotDisplay as Generate>::generate(g); crate::defs::p776::play::clientbound::DeclareRecipesStoneCutterRecipes { input: v11, slot_display: v12 } });
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
}
}
}