#![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(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct QueryBlockNbt<const V: i32> {
pub transaction_id: i32,
pub location: BlockPos,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for QueryBlockNbt<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = BlockPos::read(r, PositionLayout::Xzy)?;
Self {
transaction_id: v1,
location: v2,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for QueryBlockNbt<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
(*self).location.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for QueryBlockNbt<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.position();
Self {
transaction_id: v1,
location: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct SetDifficultyNewDifficulty(pub u8);
#[cfg(feature = "v1_16_5")]
impl SetDifficultyNewDifficulty {
pub const PEACEFUL: Self = Self(0);
pub const EASY: Self = Self(1);
pub const NORMAL: Self = Self(2);
pub const HARD: Self = Self(3);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("peaceful"),
1 => Some("easy"),
2 => Some("normal"),
3 => Some("hard"),
_ => None,
}
}
}
#[cfg(feature = "v1_16_5")]
impl std::fmt::Debug for SetDifficultyNewDifficulty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "SetDifficultyNewDifficulty::{n}"),
None => write!(f, "SetDifficultyNewDifficulty({})", self.0),
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct SetDifficulty<const V: i32> {
pub new_difficulty: crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SetDifficulty<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(r.read_u8()?);
Self { new_difficulty: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for SetDifficulty<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).new_difficulty.0);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetDifficulty<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p754::play::serverbound::SetDifficultyNewDifficulty(g.int_in(
0,
255,
&[0, 1, 2, 3],
)
as u8);
Self { new_difficulty: v1 }
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete<const V: i32> {
pub transaction_id: i32,
pub text: ByteString,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for TabComplete<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_string()?;
Self {
transaction_id: v1,
text: v2,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for TabComplete<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
w.put_string(&(*self).text)?;
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TabComplete<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.string();
Self {
transaction_id: v1,
text: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct WindowClick<const V: i32> {
pub window_id: u8,
pub slot: i16,
pub mouse_button: i8,
pub action: i16,
pub mode: i8,
pub item: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for WindowClick<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_u8()?;
let v2 = r.read_i16()?;
let v3 = r.read_i8()?;
let v4 = r.read_i16()?;
let v5 = r.read_i8()?;
let v6 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
slot: v2,
mouse_button: v3,
action: v4,
mode: v5,
item: v6,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for WindowClick<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_i16((*self).slot);
w.put_i8((*self).mouse_button);
w.put_i16((*self).action);
w.put_i8((*self).mode);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for WindowClick<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(0, 255, &[]) as u8);
let v2 = (g.int_in(-32768, 32767, &[]) as i16);
let v3 = (g.int_in(-128, 127, &[]) as i8);
let v4 = (g.int_in(-32768, 32767, &[]) as i16);
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = <crate::types::slot::modern::Slot as Generate>::generate(g);
Self {
window_id: v1,
slot: v2,
mouse_button: v3,
action: v4,
mode: v5,
item: v6,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct EditBook<const V: i32> {
pub new_book: crate::types::slot::modern::Slot,
pub signing: bool,
pub hand: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for EditBook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
let v2 = r.read_bool()?;
let v3 = r.read_varint()?;
Self {
new_book: v1,
signing: v2,
hand: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for EditBook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).new_book.encode(w)?;
w.put_bool((*self).signing);
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EditBook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = <crate::types::slot::modern::Slot as Generate>::generate(g);
let v2 = g.bool();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
new_book: v1,
signing: v2,
hand: v3,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct QueryEntityNbt<const V: i32> {
pub transaction_id: i32,
pub entity_id: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for QueryEntityNbt<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
Self {
transaction_id: v1,
entity_id: v2,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for QueryEntityNbt<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
w.put_varint((*self).entity_id);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for QueryEntityNbt<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 {
transaction_id: v1,
entity_id: v2,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct UseEntity<const V: i32> {
pub target: i32,
pub mouse: i32,
pub x: Option<f32>,
pub y: Option<f32>,
pub z: Option<f32>,
pub hand: Option<i32>,
pub sneaking: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for UseEntity<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
let v3 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
let v4 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
let v5 = if (v2 == 2) { Some(r.read_f32()?) } else { None };
let v6 = if (v2 == 0) || (v2 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v7 = r.read_bool()?;
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
hand: v6,
sneaking: v7,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for UseEntity<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).target);
w.put_varint((*self).mouse);
match (&(*self).x, ((*self).mouse == 2)) {
(Some(v1), true) => {
w.put_f32((*v1));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
}
match (&(*self).y, ((*self).mouse == 2)) {
(Some(v2), true) => {
w.put_f32((*v2));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
}
match (&(*self).z, ((*self).mouse == 2)) {
(Some(v3), true) => {
w.put_f32((*v3));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
}
match (&(*self).hand, ((*self).mouse == 0) || ((*self).mouse == 2)) {
(Some(v4), true) => {
w.put_varint((*v4));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.use_entity.hand",
));
}
}
w.put_bool((*self).sneaking);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UseEntity<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2, 0, 2]) as i32);
let v3 = if (v2 == 2) { Some(g.f32()) } else { None };
let v4 = if (v2 == 2) { Some(g.f32()) } else { None };
let v5 = if (v2 == 2) { Some(g.f32()) } else { None };
let v6 = if (v2 == 0) || (v2 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v7 = g.bool();
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
hand: v6,
sneaking: v7,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct GenerateStructure<const V: i32> {
pub location: BlockPos,
pub levels: i32,
pub keep_jigsaws: bool,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for GenerateStructure<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_bool()?;
Self {
location: v1,
levels: v2,
keep_jigsaws: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for GenerateStructure<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).levels);
w.put_bool((*self).keep_jigsaws);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for GenerateStructure<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.bool();
Self {
location: v1,
levels: v2,
keep_jigsaws: v3,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct LockDifficulty<const V: i32> {
pub locked: bool,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for LockDifficulty<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
Self { locked: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for LockDifficulty<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).locked);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for LockDifficulty<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
Self { locked: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct PickItem<const V: i32> {
pub slot: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for PickItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { slot: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for PickItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).slot);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PickItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { slot: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeRequest<const V: i32> {
pub window_id: i8,
pub recipe: ByteString,
pub make_all: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for CraftRecipeRequest<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_string()?;
let v3 = r.read_bool()?;
Self {
window_id: v1,
recipe: v2,
make_all: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for CraftRecipeRequest<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_string(&(*self).recipe)?;
w.put_bool((*self).make_all);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CraftRecipeRequest<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[]) as i8);
let v2 = g.string();
let v3 = g.bool();
Self {
window_id: v1,
recipe: v2,
make_all: v3,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Abilities<const V: i32> {
pub flags: i8,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for Abilities<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
Self { flags: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for Abilities<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).flags);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Abilities<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[]) as i8);
Self { flags: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct BlockDig<const V: i32> {
pub status: i32,
pub location: BlockPos,
pub face: i8,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for BlockDig<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 {
status: v1,
location: v2,
face: v3,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for BlockDig<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).status);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_i8((*self).face);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockDig<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 {
status: v1,
location: v2,
face: v3,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct RecipeBook<const V: i32> {
pub book_id: i32,
pub book_open: bool,
pub filter_active: bool,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for RecipeBook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_bool()?;
let v3 = r.read_bool()?;
Self {
book_id: v1,
book_open: v2,
filter_active: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for RecipeBook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).book_id);
w.put_bool((*self).book_open);
w.put_bool((*self).filter_active);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for RecipeBook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.bool();
let v3 = g.bool();
Self {
book_id: v1,
book_open: v2,
filter_active: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct DisplayedRecipe<const V: i32> {
pub recipe_id: ByteString,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for DisplayedRecipe<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
Self { recipe_id: v1 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for DisplayedRecipe<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).recipe_id)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for DisplayedRecipe<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
Self { recipe_id: v1 }
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct NameItem<const V: i32> {
pub name: ByteString,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for NameItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
Self { name: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for NameItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).name)?;
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for NameItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
Self { name: v1 }
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SelectTrade<const V: i32> {
pub slot: i32,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for SelectTrade<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { slot: v1 }
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for SelectTrade<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).slot);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SelectTrade<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { slot: v1 }
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct SetBeaconEffect<const V: i32> {
pub primary_effect: i32,
pub secondary_effect: i32,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SetBeaconEffect<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_varint()?;
Self {
primary_effect: v1,
secondary_effect: v2,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for SetBeaconEffect<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).primary_effect);
w.put_varint((*self).secondary_effect);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetBeaconEffect<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 {
primary_effect: v1,
secondary_effect: v2,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateCommandBlock<const V: i32> {
pub location: BlockPos,
pub command: ByteString,
pub mode: i32,
pub flags: u8,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for UpdateCommandBlock<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_string()?;
let v3 = r.read_varint()?;
let v4 = r.read_u8()?;
Self {
location: v1,
command: v2,
mode: v3,
flags: v4,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for UpdateCommandBlock<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_string(&(*self).command)?;
w.put_varint((*self).mode);
w.put_u8((*self).flags);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateCommandBlock<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = g.string();
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = (g.int_in(0, 255, &[]) as u8);
Self {
location: v1,
command: v2,
mode: v3,
flags: v4,
}
}
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateCommandBlockMinecart<const V: i32> {
pub entity_id: i32,
pub command: ByteString,
pub track_output: bool,
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for UpdateCommandBlockMinecart<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = r.read_string()?;
let v3 = r.read_bool()?;
Self {
entity_id: v1,
command: v2,
track_output: v3,
}
})
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for UpdateCommandBlockMinecart<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_string(&(*self).command)?;
w.put_bool((*self).track_output);
Ok(())
}
}
#[cfg(any(feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateCommandBlockMinecart<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = g.string();
let v3 = g.bool();
Self {
entity_id: v1,
command: v2,
track_output: v3,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct SetCreativeSlot<const V: i32> {
pub slot: i16,
pub item: crate::types::slot::modern::Slot,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for SetCreativeSlot<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i16()?;
let v2 = <crate::types::slot::modern::Slot as Decode>::decode(r)?;
Self { slot: v1, item: v2 }
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for SetCreativeSlot<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SetCreativeSlot<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-32768, 32767, &[]) as i16);
let v2 = <crate::types::slot::modern::Slot as Generate>::generate(g);
Self { slot: v1, item: v2 }
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateJigsawBlock<const V: i32> {
pub location: BlockPos,
pub name: ByteString,
pub target: ByteString,
pub pool: ByteString,
pub final_state: ByteString,
pub joint_type: ByteString,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for UpdateJigsawBlock<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_string()?;
let v3 = r.read_string()?;
let v4 = r.read_string()?;
let v5 = r.read_string()?;
let v6 = r.read_string()?;
Self {
location: v1,
name: v2,
target: v3,
pool: v4,
final_state: v5,
joint_type: v6,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for UpdateJigsawBlock<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_string(&(*self).name)?;
w.put_string(&(*self).target)?;
w.put_string(&(*self).pool)?;
w.put_string(&(*self).final_state)?;
w.put_string(&(*self).joint_type)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateJigsawBlock<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = g.string();
let v3 = g.string();
let v4 = g.string();
let v5 = g.string();
let v6 = g.string();
Self {
location: v1,
name: v2,
target: v3,
pool: v4,
final_state: v5,
joint_type: v6,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateStructureBlock<const V: i32> {
pub location: BlockPos,
pub action: i32,
pub mode: i32,
pub name: ByteString,
pub offset_x: i8,
pub offset_y: i8,
pub offset_z: i8,
pub size_x: i8,
pub size_y: i8,
pub size_z: i8,
pub mirror: i32,
pub rotation: i32,
pub metadata: ByteString,
pub integrity: f32,
pub seed: i64,
pub flags: u8,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for UpdateStructureBlock<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_string()?;
let v5 = r.read_i8()?;
let v6 = r.read_i8()?;
let v7 = r.read_i8()?;
let v8 = r.read_i8()?;
let v9 = r.read_i8()?;
let v10 = r.read_i8()?;
let v11 = r.read_varint()?;
let v12 = r.read_varint()?;
let v13 = r.read_string()?;
let v14 = r.read_f32()?;
let v15 = r.read_varlong()?;
let v16 = r.read_u8()?;
Self {
location: v1,
action: v2,
mode: v3,
name: v4,
offset_x: v5,
offset_y: v6,
offset_z: v7,
size_x: v8,
size_y: v9,
size_z: v10,
mirror: v11,
rotation: v12,
metadata: v13,
integrity: v14,
seed: v15,
flags: v16,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for UpdateStructureBlock<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).action);
w.put_varint((*self).mode);
w.put_string(&(*self).name)?;
w.put_i8((*self).offset_x);
w.put_i8((*self).offset_y);
w.put_i8((*self).offset_z);
w.put_i8((*self).size_x);
w.put_i8((*self).size_y);
w.put_i8((*self).size_z);
w.put_varint((*self).mirror);
w.put_varint((*self).rotation);
w.put_string(&(*self).metadata)?;
w.put_f32((*self).integrity);
w.put_varlong((*self).seed);
w.put_u8((*self).flags);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateStructureBlock<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.string();
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = (g.int_in(-128, 127, &[]) as i8);
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 = (g.int_in(-128, 127, &[]) as i8);
let v11 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v12 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v13 = g.string();
let v14 = g.f32();
let v15 = g.varlong();
let v16 = (g.int_in(0, 255, &[]) as u8);
Self {
location: v1,
action: v2,
mode: v3,
name: v4,
offset_x: v5,
offset_y: v6,
offset_z: v7,
size_x: v8,
size_y: v9,
size_z: v10,
mirror: v11,
rotation: v12,
metadata: v13,
integrity: v14,
seed: v15,
flags: v16,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateSign<const V: i32> {
pub location: BlockPos,
pub text1: ByteString,
pub text2: ByteString,
pub text3: ByteString,
pub text4: ByteString,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for UpdateSign<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xzy)?;
let v2 = r.read_string()?;
let v3 = r.read_string()?;
let v4 = r.read_string()?;
let v5 = r.read_string()?;
Self {
location: v1,
text1: v2,
text2: v3,
text3: v4,
text4: v5,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for UpdateSign<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_string(&(*self).text1)?;
w.put_string(&(*self).text2)?;
w.put_string(&(*self).text3)?;
w.put_string(&(*self).text4)?;
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UpdateSign<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.position();
let v2 = g.string();
let v3 = g.string();
let v4 = g.string();
let v5 = g.string();
Self {
location: v1,
text1: v2,
text2: v3,
text3: v4,
text4: v5,
}
}
}
}
#[cfg(feature = "v1_16_5")]
#[derive(Debug, Clone, PartialEq)]
pub struct BlockPlace<const V: i32> {
pub hand: i32,
pub location: BlockPos,
pub direction: i32,
pub cursor_x: f32,
pub cursor_y: f32,
pub cursor_z: f32,
pub inside_block: bool,
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Decode for BlockPlace<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_varint()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
let v6 = r.read_f32()?;
let v7 = r.read_bool()?;
Self {
hand: v1,
location: v2,
direction: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
inside_block: v7,
}
})
}
}
#[cfg(feature = "v1_16_5")]
impl<const V: i32> Encode for BlockPlace<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).direction);
w.put_f32((*self).cursor_x);
w.put_f32((*self).cursor_y);
w.put_f32((*self).cursor_z);
w.put_bool((*self).inside_block);
Ok(())
}
}
#[cfg(feature = "v1_16_5")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockPlace<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.f32();
let v5 = g.f32();
let v6 = g.f32();
let v7 = g.bool();
Self {
hand: v1,
location: v2,
direction: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
inside_block: v7,
}
}
}
}