// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/26.1/protocol.json + codegen/protocol/delta/776.json + codegen/protocol/delta/777.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_3")]
/// Named type `ExplosionParticleEntry`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleEntry {
/// `data`
pub data: crate::defs::p777::play::clientbound::ExplosionParticleInfo,
/// `weight`
pub weight: i32,
}
#[cfg(feature = "v26_3")]
impl Decode for ExplosionParticleEntry {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 =
<crate::defs::p777::play::clientbound::ExplosionParticleInfo as Decode>::decode(r)?;
let v2 = r.read_varint()?;
Self {
data: v1,
weight: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl Encode for ExplosionParticleEntry {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).data.encode(w)?;
w.put_varint((*self).weight);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleEntry {
fn generate(g: &mut Gen) -> Self {
{
let v1 =
<crate::defs::p777::play::clientbound::ExplosionParticleInfo as Generate>::generate(
g,
);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
data: v1,
weight: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Named type `ExplosionParticleInfo`.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionParticleInfo {
/// `particle`
pub particle: crate::defs::p777::types::Particle,
/// `scaling`
pub scaling: f32,
/// `speed`
pub speed: f32,
}
#[cfg(feature = "v26_3")]
impl Decode for ExplosionParticleInfo {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p777::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_3")]
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_3")]
#[cfg(feature = "testgen")]
impl Generate for ExplosionParticleInfo {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p777::types::Particle as Generate>::generate(g);
let v2 = g.f32();
let v3 = g.f32();
Self {
particle: v1,
scaling: v2,
speed: v3,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShapeless {
/// `ingredients`
pub ingredients: Vec<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p777::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p777::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataCraftingShaped {
/// `width`
pub width: i32,
/// `height`
pub height: i32,
/// `ingredients`
pub ingredients: Vec<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `result`
pub result: crate::defs::p777::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p777::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataFurnace {
/// `ingredient`
pub ingredient: crate::defs::p777::play::clientbound::SlotDisplay,
/// `fuel`
pub fuel: crate::defs::p777::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p777::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p777::play::clientbound::SlotDisplay,
/// `duration`
pub duration: i32,
/// `experience`
pub experience: f32,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataStonecutter {
/// `ingredient`
pub ingredient: crate::defs::p777::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p777::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p777::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeDisplayDataSmithing {
/// `template`
pub template: crate::defs::p777::play::clientbound::SlotDisplay,
/// `base`
pub base: crate::defs::p777::play::clientbound::SlotDisplay,
/// `addition`
pub addition: crate::defs::p777::play::clientbound::SlotDisplay,
/// `result`
pub result: crate::defs::p777::play::clientbound::SlotDisplay,
/// `craftingStation`
pub crafting_station: crate::defs::p777::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_3")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum RecipeDisplayData {
/// Case(s) `crafting_shapeless`.
CraftingShapeless(crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShapeless),
/// Case(s) `crafting_shaped`.
CraftingShaped(crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShaped),
/// Case(s) `furnace`.
Furnace(crate::defs::p777::play::clientbound::RecipeDisplayDataFurnace),
/// Case(s) `stonecutter`.
Stonecutter(crate::defs::p777::play::clientbound::RecipeDisplayDataStonecutter),
/// Case(s) `smithing`.
Smithing(crate::defs::p777::play::clientbound::RecipeDisplayDataSmithing),
/// Any other value.
Other,
}
#[cfg(feature = "v26_3")]
/// 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::p777::play::clientbound::RecipeDisplayData,
}
#[cfg(feature = "v26_3")]
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::p777::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::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v5
};
let v6 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v7 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p777::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::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?);
}
v12
};
let v13 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v14 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v16 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v17 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v18 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v19 = r.read_varint()?;
let v20 = r.read_f32()?;
crate::defs::p777::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v22 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v23 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p777::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v25 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v26 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v27 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
let v28 =
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?;
crate::defs::p777::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p777::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl Encode for RecipeDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p777::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::p777::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::p777::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::p777::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::p777::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::p777::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_3")]
#[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::p777::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::p777::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v5
};
let v6 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v7 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShapeless {
ingredients: v3,
result: v6,
crafting_station: v7,
}
})
} else if (v1.0 == 1) {
crate::defs::p777::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::p777::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v12
};
let v13 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v14 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p777::play::clientbound::RecipeDisplayDataCraftingShaped {
width: v8,
height: v9,
ingredients: v10,
result: v13,
crafting_station: v14,
}
})
} else if (v1.0 == 2) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Furnace({
let v15 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v16 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v17 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v18 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v19 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v20 = g.f32();
crate::defs::p777::play::clientbound::RecipeDisplayDataFurnace {
ingredient: v15,
fuel: v16,
result: v17,
crafting_station: v18,
duration: v19,
experience: v20,
}
})
} else if (v1.0 == 3) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Stonecutter({
let v21 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v22 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v23 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p777::play::clientbound::RecipeDisplayDataStonecutter {
ingredient: v21,
result: v22,
crafting_station: v23,
}
})
} else if (v1.0 == 4) {
crate::defs::p777::play::clientbound::RecipeDisplayData::Smithing({
let v24 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v25 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v26 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v27 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
let v28 =
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
);
crate::defs::p777::play::clientbound::RecipeDisplayDataSmithing {
template: v24,
base: v25,
addition: v26,
result: v27,
crafting_station: v28,
}
})
} else {
crate::defs::p777::play::clientbound::RecipeDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithAnyPotion {
/// `base`
pub base: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataOnlyWithComponent {
/// `source`
pub source: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `component`
pub component: crate::defs::p777::types::SlotComponentType,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataDyedSlotDemo {
/// `dye`
pub dye: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `target`
pub target: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataSmithingTrim {
/// `base`
pub base: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `material`
pub material: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `pattern`
pub pattern: Holder<crate::defs::p775::types::ArmorTrimPattern>,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SlotDisplayDataWithRemainder {
/// `input`
pub input: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
/// `remainder`
pub remainder: Box<crate::defs::p777::play::clientbound::SlotDisplay>,
}
#[cfg(feature = "v26_3")]
/// 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::p777::play::clientbound::SlotDisplayDataWithAnyPotion),
/// Case(s) `only_with_component`.
OnlyWithComponent(crate::defs::p777::play::clientbound::SlotDisplayDataOnlyWithComponent),
/// Case(s) `item`.
Item(i32),
/// Case(s) `item_stack`.
ItemStack(crate::defs::p777::types::ItemStackTemplate),
/// Case(s) `tag`.
Tag(HolderSet),
/// Case(s) `dyed_slot_demo`.
DyedSlotDemo(crate::defs::p777::play::clientbound::SlotDisplayDataDyedSlotDemo),
/// Case(s) `smithing_trim`.
SmithingTrim(crate::defs::p777::play::clientbound::SlotDisplayDataSmithingTrim),
/// Case(s) `with_remainder`.
WithRemainder(crate::defs::p777::play::clientbound::SlotDisplayDataWithRemainder),
/// Case(s) `composite`.
Composite(Vec<crate::defs::p777::play::clientbound::SlotDisplay>),
/// Any other value.
Other,
}
#[cfg(feature = "v26_3")]
/// 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::p777::play::clientbound::SlotDisplayData,
}
#[cfg(feature = "v26_3")]
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::p777::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p777::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p777::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p777::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p777::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v5 = crate::defs::p777::types::SlotComponentType(r.read_varint()?);
crate::defs::p777::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p777::play::clientbound::SlotDisplayData::Item(r.read_varint()?)
} else if (v1.0 == 5) {
crate::defs::p777::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p777::types::ItemStackTemplate as Decode>::decode(r)?,
)
} else if (v1.0 == 6) {
crate::defs::p777::play::clientbound::SlotDisplayData::Tag(
<HolderSet as Decode>::decode(r)?,
)
} else if (v1.0 == 7) {
crate::defs::p777::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v7 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p777::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p777::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v9 = Box::new(
<crate::defs::p777::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::p777::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p777::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
let v12 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Decode>::decode(r)?,
);
crate::defs::p777::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p777::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::p777::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?,
);
}
v14
})
} else {
crate::defs::p777::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl Encode for SlotDisplay {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type.0);
match &(*self).data {
crate::defs::p777::play::clientbound::SlotDisplayData::Empty => {
if !((*self).r#type.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p777::play::clientbound::SlotDisplayData::AnyFuel => {
if !((*self).r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
}
crate::defs::p777::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::p777::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::p777::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::p777::play::clientbound::SlotDisplayData::ItemStack(v4) => {
if !((*self).r#type.0 == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*v4).encode(w)?;
}
crate::defs::p777::play::clientbound::SlotDisplayData::Tag(v5) => {
if !((*self).r#type.0 == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.SlotDisplay.data",
));
}
(*v5).encode(w)?;
}
crate::defs::p777::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::p777::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::p777::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::p777::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::p777::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_3")]
#[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::p777::play::clientbound::SlotDisplayData::Empty
} else if (v1.0 == 1) {
crate::defs::p777::play::clientbound::SlotDisplayData::AnyFuel
} else if (v1.0 == 2) {
crate::defs::p777::play::clientbound::SlotDisplayData::WithAnyPotion({
let v3 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p777::play::clientbound::SlotDisplayDataWithAnyPotion { base: v3 }
})
} else if (v1.0 == 3) {
crate::defs::p777::play::clientbound::SlotDisplayData::OnlyWithComponent({
let v4 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v5 = crate::defs::p777::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, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
],
)
as i32);
crate::defs::p777::play::clientbound::SlotDisplayDataOnlyWithComponent {
source: v4,
component: v5,
}
})
} else if (v1.0 == 4) {
crate::defs::p777::play::clientbound::SlotDisplayData::Item(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v1.0 == 5) {
crate::defs::p777::play::clientbound::SlotDisplayData::ItemStack(
<crate::defs::p777::types::ItemStackTemplate as Generate>::generate(g),
)
} else if (v1.0 == 6) {
crate::defs::p777::play::clientbound::SlotDisplayData::Tag(
<HolderSet as Generate>::generate(g),
)
} else if (v1.0 == 7) {
crate::defs::p777::play::clientbound::SlotDisplayData::DyedSlotDemo({
let v6 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v7 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p777::play::clientbound::SlotDisplayDataDyedSlotDemo {
dye: v6,
target: v7,
}
})
} else if (v1.0 == 8) {
crate::defs::p777::play::clientbound::SlotDisplayData::SmithingTrim({
let v8 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v9 = Box::new(
<crate::defs::p777::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::p777::play::clientbound::SlotDisplayDataSmithingTrim {
base: v8,
material: v9,
pattern: v10,
}
})
} else if (v1.0 == 9) {
crate::defs::p777::play::clientbound::SlotDisplayData::WithRemainder({
let v11 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
let v12 = Box::new(
<crate::defs::p777::play::clientbound::SlotDisplay as Generate>::generate(
g,
),
);
crate::defs::p777::play::clientbound::SlotDisplayDataWithRemainder {
input: v11,
remainder: v12,
}
})
} else if (v1.0 == 10) {
crate::defs::p777::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::p777::play::clientbound::SlotDisplay as Generate>::generate(g));
}
v14
})
} else {
crate::defs::p777::play::clientbound::SlotDisplayData::Other
});
Self {
r#type: v1,
data: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct SpawnInfoGamemode(pub i32);
#[cfg(feature = "v26_3")]
impl SpawnInfoGamemode {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `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_3")]
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_3")]
/// 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::p777::play::clientbound::SpawnInfoGamemode,
/// `previousGamemode`
pub previous_gamemode: i32,
/// `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_3")]
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::p777::play::clientbound::SpawnInfoGamemode(r.read_varint()?);
let v5 = r.read_varint()?;
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_3")]
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_varint((*self).gamemode.0);
w.put_varint((*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_3")]
#[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::p777::play::clientbound::SpawnInfoGamemode(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3],
) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
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_3")]
/// `declare_commands` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareCommands<const V: i32> {
/// `nodes`
pub nodes: Vec<crate::defs::p777::types::CommandNode>,
/// `rootIndex`
pub root_index: i32,
}
#[cfg(feature = "v26_3")]
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::p777::types::CommandNode as Decode>::decode(
r,
)?);
}
v3
};
let v4 = r.read_varint()?;
Self {
nodes: v1,
root_index: v4,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::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_3")]
/// `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::p777::types::Slot>,
/// `carriedItem`
pub carried_item: crate::defs::p777::types::Slot,
}
#[cfg(feature = "v26_3")]
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::p777::types::Slot as Decode>::decode(r)?);
}
v5
};
let v6 = <crate::defs::p777::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::Slot as Generate>::generate(g));
}
v5
};
let v6 = <crate::defs::p777::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
items: v3,
carried_item: v6,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::Slot,
}
#[cfg(feature = "v26_3")]
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::p777::types::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::Slot as Generate>::generate(g);
Self {
window_id: v1,
state_id: v2,
slot: v3,
item: v4,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_3")]
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::p777::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
block_pos: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
block_pos: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_3")]
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::p777::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
chunk_pos: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
chunk_pos: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::DebugSubscriptionUpdate,
}
#[cfg(feature = "v26_3")]
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::p777::types::DebugSubscriptionUpdate as Decode>::decode(r)?;
Self {
entity_id: v1,
update: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::DebugSubscriptionUpdate as Generate>::generate(g);
Self {
entity_id: v1,
update: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `debug_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DebugEvent<const V: i32> {
/// `event`
pub event: crate::defs::p777::types::DebugSubscriptionEvent,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for DebugEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p777::types::DebugSubscriptionEvent as Decode>::decode(r)?;
Self { event: v1 }
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for DebugEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).event.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DebugEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p777::types::DebugSubscriptionEvent as Generate>::generate(g);
Self { event: v1 }
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct SyncEntityPositionPathType(pub i32);
#[cfg(feature = "v26_3")]
impl SyncEntityPositionPathType {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `linear`
pub const LINEAR: Self = Self(0);
/// `stepped`
pub const STEPPED: Self = Self(1);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("linear"),
1 => Some("stepped"),
_ => None,
}
}
}
#[cfg(feature = "v26_3")]
impl std::fmt::Debug for SyncEntityPositionPathType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SyncEntityPositionPathType::{n}"),
None => write!(f, "SyncEntityPositionPathType({})", self.0),
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SyncEntityPositionPathDataStepped {
/// `position`
pub position: crate::defs::p775::types::Vec3f64,
/// `tickOffset`
pub tick_offset: i32,
}
#[cfg(feature = "v26_3")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum SyncEntityPositionPathData {
/// Case(s) `linear`.
Linear(crate::defs::p775::types::Vec3f64),
/// Case(s) `stepped`.
Stepped(Vec<crate::defs::p777::play::clientbound::SyncEntityPositionPathDataStepped>),
/// Any other value.
Other,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SyncEntityPositionPath {
/// `type`
pub r#type: crate::defs::p777::play::clientbound::SyncEntityPositionPathType,
/// `data`
pub data: crate::defs::p777::play::clientbound::SyncEntityPositionPathData,
}
#[cfg(feature = "v26_3")]
/// `sync_entity_position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SyncEntityPosition<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `path`
pub path: crate::defs::p777::play::clientbound::SyncEntityPositionPath,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `onGround`
pub on_ground: bool,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for SyncEntityPosition<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = crate::defs::p777::play::clientbound::SyncEntityPositionPathType(
r.read_varint()?,
);
let v4 = (if (v3.0 == 0) {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Linear(
<crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?,
)
} else if (v3.0 == 1) {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Stepped({
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 25)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({ let v7 = <crate::defs::p775::types::Vec3f64 as Decode>::decode(r)?;let v8 = r.read_varint()?; crate::defs::p777::play::clientbound::SyncEntityPositionPathDataStepped { position: v7, tick_offset: v8 } });
}
v6
})
} else {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Other
});
crate::defs::p777::play::clientbound::SyncEntityPositionPath {
r#type: v3,
data: v4,
}
};
let v9 = r.read_f32()?;
let v10 = r.read_f32()?;
let v11 = r.read_bool()?;
Self {
entity_id: v1,
path: v2,
yaw: v9,
pitch: v10,
on_ground: v11,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for SyncEntityPosition<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).path.r#type.0);
match &(*self).path.data {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Linear(v1) => {
if !((*self).path.r#type.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.sync_entity_position.path.data",
));
}
(*v1).encode(w)?;
}
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Stepped(v2) => {
if !((*self).path.r#type.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.sync_entity_position.path.data",
));
}
w.put_len_varint((*v2).len())?;
for v3 in (*v2).iter() {
(*v3).position.encode(w)?;
w.put_varint((*v3).tick_offset);
}
}
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Other => {
if !(!(((*self).path.r#type.0 == 0) || ((*self).path.r#type.0 == 1))) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.sync_entity_position.path.data",
));
}
}
}
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[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 = {
let v3 = crate::defs::p777::play::clientbound::SyncEntityPositionPathType(
g.int_in(-2147483648, 2147483647, &[0, 1]) as i32,
);
let v4 = (if (v3.0 == 0) {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Linear(
<crate::defs::p775::types::Vec3f64 as Generate>::generate(g),
)
} else if (v3.0 == 1) {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Stepped({
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({ let v7 = <crate::defs::p775::types::Vec3f64 as Generate>::generate(g);let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32); crate::defs::p777::play::clientbound::SyncEntityPositionPathDataStepped { position: v7, tick_offset: v8 } });
}
v6
})
} else {
crate::defs::p777::play::clientbound::SyncEntityPositionPathData::Other
});
crate::defs::p777::play::clientbound::SyncEntityPositionPath {
r#type: v3,
data: v4,
}
};
let v9 = g.f32();
let v10 = g.f32();
let v11 = g.bool();
Self {
entity_id: v1,
path: v2,
yaw: v9,
pitch: v10,
on_ground: v11,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::Particle,
/// `sound`
pub sound: Holder<crate::defs::p775::types::ItemSoundEvent>,
/// `blockParticles`
pub block_particles: Vec<crate::defs::p777::play::clientbound::ExplosionParticleEntry>,
/// `playSound`
pub play_sound: bool,
}
#[cfg(feature = "v26_3")]
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::p777::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::p777::play::clientbound::ExplosionParticleEntry as Decode>::decode(r)?);
}
v9
};
let v10 = r.read_bool()?;
Self {
center: v1,
radius: v2,
block_count: v3,
player_knockback: v4,
explosion_particle: v5,
sound: v6,
block_particles: v7,
play_sound: v10,
}
})
}
}
#[cfg(feature = "v26_3")]
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)?;
}
w.put_bool((*self).play_sound);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[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::p777::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::p777::play::clientbound::ExplosionParticleEntry as Generate>::generate(g));
}
v9
};
let v10 = g.bool();
Self {
center: v1,
radius: v2,
block_count: v3,
player_knockback: v4,
explosion_particle: v5,
sound: v6,
block_particles: v7,
play_sound: v10,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `add_transient_block` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct AddTransientBlock<const V: i32> {
/// `location`
pub location: BlockPos,
/// `blockState`
pub block_state: i32,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for AddTransientBlock<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_varint()?;
Self {
location: v1,
block_state: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for AddTransientBlock<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).block_state);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AddTransientBlock<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
location: v1,
block_state: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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: Bytes,
/// `blockLightMask`
pub block_light_mask: Bytes,
/// `emptySkyLightMask`
pub empty_sky_light_mask: Bytes,
/// `emptyBlockLightMask`
pub empty_block_light_mask: Bytes,
/// `skyLight`
pub sky_light: Vec<Vec<u8>>,
/// `blockLight`
pub block_light: Vec<Vec<u8>>,
}
#[cfg(feature = "v26_3")]
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 = r.read_byte_array()?;
let v15 = r.read_byte_array()?;
let v16 = r.read_byte_array()?;
let v17 = r.read_byte_array()?;
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_u8()?);
}
v22
});
}
v20
};
let v23 = {
let v24 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v24 {
v25.push({
let v26 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v27 = Vec::with_capacity(v26.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v26 {
v27.push(r.read_u8()?);
}
v27
});
}
v25
};
Self {
x: v1,
z: v2,
heightmaps: v3,
chunk_data: v10,
block_entities: v11,
sky_light_mask: v14,
block_light_mask: v15,
empty_sky_light_mask: v16,
empty_block_light_mask: v17,
sky_light: v18,
block_light: v23,
}
})
}
}
#[cfg(feature = "v26_3")]
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_byte_array(&(*self).sky_light_mask)?;
w.put_byte_array(&(*self).block_light_mask)?;
w.put_byte_array(&(*self).empty_sky_light_mask)?;
w.put_byte_array(&(*self).empty_block_light_mask)?;
w.put_len_varint((*self).sky_light.len())?;
for v4 in (*self).sky_light.iter() {
w.put_len_varint((*v4).len())?;
for v5 in (*v4).iter() {
w.put_u8((*v5));
}
}
w.put_len_varint((*self).block_light.len())?;
for v6 in (*self).block_light.iter() {
w.put_len_varint((*v6).len())?;
for v7 in (*v6).iter() {
w.put_u8((*v7));
}
}
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[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 = g.bytes();
let v15 = g.bytes();
let v16 = g.bytes();
let v17 = g.bytes();
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.int_in(0, 255, &[]) as u8));
}
v22
});
}
v20
};
let v23 = {
let v24 = g.count();
let mut v25 = Vec::with_capacity(v24.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v24 {
v25.push({
let v26 = g.count();
let mut v27 = Vec::with_capacity(v26.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v26 {
v27.push((g.int_in(0, 255, &[]) as u8));
}
v27
});
}
v25
};
Self {
x: v1,
z: v2,
heightmaps: v3,
chunk_data: v10,
block_entities: v11,
sky_light_mask: v14,
block_light_mask: v15,
empty_sky_light_mask: v16,
empty_block_light_mask: v17,
sky_light: v18,
block_light: v23,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct WorldParticlesRandomization(pub i32);
#[cfg(feature = "v26_3")]
impl WorldParticlesRandomization {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `default`
pub const DEFAULT: Self = Self(0);
/// `alternative`
pub const ALTERNATIVE: Self = Self(1);
/// `alternative_with_speed`
pub const ALTERNATIVE_WITH_SPEED: Self = Self(2);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("default"),
1 => Some("alternative"),
2 => Some("alternative_with_speed"),
_ => None,
}
}
}
#[cfg(feature = "v26_3")]
impl std::fmt::Debug for WorldParticlesRandomization {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "WorldParticlesRandomization::{n}"),
None => write!(f, "WorldParticlesRandomization({})", self.0),
}
}
}
#[cfg(feature = "v26_3")]
/// `world_particles` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldParticles<const V: i32> {
/// `particle`
pub particle: crate::defs::p777::types::Particle,
/// `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,
/// `velocityOffsetX`
pub velocity_offset_x: f32,
/// `velocityOffsetY`
pub velocity_offset_y: f32,
/// `velocityOffsetZ`
pub velocity_offset_z: f32,
/// `amount`
pub amount: i32,
/// `randomization`
pub randomization: crate::defs::p777::play::clientbound::WorldParticlesRandomization,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for WorldParticles<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p777::types::Particle as Decode>::decode(r)?;
let v2 = r.read_bool()?;
let v3 = r.read_bool()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = r.read_f32()?;
let v11 = r.read_f32()?;
let v12 = r.read_f32()?;
let v13 = r.read_varint()?;
let v14 =
crate::defs::p777::play::clientbound::WorldParticlesRandomization(r.read_varint()?);
Self {
particle: v1,
long_distance: v2,
always_show: v3,
x: v4,
y: v5,
z: v6,
offset_x: v7,
offset_y: v8,
offset_z: v9,
velocity_offset_x: v10,
velocity_offset_y: v11,
velocity_offset_z: v12,
amount: v13,
randomization: v14,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for WorldParticles<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).particle.encode(w)?;
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_x);
w.put_f32((*self).velocity_offset_y);
w.put_f32((*self).velocity_offset_z);
w.put_varint((*self).amount);
w.put_varint((*self).randomization.0);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldParticles<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p777::types::Particle as Generate>::generate(g);
let v2 = g.bool();
let v3 = g.bool();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = g.f32();
let v8 = g.f32();
let v9 = g.f32();
let v10 = g.f32();
let v11 = g.f32();
let v12 = g.f32();
let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v14 = crate::defs::p777::play::clientbound::WorldParticlesRandomization(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2],
)
as i32);
Self {
particle: v1,
long_distance: v2,
always_show: v3,
x: v4,
y: v5,
z: v6,
offset_x: v7,
offset_y: v8,
offset_z: v9,
velocity_offset_x: v10,
velocity_offset_y: v11,
velocity_offset_z: v12,
amount: v13,
randomization: v14,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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: Bytes,
/// `blockLightMask`
pub block_light_mask: Bytes,
/// `emptySkyLightMask`
pub empty_sky_light_mask: Bytes,
/// `emptyBlockLightMask`
pub empty_block_light_mask: Bytes,
/// `skyLight`
pub sky_light: Vec<Vec<u8>>,
/// `blockLight`
pub block_light: Vec<Vec<u8>>,
}
#[cfg(feature = "v26_3")]
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 = r.read_byte_array()?;
let v4 = r.read_byte_array()?;
let v5 = r.read_byte_array()?;
let v6 = r.read_byte_array()?;
let v7 = {
let v8 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push({
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_u8()?);
}
v11
});
}
v9
};
let v12 = {
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({
let v15 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v16 = Vec::with_capacity(v15.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v15 {
v16.push(r.read_u8()?);
}
v16
});
}
v14
};
Self {
chunk_x: v1,
chunk_z: v2,
sky_light_mask: v3,
block_light_mask: v4,
empty_sky_light_mask: v5,
empty_block_light_mask: v6,
sky_light: v7,
block_light: v12,
}
})
}
}
#[cfg(feature = "v26_3")]
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_byte_array(&(*self).sky_light_mask)?;
w.put_byte_array(&(*self).block_light_mask)?;
w.put_byte_array(&(*self).empty_sky_light_mask)?;
w.put_byte_array(&(*self).empty_block_light_mask)?;
w.put_len_varint((*self).sky_light.len())?;
for v1 in (*self).sky_light.iter() {
w.put_len_varint((*v1).len())?;
for v2 in (*v1).iter() {
w.put_u8((*v2));
}
}
w.put_len_varint((*self).block_light.len())?;
for v3 in (*self).block_light.iter() {
w.put_len_varint((*v3).len())?;
for v4 in (*v3).iter() {
w.put_u8((*v4));
}
}
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[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 = g.bytes();
let v4 = g.bytes();
let v5 = g.bytes();
let v6 = g.bytes();
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.count();
let mut v11 = Vec::with_capacity(v10.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v10 {
v11.push((g.int_in(0, 255, &[]) as u8));
}
v11
});
}
v9
};
let v12 = {
let v13 = g.count();
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push({
let v15 = g.count();
let mut v16 = Vec::with_capacity(v15.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v15 {
v16.push((g.int_in(0, 255, &[]) as u8));
}
v16
});
}
v14
};
Self {
chunk_x: v1,
chunk_z: v2,
sky_light_mask: v3,
block_light_mask: v4,
empty_sky_light_mask: v5,
empty_block_light_mask: v6,
sky_light: v7,
block_light: v12,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::play::clientbound::SpawnInfo,
/// `onlineMode`
pub online_mode: bool,
/// `enforcesSecureChat`
pub enforces_secure_chat: bool,
}
#[cfg(feature = "v26_3")]
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::p777::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_3")]
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_3")]
#[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::p777::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_3")]
/// 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::p777::types::SlotComponent>,
}
#[cfg(feature = "v26_3")]
/// 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::p777::types::SlotComponent>,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTrades {
/// `inputItem1`
pub input_item1: crate::defs::p777::play::clientbound::TradeListTradesInputItem1,
/// `outputItem`
pub output_item: crate::defs::p777::types::Slot,
/// `inputItem2`
pub input_item2: Option<crate::defs::p777::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_3")]
/// `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::p777::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_3")]
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::p777::types::SlotComponent as Decode>::decode(r)?); } v10 }; crate::defs::p777::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p777::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::p777::types::SlotComponent as Decode>::decode(r)?); } v17 }; crate::defs::p777::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::p777::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_3")]
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_3")]
#[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::p777::types::SlotComponent as Generate>::generate(g)); } v10 }; crate::defs::p777::play::clientbound::TradeListTradesInputItem1 { item_id: v6, item_count: v7, components: v8 } };let v11 = <crate::defs::p777::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::p777::types::SlotComponent as Generate>::generate(g)); } v17 }; crate::defs::p777::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::p777::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_3")]
/// `rel_entity_move` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RelEntityMove<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `delta`
pub delta: crate::types::EntityMoveDelta,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for RelEntityMove<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = crate::types::EntityMoveDelta::read(r)?;
Self {
entity_id: v1,
delta: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for RelEntityMove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).delta.write(w);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RelEntityMove<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <crate::types::EntityMoveDelta as Generate>::generate(g);
Self {
entity_id: v1,
delta: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `entity_move_look` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMoveLook<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `delta`
pub delta: crate::types::EntityMoveDelta,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for EntityMoveLook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = crate::types::EntityMoveDelta::read(r)?;
let v3 = r.read_i8()?;
let v4 = r.read_i8()?;
Self {
entity_id: v1,
delta: v2,
yaw: v3,
pitch: v4,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for EntityMoveLook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).delta.write(w);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityMoveLook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = <crate::types::EntityMoveDelta as Generate>::generate(g);
let v3 = (g.int_in(-128, 127, &[]) as i8);
let v4 = (g.int_in(-128, 127, &[]) as i8);
Self {
entity_id: v1,
delta: v2,
yaw: v3,
pitch: v4,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `entity_look` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityLook<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `onGround`
pub on_ground: bool,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for EntityLook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_bool()?;
let v3 = r.read_i8()?;
let v4 = r.read_i8()?;
Self {
entity_id: v1,
on_ground: v2,
yaw: v3,
pitch: v4,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for EntityLook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_bool((*self).on_ground);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityLook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.bool();
let v3 = (g.int_in(-128, 127, &[]) as i8);
let v4 = (g.int_in(-128, 127, &[]) as i8);
Self {
entity_id: v1,
on_ground: v2,
yaw: v3,
pitch: v4,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct OpenSignEntitySide(pub i32);
#[cfg(feature = "v26_3")]
impl OpenSignEntitySide {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `back`
pub const BACK: Self = Self(0);
/// `front`
pub const FRONT: Self = Self(1);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("back"),
1 => Some("front"),
_ => None,
}
}
}
#[cfg(feature = "v26_3")]
impl std::fmt::Debug for OpenSignEntitySide {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "OpenSignEntitySide::{n}"),
None => write!(f, "OpenSignEntitySide({})", self.0),
}
}
}
#[cfg(feature = "v26_3")]
/// `open_sign_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenSignEntity<const V: i32> {
/// `location`
pub location: BlockPos,
/// `side`
pub side: crate::defs::p777::play::clientbound::OpenSignEntitySide,
}
#[cfg(feature = "v26_3")]
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 = crate::defs::p777::play::clientbound::OpenSignEntitySide(r.read_varint()?);
Self {
location: v1,
side: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for OpenSignEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).side.0);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenSignEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = crate::defs::p777::play::clientbound::OpenSignEntitySide(g.int_in(
-2147483648,
2147483647,
&[0, 1],
) as i32);
Self {
location: v1,
side: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::play::clientbound::RecipeDisplay,
}
#[cfg(feature = "v26_3")]
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::p777::play::clientbound::RecipeDisplay as Decode>::decode(r)?;
Self {
window_id: v1,
recipe_display: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::play::clientbound::RecipeDisplay as Generate>::generate(g);
Self {
window_id: v1,
recipe_display: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `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<Bytes>,
/// `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_3")]
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(r.read_byte_array()?)
} else {
None
};
let v16 = {
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 v17 = AnonNbt::read(r)?;
let v18 = 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: v16,
network_name: v17,
network_target_name: v18,
}
})
}
}
#[cfg(feature = "v26_3")]
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_byte_array(&(*v5))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_chat.filterTypeMask",
));
}
}
match &(*self).r#type {
Holder::Id(v7) => {
if *v7 == -1 {
return Err(EncodeError::OutOfRange("holder id"));
}
w.put_varint(v7.wrapping_add(1));
}
Holder::Inline(v6) => {
w.put_varint(0);
(*v6).encode(w)?;
}
}
(*self).network_name.write(w);
match &(*self).network_target_name {
Some(v8) => {
w.put_u8(1);
(*v8).write(w);
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[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(g.bytes()) } else { None };
let v16 = 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 v17 = g.anon_nbt();
let v18 = 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: v16,
network_name: v17,
network_target_name: v18,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntriesRecipe {
/// `displayId`
pub display_id: i32,
/// `display`
pub display: crate::defs::p777::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_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAddEntries {
/// `recipe`
pub recipe: crate::defs::p777::play::clientbound::RecipeBookAddEntriesRecipe,
/// `flags`
pub flags: crate::defs::p775::play::clientbound::RecipeBookAddEntriesFlags,
}
#[cfg(feature = "v26_3")]
/// `recipe_book_add` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBookAdd<const V: i32> {
/// `entries`
pub entries: Vec<crate::defs::p777::play::clientbound::RecipeBookAddEntries>,
/// `replace`
pub replace: bool,
}
#[cfg(feature = "v26_3")]
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::p777::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::p777::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::p777::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = r.read_bool()?;
Self {
entries: v1,
replace: v13,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::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::p777::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::p777::play::clientbound::RecipeBookAddEntries { recipe: v4, flags: v12 } });
}
v3
};
let v13 = g.bool();
Self {
entries: v1,
replace: v13,
}
}
}
}
#[cfg(feature = "v26_3")]
/// `post_effects` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct PostEffects<const V: i32> {
/// `effects`
pub effects: Vec<ByteString>,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for PostEffects<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(r.read_string()?);
}
v3
};
Self { effects: v1 }
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for PostEffects<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).effects.len())?;
for v1 in (*self).effects.iter() {
w.put_string(&(*v1))?;
}
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PostEffects<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(g.string());
}
v3
};
Self { effects: v1 }
}
}
}
#[cfg(feature = "v26_3")]
/// `respawn` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Respawn<const V: i32> {
/// `worldState`
pub world_state: crate::defs::p777::play::clientbound::SpawnInfo,
/// `copyMetadata`
pub copy_metadata: u8,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for Respawn<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p777::play::clientbound::SpawnInfo as Decode>::decode(r)?;
let v2 = r.read_u8()?;
Self {
world_state: v1,
copy_metadata: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Respawn<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p777::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_3")]
/// `set_cursor_item` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCursorItem<const V: i32> {
/// `contents`
pub contents: crate::defs::p777::types::Slot,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for SetCursorItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::defs::p777::types::Slot as Decode>::decode(r)?;
Self { contents: v1 }
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for SetCursorItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).contents.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCursorItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::defs::p777::types::Slot as Generate>::generate(g);
Self { contents: v1 }
}
}
}
#[cfg(feature = "v26_3")]
/// `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::p777::types::EntityMetadataEntry>,
}
#[cfg(feature = "v26_3")]
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::p777::types::EntityMetadataEntry as Decode>::decode(r)?);
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::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_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipmentEquipments {
/// `slot`
pub slot: i8,
/// `item`
pub item: crate::defs::p777::types::Slot,
}
#[cfg(feature = "v26_3")]
/// `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::p777::play::clientbound::EntityEquipmentEquipments>,
}
#[cfg(feature = "v26_3")]
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::p777::types::Slot as Decode>::decode(r)?;
crate::defs::p777::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
});
if v4 & 0x80 == 0 {
break;
}
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::Slot as Generate>::generate(g);
crate::defs::p777::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_3")]
/// `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::p777::types::Slot,
}
#[cfg(feature = "v26_3")]
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::p777::types::Slot as Decode>::decode(r)?;
Self {
slot_id: v1,
contents: v2,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::types::Slot as Generate>::generate(g);
Self {
slot_id: v1,
contents: v2,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct SwingAnimationHand(pub i32);
#[cfg(feature = "v26_3")]
impl SwingAnimationHand {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `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_3")]
impl std::fmt::Debug for SwingAnimationHand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SwingAnimationHand::{n}"),
None => write!(f, "SwingAnimationHand({})", self.0),
}
}
}
#[cfg(feature = "v26_3")]
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub struct SwingAnimationAnimationType(pub i32);
#[cfg(feature = "v26_3")]
impl SwingAnimationAnimationType {
/// The value with wire number `v`.
pub const fn new(v: i32) -> Self {
Self(v)
}
/// `none`
pub const NONE: Self = Self(0);
/// `whack`
pub const WHACK: Self = Self(1);
/// `stab`
pub const STAB: Self = Self(2);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("none"),
1 => Some("whack"),
2 => Some("stab"),
_ => None,
}
}
}
#[cfg(feature = "v26_3")]
impl std::fmt::Debug for SwingAnimationAnimationType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SwingAnimationAnimationType::{n}"),
None => write!(f, "SwingAnimationAnimationType({})", self.0),
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct SwingAnimationAnimation {
/// `type`
pub r#type: crate::defs::p777::play::clientbound::SwingAnimationAnimationType,
/// `duration`
pub duration: i32,
}
#[cfg(feature = "v26_3")]
/// `swing_animation` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SwingAnimation<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `hand`
pub hand: crate::defs::p777::play::clientbound::SwingAnimationHand,
/// `animation`
pub animation: crate::defs::p777::play::clientbound::SwingAnimationAnimation,
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Decode for SwingAnimation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = crate::defs::p777::play::clientbound::SwingAnimationHand(r.read_varint()?);
let v3 = {
let v4 = crate::defs::p777::play::clientbound::SwingAnimationAnimationType(
r.read_varint()?,
);
let v5 = r.read_varint()?;
crate::defs::p777::play::clientbound::SwingAnimationAnimation {
r#type: v4,
duration: v5,
}
};
Self {
entity_id: v1,
hand: v2,
animation: v3,
}
})
}
}
#[cfg(feature = "v26_3")]
impl<const V: i32> Encode for SwingAnimation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).hand.0);
w.put_varint((*self).animation.r#type.0);
w.put_varint((*self).animation.duration);
Ok(())
}
}
#[cfg(feature = "v26_3")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SwingAnimation<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = crate::defs::p777::play::clientbound::SwingAnimationHand(g.int_in(
-2147483648,
2147483647,
&[0, 1],
) as i32);
let v3 = {
let v4 = crate::defs::p777::play::clientbound::SwingAnimationAnimationType(
g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32,
);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p777::play::clientbound::SwingAnimationAnimation {
r#type: v4,
duration: v5,
}
};
Self {
entity_id: v1,
hand: v2,
animation: v3,
}
}
}
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: AnonNbt,
/// `description`
pub description: AnonNbt,
/// `icon`
pub icon: crate::defs::p777::types::ItemStackTemplate,
/// `frameType`
pub frame_type: i32,
/// `flags`
pub flags:
crate::defs::p775::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags,
/// `backgroundTexture`
pub background_texture: Option<ByteString>,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<
crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
/// `sendsTelemtryData`
pub sends_telemtry_data: bool,
}
#[cfg(feature = "v26_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValue,
/// `xCord`
pub x_cord: f32,
/// `yCord`
pub y_cord: f32,
}
#[cfg(feature = "v26_3")]
/// `advancements` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements<const V: i32> {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping:
Vec<crate::defs::p777::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_3")]
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), 13)?
};
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::p777::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 }; crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15 } }) } else { None };let v16 = { let v17 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v18 = Vec::with_capacity(v17.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v17 { v18.push({ 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(r.read_string()?); } v20 }); } v18 };let v21 = r.read_bool()?; crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v16, sends_telemtry_data: v21 } };let v22 = r.read_f32()?;let v23 = r.read_f32()?; crate::defs::p777::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6, x_cord: v22, y_cord: v23 } });
}
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_3")]
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",
));
}
}
}
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_f32((*v1).x_cord);
w.put_f32((*v1).y_cord);
}
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_3")]
#[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::p777::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 }; crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15 } }) } else { None };let v16 = { let v17 = g.count(); let mut v18 = Vec::with_capacity(v17.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v17 { v18.push({ let v19 = g.count(); let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push(g.string()); } v20 }); } v18 };let v21 = g.bool(); crate::defs::p777::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, requirements: v16, sends_telemtry_data: v21 } };let v22 = g.f32();let v23 = g.f32(); crate::defs::p777::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6, x_cord: v22, y_cord: v23 } });
}
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_3")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesStoneCutterRecipes {
/// `input`
pub input: HolderSet,
/// `slotDisplay`
pub slot_display: crate::defs::p777::play::clientbound::SlotDisplay,
}
#[cfg(feature = "v26_3")]
/// `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::p777::play::clientbound::DeclareRecipesStoneCutterRecipes>,
}
#[cfg(feature = "v26_3")]
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::p777::play::clientbound::SlotDisplay as Decode>::decode(
r,
)?;
crate::defs::p777::play::clientbound::DeclareRecipesStoneCutterRecipes {
input: v11,
slot_display: v12,
}
});
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
})
}
}
#[cfg(feature = "v26_3")]
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_3")]
#[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::p777::play::clientbound::SlotDisplay as Generate>::generate(g); crate::defs::p777::play::clientbound::DeclareRecipesStoneCutterRecipes { input: v11, slot_display: v12 } });
}
v10
};
Self {
recipes: v1,
stone_cutter_recipes: v8,
}
}
}
}