// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/1.16.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_16_5")]
/// `spawn_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `objectUUID`
pub object_uuid: Uuid,
/// `type`
pub r#type: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `pitch`
pub pitch: i8,
/// `yaw`
pub yaw: i8,
/// `objectData`
pub object_data: i32,
/// `velocity`
pub velocity: crate::defs::p47::types::Vec3i16,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SpawnEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_uuid()?;
let v3 = r.read_varint()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f64()?;
let v7 = 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_16_5")]
impl<const V: i32> Encode for SpawnEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).object_uuid);
w.put_varint((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).pitch);
w.put_i8((*self).yaw);
w.put_i32((*self).object_data);
(*self).velocity.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.uuid();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f64();
let v7 = (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(feature = "v1_16_5")]
/// `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,
}
#[cfg(feature = "v1_16_5")]
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)?;
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,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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);
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,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `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: i32,
/// `location`
pub location: BlockPos,
/// `direction`
pub direction: u8,
}
#[cfg(feature = "v1_16_5")]
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_varint()?;
let v4 = BlockPos::read(r, PositionLayout::Xzy)?;
let v5 = r.read_u8()?;
Self {
entity_id: v1,
entity_uuid: v2,
title: v3,
location: v4,
direction: v5,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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_varint((*self).title);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).direction);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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.int_in(-2147483648, 2147483647, &[]) as i32);
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_16_5")]
/// `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,
}
#[cfg(feature = "v1_16_5")]
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()?;
Self {
entity_id: v1,
player_uuid: v2,
x: v3,
y: v4,
z: v5,
yaw: v6,
pitch: v7,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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);
Self {
entity_id: v1,
player_uuid: v2,
x: v3,
y: v4,
z: v5,
yaw: v6,
pitch: v7,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct StatisticsEntries {
/// `categoryId`
pub category_id: i32,
/// `statisticId`
pub statistic_id: i32,
/// `value`
pub value: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `statistics` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Statistics<const V: i32> {
/// `entries`
pub entries: Vec<crate::defs::p754::play::clientbound::StatisticsEntries>,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for Statistics<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = r.read_varint()?;
let v5 = r.read_varint()?;
let v6 = r.read_varint()?;
crate::defs::p754::play::clientbound::StatisticsEntries {
category_id: v4,
statistic_id: v5,
value: v6,
}
});
}
v3
};
Self { entries: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for Statistics<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entries.len())?;
for v1 in (*self).entries.iter() {
w.put_varint((*v1).category_id);
w.put_varint((*v1).statistic_id);
w.put_varint((*v1).value);
}
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Statistics<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p754::play::clientbound::StatisticsEntries {
category_id: v4,
statistic_id: v5,
value: v6,
}
});
}
v3
};
Self { entries: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `acknowledge_player_digging` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct AcknowledgePlayerDigging<const V: i32> {
/// `location`
pub location: BlockPos,
/// `block`
pub block: i32,
/// `status`
pub status: i32,
/// `successful`
pub successful: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for AcknowledgePlayerDigging<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = r.read_bool()?;
Self {
location: v1,
block: v2,
status: v3,
successful: v4,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for AcknowledgePlayerDigging<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).block);
w.put_varint((*self).status);
w.put_bool((*self).successful);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AcknowledgePlayerDigging<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.bool();
Self {
location: v1,
block: v2,
status: v3,
successful: v4,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `block_break_animation` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockBreakAnimation<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `location`
pub location: BlockPos,
/// `destroyStage`
pub destroy_stage: i8,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for BlockBreakAnimation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
let v3 = r.read_i8()?;
Self {
entity_id: v1,
location: v2,
destroy_stage: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for BlockBreakAnimation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_i8((*self).destroy_stage);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockBreakAnimation<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.position();
let v3 = (g.int_in(-128, 127, &[]) as i8);
Self {
entity_id: v1,
location: v2,
destroy_stage: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `tile_entity_data` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TileEntityData<const V: i32> {
/// `location`
pub location: BlockPos,
/// `action`
pub action: u8,
/// `nbtData`
pub nbt_data: Option<RawNbt>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for TileEntityData<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_u8()?;
let v3 = RawNbt::read_optional(r)?;
Self {
location: v1,
action: v2,
nbt_data: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for TileEntityData<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).action);
RawNbt::write_optional(&(*self).nbt_data, w);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TileEntityData<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(0, 255, &[]) as u8);
let v3 = g.opt_nbt();
Self {
location: v1,
action: v2,
nbt_data: v3,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `block_action` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockAction<const V: i32> {
/// `location`
pub location: BlockPos,
/// `byte1`
pub byte1: u8,
/// `byte2`
pub byte2: u8,
/// `blockId`
pub block_id: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for BlockAction<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_u8()?;
let v3 = r.read_u8()?;
let v4 = r.read_varint()?;
Self {
location: v1,
byte1: v2,
byte2: v3,
block_id: v4,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for BlockAction<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).byte1);
w.put_u8((*self).byte2);
w.put_varint((*self).block_id);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockAction<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(0, 255, &[]) as u8);
let v3 = (g.int_in(0, 255, &[]) as u8);
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
location: v1,
byte1: v2,
byte2: v3,
block_id: v4,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `block_change` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockChange<const V: i32> {
/// `location`
pub location: BlockPos,
/// `type`
pub r#type: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for BlockChange<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_varint()?;
Self {
location: v1,
r#type: v2,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for BlockChange<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).r#type);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockChange<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
location: v1,
r#type: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `difficulty` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Difficulty<const V: i32> {
/// `difficulty`
pub difficulty: crate::defs::p47::play::clientbound::DifficultyDifficulty,
/// `difficultyLocked`
pub difficulty_locked: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for Difficulty<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(r.read_u8()?);
let v2 = r.read_bool()?;
Self {
difficulty: v1,
difficulty_locked: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for Difficulty<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).difficulty.0);
w.put_bool((*self).difficulty_locked);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Difficulty<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p47::play::clientbound::DifficultyDifficulty(g.int_in(
0,
255,
&[0, 1, 2, 3],
) as u8);
let v2 = g.bool();
Self {
difficulty: v1,
difficulty_locked: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `chat` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Chat<const V: i32> {
/// `message`
pub message: ByteString,
/// `position`
pub position: i8,
/// `sender`
pub sender: Uuid,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for Chat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = r.read_uuid()?;
Self {
message: v1,
position: v2,
sender: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for Chat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).message)?;
w.put_i8((*self).position);
w.put_uuid(&(*self).sender);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Chat<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = g.uuid();
Self {
message: v1,
position: v2,
sender: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TabCompleteMatches {
/// `match`
pub r#match: ByteString,
/// `tooltip`
pub tooltip: Option<ByteString>,
}
#[cfg(feature = "v1_16_5")]
/// `tab_complete` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete<const V: i32> {
/// `transactionId`
pub transaction_id: i32,
/// `start`
pub start: i32,
/// `length`
pub length: i32,
/// `matches`
pub matches: Vec<crate::defs::p754::play::clientbound::TabCompleteMatches>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for TabComplete<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = {
let v5 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = r.read_string()?;
let v8 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
crate::defs::p754::play::clientbound::TabCompleteMatches {
r#match: v7,
tooltip: v8,
}
});
}
v6
};
Self {
transaction_id: v1,
start: v2,
length: v3,
matches: v4,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for TabComplete<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
w.put_varint((*self).start);
w.put_varint((*self).length);
w.put_len_varint((*self).matches.len())?;
for v1 in (*self).matches.iter() {
w.put_string(&(*v1).r#match)?;
match &(*v1).tooltip {
Some(v2) => {
w.put_u8(1);
w.put_string(&(*v2))?;
}
None => w.put_u8(0),
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TabComplete<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = {
let v5 = g.count();
let mut v6 = Vec::with_capacity(v5.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v5 {
v6.push({
let v7 = g.string();
let v8 = if g.bool() { Some(g.string()) } else { None };
crate::defs::p754::play::clientbound::TabCompleteMatches {
r#match: v7,
tooltip: v8,
}
});
}
v6
};
Self {
transaction_id: v1,
start: v2,
length: v3,
matches: v4,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `declare_commands` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareCommands<const V: i32> {
/// `nodes`
pub nodes: Vec<crate::defs::p754::types::CommandNode>,
/// `rootIndex`
pub root_index: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for DeclareCommands<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(<crate::defs::p754::types::CommandNode as Decode>::decode(
r,
)?);
}
v3
};
let v4 = r.read_varint()?;
Self {
nodes: v1,
root_index: v4,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for DeclareCommands<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).nodes.len())?;
for v1 in (*self).nodes.iter() {
(*v1).encode(w)?;
}
w.put_varint((*self).root_index);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DeclareCommands<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push(<crate::defs::p754::types::CommandNode as Generate>::generate(g));
}
v3
};
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
nodes: v1,
root_index: v4,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `window_items` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WindowItems<const V: i32> {
/// `windowId`
pub window_id: u8,
/// `items`
pub items: Vec<crate::types::slot::modern::Slot>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for WindowItems<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_u8()?;
let v2 = {
let v3 = {
let c = r.read_i16()?;
r.check_count(i64::from(c), 1)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?);
}
v4
};
Self {
window_id: v1,
items: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for WindowItems<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_i16(crate::codec::count_i16((*self).items.len())?);
for v1 in (*self).items.iter() {
(*v1).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WindowItems<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(0, 255, &[]) as u8);
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push(<crate::types::slot::modern::Slot as Generate>::generate(g));
}
v4
};
Self {
window_id: v1,
items: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `set_slot` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SetSlot<const V: i32> {
/// `windowId`
pub window_id: i8,
/// `slot`
pub slot: i16,
/// `item`
pub item: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SetSlot<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_i16()?;
let v3 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
slot: v2,
item: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for SetSlot<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetSlot<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[]) as i8);
let v2 = (g.int_in(-32768, 32767, &[]) as i16);
let v3 = <crate::types::slot::modern::Slot as Generate>::generate(g);
Self {
window_id: v1,
slot: v2,
item: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Mapped `u8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct GameStateChangeReason(pub u8);
#[cfg(feature = "v1_16_5")]
impl GameStateChangeReason {
/// `no_respawn_block_available`
pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
/// `start_raining`
pub const START_RAINING: Self = Self(1);
/// `stop_raining`
pub const STOP_RAINING: Self = Self(2);
/// `change_game_mode`
pub const CHANGE_GAME_MODE: Self = Self(3);
/// `win_game`
pub const WIN_GAME: Self = Self(4);
/// `demo_event`
pub const DEMO_EVENT: Self = Self(5);
/// `play_arrow_hit_sound`
pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
/// `rain_level_change`
pub const RAIN_LEVEL_CHANGE: Self = Self(7);
/// `thunder_level_change`
pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
/// `puffer_fish_sting`
pub const PUFFER_FISH_STING: Self = Self(9);
/// `guardian_elder_effect`
pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
/// `immediate_respawn`
pub const IMMEDIATE_RESPAWN: Self = Self(11);
/// minecraft-data name of the value, if known.
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("no_respawn_block_available"),
1 => Some("start_raining"),
2 => Some("stop_raining"),
3 => Some("change_game_mode"),
4 => Some("win_game"),
5 => Some("demo_event"),
6 => Some("play_arrow_hit_sound"),
7 => Some("rain_level_change"),
8 => Some("thunder_level_change"),
9 => Some("puffer_fish_sting"),
10 => Some("guardian_elder_effect"),
11 => Some("immediate_respawn"),
_ => None,
}
}
}
#[cfg(feature = "v1_16_5")]
impl std::fmt::Debug for GameStateChangeReason {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "GameStateChangeReason::{n}"),
None => write!(f, "GameStateChangeReason({})", self.0),
}
}
}
#[cfg(feature = "v1_16_5")]
/// `game_state_change` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct GameStateChange<const V: i32> {
/// `reason`
pub reason: crate::defs::p754::play::clientbound::GameStateChangeReason,
/// `gameMode`
pub game_mode: f32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for GameStateChange<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p754::play::clientbound::GameStateChangeReason(r.read_u8()?);
let v2 = r.read_f32()?;
Self {
reason: v1,
game_mode: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for GameStateChange<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).reason.0);
w.put_f32((*self).game_mode);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for GameStateChange<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p754::play::clientbound::GameStateChangeReason(g.int_in(
0,
255,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
)
as u8);
let v2 = g.f32();
Self {
reason: v1,
game_mode: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `open_horse_window` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenHorseWindow<const V: i32> {
/// `windowId`
pub window_id: u8,
/// `nbSlots`
pub nb_slots: i32,
/// `entityId`
pub entity_id: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for OpenHorseWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_u8()?;
let v2 = r.read_varint()?;
let v3 = r.read_i32()?;
Self {
window_id: v1,
nb_slots: v2,
entity_id: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for OpenHorseWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_varint((*self).nb_slots);
w.put_i32((*self).entity_id);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenHorseWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(0, 255, &[]) as u8);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
window_id: v1,
nb_slots: v2,
entity_id: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `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,
/// `heightmaps`
pub heightmaps: RawNbt,
/// `biomes`
pub biomes: Option<Vec<i32>>,
/// `chunkData`
pub chunk_data: Bytes,
/// `blockEntities`
pub block_entities: Vec<RawNbt>,
}
#[cfg(feature = "v1_16_5")]
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 = RawNbt::read(r)?;
let v6 = if v3 {
Some({
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(r.read_varint()?);
}
v8
})
} else {
None
};
let v9 = r.read_byte_array()?;
let v10 = {
let v11 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(RawNbt::read(r)?);
}
v12
};
Self {
x: v1,
z: v2,
ground_up: v3,
bit_map: v4,
heightmaps: v5,
biomes: v6,
chunk_data: v9,
block_entities: v10,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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);
(*self).heightmaps.write(w);
match (&(*self).biomes, (*self).ground_up) {
(Some(v1), true) => {
w.put_len_varint((*v1).len())?;
for v2 in (*v1).iter() {
w.put_varint((*v2));
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.map_chunk.biomes",
));
}
}
w.put_byte_array(&(*self).chunk_data)?;
w.put_len_varint((*self).block_entities.len())?;
for v3 in (*self).block_entities.iter() {
(*v3).write(w);
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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.nbt();
let v6 = if v3 {
Some({
let v7 = g.count();
let mut v8 = Vec::with_capacity(v7.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v7 {
v8.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v8
})
} else {
None
};
let v9 = g.bytes();
let v10 = {
let v11 = g.count();
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(g.nbt());
}
v12
};
Self {
x: v1,
z: v2,
ground_up: v3,
bit_map: v4,
heightmaps: v5,
biomes: v6,
chunk_data: v9,
block_entities: v10,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `world_event` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldEvent<const V: i32> {
/// `effectId`
pub effect_id: i32,
/// `location`
pub location: BlockPos,
/// `data`
pub data: i32,
/// `global`
pub global: bool,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for WorldEvent<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
let v3 = r.read_i32()?;
let v4 = r.read_bool()?;
Self {
effect_id: v1,
location: v2,
data: v3,
global: v4,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for WorldEvent<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).effect_id);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_i32((*self).data);
w.put_bool((*self).global);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldEvent<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.position();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.bool();
Self {
effect_id: v1,
location: v2,
data: v3,
global: v4,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `world_particles` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldParticles<const V: i32> {
/// `particleId`
pub particle_id: i32,
/// `longDistance`
pub long_distance: bool,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `offsetX`
pub offset_x: f32,
/// `offsetY`
pub offset_y: f32,
/// `offsetZ`
pub offset_z: f32,
/// `particleData`
pub particle_data: f32,
/// `particles`
pub particles: i32,
/// `data`
pub data: crate::defs::p754::types::ParticleData,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for WorldParticles<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_bool()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_f64()?;
let v6 = r.read_f32()?;
let v7 = r.read_f32()?;
let v8 = r.read_f32()?;
let v9 = r.read_f32()?;
let v10 = r.read_i32()?;
let v11 = (if (v1 == 3) {
crate::defs::p754::types::ParticleData::Case3({
let v12 = r.read_varint()?;
crate::defs::p754::types::ParticleDataCase3 { block_state: v12 }
})
} else if (v1 == 14) {
crate::defs::p754::types::ParticleData::Case14({
let v13 = r.read_f32()?;
let v14 = r.read_f32()?;
let v15 = r.read_f32()?;
let v16 = r.read_f32()?;
crate::defs::p754::types::ParticleDataCase14 {
red: v13,
green: v14,
blue: v15,
scale: v16,
}
})
} else if (v1 == 23) {
crate::defs::p754::types::ParticleData::Case23({
let v17 = r.read_varint()?;
crate::defs::p754::types::ParticleDataCase23 { block_state: v17 }
})
} else if (v1 == 34) {
crate::defs::p754::types::ParticleData::Case34({
let v18 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
crate::defs::p754::types::ParticleDataCase34 { item: v18 }
})
} else {
crate::defs::p754::types::ParticleData::Other
});
Self {
particle_id: v1,
long_distance: v2,
x: v3,
y: v4,
z: v5,
offset_x: v6,
offset_y: v7,
offset_z: v8,
particle_data: v9,
particles: v10,
data: v11,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for WorldParticles<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).particle_id);
w.put_bool((*self).long_distance);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).offset_x);
w.put_f32((*self).offset_y);
w.put_f32((*self).offset_z);
w.put_f32((*self).particle_data);
w.put_i32((*self).particles);
match &(*self).data {
crate::defs::p754::types::ParticleData::Case3(v1) => {
if !((*self).particle_id == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_varint((*v1).block_state);
}
crate::defs::p754::types::ParticleData::Case14(v2) => {
if !((*self).particle_id == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_f32((*v2).red);
w.put_f32((*v2).green);
w.put_f32((*v2).blue);
w.put_f32((*v2).scale);
}
crate::defs::p754::types::ParticleData::Case23(v3) => {
if !((*self).particle_id == 23) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_varint((*v3).block_state);
}
crate::defs::p754::types::ParticleData::Case34(v4) => {
if !((*self).particle_id == 34) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
(*v4).item.encode(w)?;
}
crate::defs::p754::types::ParticleData::Other => {
if !(!(((*self).particle_id == 3)
|| ((*self).particle_id == 14)
|| ((*self).particle_id == 23)
|| ((*self).particle_id == 34)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WorldParticles<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[3, 14, 23, 34]) as i32);
let v2 = g.bool();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.f64();
let v6 = g.f32();
let v7 = g.f32();
let v8 = g.f32();
let v9 = g.f32();
let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v11 = (if (v1 == 3) {
crate::defs::p754::types::ParticleData::Case3({
let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p754::types::ParticleDataCase3 { block_state: v12 }
})
} else if (v1 == 14) {
crate::defs::p754::types::ParticleData::Case14({
let v13 = g.f32();
let v14 = g.f32();
let v15 = g.f32();
let v16 = g.f32();
crate::defs::p754::types::ParticleDataCase14 {
red: v13,
green: v14,
blue: v15,
scale: v16,
}
})
} else if (v1 == 23) {
crate::defs::p754::types::ParticleData::Case23({
let v17 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p754::types::ParticleDataCase23 { block_state: v17 }
})
} else if (v1 == 34) {
crate::defs::p754::types::ParticleData::Case34({
let v18 = <crate::types::slot::modern::Slot as Generate>::generate(g);
crate::defs::p754::types::ParticleDataCase34 { item: v18 }
})
} else {
crate::defs::p754::types::ParticleData::Other
});
Self {
particle_id: v1,
long_distance: v2,
x: v3,
y: v4,
z: v5,
offset_x: v6,
offset_y: v7,
offset_z: v8,
particle_data: v9,
particles: v10,
data: v11,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `update_light` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateLight<const V: i32> {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
/// `trustEdges`
pub trust_edges: bool,
/// `skyLightMask`
pub sky_light_mask: i32,
/// `blockLightMask`
pub block_light_mask: i32,
/// `emptySkyLightMask`
pub empty_sky_light_mask: i32,
/// `emptyBlockLightMask`
pub empty_block_light_mask: i32,
/// `data`
pub data: Bytes,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for UpdateLight<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_bool()?;
let v4 = r.read_varint()?;
let v5 = r.read_varint()?;
let v6 = r.read_varint()?;
let v7 = r.read_varint()?;
let v8 = r.read_rest();
Self {
chunk_x: v1,
chunk_z: v2,
trust_edges: v3,
sky_light_mask: v4,
block_light_mask: v5,
empty_sky_light_mask: v6,
empty_block_light_mask: v7,
data: v8,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for UpdateLight<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).chunk_x);
w.put_varint((*self).chunk_z);
w.put_bool((*self).trust_edges);
w.put_varint((*self).sky_light_mask);
w.put_varint((*self).block_light_mask);
w.put_varint((*self).empty_sky_light_mask);
w.put_varint((*self).empty_block_light_mask);
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateLight<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.bool();
let v4 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v5 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v7 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v8 = g.bytes();
Self {
chunk_x: v1,
chunk_z: v2,
trust_edges: v3,
sky_light_mask: v4,
block_light_mask: v5,
empty_sky_light_mask: v6,
empty_block_light_mask: v7,
data: v8,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `login` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Login<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `isHardcore`
pub is_hardcore: bool,
/// `gameMode`
pub game_mode: u8,
/// `previousGameMode`
pub previous_game_mode: u8,
/// `worldNames`
pub world_names: Vec<ByteString>,
/// `dimensionCodec`
pub dimension_codec: RawNbt,
/// `dimension`
pub dimension: RawNbt,
/// `worldName`
pub world_name: ByteString,
/// `hashedSeed`
pub hashed_seed: i64,
/// `maxPlayers`
pub max_players: i32,
/// `viewDistance`
pub view_distance: i32,
/// `reducedDebugInfo`
pub reduced_debug_info: bool,
/// `enableRespawnScreen`
pub enable_respawn_screen: bool,
/// `isDebug`
pub is_debug: bool,
/// `isFlat`
pub is_flat: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for Login<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i32()?;
let v2 = r.read_bool()?;
let v3 = r.read_u8()?;
let v4 = r.read_u8()?;
let v5 = {
let v6 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push(r.read_string()?);
}
v7
};
let v8 = RawNbt::read(r)?;
let v9 = RawNbt::read(r)?;
let v10 = r.read_string()?;
let v11 = r.read_i64()?;
let v12 = r.read_varint()?;
let v13 = r.read_varint()?;
let v14 = r.read_bool()?;
let v15 = r.read_bool()?;
let v16 = r.read_bool()?;
let v17 = r.read_bool()?;
Self {
entity_id: v1,
is_hardcore: v2,
game_mode: v3,
previous_game_mode: v4,
world_names: v5,
dimension_codec: v8,
dimension: v9,
world_name: v10,
hashed_seed: v11,
max_players: v12,
view_distance: v13,
reduced_debug_info: v14,
enable_respawn_screen: v15,
is_debug: v16,
is_flat: v17,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for Login<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_bool((*self).is_hardcore);
w.put_u8((*self).game_mode);
w.put_u8((*self).previous_game_mode);
w.put_len_varint((*self).world_names.len())?;
for v1 in (*self).world_names.iter() {
w.put_string(&(*v1))?;
}
(*self).dimension_codec.write(w);
(*self).dimension.write(w);
w.put_string(&(*self).world_name)?;
w.put_i64((*self).hashed_seed);
w.put_varint((*self).max_players);
w.put_varint((*self).view_distance);
w.put_bool((*self).reduced_debug_info);
w.put_bool((*self).enable_respawn_screen);
w.put_bool((*self).is_debug);
w.put_bool((*self).is_flat);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Login<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.bool();
let v3 = (g.int_in(0, 255, &[]) as u8);
let v4 = (g.int_in(0, 255, &[]) as u8);
let v5 = {
let v6 = g.count();
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push(g.string());
}
v7
};
let v8 = g.nbt();
let v9 = g.nbt();
let v10 = g.string();
let v11 = g.i64();
let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v14 = g.bool();
let v15 = g.bool();
let v16 = g.bool();
let v17 = g.bool();
Self {
entity_id: v1,
is_hardcore: v2,
game_mode: v3,
previous_game_mode: v4,
world_names: v5,
dimension_codec: v8,
dimension: v9,
world_name: v10,
hashed_seed: v11,
max_players: v12,
view_distance: v13,
reduced_debug_info: v14,
enable_respawn_screen: v15,
is_debug: v16,
is_flat: v17,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MapIcons {
/// `type`
pub r#type: i32,
/// `x`
pub x: i8,
/// `z`
pub z: i8,
/// `direction`
pub direction: u8,
/// `displayName`
pub display_name: Option<ByteString>,
}
#[cfg(feature = "v1_16_5")]
/// `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,
/// `locked`
pub locked: bool,
/// `icons`
pub icons: Vec<crate::defs::p754::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_16_5")]
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 = r.read_bool()?;
let v5 = {
let v6 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push({
let v8 = r.read_varint()?;
let v9 = r.read_i8()?;
let v10 = r.read_i8()?;
let v11 = r.read_u8()?;
let v12 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
crate::defs::p754::play::clientbound::MapIcons {
r#type: v8,
x: v9,
z: v10,
direction: v11,
display_name: v12,
}
});
}
v7
};
let v13 = r.read_i8()?;
let v14 = if !(v13 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v15 = if !(v13 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v16 = if !(v13 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v17 = if !(v13 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Self {
item_damage: v1,
scale: v2,
tracking_position: v3,
locked: v4,
icons: v5,
columns: v13,
rows: v14,
x: v15,
y: v16,
data: v17,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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_bool((*self).locked);
w.put_len_varint((*self).icons.len())?;
for v1 in (*self).icons.iter() {
w.put_varint((*v1).r#type);
w.put_i8((*v1).x);
w.put_i8((*v1).z);
w.put_u8((*v1).direction);
match &(*v1).display_name {
Some(v2) => {
w.put_u8(1);
w.put_string(&(*v2))?;
}
None => w.put_u8(0),
}
}
w.put_i8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v3), true) => {
w.put_i8((*v3));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v4), true) => {
w.put_i8((*v4));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v5), true) => {
w.put_i8((*v5));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v6), true) => {
w.put_byte_array(&(*v6))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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 = g.bool();
let v5 = {
let v6 = g.count();
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push({
let v8 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v9 = (g.int_in(-128, 127, &[]) as i8);
let v10 = (g.int_in(-128, 127, &[]) as i8);
let v11 = (g.int_in(0, 255, &[]) as u8);
let v12 = if g.bool() { Some(g.string()) } else { None };
crate::defs::p754::play::clientbound::MapIcons {
r#type: v8,
x: v9,
z: v10,
direction: v11,
display_name: v12,
}
});
}
v7
};
let v13 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
let v14 = if !(v13 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v15 = if !(v13 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v16 = if !(v13 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v17 = if !(v13 == 0) { Some(g.bytes()) } else { None };
Self {
item_damage: v1,
scale: v2,
tracking_position: v3,
locked: v4,
icons: v5,
columns: v13,
rows: v14,
x: v15,
y: v16,
data: v17,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTrades {
/// `inputItem1`
pub input_item1: crate::types::slot::modern::Slot,
/// `outputItem`
pub output_item: crate::types::slot::modern::Slot,
/// `inputItem2`
pub input_item2: Option<crate::types::slot::modern::Slot>,
/// `tradeDisabled`
pub trade_disabled: bool,
/// `nbTradeUses`
pub nb_trade_uses: i32,
/// `maximumNbTradeUses`
pub maximum_nb_trade_uses: i32,
/// `xp`
pub xp: i32,
/// `specialPrice`
pub special_price: i32,
/// `priceMultiplier`
pub price_multiplier: f32,
/// `demand`
pub demand: i32,
}
#[cfg(feature = "v1_16_5")]
/// `trade_list` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct TradeList<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `trades`
pub trades: Vec<crate::defs::p754::play::clientbound::TradeListTrades>,
/// `villagerLevel`
pub villager_level: i32,
/// `experience`
pub experience: i32,
/// `isRegularVillager`
pub is_regular_villager: bool,
/// `canRestock`
pub can_restock: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for TradeList<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let v3 = {
let c = r.read_u8()?;
r.check_count(i64::from(c), 28)?
};
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
let v7 = if r.read_bool()? {
Some(<crate::types::slot::modern::Slot as Decode>::decode(r)?)
} else {
None
};
let v8 = r.read_bool()?;
let v9 = r.read_i32()?;
let v10 = r.read_i32()?;
let v11 = r.read_i32()?;
let v12 = r.read_i32()?;
let v13 = r.read_f32()?;
let v14 = r.read_i32()?;
crate::defs::p754::play::clientbound::TradeListTrades {
input_item1: v5,
output_item: v6,
input_item2: v7,
trade_disabled: v8,
nb_trade_uses: v9,
maximum_nb_trade_uses: v10,
xp: v11,
special_price: v12,
price_multiplier: v13,
demand: v14,
}
});
}
v4
};
let v15 = r.read_varint()?;
let v16 = r.read_varint()?;
let v17 = r.read_bool()?;
let v18 = r.read_bool()?;
Self {
window_id: v1,
trades: v2,
villager_level: v15,
experience: v16,
is_regular_villager: v17,
can_restock: v18,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for TradeList<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_u8(crate::codec::count_u8((*self).trades.len())?);
for v1 in (*self).trades.iter() {
(*v1).input_item1.encode(w)?;
(*v1).output_item.encode(w)?;
match &(*v1).input_item2 {
Some(v2) => {
w.put_u8(1);
(*v2).encode(w)?;
}
None => w.put_u8(0),
}
w.put_bool((*v1).trade_disabled);
w.put_i32((*v1).nb_trade_uses);
w.put_i32((*v1).maximum_nb_trade_uses);
w.put_i32((*v1).xp);
w.put_i32((*v1).special_price);
w.put_f32((*v1).price_multiplier);
w.put_i32((*v1).demand);
}
w.put_varint((*self).villager_level);
w.put_varint((*self).experience);
w.put_bool((*self).is_regular_villager);
w.put_bool((*self).can_restock);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TradeList<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let v3 = g.count();
let mut v4 = Vec::with_capacity(v3.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v3 {
v4.push({
let v5 = <crate::types::slot::modern::Slot as Generate>::generate(g);
let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
let v7 = if g.bool() {
Some(<crate::types::slot::modern::Slot as Generate>::generate(g))
} else {
None
};
let v8 = g.bool();
let v9 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v10 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v13 = g.f32();
let v14 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p754::play::clientbound::TradeListTrades {
input_item1: v5,
output_item: v6,
input_item2: v7,
trade_disabled: v8,
nb_trade_uses: v9,
maximum_nb_trade_uses: v10,
xp: v11,
special_price: v12,
price_multiplier: v13,
demand: v14,
}
});
}
v4
};
let v15 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v16 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v17 = g.bool();
let v18 = g.bool();
Self {
window_id: v1,
trades: v2,
villager_level: v15,
experience: v16,
is_regular_villager: v17,
can_restock: v18,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `open_book` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenBook<const V: i32> {
/// `hand`
pub hand: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for OpenBook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { hand: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for OpenBook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenBook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { hand: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `open_window` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenWindow<const V: i32> {
/// `windowId`
pub window_id: i32,
/// `inventoryType`
pub inventory_type: i32,
/// `windowTitle`
pub window_title: ByteString,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for OpenWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_string()?;
Self {
window_id: v1,
inventory_type: v2,
window_title: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for OpenWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).inventory_type);
w.put_string(&(*self).window_title)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.string();
Self {
window_id: v1,
inventory_type: v2,
window_title: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `open_sign_entity` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenSignEntity<const V: i32> {
/// `location`
pub location: BlockPos,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for OpenSignEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
Self { location: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for OpenSignEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for OpenSignEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
Self { location: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `craft_recipe_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeResponse<const V: i32> {
/// `windowId`
pub window_id: i8,
/// `recipe`
pub recipe: ByteString,
}
#[cfg(feature = "v1_16_5")]
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_string()?;
Self {
window_id: v1,
recipe: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for CraftRecipeResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_string(&(*self).recipe)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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.string();
Self {
window_id: v1,
recipe: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `face_player` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct FacePlayer<const V: i32> {
/// `feet_eyes`
pub feet_eyes: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `isEntity`
pub is_entity: bool,
/// `entityId`
pub entity_id: Option<i32>,
/// `entity_feet_eyes`
pub entity_feet_eyes: Option<ByteString>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for FacePlayer<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f64()?;
let v5 = r.read_bool()?;
let v6 = if v5 { Some(r.read_varint()?) } else { None };
let v7 = if v5 { Some(r.read_string()?) } else { None };
Self {
feet_eyes: v1,
x: v2,
y: v3,
z: v4,
is_entity: v5,
entity_id: v6,
entity_feet_eyes: v7,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for FacePlayer<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).feet_eyes);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_bool((*self).is_entity);
match (&(*self).entity_id, (*self).is_entity) {
(Some(v1), true) => {
w.put_varint((*v1));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entityId",
));
}
}
match (&(*self).entity_feet_eyes, (*self).is_entity) {
(Some(v2), true) => {
w.put_string(&(*v2))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entity_feet_eyes",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for FacePlayer<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f64();
let v5 = g.bool();
let v6 = if v5 {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v7 = if v5 { Some(g.string()) } else { None };
Self {
feet_eyes: v1,
x: v2,
y: v3,
z: v4,
is_entity: v5,
entity_id: v6,
entity_feet_eyes: v7,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `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,
/// `smeltingBookOpen`
pub smelting_book_open: bool,
/// `filteringSmeltable`
pub filtering_smeltable: bool,
/// `blastFurnaceOpen`
pub blast_furnace_open: bool,
/// `filteringBlastFurnace`
pub filtering_blast_furnace: bool,
/// `smokerBookOpen`
pub smoker_book_open: bool,
/// `filteringSmoker`
pub filtering_smoker: bool,
/// `recipes1`
pub recipes1: Vec<ByteString>,
/// `recipes2`
pub recipes2: Option<Vec<ByteString>>,
}
#[cfg(feature = "v1_16_5")]
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 = r.read_bool()?;
let v5 = r.read_bool()?;
let v6 = r.read_bool()?;
let v7 = r.read_bool()?;
let v8 = r.read_bool()?;
let v9 = r.read_bool()?;
let v10 = {
let v11 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v11 {
v12.push(r.read_string()?);
}
v12
};
let v13 = if (v1 == 0) {
Some({
let v14 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v14 {
v15.push(r.read_string()?);
}
v15
})
} else {
None
};
Self {
action: v1,
crafting_book_open: v2,
filtering_craftable: v3,
smelting_book_open: v4,
filtering_smeltable: v5,
blast_furnace_open: v6,
filtering_blast_furnace: v7,
smoker_book_open: v8,
filtering_smoker: v9,
recipes1: v10,
recipes2: v13,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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_bool((*self).smelting_book_open);
w.put_bool((*self).filtering_smeltable);
w.put_bool((*self).blast_furnace_open);
w.put_bool((*self).filtering_blast_furnace);
w.put_bool((*self).smoker_book_open);
w.put_bool((*self).filtering_smoker);
w.put_len_varint((*self).recipes1.len())?;
for v1 in (*self).recipes1.iter() {
w.put_string(&(*v1))?;
}
match (&(*self).recipes2, ((*self).action == 0)) {
(Some(v2), true) => {
w.put_len_varint((*v2).len())?;
for v3 in (*v2).iter() {
w.put_string(&(*v3))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.unlock_recipes.recipes2",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[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 = g.bool();
let v5 = g.bool();
let v6 = g.bool();
let v7 = g.bool();
let v8 = g.bool();
let v9 = g.bool();
let v10 = {
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
};
let v13 = if (v1 == 0) {
Some({
let v14 = g.count();
let mut v15 = Vec::with_capacity(v14.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v14 {
v15.push(g.string());
}
v15
})
} else {
None
};
Self {
action: v1,
crafting_book_open: v2,
filtering_craftable: v3,
smelting_book_open: v4,
filtering_smeltable: v5,
blast_furnace_open: v6,
filtering_blast_furnace: v7,
smoker_book_open: v8,
filtering_smoker: v9,
recipes1: v10,
recipes2: v13,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `respawn` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Respawn<const V: i32> {
/// `dimension`
pub dimension: RawNbt,
/// `worldName`
pub world_name: ByteString,
/// `hashedSeed`
pub hashed_seed: i64,
/// `gamemode`
pub gamemode: u8,
/// `previousGamemode`
pub previous_gamemode: u8,
/// `isDebug`
pub is_debug: bool,
/// `isFlat`
pub is_flat: bool,
/// `copyMetadata`
pub copy_metadata: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for Respawn<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = RawNbt::read(r)?;
let v2 = r.read_string()?;
let v3 = r.read_i64()?;
let v4 = r.read_u8()?;
let v5 = r.read_u8()?;
let v6 = r.read_bool()?;
let v7 = r.read_bool()?;
let v8 = r.read_bool()?;
Self {
dimension: v1,
world_name: v2,
hashed_seed: v3,
gamemode: v4,
previous_gamemode: v5,
is_debug: v6,
is_flat: v7,
copy_metadata: v8,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for Respawn<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).dimension.write(w);
w.put_string(&(*self).world_name)?;
w.put_i64((*self).hashed_seed);
w.put_u8((*self).gamemode);
w.put_u8((*self).previous_gamemode);
w.put_bool((*self).is_debug);
w.put_bool((*self).is_flat);
w.put_bool((*self).copy_metadata);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Respawn<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.nbt();
let v2 = g.string();
let v3 = g.i64();
let v4 = (g.int_in(0, 255, &[]) as u8);
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = g.bool();
let v7 = g.bool();
let v8 = g.bool();
Self {
dimension: v1,
world_name: v2,
hashed_seed: v3,
gamemode: v4,
previous_gamemode: v5,
is_debug: v6,
is_flat: v7,
copy_metadata: v8,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Packed bit field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct MultiBlockChangeChunkCoordinates {
/// `x` (22 bits)
pub x: i32,
/// `z` (22 bits)
pub z: i32,
/// `y` (20 bits)
pub y: u32,
}
#[cfg(feature = "v1_16_5")]
/// `multi_block_change` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct MultiBlockChange<const V: i32> {
/// `chunkCoordinates`
pub chunk_coordinates: crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates,
/// `notTrustEdges`
pub not_trust_edges: bool,
/// `records`
pub records: Vec<i64>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for MultiBlockChange<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = r.read_u64()?;
crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates {
x: ((((((v2 >> 42) & 0x3fffff) << 42) as i64) >> 42) as i32),
z: ((((((v2 >> 20) & 0x3fffff) << 42) as i64) >> 42) as i32),
y: (((v2 >> 0) & 0xfffff) as u32),
}
};
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_varlong()?);
}
v6
};
Self {
chunk_coordinates: v1,
not_trust_edges: v3,
records: v4,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for MultiBlockChange<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
{
let mut bits: u64 = 0;
{
let x = i128::from((*self).chunk_coordinates.x);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("x"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.z);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("z"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.y);
if x < 0 || x > 1048575 {
return Err(EncodeError::OutOfRange("y"));
}
bits = (bits << 20) | ((x as u64) & 0xfffff);
}
w.put_u64(bits);
}
w.put_bool((*self).not_trust_edges);
w.put_len_varint((*self).records.len())?;
for v1 in (*self).records.iter() {
w.put_varlong((*v1));
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for MultiBlockChange<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
crate::defs::p754::play::clientbound::MultiBlockChangeChunkCoordinates {
x: (g.int_in(-2097152, 2097151, &[]) as i32),
z: (g.int_in(-2097152, 2097151, &[]) as i32),
y: (g.int_in(0, 1048575, &[]) as u32),
}
};
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.varlong());
}
v6
};
Self {
chunk_coordinates: v1,
not_trust_edges: v3,
records: v4,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `update_view_position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateViewPosition<const V: i32> {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for UpdateViewPosition<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
Self {
chunk_x: v1,
chunk_z: v2,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for UpdateViewPosition<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).chunk_x);
w.put_varint((*self).chunk_z);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateViewPosition<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_16_5", feature = "v26_1", feature = "v26_2"))]
/// `update_view_distance` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateViewDistance<const V: i32> {
/// `viewDistance`
pub view_distance: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for UpdateViewDistance<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { view_distance: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for UpdateViewDistance<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).view_distance);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateViewDistance<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { view_distance: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `spawn_position` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnPosition<const V: i32> {
/// `location`
pub location: BlockPos,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SpawnPosition<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
Self { location: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for SpawnPosition<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SpawnPosition<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
Self { location: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `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::p754::types::EntityMetadataEntry>,
}
#[cfg(feature = "v1_16_5")]
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_varint()?;
let v6 = (if (v5 == 0) {
crate::defs::p754::types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v5 == 1) {
crate::defs::p754::types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v5 == 2) {
crate::defs::p754::types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v5 == 3) {
crate::defs::p754::types::EntityMetadataValue::String(r.read_string()?)
} else if (v5 == 4) {
crate::defs::p754::types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v5 == 5) {
crate::defs::p754::types::EntityMetadataValue::OptChat(
if r.read_bool()? {
Some(r.read_string()?)
} else {
None
},
)
} else if (v5 == 6) {
crate::defs::p754::types::EntityMetadataValue::Slot(
<crate::types::slot::modern::Slot as Decode>::decode(r)?,
)
} else if (v5 == 7) {
crate::defs::p754::types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v5 == 8) {
crate::defs::p754::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 == 9) {
crate::defs::p754::types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xzy,
)?)
} else if (v5 == 10) {
crate::defs::p754::types::EntityMetadataValue::OptPosition(
if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xzy)?)
} else {
None
},
)
} else if (v5 == 11) {
crate::defs::p754::types::EntityMetadataValue::Direction(
r.read_varint()?,
)
} else if (v5 == 12) {
crate::defs::p754::types::EntityMetadataValue::OptUuid(
if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
},
)
} else if (v5 == 13) {
crate::defs::p754::types::EntityMetadataValue::BlockState(
r.read_varint()?,
)
} else if (v5 == 14) {
crate::defs::p754::types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else if (v5 == 15) {
crate::defs::p754::types::EntityMetadataValue::Particle(
<crate::defs::p754::types::Particle as Decode>::decode(r)?,
)
} else if (v5 == 16) {
crate::defs::p754::types::EntityMetadataValue::VillagerData({
let v10 = r.read_varint()?;
let v11 = r.read_varint()?;
let v12 = r.read_varint()?;
crate::defs::p754::types::EntityMetadataValueVillagerData {
villager_type: v10,
villager_profession: v11,
level: v12,
}
})
} else if (v5 == 17) {
crate::defs::p754::types::EntityMetadataValue::OptVarInt(
r.read_varint()?,
)
} else if (v5 == 18) {
crate::defs::p754::types::EntityMetadataValue::Pose(r.read_varint()?)
} else {
crate::defs::p754::types::EntityMetadataValue::Other
});
crate::defs::p754::types::EntityMetadataEntry {
key: v4,
r#type: v5,
value: v6,
}
});
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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_varint((*v1).r#type);
match &(*v1).value {
crate::defs::p754::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::p754::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::p754::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::p754::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::p754::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::p754::types::EntityMetadataValue::OptChat(v8) => {
if !((*v1).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v8) {
Some(v9) => {
w.put_u8(1);
w.put_string(&(*v9))?;
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::Slot(v10) => {
if !((*v1).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v10).encode(w)?;
}
crate::defs::p754::types::EntityMetadataValue::Boolean(v11) => {
if !((*v1).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v11));
}
crate::defs::p754::types::EntityMetadataValue::Rotation(v12) => {
if !((*v1).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v12).pitch);
w.put_f32((*v12).yaw);
w.put_f32((*v12).roll);
}
crate::defs::p754::types::EntityMetadataValue::Position(v13) => {
if !((*v1).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v13).write(w, PositionLayout::Xzy)?;
}
crate::defs::p754::types::EntityMetadataValue::OptPosition(v14) => {
if !((*v1).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v14) {
Some(v15) => {
w.put_u8(1);
(*v15).write(w, PositionLayout::Xzy)?;
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::Direction(v16) => {
if !((*v1).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v16));
}
crate::defs::p754::types::EntityMetadataValue::OptUuid(v17) => {
if !((*v1).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v17) {
Some(v18) => {
w.put_u8(1);
w.put_uuid(&(*v18));
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::BlockState(v19) => {
if !((*v1).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v19));
}
crate::defs::p754::types::EntityMetadataValue::Nbt(v20) => {
if !((*v1).r#type == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v20).write(w);
}
crate::defs::p754::types::EntityMetadataValue::Particle(v21) => {
if !((*v1).r#type == 15) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v21).encode(w)?;
}
crate::defs::p754::types::EntityMetadataValue::VillagerData(v22) => {
if !((*v1).r#type == 16) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v22).villager_type);
w.put_varint((*v22).villager_profession);
w.put_varint((*v22).level);
}
crate::defs::p754::types::EntityMetadataValue::OptVarInt(v23) => {
if !((*v1).r#type == 17) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v23));
}
crate::defs::p754::types::EntityMetadataValue::Pose(v24) => {
if !((*v1).r#type == 18) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v24));
}
crate::defs::p754::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)
|| ((*v1).r#type == 14)
|| ((*v1).r#type == 15)
|| ((*v1).r#type == 16)
|| ((*v1).r#type == 17)
|| ((*v1).r#type == 18)))
{
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_16_5")]
#[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(
-2147483648,
2147483647,
&[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18,
],
) as i32);
let v7 = (if (v6 == 0) {
crate::defs::p754::types::EntityMetadataValue::Byte(
(g.int_in(-128, 127, &[]) as i8),
)
} else if (v6 == 1) {
crate::defs::p754::types::EntityMetadataValue::VarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 2) {
crate::defs::p754::types::EntityMetadataValue::Float(g.f32())
} else if (v6 == 3) {
crate::defs::p754::types::EntityMetadataValue::String(g.string())
} else if (v6 == 4) {
crate::defs::p754::types::EntityMetadataValue::Chat(g.string())
} else if (v6 == 5) {
crate::defs::p754::types::EntityMetadataValue::OptChat(
if g.bool() { Some(g.string()) } else { None },
)
} else if (v6 == 6) {
crate::defs::p754::types::EntityMetadataValue::Slot(
<crate::types::slot::modern::Slot as Generate>::generate(g),
)
} else if (v6 == 7) {
crate::defs::p754::types::EntityMetadataValue::Boolean(g.bool())
} else if (v6 == 8) {
crate::defs::p754::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 == 9) {
crate::defs::p754::types::EntityMetadataValue::Position(
g.position(),
)
} else if (v6 == 10) {
crate::defs::p754::types::EntityMetadataValue::OptPosition(
if g.bool() { Some(g.position()) } else { None },
)
} else if (v6 == 11) {
crate::defs::p754::types::EntityMetadataValue::Direction(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 12) {
crate::defs::p754::types::EntityMetadataValue::OptUuid(
if g.bool() { Some(g.uuid()) } else { None },
)
} else if (v6 == 13) {
crate::defs::p754::types::EntityMetadataValue::BlockState(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 14) {
crate::defs::p754::types::EntityMetadataValue::Nbt(g.nbt())
} else if (v6 == 15) {
crate::defs::p754::types::EntityMetadataValue::Particle(
<crate::defs::p754::types::Particle as Generate>::generate(g),
)
} else if (v6 == 16) {
crate::defs::p754::types::EntityMetadataValue::VillagerData({
let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v13 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p754::types::EntityMetadataValueVillagerData {
villager_type: v11,
villager_profession: v12,
level: v13,
}
})
} else if (v6 == 17) {
crate::defs::p754::types::EntityMetadataValue::OptVarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v6 == 18) {
crate::defs::p754::types::EntityMetadataValue::Pose(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else {
crate::defs::p754::types::EntityMetadataValue::Other
});
crate::defs::p754::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_varint(v4.r#type);
match &v4.value {
crate::defs::p754::types::EntityMetadataValue::Byte(v14) => {
if !(v4.r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v14));
}
crate::defs::p754::types::EntityMetadataValue::VarInt(v15) => {
if !(v4.r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v15));
}
crate::defs::p754::types::EntityMetadataValue::Float(v16) => {
if !(v4.r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v16));
}
crate::defs::p754::types::EntityMetadataValue::String(v17) => {
if !(v4.r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v17))?;
}
crate::defs::p754::types::EntityMetadataValue::Chat(v18) => {
if !(v4.r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v18))?;
}
crate::defs::p754::types::EntityMetadataValue::OptChat(v19) => {
if !(v4.r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v19) {
Some(v20) => {
w.put_u8(1);
w.put_string(&(*v20))?;
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::Slot(v21) => {
if !(v4.r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v21).encode(w)?;
}
crate::defs::p754::types::EntityMetadataValue::Boolean(v22) => {
if !(v4.r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v22));
}
crate::defs::p754::types::EntityMetadataValue::Rotation(
v23,
) => {
if !(v4.r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v23).pitch);
w.put_f32((*v23).yaw);
w.put_f32((*v23).roll);
}
crate::defs::p754::types::EntityMetadataValue::Position(
v24,
) => {
if !(v4.r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v24).write(w, PositionLayout::Xzy)?;
}
crate::defs::p754::types::EntityMetadataValue::OptPosition(
v25,
) => {
if !(v4.r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v25) {
Some(v26) => {
w.put_u8(1);
(*v26).write(w, PositionLayout::Xzy)?;
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::Direction(
v27,
) => {
if !(v4.r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v27));
}
crate::defs::p754::types::EntityMetadataValue::OptUuid(v28) => {
if !(v4.r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v28) {
Some(v29) => {
w.put_u8(1);
w.put_uuid(&(*v29));
}
None => w.put_u8(0),
}
}
crate::defs::p754::types::EntityMetadataValue::BlockState(
v30,
) => {
if !(v4.r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v30));
}
crate::defs::p754::types::EntityMetadataValue::Nbt(v31) => {
if !(v4.r#type == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v31).write(w);
}
crate::defs::p754::types::EntityMetadataValue::Particle(
v32,
) => {
if !(v4.r#type == 15) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v32).encode(w)?;
}
crate::defs::p754::types::EntityMetadataValue::VillagerData(
v33,
) => {
if !(v4.r#type == 16) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v33).villager_type);
w.put_varint((*v33).villager_profession);
w.put_varint((*v33).level);
}
crate::defs::p754::types::EntityMetadataValue::OptVarInt(
v34,
) => {
if !(v4.r#type == 17) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v34));
}
crate::defs::p754::types::EntityMetadataValue::Pose(v35) => {
if !(v4.r#type == 18) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v35));
}
crate::defs::p754::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)
|| (v4.r#type == 14)
|| (v4.r#type == 15)
|| (v4.r#type == 16)
|| (v4.r#type == 17)
|| (v4.r#type == 18)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
Ok(())
},
|b| b != 255,
) {
break v4;
}
});
}
v3
};
Self {
entity_id: v1,
metadata: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipmentEquipments {
/// `slot`
pub slot: i8,
/// `item`
pub item: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
/// `entity_equipment` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment<const V: i32> {
/// `entityId`
pub entity_id: i32,
/// `equipments`
pub equipments: Vec<crate::defs::p754::play::clientbound::EntityEquipmentEquipments>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for EntityEquipment<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = {
let mut v3 = Vec::new();
loop {
let v4 = r.read_u8()?;
v3.push({
let v5 = ((v4 & 0x7f) as i8);
let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
crate::defs::p754::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
});
if v4 & 0x80 == 0 {
break;
}
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for EntityEquipment<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
if (*self).equipments.is_empty() {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.entity_equipment.equipments",
expected: 1,
actual: 0,
});
}
for (v2, v1) in (*self).equipments.iter().enumerate() {
let v3 = w.len();
w.put_i8((*v1).slot);
(*v1).item.encode(w)?;
match w.get_mut(v3) {
Some(b) if *b & 0x80 == 0 => {
if v2 + 1 < (*self).equipments.len() {
*b |= 0x80;
}
}
_ => {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_equipment.equipments",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityEquipment<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = {
let n = 1 + g.count();
let mut v3 = Vec::with_capacity(n);
for _ in 0..n {
v3.push(loop {
let v4 = {
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
crate::defs::p754::play::clientbound::EntityEquipmentEquipments {
slot: v5,
item: v6,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_i8(v4.slot);
v4.item.encode(w)?;
Ok(())
},
|b| b & 0x80 == 0,
) {
break v4;
}
});
}
v3
};
Self {
entity_id: v1,
equipments: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `scoreboard_objective` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardObjective<const V: i32> {
/// `name`
pub name: ByteString,
/// `action`
pub action: i8,
/// `displayText`
pub display_text: Option<ByteString>,
/// `type`
pub r#type: Option<i32>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for ScoreboardObjective<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = if (v2 == 0) || (v2 == 2) {
Some(r.read_string()?)
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some(r.read_varint()?)
} else {
None
};
Self {
name: v1,
action: v2,
display_text: v3,
r#type: v4,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for ScoreboardObjective<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).name)?;
w.put_i8((*self).action);
match (
&(*self).display_text,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v1), true) => {
w.put_string(&(*v1))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.displayText",
));
}
}
match (
&(*self).r#type,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v2), true) => {
w.put_varint((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.type",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ScoreboardObjective<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
let v3 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v4 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Self {
name: v1,
action: v2,
display_text: v3,
r#type: v4,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `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>,
/// `friendlyFire`
pub friendly_fire: Option<i8>,
/// `nameTagVisibility`
pub name_tag_visibility: Option<ByteString>,
/// `collisionRule`
pub collision_rule: Option<ByteString>,
/// `formatting`
pub formatting: Option<i32>,
/// `prefix`
pub prefix: Option<ByteString>,
/// `suffix`
pub suffix: Option<ByteString>,
/// `players`
pub players: Option<Vec<ByteString>>,
}
#[cfg(feature = "v1_16_5")]
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_i8()?)
} 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_string()?)
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 2) {
Some(r.read_varint()?)
} 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_string()?)
} 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,
friendly_fire: v4,
name_tag_visibility: v5,
collision_rule: v6,
formatting: v7,
prefix: v8,
suffix: v9,
players: v10,
}
})
}
}
#[cfg(feature = "v1_16_5")]
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).friendly_fire,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v2), true) => {
w.put_i8((*v2));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.friendlyFire",
));
}
}
match (
&(*self).name_tag_visibility,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v3), true) => {
w.put_string(&(*v3))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.nameTagVisibility",
));
}
}
match (
&(*self).collision_rule,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v4), true) => {
w.put_string(&(*v4))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.collisionRule",
));
}
}
match (
&(*self).formatting,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v5), true) => {
w.put_varint((*v5));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.formatting",
));
}
}
match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v6), true) => {
w.put_string(&(*v6))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
}
match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v7), true) => {
w.put_string(&(*v7))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
}
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_16_5")]
#[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.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v5 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v6 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v7 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v8 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} else {
None
};
let v9 = if (v2 == 0) || (v2 == 2) {
Some(g.string())
} 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,
friendly_fire: v4,
name_tag_visibility: v5,
collision_rule: v6,
formatting: v7,
prefix: v8,
suffix: v9,
players: v10,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `entity_sound_effect` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct EntitySoundEffect<const V: i32> {
/// `soundId`
pub sound_id: i32,
/// `soundCategory`
pub sound_category: i32,
/// `entityId`
pub entity_id: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: f32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for EntitySoundEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
Self {
sound_id: v1,
sound_category: v2,
entity_id: v3,
volume: v4,
pitch: v5,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for EntitySoundEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).sound_id);
w.put_varint((*self).sound_category);
w.put_varint((*self).entity_id);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntitySoundEffect<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.f32();
let v5 = g.f32();
Self {
sound_id: v1,
sound_category: v2,
entity_id: v3,
volume: v4,
pitch: v5,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
/// `stop_sound` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct StopSound<const V: i32> {
/// `flags`
pub flags: i8,
/// `source`
pub source: Option<i32>,
/// `sound`
pub sound: Option<ByteString>,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Decode for StopSound<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = if (v1 == 1) || (v1 == 3) {
Some(r.read_varint()?)
} else {
None
};
let v3 = if (v1 == 2) || (v1 == 3) {
Some(r.read_string()?)
} else {
None
};
Self {
flags: v1,
source: v2,
sound: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
impl<const V: i32> Encode for StopSound<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).flags);
match (
&(*self).source,
((*self).flags == 1) || ((*self).flags == 3),
) {
(Some(v1), true) => {
w.put_varint((*v1));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.stop_sound.source",
));
}
}
match (&(*self).sound, ((*self).flags == 2) || ((*self).flags == 3)) {
(Some(v2), true) => {
w.put_string(&(*v2))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.stop_sound.sound",
));
}
}
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1", feature = "v26_2"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for StopSound<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[1, 3, 2, 3]) as i8);
let v2 = if (v1 == 1) || (v1 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v3 = if (v1 == 2) || (v1 == 3) {
Some(g.string())
} else {
None
};
Self {
flags: v1,
source: v2,
sound: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// `nbt_query_response` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct NbtQueryResponse<const V: i32> {
/// `transactionId`
pub transaction_id: i32,
/// `nbt`
pub nbt: Option<RawNbt>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for NbtQueryResponse<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = RawNbt::read_optional(r)?;
Self {
transaction_id: v1,
nbt: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for NbtQueryResponse<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
RawNbt::write_optional(&(*self).nbt, w);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for NbtQueryResponse<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.opt_nbt();
Self {
transaction_id: v1,
nbt: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: ByteString,
/// `description`
pub description: ByteString,
/// `icon`
pub icon: crate::types::slot::modern::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(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<
crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValueDisplayData,
>,
/// `criteria`
pub criteria:
Vec<crate::defs::p340::play::clientbound::AdvancementsAdvancementMappingValueCriteria>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: crate::defs::p754::play::clientbound::AdvancementsAdvancementMappingValue,
}
#[cfg(feature = "v1_16_5")]
/// `advancements` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements<const V: i32> {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping:
Vec<crate::defs::p754::play::clientbound::AdvancementsAdvancementMapping>,
/// `identifiers`
pub identifiers: Vec<ByteString>,
/// `progressMapping`
pub progress_mapping: Vec<crate::defs::p340::play::clientbound::AdvancementsProgressMapping>,
}
#[cfg(feature = "v1_16_5")]
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::modern::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::p754::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::p754::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p754::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_16_5")]
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_16_5")]
#[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::modern::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::p754::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::p754::play::clientbound::AdvancementsAdvancementMappingValue { parent_id: v7, display_data: v8, criteria: v18, requirements: v23 } }; crate::defs::p754::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(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataCraftingShapeless {
/// `group`
pub group: ByteString,
/// `ingredients`
pub ingredients: Vec<Vec<crate::types::slot::modern::Slot>>,
/// `result`
pub result: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataCraftingShaped {
/// `width`
pub width: i32,
/// `height`
pub height: i32,
/// `group`
pub group: ByteString,
/// `ingredients`
pub ingredients: Vec<Vec<Vec<crate::types::slot::modern::Slot>>>,
/// `result`
pub result: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataStonecutting {
/// `group`
pub group: ByteString,
/// `ingredient`
pub ingredient: Vec<crate::types::slot::modern::Slot>,
/// `result`
pub result: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataSmithing {
/// `base`
pub base: Vec<crate::types::slot::modern::Slot>,
/// `addition`
pub addition: Vec<crate::types::slot::modern::Slot>,
/// `result`
pub result: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
/// Switch on `type`.
#[derive(Debug, Clone, PartialEq)]
pub enum DeclareRecipesRecipesData {
/// Case(s) `minecraft:crafting_shapeless`.
CraftingShapeless(
crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless,
),
/// Case(s) `minecraft:crafting_shaped`.
CraftingShaped(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped),
/// Case(s) `minecraft:crafting_special_armordye`.
CraftingSpecialArmordye,
/// Case(s) `minecraft:crafting_special_bookcloning`.
CraftingSpecialBookcloning,
/// Case(s) `minecraft:crafting_special_mapcloning`.
CraftingSpecialMapcloning,
/// Case(s) `minecraft:crafting_special_mapextending`.
CraftingSpecialMapextending,
/// Case(s) `minecraft:crafting_special_firework_rocket`.
CraftingSpecialFireworkRocket,
/// Case(s) `minecraft:crafting_special_firework_star`.
CraftingSpecialFireworkStar,
/// Case(s) `minecraft:crafting_special_firework_star_fade`.
CraftingSpecialFireworkStarFade,
/// Case(s) `minecraft:crafting_special_repairitem`.
CraftingSpecialRepairitem,
/// Case(s) `minecraft:crafting_special_tippedarrow`.
CraftingSpecialTippedarrow,
/// Case(s) `minecraft:crafting_special_bannerduplicate`.
CraftingSpecialBannerduplicate,
/// Case(s) `minecraft:crafting_special_banneraddpattern`.
CraftingSpecialBanneraddpattern,
/// Case(s) `minecraft:crafting_special_shielddecoration`.
CraftingSpecialShielddecoration,
/// Case(s) `minecraft:crafting_special_shulkerboxcoloring`.
CraftingSpecialShulkerboxcoloring,
/// Case(s) `minecraft:crafting_special_suspiciousstew`.
CraftingSpecialSuspiciousstew,
/// Case(s) `minecraft:smelting`.
Smelting(crate::defs::p754::types::MinecraftSmeltingFormat),
/// Case(s) `minecraft:blasting`.
Blasting(crate::defs::p754::types::MinecraftSmeltingFormat),
/// Case(s) `minecraft:smoking`.
Smoking(crate::defs::p754::types::MinecraftSmeltingFormat),
/// Case(s) `minecraft:campfire_cooking`.
CampfireCooking(crate::defs::p754::types::MinecraftSmeltingFormat),
/// Case(s) `minecraft:stonecutting`.
Stonecutting(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting),
/// Case(s) `minecraft:smithing`.
Smithing(crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing),
/// Any other value.
Other,
}
#[cfg(feature = "v1_16_5")]
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipes {
/// `type`
pub r#type: ByteString,
/// `recipeId`
pub recipe_id: ByteString,
/// `data`
pub data: crate::defs::p754::play::clientbound::DeclareRecipesRecipesData,
}
#[cfg(feature = "v1_16_5")]
/// `declare_recipes` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipes<const V: i32> {
/// `recipes`
pub recipes: Vec<crate::defs::p754::play::clientbound::DeclareRecipesRecipes>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for DeclareRecipes<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({ let v4 = r.read_string()?;let v5 = r.read_string()?;let v6 = (if (&*v4 == "minecraft:crafting_shapeless") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless({ let v7 = r.read_string()?;let v8 = { let v9 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push({ let v11 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v11 { v12.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v12 }); } v10 };let v13 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless { group: v7, ingredients: v8, result: v13 } }) } else if (&*v4 == "minecraft:crafting_shaped") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped({ let v14 = r.read_varint()?;let v15 = r.read_varint()?;let v16 = r.read_string()?;let v17 = { let v18 = r.check_count(i64::from(v15), 0)?; let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v18 { v19.push({ let v20 = r.check_count(i64::from(v14), 1)?; let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v20 { v21.push({ let v22 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v23 = Vec::with_capacity(v22.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v22 { v23.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v23 }); } v21 }); } v19 };let v24 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped { width: v14, height: v15, group: v16, ingredients: v17, result: v24 } }) } else if (&*v4 == "minecraft:crafting_special_armordye") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye } else if (&*v4 == "minecraft:crafting_special_bookcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning } else if (&*v4 == "minecraft:crafting_special_mapcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning } else if (&*v4 == "minecraft:crafting_special_mapextending") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending } else if (&*v4 == "minecraft:crafting_special_firework_rocket") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket } else if (&*v4 == "minecraft:crafting_special_firework_star") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar } else if (&*v4 == "minecraft:crafting_special_firework_star_fade") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade } else if (&*v4 == "minecraft:crafting_special_repairitem") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem } else if (&*v4 == "minecraft:crafting_special_tippedarrow") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow } else if (&*v4 == "minecraft:crafting_special_bannerduplicate") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate } else if (&*v4 == "minecraft:crafting_special_banneraddpattern") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern } else if (&*v4 == "minecraft:crafting_special_shielddecoration") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration } else if (&*v4 == "minecraft:crafting_special_shulkerboxcoloring") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring } else if (&*v4 == "minecraft:crafting_special_suspiciousstew") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew } else if (&*v4 == "minecraft:smelting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:blasting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:smoking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:campfire_cooking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(<crate::defs::p754::types::MinecraftSmeltingFormat as Decode>::decode(r)?) } else if (&*v4 == "minecraft:stonecutting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting({ let v25 = r.read_string()?;let v26 = { let v27 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v27 { v28.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v28 };let v29 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting { group: v25, ingredient: v26, result: v29 } }) } else if (&*v4 == "minecraft:smithing") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing({ let v30 = { let v31 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v32 = Vec::with_capacity(v31.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v31 { v32.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v32 };let v33 = { let v34 = { let c = r.read_varint()?; r.check_count(i64::from(c), 1)? }; let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v34 { v35.push(<crate::types::slot::modern::Slot as Decode>::decode(r)?); } v35 };let v36 = <crate::types::slot::modern::Slot as Decode>::decode(r)?; crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing { base: v30, addition: v33, result: v36 } }) } else { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other }); crate::defs::p754::play::clientbound::DeclareRecipesRecipes { r#type: v4, recipe_id: v5, data: v6 } });
}
v3
};
Self { recipes: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for DeclareRecipes<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).recipes.len())?;
for v1 in (*self).recipes.iter() {
w.put_string(&(*v1).r#type)?;
w.put_string(&(*v1).recipe_id)?;
match &(*v1).data { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless(v2) => { if !((&*(*v1).r#type == "minecraft:crafting_shapeless")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_string(&(*v2).group)?;w.put_len_varint((*v2).ingredients.len())?;for v3 in (*v2).ingredients.iter() { w.put_len_varint((*v3).len())?;for v4 in (*v3).iter() { (*v4).encode(w)?; } }(*v2).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped(v5) => { if !((&*(*v1).r#type == "minecraft:crafting_shaped")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_varint((*v5).width);w.put_varint((*v5).height);w.put_string(&(*v5).group)?;if usize::try_from((*v5).height).ok() != Some((*v5).ingredients.len()) { return Err(EncodeError::CountMismatch { field: "play.clientbound.declare_recipes.recipes.data.ingredients", expected: usize::try_from((*v5).height).unwrap_or(0), actual: (*v5).ingredients.len() }); }for v6 in (*v5).ingredients.iter() { if usize::try_from((*v5).width).ok() != Some((*v6).len()) { return Err(EncodeError::CountMismatch { field: "play.clientbound.declare_recipes.recipes.data.ingredients", expected: usize::try_from((*v5).width).unwrap_or(0), actual: (*v6).len() }); }for v7 in (*v6).iter() { w.put_len_varint((*v7).len())?;for v8 in (*v7).iter() { (*v8).encode(w)?; } } }(*v5).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye => { if !((&*(*v1).r#type == "minecraft:crafting_special_armordye")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning => { if !((&*(*v1).r#type == "minecraft:crafting_special_bookcloning")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning => { if !((&*(*v1).r#type == "minecraft:crafting_special_mapcloning")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending => { if !((&*(*v1).r#type == "minecraft:crafting_special_mapextending")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_rocket")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_star")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade => { if !((&*(*v1).r#type == "minecraft:crafting_special_firework_star_fade")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem => { if !((&*(*v1).r#type == "minecraft:crafting_special_repairitem")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow => { if !((&*(*v1).r#type == "minecraft:crafting_special_tippedarrow")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate => { if !((&*(*v1).r#type == "minecraft:crafting_special_bannerduplicate")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern => { if !((&*(*v1).r#type == "minecraft:crafting_special_banneraddpattern")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration => { if !((&*(*v1).r#type == "minecraft:crafting_special_shielddecoration")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring => { if !((&*(*v1).r#type == "minecraft:crafting_special_shulkerboxcoloring")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew => { if !((&*(*v1).r#type == "minecraft:crafting_special_suspiciousstew")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(v9) => { if !((&*(*v1).r#type == "minecraft:smelting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v9).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(v10) => { if !((&*(*v1).r#type == "minecraft:blasting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v10).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(v11) => { if !((&*(*v1).r#type == "minecraft:smoking")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v11).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(v12) => { if !((&*(*v1).r#type == "minecraft:campfire_cooking")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } (*v12).encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting(v13) => { if !((&*(*v1).r#type == "minecraft:stonecutting")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_string(&(*v13).group)?;w.put_len_varint((*v13).ingredient.len())?;for v14 in (*v13).ingredient.iter() { (*v14).encode(w)?; }(*v13).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing(v15) => { if !((&*(*v1).r#type == "minecraft:smithing")) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } w.put_len_varint((*v15).base.len())?;for v16 in (*v15).base.iter() { (*v16).encode(w)?; }w.put_len_varint((*v15).addition.len())?;for v17 in (*v15).addition.iter() { (*v17).encode(w)?; }(*v15).result.encode(w)?; }crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other => { if !(!((&*(*v1).r#type == "minecraft:crafting_shapeless") || (&*(*v1).r#type == "minecraft:crafting_shaped") || (&*(*v1).r#type == "minecraft:crafting_special_armordye") || (&*(*v1).r#type == "minecraft:crafting_special_bookcloning") || (&*(*v1).r#type == "minecraft:crafting_special_mapcloning") || (&*(*v1).r#type == "minecraft:crafting_special_mapextending") || (&*(*v1).r#type == "minecraft:crafting_special_firework_rocket") || (&*(*v1).r#type == "minecraft:crafting_special_firework_star") || (&*(*v1).r#type == "minecraft:crafting_special_firework_star_fade") || (&*(*v1).r#type == "minecraft:crafting_special_repairitem") || (&*(*v1).r#type == "minecraft:crafting_special_tippedarrow") || (&*(*v1).r#type == "minecraft:crafting_special_bannerduplicate") || (&*(*v1).r#type == "minecraft:crafting_special_banneraddpattern") || (&*(*v1).r#type == "minecraft:crafting_special_shielddecoration") || (&*(*v1).r#type == "minecraft:crafting_special_shulkerboxcoloring") || (&*(*v1).r#type == "minecraft:crafting_special_suspiciousstew") || (&*(*v1).r#type == "minecraft:smelting") || (&*(*v1).r#type == "minecraft:blasting") || (&*(*v1).r#type == "minecraft:smoking") || (&*(*v1).r#type == "minecraft:campfire_cooking") || (&*(*v1).r#type == "minecraft:stonecutting") || (&*(*v1).r#type == "minecraft:smithing"))) { return Err(EncodeError::SwitchMismatch("play.clientbound.declare_recipes.recipes.data")); } } }
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DeclareRecipes<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({ let v4 = g.string_in(&["minecraft:crafting_shapeless", "minecraft:crafting_shaped", "minecraft:crafting_special_armordye", "minecraft:crafting_special_bookcloning", "minecraft:crafting_special_mapcloning", "minecraft:crafting_special_mapextending", "minecraft:crafting_special_firework_rocket", "minecraft:crafting_special_firework_star", "minecraft:crafting_special_firework_star_fade", "minecraft:crafting_special_repairitem", "minecraft:crafting_special_tippedarrow", "minecraft:crafting_special_bannerduplicate", "minecraft:crafting_special_banneraddpattern", "minecraft:crafting_special_shielddecoration", "minecraft:crafting_special_shulkerboxcoloring", "minecraft:crafting_special_suspiciousstew", "minecraft:smelting", "minecraft:blasting", "minecraft:smoking", "minecraft:campfire_cooking", "minecraft:stonecutting", "minecraft:smithing"]);let v5 = g.string();let v6 = (if (&*v4 == "minecraft:crafting_shapeless") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShapeless({ let v7 = g.string();let v8 = { let v9 = g.count(); let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v9 { v10.push({ let v11 = g.count(); let mut v12 = Vec::with_capacity(v11.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v11 { v12.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v12 }); } v10 };let v13 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShapeless { group: v7, ingredients: v8, result: v13 } }) } else if (&*v4 == "minecraft:crafting_shaped") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingShaped({ let v14 = (g.small_count() as i32);let v15 = (g.small_count() as i32);let v16 = g.string();let v17 = { let v18 = usize::try_from(v15).unwrap_or(0); let mut v19 = Vec::with_capacity(v18.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v18 { v19.push({ let v20 = usize::try_from(v14).unwrap_or(0); let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v20 { v21.push({ let v22 = g.count(); let mut v23 = Vec::with_capacity(v22.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v22 { v23.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v23 }); } v21 }); } v19 };let v24 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataCraftingShaped { width: v14, height: v15, group: v16, ingredients: v17, result: v24 } }) } else if (&*v4 == "minecraft:crafting_special_armordye") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialArmordye } else if (&*v4 == "minecraft:crafting_special_bookcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBookcloning } else if (&*v4 == "minecraft:crafting_special_mapcloning") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapcloning } else if (&*v4 == "minecraft:crafting_special_mapextending") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialMapextending } else if (&*v4 == "minecraft:crafting_special_firework_rocket") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkRocket } else if (&*v4 == "minecraft:crafting_special_firework_star") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStar } else if (&*v4 == "minecraft:crafting_special_firework_star_fade") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade } else if (&*v4 == "minecraft:crafting_special_repairitem") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialRepairitem } else if (&*v4 == "minecraft:crafting_special_tippedarrow") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialTippedarrow } else if (&*v4 == "minecraft:crafting_special_bannerduplicate") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBannerduplicate } else if (&*v4 == "minecraft:crafting_special_banneraddpattern") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern } else if (&*v4 == "minecraft:crafting_special_shielddecoration") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShielddecoration } else if (&*v4 == "minecraft:crafting_special_shulkerboxcoloring") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring } else if (&*v4 == "minecraft:crafting_special_suspiciousstew") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew } else if (&*v4 == "minecraft:smelting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smelting(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:blasting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Blasting(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:smoking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smoking(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:campfire_cooking") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::CampfireCooking(<crate::defs::p754::types::MinecraftSmeltingFormat as Generate>::generate(g)) } else if (&*v4 == "minecraft:stonecutting") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Stonecutting({ let v25 = g.string();let v26 = { let v27 = g.count(); let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v27 { v28.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v28 };let v29 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataStonecutting { group: v25, ingredient: v26, result: v29 } }) } else if (&*v4 == "minecraft:smithing") { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Smithing({ let v30 = { let v31 = g.count(); let mut v32 = Vec::with_capacity(v31.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v31 { v32.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v32 };let v33 = { let v34 = g.count(); let mut v35 = Vec::with_capacity(v34.min(crate::codec::PREALLOC_LIMIT)); for _ in 0..v34 { v35.push(<crate::types::slot::modern::Slot as Generate>::generate(g)); } v35 };let v36 = <crate::types::slot::modern::Slot as Generate>::generate(g); crate::defs::p754::play::clientbound::DeclareRecipesRecipesDataSmithing { base: v30, addition: v33, result: v36 } }) } else { crate::defs::p754::play::clientbound::DeclareRecipesRecipesData::Other }); crate::defs::p754::play::clientbound::DeclareRecipesRecipes { r#type: v4, recipe_id: v5, data: v6 } });
}
v3
};
Self { recipes: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
/// `tags` (clientbound play).
#[derive(Debug, Clone, PartialEq)]
pub struct Tags<const V: i32> {
/// `blockTags`
pub block_tags: Vec<crate::defs::p754::types::Tags>,
/// `itemTags`
pub item_tags: Vec<crate::defs::p754::types::Tags>,
/// `fluidTags`
pub fluid_tags: Vec<crate::defs::p754::types::Tags>,
/// `entityTags`
pub entity_tags: Vec<crate::defs::p754::types::Tags>,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for Tags<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = {
let v2 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = r.read_string()?;
let v5 = {
let v6 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push(r.read_varint()?);
}
v7
};
crate::defs::p754::types::Tags {
tag_name: v4,
entries: v5,
}
});
}
v3
};
let v8 = {
let v9 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({
let v11 = r.read_string()?;
let v12 = {
let v13 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push(r.read_varint()?);
}
v14
};
crate::defs::p754::types::Tags {
tag_name: v11,
entries: v12,
}
});
}
v10
};
let v15 = {
let v16 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push({
let v18 = r.read_string()?;
let v19 = {
let v20 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v20 {
v21.push(r.read_varint()?);
}
v21
};
crate::defs::p754::types::Tags {
tag_name: v18,
entries: v19,
}
});
}
v17
};
let v22 = {
let v23 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v23 {
v24.push({
let v25 = r.read_string()?;
let v26 = {
let v27 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v27 {
v28.push(r.read_varint()?);
}
v28
};
crate::defs::p754::types::Tags {
tag_name: v25,
entries: v26,
}
});
}
v24
};
Self {
block_tags: v1,
item_tags: v8,
fluid_tags: v15,
entity_tags: v22,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for Tags<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).block_tags.len())?;
for v1 in (*self).block_tags.iter() {
w.put_string(&(*v1).tag_name)?;
w.put_len_varint((*v1).entries.len())?;
for v2 in (*v1).entries.iter() {
w.put_varint((*v2));
}
}
w.put_len_varint((*self).item_tags.len())?;
for v3 in (*self).item_tags.iter() {
w.put_string(&(*v3).tag_name)?;
w.put_len_varint((*v3).entries.len())?;
for v4 in (*v3).entries.iter() {
w.put_varint((*v4));
}
}
w.put_len_varint((*self).fluid_tags.len())?;
for v5 in (*self).fluid_tags.iter() {
w.put_string(&(*v5).tag_name)?;
w.put_len_varint((*v5).entries.len())?;
for v6 in (*v5).entries.iter() {
w.put_varint((*v6));
}
}
w.put_len_varint((*self).entity_tags.len())?;
for v7 in (*self).entity_tags.iter() {
w.put_string(&(*v7).tag_name)?;
w.put_len_varint((*v7).entries.len())?;
for v8 in (*v7).entries.iter() {
w.put_varint((*v8));
}
}
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Tags<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = {
let v2 = g.count();
let mut v3 = Vec::with_capacity(v2.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v2 {
v3.push({
let v4 = g.string();
let v5 = {
let v6 = g.count();
let mut v7 = Vec::with_capacity(v6.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v6 {
v7.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v7
};
crate::defs::p754::types::Tags {
tag_name: v4,
entries: v5,
}
});
}
v3
};
let v8 = {
let v9 = g.count();
let mut v10 = Vec::with_capacity(v9.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v9 {
v10.push({
let v11 = g.string();
let v12 = {
let v13 = g.count();
let mut v14 = Vec::with_capacity(v13.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v13 {
v14.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v14
};
crate::defs::p754::types::Tags {
tag_name: v11,
entries: v12,
}
});
}
v10
};
let v15 = {
let v16 = g.count();
let mut v17 = Vec::with_capacity(v16.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v16 {
v17.push({
let v18 = g.string();
let v19 = {
let v20 = g.count();
let mut v21 = Vec::with_capacity(v20.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v20 {
v21.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v21
};
crate::defs::p754::types::Tags {
tag_name: v18,
entries: v19,
}
});
}
v17
};
let v22 = {
let v23 = g.count();
let mut v24 = Vec::with_capacity(v23.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v23 {
v24.push({
let v25 = g.string();
let v26 = {
let v27 = g.count();
let mut v28 = Vec::with_capacity(v27.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v27 {
v28.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v28
};
crate::defs::p754::types::Tags {
tag_name: v25,
entries: v26,
}
});
}
v24
};
Self {
block_tags: v1,
item_tags: v8,
fluid_tags: v15,
entity_tags: v22,
}
}
}
}