// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/1.12.2/protocol.json). Do not edit; run `cargo run -p ghast-codegen-protocol`.
// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see the NOTICE file
// in crates/ghast-protocol/src/generated/.
//! Clientbound packets of the play state.
#![allow(
unused_imports,
unused_variables,
unused_mut,
unused_parens,
unused_braces,
clippy::all,
clippy::pedantic,
non_camel_case_types,
non_snake_case
)]
use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
use crate::error::{DecodeError, EncodeError};
use crate::nbt::{AnonNbt, RawNbt};
use crate::packet::{Direction, PacketSet, RawPacket, State};
#[cfg(feature = "testgen")]
use crate::testgen::{Gen, Generate};
use crate::types::{BlockPos, ByteString, Holder, HolderSet, LpVec3, PositionLayout, Uuid};
use bytes::{BufMut, Bytes, BytesMut};
#[cfg(feature = "v1_12_2")]
/// `spawn_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `objectUUID`
pub object_uuid: Uuid,
/// `type`
pub r#type: i8,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `pitch`
pub pitch: i8,
/// `yaw`
pub yaw: i8,
/// `objectData`
pub object_data: i32,
/// `velocity`
pub velocity: crate::defs::p47::types::Vec3i16,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for SpawnEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_i8()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_i8()?;
let v8 = r.read_i8()?;
let v9 = r.read_i32()?;
let v10 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
Self {
entity_id: v1,
object_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
pitch: v7,
yaw: v8,
object_data: v9,
velocity: v10,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for SpawnEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).object_uuid);
w.put_i8((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).pitch);
w.put_i8((*self).yaw);
w.put_i32((*self).object_data);
(*self).velocity.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = (g.int_in(-128, 127, &[]) as i8);
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = (g.int_in(-128, 127, &[]) as i8);
let v8 = (g.int_in(-128, 127, &[]) as i8);
let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v10 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
Self {
entity_id: v1,
object_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
pitch: v7,
yaw: v8,
object_data: v9,
velocity: v10,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `spawn_entity_experience_orb` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityExperienceOrb<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `count`
pub count: i16,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for SpawnEntityExperienceOrb<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_i16()?;
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
count: v5,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for SpawnEntityExperienceOrb<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i16((*self).count);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntityExperienceOrb<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = (g.int_in(-32768, 32767, &[]) as i16);
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
count: v5,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `spawn_entity_weather` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityWeather<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `type`
pub r#type: i8,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for SpawnEntityWeather<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i8()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
Self {
entity_id: v1,
r#type: v2,
x: v3,
y: v4,
z: v5,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for SpawnEntityWeather<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntityWeather<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
Self {
entity_id: v1,
r#type: v2,
x: v3,
y: v4,
z: v5,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `spawn_entity_living` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityLiving<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `entityUUID`
pub entity_uuid: Uuid,
/// `type`
pub r#type: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `headPitch`
pub head_pitch: i8,
/// `velocity`
pub velocity: crate::defs::p47::types::Vec3i16,
/// `metadata`
pub metadata: Vec<crate::defs::p340::types::EntityMetadataEntry>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for SpawnEntityLiving<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_varint()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = r.read_i8()?;
let v8 = r.read_i8()?;
let v9 = r.read_i8()?;
let v10 = <crate::defs::p47::types::Vec3i16 as Decode>::decode(r)?;
let v11 = {
let mut v12 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v12.push({
let v13 = r.read_u8()?;
let v14 = r.read_i8()?;
let v15 = (if (v14 == 0) {
crate::defs::p340::types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v14 == 1) {
crate::defs::p340::types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v14 == 2) {
crate::defs::p340::types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v14 == 3) {
crate::defs::p340::types::EntityMetadataValue::String(r.read_string()?)
} else if (v14 == 4) {
crate::defs::p340::types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v14 == 5) {
crate::defs::p340::types::EntityMetadataValue::Slot(
<crate::types::slot::legacy::Slot as Decode>::decode(r)?,
)
} else if (v14 == 6) {
crate::defs::p340::types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v14 == 7) {
crate::defs::p340::types::EntityMetadataValue::Rotation({
let v16 = r.read_f32()?;
let v17 = r.read_f32()?;
let v18 = r.read_f32()?;
crate::defs::p47::types::EntityMetadataValueRotation {
pitch: v16,
yaw: v17,
roll: v18,
}
})
} else if (v14 == 8) {
crate::defs::p340::types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v14 == 9) {
crate::defs::p340::types::EntityMetadataValue::OptPosition(
if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
},
)
} else if (v14 == 10) {
crate::defs::p340::types::EntityMetadataValue::Direction(
r.read_varint()?,
)
} else if (v14 == 11) {
crate::defs::p340::types::EntityMetadataValue::OptUuid(
if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
},
)
} else if (v14 == 12) {
crate::defs::p340::types::EntityMetadataValue::BlockState(
r.read_varint()?,
)
} else if (v14 == 13) {
crate::defs::p340::types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
crate::defs::p340::types::EntityMetadataValue::Other
});
crate::defs::p340::types::EntityMetadataEntry {
key: v13,
r#type: v14,
value: v15,
}
});
}
v12
};
Self {
entity_id: v1,
entity_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
yaw: v7,
pitch: v8,
head_pitch: v9,
velocity: v10,
metadata: v11,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for SpawnEntityLiving<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_i8((*self).head_pitch);
(*self).velocity.encode(w)?;
for v1 in (*self).metadata.iter() {
let v2 = w.len();
w.put_u8((*v1).key);
w.put_i8((*v1).r#type);
match &(*v1).value {
crate::defs::p340::types::EntityMetadataValue::Byte(v3) => {
if !((*v1).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i8((*v3));
}
crate::defs::p340::types::EntityMetadataValue::VarInt(v4) => {
if !((*v1).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v4));
}
crate::defs::p340::types::EntityMetadataValue::Float(v5) => {
if !((*v1).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v5));
}
crate::defs::p340::types::EntityMetadataValue::String(v6) => {
if !((*v1).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_string(&(*v6))?;
}
crate::defs::p340::types::EntityMetadataValue::Chat(v7) => {
if !((*v1).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_string(&(*v7))?;
}
crate::defs::p340::types::EntityMetadataValue::Slot(v8) => {
if !((*v1).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v8).encode(w)?;
}
crate::defs::p340::types::EntityMetadataValue::Boolean(v9) => {
if !((*v1).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_bool((*v9));
}
crate::defs::p340::types::EntityMetadataValue::Rotation(v10) => {
if !((*v1).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v10).pitch);
w.put_f32((*v10).yaw);
w.put_f32((*v10).roll);
}
crate::defs::p340::types::EntityMetadataValue::Position(v11) => {
if !((*v1).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v11).write(w, PositionLayout::Xyz)?;
}
crate::defs::p340::types::EntityMetadataValue::OptPosition(v12) => {
if !((*v1).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
match &(*v12) {
Some(v13) => {
w.put_u8(1);
(*v13).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::Direction(v14) => {
if !((*v1).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v14));
}
crate::defs::p340::types::EntityMetadataValue::OptUuid(v15) => {
if !((*v1).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
match &(*v15) {
Some(v16) => {
w.put_u8(1);
w.put_uuid(&(*v16));
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::BlockState(v17) => {
if !((*v1).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v17));
}
crate::defs::p340::types::EntityMetadataValue::Nbt(v18) => {
if !((*v1).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v18).write(w);
}
crate::defs::p340::types::EntityMetadataValue::Other => {
if !(!(((*v1).r#type == 0)
|| ((*v1).r#type == 1)
|| ((*v1).r#type == 2)
|| ((*v1).r#type == 3)
|| ((*v1).r#type == 4)
|| ((*v1).r#type == 5)
|| ((*v1).r#type == 6)
|| ((*v1).r#type == 7)
|| ((*v1).r#type == 8)
|| ((*v1).r#type == 9)
|| ((*v1).r#type == 10)
|| ((*v1).r#type == 11)
|| ((*v1).r#type == 12)
|| ((*v1).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
}
}
if w.get(v2) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.spawn_entity_living.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntityLiving<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = (g.int_in(-128, 127, &[]) as i8);
let v8 = (g.int_in(-128, 127, &[]) as i8);
let v9 = (g.int_in(-128, 127, &[]) as i8);
let v10 = <crate::defs::p47::types::Vec3i16 as Generate>::generate(g);
let v11 = {
let n = g.count();
let mut v12 = Vec::with_capacity(n);
for _ in 0..n {
v12.push(loop { let v13 = { let v14 = (g.int_in(0, 255, &[]) as u8);let v15 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v16 = (if (v15 == 0) { crate::defs::p340::types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v15 == 1) { crate::defs::p340::types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v15 == 2) { crate::defs::p340::types::EntityMetadataValue::Float(g.f32()) } else if (v15 == 3) { crate::defs::p340::types::EntityMetadataValue::String(g.string()) } else if (v15 == 4) { crate::defs::p340::types::EntityMetadataValue::Chat(g.string()) } else if (v15 == 5) { crate::defs::p340::types::EntityMetadataValue::Slot(<crate::types::slot::legacy::Slot as Generate>::generate(g)) } else if (v15 == 6) { crate::defs::p340::types::EntityMetadataValue::Boolean(g.bool()) } else if (v15 == 7) { crate::defs::p340::types::EntityMetadataValue::Rotation({ let v17 = g.f32();let v18 = g.f32();let v19 = g.f32(); crate::defs::p47::types::EntityMetadataValueRotation { pitch: v17, yaw: v18, roll: v19 } }) } else if (v15 == 8) { crate::defs::p340::types::EntityMetadataValue::Position(g.position()) } else if (v15 == 9) { crate::defs::p340::types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v15 == 10) { crate::defs::p340::types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v15 == 11) { crate::defs::p340::types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v15 == 12) { crate::defs::p340::types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v15 == 13) { crate::defs::p340::types::EntityMetadataValue::Nbt(g.nbt()) } else { crate::defs::p340::types::EntityMetadataValue::Other }); crate::defs::p340::types::EntityMetadataEntry { key: v14, r#type: v15, value: v16 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v13.key);w.put_i8(v13.r#type);match &v13.value { crate::defs::p340::types::EntityMetadataValue::Byte(v20) => { if !((v13.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v20)); }crate::defs::p340::types::EntityMetadataValue::VarInt(v21) => { if !((v13.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v21)); }crate::defs::p340::types::EntityMetadataValue::Float(v22) => { if !((v13.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v22)); }crate::defs::p340::types::EntityMetadataValue::String(v23) => { if !((v13.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v23))?; }crate::defs::p340::types::EntityMetadataValue::Chat(v24) => { if !((v13.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v24))?; }crate::defs::p340::types::EntityMetadataValue::Slot(v25) => { if !((v13.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v25).encode(w)?; }crate::defs::p340::types::EntityMetadataValue::Boolean(v26) => { if !((v13.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_bool((*v26)); }crate::defs::p340::types::EntityMetadataValue::Rotation(v27) => { if !((v13.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v27).pitch);w.put_f32((*v27).yaw);w.put_f32((*v27).roll); }crate::defs::p340::types::EntityMetadataValue::Position(v28) => { if !((v13.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v28).write(w, PositionLayout::Xyz)?; }crate::defs::p340::types::EntityMetadataValue::OptPosition(v29) => { if !((v13.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v29) { Some(v30) => { w.put_u8(1); (*v30).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }crate::defs::p340::types::EntityMetadataValue::Direction(v31) => { if !((v13.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v31)); }crate::defs::p340::types::EntityMetadataValue::OptUuid(v32) => { if !((v13.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v32) { Some(v33) => { w.put_u8(1); w.put_uuid(&(*v33)); } None => w.put_u8(0), } }crate::defs::p340::types::EntityMetadataValue::BlockState(v34) => { if !((v13.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v34)); }crate::defs::p340::types::EntityMetadataValue::Nbt(v35) => { if !((v13.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v35).write(w); }crate::defs::p340::types::EntityMetadataValue::Other => { if !(!((v13.r#type == 0) || (v13.r#type == 1) || (v13.r#type == 2) || (v13.r#type == 3) || (v13.r#type == 4) || (v13.r#type == 5) || (v13.r#type == 6) || (v13.r#type == 7) || (v13.r#type == 8) || (v13.r#type == 9) || (v13.r#type == 10) || (v13.r#type == 11) || (v13.r#type == 12) || (v13.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v13; } });
}
v12
};
Self {
entity_id: v1,
entity_uuid: v2,
r#type: v3,
x: v4,
y: v5,
z: v6,
yaw: v7,
pitch: v8,
head_pitch: v9,
velocity: v10,
metadata: v11,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `spawn_entity_painting` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityPainting<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `entityUUID`
pub entity_uuid: Uuid,
/// `title`
pub title: ByteString,
/// `location`
pub location: BlockPos,
/// `direction`
pub direction: u8,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for SpawnEntityPainting<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_string()?;
let v4 = BlockPos::read(r, PositionLayout::Xyz)?;
let v5 = r.read_u8()?;
Self {
entity_id: v1,
entity_uuid: v2,
title: v3,
location: v4,
direction: v5,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for SpawnEntityPainting<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).entity_uuid);
w.put_string(&(*self).title)?;
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_u8((*self).direction);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntityPainting<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = g.string();
let v4 = g.position();
let v5 = (g.int_in(0, 255, &[]) as u8);
Self {
entity_id: v1,
entity_uuid: v2,
title: v3,
location: v4,
direction: v5,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `named_entity_spawn` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedEntitySpawn<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `playerUUID`
pub player_uuid: Uuid,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `metadata`
pub metadata: Vec<crate::defs::p340::types::EntityMetadataEntry>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for NamedEntitySpawn<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_i8()?;
let v7 = r.read_i8()?;
let v8 = {
let mut v9 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v9.push({
let v10 = r.read_u8()?;
let v11 = r.read_i8()?;
let v12 = (if (v11 == 0) {
crate::defs::p340::types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v11 == 1) {
crate::defs::p340::types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v11 == 2) {
crate::defs::p340::types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v11 == 3) {
crate::defs::p340::types::EntityMetadataValue::String(r.read_string()?)
} else if (v11 == 4) {
crate::defs::p340::types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v11 == 5) {
crate::defs::p340::types::EntityMetadataValue::Slot(
<crate::types::slot::legacy::Slot as Decode>::decode(r)?,
)
} else if (v11 == 6) {
crate::defs::p340::types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v11 == 7) {
crate::defs::p340::types::EntityMetadataValue::Rotation({
let v13 = r.read_f32()?;
let v14 = r.read_f32()?;
let v15 = r.read_f32()?;
crate::defs::p47::types::EntityMetadataValueRotation {
pitch: v13,
yaw: v14,
roll: v15,
}
})
} else if (v11 == 8) {
crate::defs::p340::types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v11 == 9) {
crate::defs::p340::types::EntityMetadataValue::OptPosition(
if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
},
)
} else if (v11 == 10) {
crate::defs::p340::types::EntityMetadataValue::Direction(
r.read_varint()?,
)
} else if (v11 == 11) {
crate::defs::p340::types::EntityMetadataValue::OptUuid(
if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
},
)
} else if (v11 == 12) {
crate::defs::p340::types::EntityMetadataValue::BlockState(
r.read_varint()?,
)
} else if (v11 == 13) {
crate::defs::p340::types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
crate::defs::p340::types::EntityMetadataValue::Other
});
crate::defs::p340::types::EntityMetadataEntry {
key: v10,
r#type: v11,
value: v12,
}
});
}
v9
};
Self {
entity_id: v1,
player_uuid: v2,
x: v3,
y: v4,
z: v5,
yaw: v6,
pitch: v7,
metadata: v8,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for NamedEntitySpawn<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).player_uuid);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
for v1 in (*self).metadata.iter() {
let v2 = w.len();
w.put_u8((*v1).key);
w.put_i8((*v1).r#type);
match &(*v1).value {
crate::defs::p340::types::EntityMetadataValue::Byte(v3) => {
if !((*v1).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i8((*v3));
}
crate::defs::p340::types::EntityMetadataValue::VarInt(v4) => {
if !((*v1).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v4));
}
crate::defs::p340::types::EntityMetadataValue::Float(v5) => {
if !((*v1).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v5));
}
crate::defs::p340::types::EntityMetadataValue::String(v6) => {
if !((*v1).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_string(&(*v6))?;
}
crate::defs::p340::types::EntityMetadataValue::Chat(v7) => {
if !((*v1).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_string(&(*v7))?;
}
crate::defs::p340::types::EntityMetadataValue::Slot(v8) => {
if !((*v1).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v8).encode(w)?;
}
crate::defs::p340::types::EntityMetadataValue::Boolean(v9) => {
if !((*v1).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_bool((*v9));
}
crate::defs::p340::types::EntityMetadataValue::Rotation(v10) => {
if !((*v1).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v10).pitch);
w.put_f32((*v10).yaw);
w.put_f32((*v10).roll);
}
crate::defs::p340::types::EntityMetadataValue::Position(v11) => {
if !((*v1).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v11).write(w, PositionLayout::Xyz)?;
}
crate::defs::p340::types::EntityMetadataValue::OptPosition(v12) => {
if !((*v1).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
match &(*v12) {
Some(v13) => {
w.put_u8(1);
(*v13).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::Direction(v14) => {
if !((*v1).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v14));
}
crate::defs::p340::types::EntityMetadataValue::OptUuid(v15) => {
if !((*v1).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
match &(*v15) {
Some(v16) => {
w.put_u8(1);
w.put_uuid(&(*v16));
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::BlockState(v17) => {
if !((*v1).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v17));
}
crate::defs::p340::types::EntityMetadataValue::Nbt(v18) => {
if !((*v1).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v18).write(w);
}
crate::defs::p340::types::EntityMetadataValue::Other => {
if !(!(((*v1).r#type == 0)
|| ((*v1).r#type == 1)
|| ((*v1).r#type == 2)
|| ((*v1).r#type == 3)
|| ((*v1).r#type == 4)
|| ((*v1).r#type == 5)
|| ((*v1).r#type == 6)
|| ((*v1).r#type == 7)
|| ((*v1).r#type == 8)
|| ((*v1).r#type == 9)
|| ((*v1).r#type == 10)
|| ((*v1).r#type == 11)
|| ((*v1).r#type == 12)
|| ((*v1).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
}
}
if w.get(v2) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.named_entity_spawn.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for NamedEntitySpawn<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = (g.int_in(-128, 127, &[]) as i8);
let v7 = (g.int_in(-128, 127, &[]) as i8);
let v8 = {
let n = g.count();
let mut v9 = Vec::with_capacity(n);
for _ in 0..n {
v9.push(loop { let v10 = { let v11 = (g.int_in(0, 255, &[]) as u8);let v12 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v13 = (if (v12 == 0) { crate::defs::p340::types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v12 == 1) { crate::defs::p340::types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v12 == 2) { crate::defs::p340::types::EntityMetadataValue::Float(g.f32()) } else if (v12 == 3) { crate::defs::p340::types::EntityMetadataValue::String(g.string()) } else if (v12 == 4) { crate::defs::p340::types::EntityMetadataValue::Chat(g.string()) } else if (v12 == 5) { crate::defs::p340::types::EntityMetadataValue::Slot(<crate::types::slot::legacy::Slot as Generate>::generate(g)) } else if (v12 == 6) { crate::defs::p340::types::EntityMetadataValue::Boolean(g.bool()) } else if (v12 == 7) { crate::defs::p340::types::EntityMetadataValue::Rotation({ let v14 = g.f32();let v15 = g.f32();let v16 = g.f32(); crate::defs::p47::types::EntityMetadataValueRotation { pitch: v14, yaw: v15, roll: v16 } }) } else if (v12 == 8) { crate::defs::p340::types::EntityMetadataValue::Position(g.position()) } else if (v12 == 9) { crate::defs::p340::types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v12 == 10) { crate::defs::p340::types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v12 == 11) { crate::defs::p340::types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v12 == 12) { crate::defs::p340::types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v12 == 13) { crate::defs::p340::types::EntityMetadataValue::Nbt(g.nbt()) } else { crate::defs::p340::types::EntityMetadataValue::Other }); crate::defs::p340::types::EntityMetadataEntry { key: v11, r#type: v12, value: v13 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v10.key);w.put_i8(v10.r#type);match &v10.value { crate::defs::p340::types::EntityMetadataValue::Byte(v17) => { if !((v10.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v17)); }crate::defs::p340::types::EntityMetadataValue::VarInt(v18) => { if !((v10.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v18)); }crate::defs::p340::types::EntityMetadataValue::Float(v19) => { if !((v10.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v19)); }crate::defs::p340::types::EntityMetadataValue::String(v20) => { if !((v10.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v20))?; }crate::defs::p340::types::EntityMetadataValue::Chat(v21) => { if !((v10.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v21))?; }crate::defs::p340::types::EntityMetadataValue::Slot(v22) => { if !((v10.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v22).encode(w)?; }crate::defs::p340::types::EntityMetadataValue::Boolean(v23) => { if !((v10.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_bool((*v23)); }crate::defs::p340::types::EntityMetadataValue::Rotation(v24) => { if !((v10.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v24).pitch);w.put_f32((*v24).yaw);w.put_f32((*v24).roll); }crate::defs::p340::types::EntityMetadataValue::Position(v25) => { if !((v10.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v25).write(w, PositionLayout::Xyz)?; }crate::defs::p340::types::EntityMetadataValue::OptPosition(v26) => { if !((v10.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v26) { Some(v27) => { w.put_u8(1); (*v27).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }crate::defs::p340::types::EntityMetadataValue::Direction(v28) => { if !((v10.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v28)); }crate::defs::p340::types::EntityMetadataValue::OptUuid(v29) => { if !((v10.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v29) { Some(v30) => { w.put_u8(1); w.put_uuid(&(*v30)); } None => w.put_u8(0), } }crate::defs::p340::types::EntityMetadataValue::BlockState(v31) => { if !((v10.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v31)); }crate::defs::p340::types::EntityMetadataValue::Nbt(v32) => { if !((v10.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v32).write(w); }crate::defs::p340::types::EntityMetadataValue::Other => { if !(!((v10.r#type == 0) || (v10.r#type == 1) || (v10.r#type == 2) || (v10.r#type == 3) || (v10.r#type == 4) || (v10.r#type == 5) || (v10.r#type == 6) || (v10.r#type == 7) || (v10.r#type == 8) || (v10.r#type == 9) || (v10.r#type == 10) || (v10.r#type == 11) || (v10.r#type == 12) || (v10.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v10; } });
}
v9
};
Self {
entity_id: v1,
player_uuid: v2,
x: v3,
y: v4,
z: v5,
yaw: v6,
pitch: v7,
metadata: v8,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `boss_bar` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BossBar<const V: i32> {
/// `entityUUID`
pub entity_uuid: Uuid,
/// `action`
pub action: i32,
/// `title`
pub title: Option<ByteString>,
/// `health`
pub health: Option<f32>,
/// `color`
pub color: Option<i32>,
/// `dividers`
pub dividers: Option<i32>,
/// `flags`
pub flags: Option<u8>,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for BossBar<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
let v2 = r.read_varint()?;
let v3 = if (v2 == 0) || (v2 == 3) {
Some(r.read_string()?)
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 5) {
Some(r.read_u8()?)
} else {
None
};
Self {
entity_uuid: v1,
action: v2,
title: v3,
health: v4,
color: v5,
dividers: v6,
flags: v7,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for BossBar<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).action);
match (
&(*self).title,
((*self).action == 0) || ((*self).action == 3),
) {
(Some(v1), true) => {
w.put_string(&(*v1))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.title",
));
}
}
match (
&(*self).health,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v2), true) => {
w.put_f32((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.health",
));
}
}
match (
&(*self).color,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v3), true) => {
w.put_varint((*v3));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.color",
));
}
}
match (
&(*self).dividers,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v4), true) => {
w.put_varint((*v4));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.dividers",
));
}
}
match (
&(*self).flags,
((*self).action == 0) || ((*self).action == 5),
) {
(Some(v5), true) => {
w.put_u8((*v5));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.flags",
));
}
}
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BossBar<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
let v2 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
let v3 = if (v2 == 0) || (v2 == 3) {
Some(g.string())
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(g.f32())
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 5) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
Self {
entity_uuid: v1,
action: v2,
title: v3,
health: v4,
color: v5,
dividers: v6,
flags: v7,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `set_cooldown` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCooldown<const V: i32> {
/// `itemID`
pub item_id: i32,
/// `cooldownTicks`
pub cooldown_ticks: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for SetCooldown<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
Self {
item_id: v1,
cooldown_ticks: v2,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for SetCooldown<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_id);
w.put_varint((*self).cooldown_ticks);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCooldown<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
item_id: v1,
cooldown_ticks: v2,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `named_sound_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedSoundEffect<const V: i32> {
/// `soundName`
pub sound_name: ByteString,
/// `soundCategory`
pub sound_category: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: f32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for NamedSoundEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_varint()?;
let v3 = r.read_i32()?;
let v4 = r.read_i32()?;
let v5 = r.read_i32()?;
let v6 = r.read_f32()?;
let v7 = r.read_f32()?;
Self {
sound_name: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for NamedSoundEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).sound_name)?;
w.put_varint((*self).sound_category);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for NamedSoundEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = g.f32();
let v7 = g.f32();
Self {
sound_name: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `unload_chunk` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UnloadChunk<const V: i32> {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for UnloadChunk<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_i32()?;
Self {
chunk_x: v1,
chunk_z: v2,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for UnloadChunk<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).chunk_x);
w.put_i32((*self).chunk_z);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UnloadChunk<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
chunk_x: v1,
chunk_z: v2,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `keep_alive` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive<const V: i32> {
/// `keepAliveId`
pub keep_alive_id: i64,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for KeepAlive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i64()?;
Self { keep_alive_id: v1 }
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for KeepAlive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).keep_alive_id);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for KeepAlive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.i64();
Self { keep_alive_id: v1 }
}
}
}
#[cfg(feature = "v1_12_2")]
/// `map_chunk` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunk<const V: i32> {
/// `x`
pub x: i32,
/// `z`
pub z: i32,
/// `groundUp`
pub ground_up: bool,
/// `bitMap`
pub bit_map: i32,
/// `chunkData`
pub chunk_data: Bytes,
/// `blockEntities`
pub block_entities: Vec<RawNbt>,
}
#[cfg(feature = "v1_12_2")]
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 = r.read_bool()?;
let v4 = r.read_varint()?;
let v5 = r.read_byte_array()?;
let v6 = {
let v7 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v7 {
v8.push(RawNbt::read(r)?);
}
v8
};
Self {
x: v1,
z: v2,
ground_up: v3,
bit_map: v4,
chunk_data: v5,
block_entities: v6,
}
})
}
}
#[cfg(feature = "v1_12_2")]
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_bool((*self).ground_up);
w.put_varint((*self).bit_map);
w.put_byte_array(&(*self).chunk_data)?;
w.put_len_varint((*self).block_entities.len())?;
for v1 in (*self).block_entities.iter() {
(*v1).write(w);
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[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 = g.bool();
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = g.bytes();
let v6 = {
let v7 = g.count();
let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v7 {
v8.push(g.nbt());
}
v8
};
Self {
x: v1,
z: v2,
ground_up: v3,
bit_map: v4,
chunk_data: v5,
block_entities: v6,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `login` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Login<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `gameMode`
pub game_mode: u8,
/// `dimension`
pub dimension: i32,
/// `difficulty`
pub difficulty: u8,
/// `maxPlayers`
pub max_players: u8,
/// `levelType`
pub level_type: ByteString,
/// `reducedDebugInfo`
pub reduced_debug_info: bool,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for Login<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_u8()?;
let v3 = r.read_i32()?;
let v4 = r.read_u8()?;
let v5 = r.read_u8()?;
let v6 = r.read_string()?;
let v7 = r.read_bool()?;
Self {
entity_id: v1,
game_mode: v2,
dimension: v3,
difficulty: v4,
max_players: v5,
level_type: v6,
reduced_debug_info: v7,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for Login<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_u8((*self).game_mode);
w.put_i32((*self).dimension);
w.put_u8((*self).difficulty);
w.put_u8((*self).max_players);
w.put_string(&(*self).level_type)?;
w.put_bool((*self).reduced_debug_info);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Login<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(0, 255, &[]) as u8);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(0, 255, &[]) as u8);
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = g.string();
let v7 = g.bool();
Self {
entity_id: v1,
game_mode: v2,
dimension: v3,
difficulty: v4,
max_players: v5,
level_type: v6,
reduced_debug_info: v7,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `map` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Map<const V: i32> {
/// `itemDamage`
pub item_damage: i32,
/// `scale`
pub scale: i8,
/// `trackingPosition`
pub tracking_position: bool,
/// `icons`
pub icons: Vec<crate::defs::p47::play::clientbound::MapIcons>,
/// `columns`
pub columns: i8,
/// `rows`
pub rows: Option<i8>,
/// `x`
pub x: Option<i8>,
/// `y`
pub y: Option<i8>,
/// `data`
pub data: Option<Bytes>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for Map<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i8()?;
let v3 = r.read_bool()?;
let v4 = {
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = r.read_i8()?;
let v8 = r.read_i8()?;
let v9 = r.read_i8()?;
crate::defs::p47::play::clientbound::MapIcons {
direction_and_type: v7,
x: v8,
z: v9,
}
});
}
v6
};
let v10 = r.read_i8()?;
let v11 = if !(v10 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v12 = if !(v10 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v13 = if !(v10 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v14 = if !(v10 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Self {
item_damage: v1,
scale: v2,
tracking_position: v3,
icons: v4,
columns: v10,
rows: v11,
x: v12,
y: v13,
data: v14,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for Map<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_damage);
w.put_i8((*self).scale);
w.put_bool((*self).tracking_position);
w.put_len_varint((*self).icons.len())?;
for v1 in (*self).icons.iter() {
w.put_i8((*v1).direction_and_type);
w.put_i8((*v1).x);
w.put_i8((*v1).z);
}
w.put_i8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v2), true) => {
w.put_i8((*v2));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v3), true) => {
w.put_i8((*v3));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v4), true) => {
w.put_i8((*v4));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v5), true) => {
w.put_byte_array(&(*v5))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Map<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = g.bool();
let v4 = {
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = (g.int_in(-128, 127, &[]) as i8);
let v8 = (g.int_in(-128, 127, &[]) as i8);
let v9 = (g.int_in(-128, 127, &[]) as i8);
crate::defs::p47::play::clientbound::MapIcons {
direction_and_type: v7,
x: v8,
z: v9,
}
});
}
v6
};
let v10 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
let v11 = if !(v10 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v12 = if !(v10 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v13 = if !(v10 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v14 = if !(v10 == 0) { Some(g.bytes()) } else { None };
Self {
item_damage: v1,
scale: v2,
tracking_position: v3,
icons: v4,
columns: v10,
rows: v11,
x: v12,
y: v13,
data: v14,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `rel_entity_move` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct RelEntityMove<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i16,
/// `dY`
pub d_y: i16,
/// `dZ`
pub d_z: i16,
/// `onGround`
pub on_ground: bool,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for RelEntityMove<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i16()?;
let v3 = r.read_i16()?;
let v4 = r.read_i16()?;
let v5 = r.read_bool()?;
Self {
entity_id: v1,
d_x: v2,
d_y: v3,
d_z: v4,
on_ground: v5,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for RelEntityMove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i16((*self).d_x);
w.put_i16((*self).d_y);
w.put_i16((*self).d_z);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[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 = (g.int_in(-32768, 32767, &[]) as i16);
let v3 = (g.int_in(-32768, 32767, &[]) as i16);
let v4 = (g.int_in(-32768, 32767, &[]) as i16);
let v5 = g.bool();
Self {
entity_id: v1,
d_x: v2,
d_y: v3,
d_z: v4,
on_ground: v5,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `entity_move_look` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMoveLook<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i16,
/// `dY`
pub d_y: i16,
/// `dZ`
pub d_z: i16,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `onGround`
pub on_ground: bool,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for EntityMoveLook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i16()?;
let v3 = r.read_i16()?;
let v4 = r.read_i16()?;
let v5 = r.read_i8()?;
let v6 = r.read_i8()?;
let v7 = r.read_bool()?;
Self {
entity_id: v1,
d_x: v2,
d_y: v3,
d_z: v4,
yaw: v5,
pitch: v6,
on_ground: v7,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for EntityMoveLook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i16((*self).d_x);
w.put_i16((*self).d_y);
w.put_i16((*self).d_z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[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 = (g.int_in(-32768, 32767, &[]) as i16);
let v3 = (g.int_in(-32768, 32767, &[]) as i16);
let v4 = (g.int_in(-32768, 32767, &[]) as i16);
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = (g.int_in(-128, 127, &[]) as i8);
let v7 = g.bool();
Self {
entity_id: v1,
d_x: v2,
d_y: v3,
d_z: v4,
yaw: v5,
pitch: v6,
on_ground: v7,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `vehicle_move` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct VehicleMove<const V: i32> {
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for VehicleMove<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for VehicleMove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for VehicleMove<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f32();
let v5 = g.f32();
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `craft_recipe_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeResponse<const V: i32> {
/// `windowId`
pub window_id: i8,
/// `recipe`
pub recipe: i32,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for CraftRecipeResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_varint()?;
Self {
window_id: v1,
recipe: v2,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for CraftRecipeResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_varint((*self).recipe);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CraftRecipeResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[]) as i8);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
window_id: v1,
recipe: v2,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Position<const V: i32> {
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `flags`
pub flags: i8,
/// `teleportId`
pub teleport_id: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Position<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
let v6 = r.read_i8()?;
let v7 = r.read_varint()?;
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
flags: v6,
teleport_id: v7,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Position<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_i8((*self).flags);
w.put_varint((*self).teleport_id);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Position<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f32();
let v5 = g.f32();
let v6 = (g.int_in(-128, 127, &[]) as i8);
let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
flags: v6,
teleport_id: v7,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `unlock_recipes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UnlockRecipes<const V: i32> {
/// `action`
pub action: i32,
/// `craftingBookOpen`
pub crafting_book_open: bool,
/// `filteringCraftable`
pub filtering_craftable: bool,
/// `recipes1`
pub recipes1: Vec<i32>,
/// `recipes2`
pub recipes2: Option<Vec<i32>>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for UnlockRecipes<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_bool()?;
let v3 = r.read_bool()?;
let v4 = {
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push(r.read_varint()?);
}
v6
};
let v7 = if (v1 == 0) {
Some({
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(r.read_varint()?);
}
v9
})
} else {
None
};
Self {
action: v1,
crafting_book_open: v2,
filtering_craftable: v3,
recipes1: v4,
recipes2: v7,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for UnlockRecipes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
w.put_bool((*self).crafting_book_open);
w.put_bool((*self).filtering_craftable);
w.put_len_varint((*self).recipes1.len())?;
for v1 in (*self).recipes1.iter() {
w.put_varint((*v1));
}
match (&(*self).recipes2, ((*self).action == 0)) {
(Some(v2), true) => {
w.put_len_varint((*v2).len())?;
for v3 in (*v2).iter() {
w.put_varint((*v3));
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.unlock_recipes.recipes2",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UnlockRecipes<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
let v2 = g.bool();
let v3 = g.bool();
let v4 = {
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v6
};
let v7 = if (v1 == 0) {
Some({
let v8 = g.count();
let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v8 {
v9.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v9
})
} else {
None
};
Self {
action: v1,
crafting_book_open: v2,
filtering_craftable: v3,
recipes1: v4,
recipes2: v7,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `select_advancement_tab` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SelectAdvancementTab<const V: i32> {
/// `id`
pub id: Option<ByteString>,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for SelectAdvancementTab<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
Self { id: v1 }
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for SelectAdvancementTab<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).id {
Some(v1) => {
w.put_u8(1);
w.put_string(&(*v1))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SelectAdvancementTab<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = if g.bool() { Some(g.string()) } else { None };
Self { id: v1 }
}
}
}
#[cfg(feature = "v1_12_2")]
/// `entity_metadata` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMetadata<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `metadata`
pub metadata: Vec<crate::defs::p340::types::EntityMetadataEntry>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for EntityMetadata<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let mut v3 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v3.push({
let v4 = r.read_u8()?;
let v5 = r.read_i8()?;
let v6 = (if (v5 == 0) {
crate::defs::p340::types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v5 == 1) {
crate::defs::p340::types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v5 == 2) {
crate::defs::p340::types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v5 == 3) {
crate::defs::p340::types::EntityMetadataValue::String(r.read_string()?)
} else if (v5 == 4) {
crate::defs::p340::types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v5 == 5) {
crate::defs::p340::types::EntityMetadataValue::Slot(
<crate::types::slot::legacy::Slot as Decode>::decode(r)?,
)
} else if (v5 == 6) {
crate::defs::p340::types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v5 == 7) {
crate::defs::p340::types::EntityMetadataValue::Rotation({
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
crate::defs::p47::types::EntityMetadataValueRotation {
pitch: v7,
yaw: v8,
roll: v9,
}
})
} else if (v5 == 8) {
crate::defs::p340::types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v5 == 9) {
crate::defs::p340::types::EntityMetadataValue::OptPosition(
if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
},
)
} else if (v5 == 10) {
crate::defs::p340::types::EntityMetadataValue::Direction(
r.read_varint()?,
)
} else if (v5 == 11) {
crate::defs::p340::types::EntityMetadataValue::OptUuid(
if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
},
)
} else if (v5 == 12) {
crate::defs::p340::types::EntityMetadataValue::BlockState(
r.read_varint()?,
)
} else if (v5 == 13) {
crate::defs::p340::types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
crate::defs::p340::types::EntityMetadataValue::Other
});
crate::defs::p340::types::EntityMetadataEntry {
key: v4,
r#type: v5,
value: v6,
}
});
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for EntityMetadata<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
for v1 in (*self).metadata.iter() {
let v2 = w.len();
w.put_u8((*v1).key);
w.put_i8((*v1).r#type);
match &(*v1).value {
crate::defs::p340::types::EntityMetadataValue::Byte(v3) => {
if !((*v1).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v3));
}
crate::defs::p340::types::EntityMetadataValue::VarInt(v4) => {
if !((*v1).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v4));
}
crate::defs::p340::types::EntityMetadataValue::Float(v5) => {
if !((*v1).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v5));
}
crate::defs::p340::types::EntityMetadataValue::String(v6) => {
if !((*v1).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v6))?;
}
crate::defs::p340::types::EntityMetadataValue::Chat(v7) => {
if !((*v1).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v7))?;
}
crate::defs::p340::types::EntityMetadataValue::Slot(v8) => {
if !((*v1).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v8).encode(w)?;
}
crate::defs::p340::types::EntityMetadataValue::Boolean(v9) => {
if !((*v1).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v9));
}
crate::defs::p340::types::EntityMetadataValue::Rotation(v10) => {
if !((*v1).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v10).pitch);
w.put_f32((*v10).yaw);
w.put_f32((*v10).roll);
}
crate::defs::p340::types::EntityMetadataValue::Position(v11) => {
if !((*v1).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v11).write(w, PositionLayout::Xyz)?;
}
crate::defs::p340::types::EntityMetadataValue::OptPosition(v12) => {
if !((*v1).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v12) {
Some(v13) => {
w.put_u8(1);
(*v13).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::Direction(v14) => {
if !((*v1).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v14));
}
crate::defs::p340::types::EntityMetadataValue::OptUuid(v15) => {
if !((*v1).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v15) {
Some(v16) => {
w.put_u8(1);
w.put_uuid(&(*v16));
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::BlockState(v17) => {
if !((*v1).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v17));
}
crate::defs::p340::types::EntityMetadataValue::Nbt(v18) => {
if !((*v1).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v18).write(w);
}
crate::defs::p340::types::EntityMetadataValue::Other => {
if !(!(((*v1).r#type == 0)
|| ((*v1).r#type == 1)
|| ((*v1).r#type == 2)
|| ((*v1).r#type == 3)
|| ((*v1).r#type == 4)
|| ((*v1).r#type == 5)
|| ((*v1).r#type == 6)
|| ((*v1).r#type == 7)
|| ((*v1).r#type == 8)
|| ((*v1).r#type == 9)
|| ((*v1).r#type == 10)
|| ((*v1).r#type == 11)
|| ((*v1).r#type == 12)
|| ((*v1).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
if w.get(v2) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_metadata.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityMetadata<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let n = g.count();
let mut v3 = Vec::with_capacity(n);
for _ in 0..n {
v3.push(loop {
let v4 = {
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = (g.int_in(
-128,
127,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
) as i8);
let v7 = (if (v6 == 0) {
crate::defs::p340::types::EntityMetadataValue::Byte(
(g.int_in(-128, 127, &[]) as i8),
)
} else if (v6 == 1) {
crate::defs::p340::types::EntityMetadataValue::VarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 2) {
crate::defs::p340::types::EntityMetadataValue::Float(g.f32())
} else if (v6 == 3) {
crate::defs::p340::types::EntityMetadataValue::String(g.string())
} else if (v6 == 4) {
crate::defs::p340::types::EntityMetadataValue::Chat(g.string())
} else if (v6 == 5) {
crate::defs::p340::types::EntityMetadataValue::Slot(
<crate::types::slot::legacy::Slot as Generate>::generate(g),
)
} else if (v6 == 6) {
crate::defs::p340::types::EntityMetadataValue::Boolean(g.bool())
} else if (v6 == 7) {
crate::defs::p340::types::EntityMetadataValue::Rotation({
let v8 = g.f32();
let v9 = g.f32();
let v10 = g.f32();
crate::defs::p47::types::EntityMetadataValueRotation {
pitch: v8,
yaw: v9,
roll: v10,
}
})
} else if (v6 == 8) {
crate::defs::p340::types::EntityMetadataValue::Position(
g.position(),
)
} else if (v6 == 9) {
crate::defs::p340::types::EntityMetadataValue::OptPosition(
if g.bool() { Some(g.position()) } else { None },
)
} else if (v6 == 10) {
crate::defs::p340::types::EntityMetadataValue::Direction(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 11) {
crate::defs::p340::types::EntityMetadataValue::OptUuid(
if g.bool() { Some(g.uuid()) } else { None },
)
} else if (v6 == 12) {
crate::defs::p340::types::EntityMetadataValue::BlockState(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 13) {
crate::defs::p340::types::EntityMetadataValue::Nbt(g.nbt())
} else {
crate::defs::p340::types::EntityMetadataValue::Other
});
crate::defs::p340::types::EntityMetadataEntry {
key: v5,
r#type: v6,
value: v7,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_u8(v4.key);
w.put_i8(v4.r#type);
match &v4.value {
crate::defs::p340::types::EntityMetadataValue::Byte(v11) => {
if !(v4.r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v11));
}
crate::defs::p340::types::EntityMetadataValue::VarInt(v12) => {
if !(v4.r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v12));
}
crate::defs::p340::types::EntityMetadataValue::Float(v13) => {
if !(v4.r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v13));
}
crate::defs::p340::types::EntityMetadataValue::String(v14) => {
if !(v4.r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v14))?;
}
crate::defs::p340::types::EntityMetadataValue::Chat(v15) => {
if !(v4.r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v15))?;
}
crate::defs::p340::types::EntityMetadataValue::Slot(v16) => {
if !(v4.r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v16).encode(w)?;
}
crate::defs::p340::types::EntityMetadataValue::Boolean(v17) => {
if !(v4.r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v17));
}
crate::defs::p340::types::EntityMetadataValue::Rotation(
v18,
) => {
if !(v4.r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v18).pitch);
w.put_f32((*v18).yaw);
w.put_f32((*v18).roll);
}
crate::defs::p340::types::EntityMetadataValue::Position(
v19,
) => {
if !(v4.r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v19).write(w, PositionLayout::Xyz)?;
}
crate::defs::p340::types::EntityMetadataValue::OptPosition(
v20,
) => {
if !(v4.r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v20) {
Some(v21) => {
w.put_u8(1);
(*v21).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::Direction(
v22,
) => {
if !(v4.r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v22));
}
crate::defs::p340::types::EntityMetadataValue::OptUuid(v23) => {
if !(v4.r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v23) {
Some(v24) => {
w.put_u8(1);
w.put_uuid(&(*v24));
}
None => w.put_u8(0),
}
}
crate::defs::p340::types::EntityMetadataValue::BlockState(
v25,
) => {
if !(v4.r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v25));
}
crate::defs::p340::types::EntityMetadataValue::Nbt(v26) => {
if !(v4.r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v26).write(w);
}
crate::defs::p340::types::EntityMetadataValue::Other => {
if !(!((v4.r#type == 0)
|| (v4.r#type == 1)
|| (v4.r#type == 2)
|| (v4.r#type == 3)
|| (v4.r#type == 4)
|| (v4.r#type == 5)
|| (v4.r#type == 6)
|| (v4.r#type == 7)
|| (v4.r#type == 8)
|| (v4.r#type == 9)
|| (v4.r#type == 10)
|| (v4.r#type == 11)
|| (v4.r#type == 12)
|| (v4.r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
Ok(())
},
|b| b != 255,
) {
break v4;
}
});
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `attach_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct AttachEntity<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `vehicleId`
pub vehicle_id: i32,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for AttachEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_i32()?;
Self {
entity_id: v1,
vehicle_id: v2,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for AttachEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_i32((*self).vehicle_id);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AttachEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
entity_id: v1,
vehicle_id: v2,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `entity_equipment` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `slot`
pub slot: i32,
/// `item`
pub item: crate::types::slot::legacy::Slot,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for EntityEquipment<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
Self {
entity_id: v1,
slot: v2,
item: v3,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for EntityEquipment<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityEquipment<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
Self {
entity_id: v1,
slot: v2,
item: v3,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `set_passengers` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetPassengers<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `passengers`
pub passengers: Vec<i32>,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for SetPassengers<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(r.read_varint()?);
}
v4
};
Self {
entity_id: v1,
passengers: v2,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for SetPassengers<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_len_varint((*self).passengers.len())?;
for v1 in (*self).passengers.iter() {
w.put_varint((*v1));
}
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetPassengers<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v4
};
Self {
entity_id: v1,
passengers: v2,
}
}
}
}
#[cfg(feature = "v1_12_2")]
/// `teams` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Teams<const V: i32> {
/// `team`
pub team: ByteString,
/// `mode`
pub mode: i8,
/// `name`
pub name: Option<ByteString>,
/// `prefix`
pub prefix: Option<ByteString>,
/// `suffix`
pub suffix: Option<ByteString>,
/// `friendlyFire`
pub friendly_fire: Option<i8>,
/// `nameTagVisibility`
pub name_tag_visibility: Option<ByteString>,
/// `collisionRule`
pub collision_rule: Option<ByteString>,
/// `color`
pub color: Option<i8>,
/// `players`
pub players: Option<Vec<ByteString>>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for Teams<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v8 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v9 = if (v2 == 0) || (v2 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v10 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
Some({
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(r.read_string()?);
}
v12
})
} else {
None
};
Self {
team: v1,
mode: v2,
name: v3,
prefix: v4,
suffix: v5,
friendly_fire: v6,
name_tag_visibility: v7,
collision_rule: v8,
color: v9,
players: v10,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for Teams<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).team)?;
w.put_i8((*self).mode);
match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v1), true) => {
w.put_string(&(*v1))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
}
match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v2), true) => {
w.put_string(&(*v2))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
}
match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v3), true) => {
w.put_string(&(*v3))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
}
match (
&(*self).friendly_fire,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v4), true) => {
w.put_i8((*v4));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.friendlyFire",
));
}
}
match (
&(*self).name_tag_visibility,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v5), true) => {
w.put_string(&(*v5))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.nameTagVisibility",
));
}
}
match (
&(*self).collision_rule,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v6), true) => {
w.put_string(&(*v6))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.collisionRule",
));
}
}
match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v7), true) => {
w.put_i8((*v7));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.color")),
}
match (
&(*self).players,
((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
) {
(Some(v8), true) => {
w.put_len_varint((*v8).len())?;
for v9 in (*v8).iter() {
w.put_string(&(*v9))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.players",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Teams<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(
-128,
127,
&[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4],
) as i8);
let v3 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v8 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v9 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v10 = if (v2 == 0) || (v2 == 3) || (v2 == 4) {
Some({
let v11 = g.count();
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(g.string());
}
v12
})
} else {
None
};
Self {
team: v1,
mode: v2,
name: v3,
prefix: v4,
suffix: v5,
friendly_fire: v6,
name_tag_visibility: v7,
collision_rule: v8,
color: v9,
players: v10,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `title` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Title<const V: i32> {
/// `action`
pub action: i32,
/// `text`
pub text: Option<ByteString>,
/// `fadeIn`
pub fade_in: Option<i32>,
/// `stay`
pub stay: Option<i32>,
/// `fadeOut`
pub fade_out: Option<i32>,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Title<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = if (v1 == 0) || (v1 == 1) || (v1 == 2) {
Some(r.read_string()?)
} else {
None
};
let v3 = if (v1 == 3) { Some(r.read_i32()?) } else { None };
let v4 = if (v1 == 3) { Some(r.read_i32()?) } else { None };
let v5 = if (v1 == 3) { Some(r.read_i32()?) } else { None };
Self {
action: v1,
text: v2,
fade_in: v3,
stay: v4,
fade_out: v5,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Title<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (
&(*self).text,
((*self).action == 0) || ((*self).action == 1) || ((*self).action == 2),
) {
(Some(v1), true) => {
w.put_string(&(*v1))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
}
match (&(*self).fade_in, ((*self).action == 3)) {
(Some(v2), true) => {
w.put_i32((*v2));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
}
match (&(*self).stay, ((*self).action == 3)) {
(Some(v3), true) => {
w.put_i32((*v3));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
}
match (&(*self).fade_out, ((*self).action == 3)) {
(Some(v4), true) => {
w.put_i32((*v4));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.title.fadeOut",
));
}
}
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Title<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 3, 3]) as i32);
let v2 = if (v1 == 0) || (v1 == 1) || (v1 == 2) {
Some(g.string())
} else {
None
};
let v3 = if (v1 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v4 = if (v1 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v5 = if (v1 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Self {
action: v1,
text: v2,
fade_in: v3,
stay: v4,
fade_out: v5,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `sound_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SoundEffect<const V: i32> {
/// `soundId`
pub sound_id: i32,
/// `soundCategory`
pub sound_category: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: f32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for SoundEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_i32()?;
let v4 = r.read_i32()?;
let v5 = r.read_i32()?;
let v6 = r.read_f32()?;
let v7 = r.read_f32()?;
Self {
sound_id: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for SoundEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).sound_id);
w.put_varint((*self).sound_category);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SoundEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = g.f32();
let v7 = g.f32();
Self {
sound_id: v1,
sound_category: v2,
x: v3,
y: v4,
z: v5,
volume: v6,
pitch: v7,
}
}
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// `collect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Collect<const V: i32> {
/// `collectedEntityId`
pub collected_entity_id: i32,
/// `collectorEntityId`
pub collector_entity_id: i32,
/// `pickupItemCount`
pub pickup_item_count: i32,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for Collect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
Self {
collected_entity_id: v1,
collector_entity_id: v2,
pickup_item_count: v3,
}
})
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for Collect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).collected_entity_id);
w.put_varint((*self).collector_entity_id);
w.put_varint((*self).pickup_item_count);
Ok(())
}
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Collect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
collected_entity_id: v1,
collector_entity_id: v2,
pickup_item_count: v3,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `entity_teleport` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityTeleport<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `onGround`
pub on_ground: bool,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for EntityTeleport<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_i8()?;
let v6 = r.read_i8()?;
let v7 = r.read_bool()?;
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
yaw: v5,
pitch: v6,
on_ground: v7,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for EntityTeleport<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityTeleport<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = (g.int_in(-128, 127, &[]) as i8);
let v7 = g.bool();
Self {
entity_id: v1,
x: v2,
y: v3,
z: v4,
yaw: v5,
pitch: v6,
on_ground: v7,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// Packed bit field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
/// `_unused` (29 bits)
pub _unused: u32,
/// `hidden` (1 bits)
pub hidden: u8,
/// `show_toast` (1 bits)
pub show_toast: u8,
/// `has_background_texture` (1 bits)
pub has_background_texture: u8,
}
#[cfg(feature = "v1_12_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: ByteString,
/// `description`
pub description: ByteString,
/// `icon`
pub icon: crate::types::slot::legacy::Slot,
/// `frameType`
pub frame_type: i32,
/// `flags`
pub flags:
crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags,
/// `backgroundTexture`
pub background_texture: Option<ByteString>,
/// `xCord`
pub x_cord: f32,
/// `yCord`
pub y_cord: f32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueCriteria {
/// `key`
pub key: ByteString,
}
#[cfg(feature = "v1_12_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<
crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
>,
/// `criteria`
pub criteria:
Vec<crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
}
#[cfg(feature = "v1_12_2")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValue,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMappingValue {
/// `criterionIdentifier`
pub criterion_identifier: ByteString,
/// `criterionProgress`
pub criterion_progress: Option<i64>,
}
#[cfg(any(
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue>,
}
#[cfg(feature = "v1_12_2")]
/// `advancements` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements<const V: i32> {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping:
Vec<crate::defs::p340::play::clientbound::AdvancementsAdvancementMapping>,
/// `identifiers`
pub identifiers: Vec<ByteString>,
/// `progressMapping`
pub progress_mapping: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMapping>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for Advancements<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
let v2 = {
let v3 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = r.read_string()?;let v6 = { let v7 = if r.read_bool()? { Some(r.read_string()?) } else { None };let v8 = if r.read_bool()? { Some({ let v9 = r.read_string()?;let v10 = r.read_string()?;let v11 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;let v12 = r.read_varint()?;let v13 = { let v14 = u64::from(r.read_i32()? as u32); crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { _unused: (((v14 >> 3) & 0x1fffffff) as u32), hidden: (((v14 >> 2) & 0x1) as u8), show_toast: (((v14 >> 1) & 0x1) as u8), has_background_texture: (((v14 >> 0) & 0x1) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(r.read_string()?) } else { None };let v16 = r.read_f32()?;let v17 = r.read_f32()?; crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = r.read_string()?; crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria { key: v21 } }); } 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_string()?); } v27 }); } v25 }; crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p340::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
}
v4
};
let v28 = {
let v29 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v29 {
v30.push(r.read_string()?);
}
v30
};
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 = { let v36 = { let c = r.read_varint()?; r.check_count(i64::from(c), 2)? }; let mut v37 = Vec::with_capacity(v36.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v36 { v37.push({ let v38 = r.read_string()?;let v39 = if r.read_bool()? { Some(r.read_i64()?) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v38, criterion_progress: v39 } }); } v37 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v34, value: v35 } });
}
v33
};
Self {
reset: v1,
advancement_mapping: v2,
identifiers: v28,
progress_mapping: v31,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for Advancements<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).reset);
w.put_len_varint((*self).advancement_mapping.len())?;
for v1 in (*self).advancement_mapping.iter() {
w.put_string(&(*v1).key)?;
match &(*v1).value.parent_id {
Some(v2) => {
w.put_u8(1);
w.put_string(&(*v2))?;
}
None => w.put_u8(0),
}
match &(*v1).value.display_data {
Some(v3) => {
w.put_u8(1);
w.put_string(&(*v3).title)?;
w.put_string(&(*v3).description)?;
(*v3).icon.encode(w)?;
w.put_varint((*v3).frame_type);
{
let mut bits: u64 = 0;
{
let x = i128::from((*v3).flags._unused);
if x < 0 || x > 536870911 {
return Err(EncodeError::OutOfRange("_unused"));
}
bits = (bits << 29) | ((x as u64) & 0x1fffffff);
}
{
let x = i128::from((*v3).flags.hidden);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("hidden"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v3).flags.show_toast);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("show_toast"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v3).flags.has_background_texture);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("has_background_texture"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
w.put_u32(bits as u32);
}
match (
&(*v3).background_texture,
((*v3).flags.has_background_texture == 1),
) {
(Some(v4), true) => {
w.put_string(&(*v4))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
));
}
}
w.put_f32((*v3).x_cord);
w.put_f32((*v3).y_cord);
}
None => w.put_u8(0),
}
w.put_len_varint((*v1).value.criteria.len())?;
for v5 in (*v1).value.criteria.iter() {
w.put_string(&(*v5).key)?;
}
w.put_len_varint((*v1).value.requirements.len())?;
for v6 in (*v1).value.requirements.iter() {
w.put_len_varint((*v6).len())?;
for v7 in (*v6).iter() {
w.put_string(&(*v7))?;
}
}
}
w.put_len_varint((*self).identifiers.len())?;
for v8 in (*self).identifiers.iter() {
w.put_string(&(*v8))?;
}
w.put_len_varint((*self).progress_mapping.len())?;
for v9 in (*self).progress_mapping.iter() {
w.put_string(&(*v9).key)?;
w.put_len_varint((*v9).value.len())?;
for v10 in (*v9).value.iter() {
w.put_string(&(*v10).criterion_identifier)?;
match &(*v10).criterion_progress {
Some(v11) => {
w.put_u8(1);
w.put_i64((*v11));
}
None => w.put_u8(0),
}
}
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Advancements<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = g.string();let v6 = { let v7 = if g.bool() { Some(g.string()) } else { None };let v8 = if g.bool() { Some({ let v9 = g.string();let v10 = g.string();let v11 = <crate::types::slot::legacy::Slot as Generate>::generate(g);let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v13 = { crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayDataFlags { _unused: (g.int_in(0, 536870911, &[]) as u32), hidden: (g.int_in(0, 1, &[]) as u8), show_toast: (g.int_in(0, 1, &[]) as u8), has_background_texture: (g.int_in(0, 1, &[1]) as u8) } };let v15 = if (v13.has_background_texture == 1) { Some(g.string()) } else { None };let v16 = g.f32();let v17 = g.f32(); crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueDisplayData { title: v9, description: v10, icon: v11, frame_type: v12, flags: v13, background_texture: v15, x_cord: v16, y_cord: v17 } }) } else { None };let v18 = { let v19 = g.count(); let mut v20 = Vec::with_capacity(v19.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v19 { v20.push({ let v21 = g.string(); crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria { key: v21 } }); } 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.string()); } v27 }); } v25 }; crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p340::play::clientbound::AdvancementsAdvancementMapping { key: v5, value: v6 } });
}
v4
};
let v28 = {
let v29 = g.count();
let mut v30 = Vec::with_capacity(v29.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v29 {
v30.push(g.string());
}
v30
};
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 = { let v36 = g.count(); let mut v37 = Vec::with_capacity(v36.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v36 { v37.push({ let v38 = g.string();let v39 = if g.bool() { Some(g.i64()) } else { None }; crate::defs::p340::play::clientbound::AdvancementsProgressMappingValue { criterion_identifier: v38, criterion_progress: v39 } }); } v37 }; crate::defs::p340::play::clientbound::AdvancementsProgressMapping { key: v34, value: v35 } });
}
v33
};
Self {
reset: v1,
advancement_mapping: v2,
identifiers: v28,
progress_mapping: v31,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesPropertiesModifiers {
/// `uuid`
pub uuid: Uuid,
/// `amount`
pub amount: f64,
/// `operation`
pub operation: i8,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesProperties {
/// `key`
pub key: ByteString,
/// `value`
pub value: f64,
/// `modifiers`
pub modifiers:
Vec<crate::defs::p340::play::clientbound::EntityUpdateAttributesPropertiesModifiers>,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `entity_update_attributes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributes<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `properties`
pub properties: Vec<crate::defs::p340::play::clientbound::EntityUpdateAttributesProperties>,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for EntityUpdateAttributes<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 10)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = r.read_string()?;let v6 = r.read_f64()?;let v7 = { let v8 = { let c = r.read_varint()?; r.check_count(i64::from(c), 25)? }; let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = r.read_uuid()?;let v11 = r.read_f64()?;let v12 = r.read_i8()?; crate::defs::p340::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p340::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for EntityUpdateAttributes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i32(crate::codec::count_i32((*self).properties.len())?);
for v1 in (*self).properties.iter() {
w.put_string(&(*v1).key)?;
w.put_f64((*v1).value);
w.put_len_varint((*v1).modifiers.len())?;
for v2 in (*v1).modifiers.iter() {
w.put_uuid(&(*v2).uuid);
w.put_f64((*v2).amount);
w.put_i8((*v2).operation);
}
}
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityUpdateAttributes<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({ let v5 = g.string();let v6 = g.f64();let v7 = { let v8 = g.count(); let mut v9 = Vec::with_capacity(v8.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v8 { v9.push({ let v10 = g.uuid();let v11 = g.f64();let v12 = (g.int_in(-128, 127, &[]) as i8); crate::defs::p340::play::clientbound::EntityUpdateAttributesPropertiesModifiers { uuid: v10, amount: v11, operation: v12 } }); } v9 }; crate::defs::p340::play::clientbound::EntityUpdateAttributesProperties { key: v5, value: v6, modifiers: v7 } });
}
v4
};
Self {
entity_id: v1,
properties: v2,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
/// `entity_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEffect<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `effectId`
pub effect_id: i8,
/// `amplifier`
pub amplifier: i8,
/// `duration`
pub duration: i32,
/// `hideParticles`
pub hide_particles: i8,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for EntityEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_i8()?;
let v3 = r.read_i8()?;
let v4 = r.read_varint()?;
let v5 = r.read_i8()?;
Self {
entity_id: v1,
effect_id: v2,
amplifier: v3,
duration: v4,
hide_particles: v5,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for EntityEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).effect_id);
w.put_i8((*self).amplifier);
w.put_varint((*self).duration);
w.put_i8((*self).hide_particles);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityEffect<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = (g.int_in(-128, 127, &[]) as i8);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-128, 127, &[]) as i8);
Self {
entity_id: v1,
effect_id: v2,
amplifier: v3,
duration: v4,
hide_particles: v5,
}
}
}
}