#![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_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct TeleportConfirm<const V: i32> {
pub teleport_id: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for TeleportConfirm<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { teleport_id: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for TeleportConfirm<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).teleport_id);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TeleportConfirm<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { teleport_id: v1 }
}
}
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete<const V: i32> {
pub text: ByteString,
pub assume_command: bool,
pub looked_at_block: Option<BlockPos>,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for TabComplete<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_bool()?;
let v3 = if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
};
Self {
text: v1,
assume_command: v2,
looked_at_block: v3,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for TabComplete<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).text)?;
w.put_bool((*self).assume_command);
match &(*self).looked_at_block {
Some(v1) => {
w.put_u8(1);
(*v1).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TabComplete<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.bool();
let v3 = if g.bool() { Some(g.position()) } else { None };
Self {
text: v1,
assume_command: v2,
looked_at_block: v3,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct ClientCommandActionId(pub i32);
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl ClientCommandActionId {
pub const PERFORM_RESPAWN: Self = Self(0);
pub const REQUEST_STATS: Self = Self(1);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("perform_respawn"),
1 => Some("request_stats"),
_ => None,
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl std::fmt::Debug for ClientCommandActionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "ClientCommandActionId::{n}"),
None => write!(f, "ClientCommandActionId({})", self.0),
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct ClientCommand<const V: i32> {
pub action_id: crate::defs::p340::play::serverbound::ClientCommandActionId,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for ClientCommand<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p340::play::serverbound::ClientCommandActionId(r.read_varint()?);
Self { action_id: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for ClientCommand<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action_id.0);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ClientCommand<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p340::play::serverbound::ClientCommandActionId(g.int_in(
-2147483648,
2147483647,
&[0, 1],
)
as i32);
Self { action_id: v1 }
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Settings<const V: i32> {
pub locale: ByteString,
pub view_distance: i8,
pub chat_flags: i32,
pub chat_colors: bool,
pub skin_parts: u8,
pub main_hand: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Settings<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_i8()?;
let v3 = r.read_varint()?;
let v4 = r.read_bool()?;
let v5 = r.read_u8()?;
let v6 = r.read_varint()?;
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
main_hand: v6,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Settings<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).locale)?;
w.put_i8((*self).view_distance);
w.put_varint((*self).chat_flags);
w.put_bool((*self).chat_colors);
w.put_u8((*self).skin_parts);
w.put_varint((*self).main_hand);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Settings<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-128, 127, &[]) as i8);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v4 = g.bool();
let v5 = (g.int_in(0, 255, &[]) as u8);
let v6 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
main_hand: v6,
}
}
}
}
#[cfg(feature = "v1_12_2")]
#[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>,
}
#[cfg(feature = "v1_12_2")]
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
};
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
hand: v6,
}
})
}
}
#[cfg(feature = "v1_12_2")]
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",
));
}
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[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
};
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
hand: v6,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive<const V: i32> {
pub keep_alive_id: i64,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for KeepAlive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i64()?;
Self { keep_alive_id: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for KeepAlive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).keep_alive_id);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for KeepAlive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.i64();
Self { keep_alive_id: v1 }
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct VehicleMove<const V: i32> {
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for VehicleMove<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for VehicleMove<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for VehicleMove<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f32();
let v5 = g.f32();
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SteerBoat<const V: i32> {
pub left_paddle: bool,
pub right_paddle: bool,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for SteerBoat<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
let v2 = r.read_bool()?;
Self {
left_paddle: v1,
right_paddle: v2,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for SteerBoat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).left_paddle);
w.put_bool((*self).right_paddle);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SteerBoat<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
let v2 = g.bool();
Self {
left_paddle: v1,
right_paddle: v2,
}
}
}
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeRequest<const V: i32> {
pub window_id: i8,
pub recipe: i32,
pub make_all: bool,
}
#[cfg(feature = "v1_12_2")]
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_varint()?;
let v3 = r.read_bool()?;
Self {
window_id: v1,
recipe: v2,
make_all: v3,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for CraftRecipeRequest<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_varint((*self).recipe);
w.put_bool((*self).make_all);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[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.int_in(-2147483648, 2147483647, &[]) as i32);
let v3 = g.bool();
Self {
window_id: v1,
recipe: v2,
make_all: v3,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct EntityActionActionId(pub i32);
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl EntityActionActionId {
pub const START_SNEAKING: Self = Self(0);
pub const STOP_SNEAKING: Self = Self(1);
pub const STOP_SLEEPING: Self = Self(2);
pub const START_SPRINTING: Self = Self(3);
pub const STOP_SPRINTING: Self = Self(4);
pub const START_RIDING_JUMP: Self = Self(5);
pub const STOP_RIDING_JUMP: Self = Self(6);
pub const OPEN_INVENTORY: Self = Self(7);
pub const START_FALL_FLYING: Self = Self(8);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("start_sneaking"),
1 => Some("stop_sneaking"),
2 => Some("stop_sleeping"),
3 => Some("start_sprinting"),
4 => Some("stop_sprinting"),
5 => Some("start_riding_jump"),
6 => Some("stop_riding_jump"),
7 => Some("open_inventory"),
8 => Some("start_fall_flying"),
_ => None,
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl std::fmt::Debug for EntityActionActionId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "EntityActionActionId::{n}"),
None => write!(f, "EntityActionActionId({})", self.0),
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct EntityAction<const V: i32> {
pub entity_id: i32,
pub action_id: crate::defs::p340::play::serverbound::EntityActionActionId,
pub jump_boost: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for EntityAction<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = crate::defs::p340::play::serverbound::EntityActionActionId(r.read_varint()?);
let v3 = r.read_varint()?;
Self {
entity_id: v1,
action_id: v2,
jump_boost: v3,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for EntityAction<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).action_id.0);
w.put_varint((*self).jump_boost);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EntityAction<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v2 = crate::defs::p340::play::serverbound::EntityActionActionId(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6, 7, 8],
)
as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
entity_id: v1,
action_id: v2,
jump_boost: v3,
}
}
}
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct CraftingBookDataBodyCase0 {
pub displayed_recipe: i32,
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct CraftingBookDataBodyCase1 {
pub crafting_book_open: bool,
pub crafting_filter: bool,
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub enum CraftingBookDataBody {
Case0(crate::defs::p340::play::serverbound::CraftingBookDataBodyCase0),
Case1(crate::defs::p340::play::serverbound::CraftingBookDataBodyCase1),
Other,
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct CraftingBookData<const V: i32> {
pub r#type: i32,
pub body: crate::defs::p340::play::serverbound::CraftingBookDataBody,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for CraftingBookData<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = (if (v1 == 0) {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case0({
let v3 = r.read_i32()?;
crate::defs::p340::play::serverbound::CraftingBookDataBodyCase0 {
displayed_recipe: v3,
}
})
} else if (v1 == 1) {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case1({
let v4 = r.read_bool()?;
let v5 = r.read_bool()?;
crate::defs::p340::play::serverbound::CraftingBookDataBodyCase1 {
crafting_book_open: v4,
crafting_filter: v5,
}
})
} else {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Other
});
Self {
r#type: v1,
body: v2,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for CraftingBookData<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type);
match &(*self).body {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case0(v1) => {
if !((*self).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
w.put_i32((*v1).displayed_recipe);
}
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case1(v2) => {
if !((*self).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
w.put_bool((*v2).crafting_book_open);
w.put_bool((*v2).crafting_filter);
}
crate::defs::p340::play::serverbound::CraftingBookDataBody::Other => {
if !(!(((*self).r#type == 0) || ((*self).r#type == 1))) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CraftingBookData<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
let v2 = (if (v1 == 0) {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case0({
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
crate::defs::p340::play::serverbound::CraftingBookDataBodyCase0 {
displayed_recipe: v3,
}
})
} else if (v1 == 1) {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Case1({
let v4 = g.bool();
let v5 = g.bool();
crate::defs::p340::play::serverbound::CraftingBookDataBodyCase1 {
crafting_book_open: v4,
crafting_filter: v5,
}
})
} else {
crate::defs::p340::play::serverbound::CraftingBookDataBody::Other
});
Self {
r#type: v1,
body: v2,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackReceive<const V: i32> {
pub result: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for ResourcePackReceive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { result: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for ResourcePackReceive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).result);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ResourcePackReceive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { result: v1 }
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementTab<const V: i32> {
pub action: i32,
pub tab_id: Option<ByteString>,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Decode for AdvancementTab<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
let v2 = if (v1 == 0) {
Some(r.read_string()?)
} else {
None
};
Self {
action: v1,
tab_id: v2,
}
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
impl<const V: i32> Encode for AdvancementTab<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (&(*self).tab_id, ((*self).action == 0)) {
(Some(v1), true) => {
w.put_string(&(*v1))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.advancement_tab.tabId",
));
}
}
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5", feature = "v26_1"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for AdvancementTab<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
let v2 = if (v1 == 0) { Some(g.string()) } else { None };
Self {
action: v1,
tab_id: v2,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct ArmAnimation<const V: i32> {
pub hand: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for ArmAnimation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { hand: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for ArmAnimation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ArmAnimation<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { hand: v1 }
}
}
}
#[cfg(feature = "v1_12_2")]
#[derive(Debug, Clone, PartialEq)]
pub struct BlockPlace<const V: i32> {
pub location: BlockPos,
pub direction: i32,
pub hand: i32,
pub cursor_x: f32,
pub cursor_y: f32,
pub cursor_z: f32,
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Decode for BlockPlace<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
let v2 = r.read_varint()?;
let v3 = r.read_varint()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
let v6 = r.read_f32()?;
Self {
location: v1,
direction: v2,
hand: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
}
})
}
}
#[cfg(feature = "v1_12_2")]
impl<const V: i32> Encode for BlockPlace<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_varint((*self).direction);
w.put_varint((*self).hand);
w.put_f32((*self).cursor_x);
w.put_f32((*self).cursor_y);
w.put_f32((*self).cursor_z);
Ok(())
}
}
#[cfg(feature = "v1_12_2")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for BlockPlace<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.f32();
let v5 = g.f32();
let v6 = g.f32();
Self {
location: v1,
direction: v2,
hand: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
}
}
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct UseItem<const V: i32> {
pub hand: i32,
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for UseItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { hand: v1 }
})
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for UseItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(any(feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for UseItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { hand: v1 }
}
}
}