#![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_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive<const V: i32> {
pub keep_alive_id: i32,
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Decode for KeepAlive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_varint()?;
Self { keep_alive_id: v1 }
})
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for KeepAlive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).keep_alive_id);
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for KeepAlive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self { keep_alive_id: v1 }
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Chat<const V: i32> {
pub message: ByteString,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", 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()?;
Self { message: v1 }
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Chat<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).message)?;
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", 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();
Self { message: v1 }
}
}
}
#[cfg(feature = "v1_8")]
#[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>,
}
#[cfg(feature = "v1_8")]
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 };
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
}
})
}
}
#[cfg(feature = "v1_8")]
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")),
}
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[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]) 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 };
Self {
target: v1,
mouse: v2,
x: v3,
y: v4,
z: v5,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Flying<const V: i32> {
pub on_ground: bool,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Flying<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_bool()?;
Self { on_ground: v1 }
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Flying<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Flying<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.bool();
Self { on_ground: v1 }
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Position<const V: i32> {
pub x: f64,
pub y: f64,
pub z: f64,
pub on_ground: bool,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Position<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_bool()?;
Self {
x: v1,
y: v2,
z: v3,
on_ground: v4,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Position<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Position<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.bool();
Self {
x: v1,
y: v2,
z: v3,
on_ground: v4,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Look<const V: i32> {
pub yaw: f32,
pub pitch: f32,
pub on_ground: bool,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Look<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f32()?;
let v2 = r.read_f32()?;
let v3 = r.read_bool()?;
Self {
yaw: v1,
pitch: v2,
on_ground: v3,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Look<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Look<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f32();
let v2 = g.f32();
let v3 = g.bool();
Self {
yaw: v1,
pitch: v2,
on_ground: v3,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct PositionLook<const V: i32> {
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
pub on_ground: bool,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for PositionLook<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f64()?;
let v2 = r.read_f64()?;
let v3 = r.read_f64()?;
let v4 = r.read_f32()?;
let v5 = r.read_f32()?;
let v6 = r.read_bool()?;
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
on_ground: v6,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for PositionLook<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for PositionLook<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f64();
let v2 = g.f64();
let v3 = g.f64();
let v4 = g.f32();
let v5 = g.f32();
let v6 = g.bool();
Self {
x: v1,
y: v2,
z: v3,
yaw: v4,
pitch: v5,
on_ground: v6,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct BlockDig<const V: i32> {
pub status: i32,
pub location: BlockPos,
pub face: i8,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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::Xyz)?;
let v3 = r.read_i8()?;
Self {
status: v1,
location: v2,
face: v3,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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::Xyz)?;
w.put_i8((*self).face);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[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(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct BlockPlace<const V: i32> {
pub location: BlockPos,
pub direction: i8,
pub held_item: crate::types::slot::legacy::Slot,
pub cursor_x: i8,
pub cursor_y: i8,
pub cursor_z: i8,
}
#[cfg(feature = "v1_8")]
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_i8()?;
let v3 = <crate::types::slot::legacy::Slot as Decode>::decode(r)?;
let v4 = r.read_i8()?;
let v5 = r.read_i8()?;
let v6 = r.read_i8()?;
Self {
location: v1,
direction: v2,
held_item: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
}
})
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for BlockPlace<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_i8((*self).direction);
(*self).held_item.encode(w)?;
w.put_i8((*self).cursor_x);
w.put_i8((*self).cursor_y);
w.put_i8((*self).cursor_z);
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[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(-128, 127, &[]) as i8);
let v3 = <crate::types::slot::legacy::Slot as Generate>::generate(g);
let v4 = (g.int_in(-128, 127, &[]) as i8);
let v5 = (g.int_in(-128, 127, &[]) as i8);
let v6 = (g.int_in(-128, 127, &[]) as i8);
Self {
location: v1,
direction: v2,
held_item: v3,
cursor_x: v4,
cursor_y: v5,
cursor_z: v6,
}
}
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[derive(Debug, Clone, PartialEq)]
pub struct HeldItemSlot<const V: i32> {
pub slot_id: i16,
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for HeldItemSlot<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i16()?;
Self { slot_id: v1 }
})
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for HeldItemSlot<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i16((*self).slot_id);
Ok(())
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for HeldItemSlot<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-32768, 32767, &[]) as i16);
Self { slot_id: v1 }
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct ArmAnimation<const V: i32> {}
#[cfg(feature = "v1_8")]
impl<const V: i32> Decode for ArmAnimation<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ Self {} })
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for ArmAnimation<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ArmAnimation<V> {
fn generate(g: &mut Gen) -> Self {
{ Self {} }
}
}
#[cfg(feature = "v1_8")]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct EntityActionActionId(pub i32);
#[cfg(feature = "v1_8")]
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 OPEN_INVENTORY: Self = Self(6);
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("open_inventory"),
_ => None,
}
}
}
#[cfg(feature = "v1_8")]
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(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct EntityAction<const V: i32> {
pub entity_id: i32,
pub action_id: crate::defs::p47::play::serverbound::EntityActionActionId,
pub jump_boost: i32,
}
#[cfg(feature = "v1_8")]
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::p47::play::serverbound::EntityActionActionId(r.read_varint()?);
let v3 = r.read_varint()?;
Self {
entity_id: v1,
action_id: v2,
jump_boost: v3,
}
})
}
}
#[cfg(feature = "v1_8")]
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(feature = "v1_8")]
#[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::p47::play::serverbound::EntityActionActionId(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2, 3, 4, 5, 6],
)
as i32);
let v3 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
entity_id: v1,
action_id: v2,
jump_boost: v3,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SteerVehicle<const V: i32> {
pub sideways: f32,
pub forward: f32,
pub jump: u8,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for SteerVehicle<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_f32()?;
let v2 = r.read_f32()?;
let v3 = r.read_u8()?;
Self {
sideways: v1,
forward: v2,
jump: v3,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for SteerVehicle<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).sideways);
w.put_f32((*self).forward);
w.put_u8((*self).jump);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for SteerVehicle<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.f32();
let v2 = g.f32();
let v3 = (g.int_in(0, 255, &[]) as u8);
Self {
sideways: v1,
forward: v2,
jump: v3,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct CloseWindow<const V: i32> {
pub window_id: u8,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for CloseWindow<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_u8()?;
Self { window_id: v1 }
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for CloseWindow<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CloseWindow<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(0, 255, &[]) as u8);
Self { window_id: v1 }
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[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::legacy::Slot,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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::legacy::Slot as Decode>::decode(r)?;
Self {
window_id: v1,
slot: v2,
mouse_button: v3,
action: v4,
mode: v5,
item: v6,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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(any(feature = "v1_8", feature = "v1_12_2"))]
#[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::legacy::Slot as Generate>::generate(g);
Self {
window_id: v1,
slot: v2,
mouse_button: v3,
action: v4,
mode: v5,
item: v6,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Transaction<const V: i32> {
pub window_id: i8,
pub action: i16,
pub accepted: bool,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for Transaction<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_i16()?;
let v3 = r.read_bool()?;
Self {
window_id: v1,
action: v2,
accepted: v3,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for Transaction<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_i16((*self).action);
w.put_bool((*self).accepted);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Transaction<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 = g.bool();
Self {
window_id: v1,
action: v2,
accepted: v3,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct SetCreativeSlot<const V: i32> {
pub slot: i16,
pub item: crate::types::slot::legacy::Slot,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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::legacy::Slot as Decode>::decode(r)?;
Self { slot: v1, item: v2 }
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
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(any(feature = "v1_8", feature = "v1_12_2"))]
#[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::legacy::Slot as Generate>::generate(g);
Self { slot: v1, item: v2 }
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[derive(Debug, Clone, PartialEq)]
pub struct EnchantItem<const V: i32> {
pub window_id: i8,
pub enchantment: i8,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Decode for EnchantItem<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_i8()?;
Self {
window_id: v1,
enchantment: v2,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
impl<const V: i32> Encode for EnchantItem<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_i8((*self).enchantment);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2", feature = "v1_16_5"))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for EnchantItem<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = (g.int_in(-128, 127, &[]) as i8);
let v2 = (g.int_in(-128, 127, &[]) as i8);
Self {
window_id: v1,
enchantment: v2,
}
}
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[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(any(feature = "v1_8", feature = "v1_12_2"))]
impl<const V: i32> Decode for UpdateSign<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = BlockPos::read(r, PositionLayout::Xyz)?;
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(any(feature = "v1_8", feature = "v1_12_2"))]
impl<const V: i32> Encode for UpdateSign<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_string(&(*self).text1)?;
w.put_string(&(*self).text2)?;
w.put_string(&(*self).text3)?;
w.put_string(&(*self).text4)?;
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[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(any(feature = "v1_8", feature = "v1_12_2"))]
#[derive(Debug, Clone, PartialEq)]
pub struct Abilities<const V: i32> {
pub flags: i8,
pub flying_speed: f32,
pub walking_speed: f32,
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
impl<const V: i32> Decode for Abilities<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_i8()?;
let v2 = r.read_f32()?;
let v3 = r.read_f32()?;
Self {
flags: v1,
flying_speed: v2,
walking_speed: v3,
}
})
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
impl<const V: i32> Encode for Abilities<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).flags);
w.put_f32((*self).flying_speed);
w.put_f32((*self).walking_speed);
Ok(())
}
}
#[cfg(any(feature = "v1_8", feature = "v1_12_2"))]
#[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);
let v2 = g.f32();
let v3 = g.f32();
Self {
flags: v1,
flying_speed: v2,
walking_speed: v3,
}
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete<const V: i32> {
pub text: ByteString,
pub block: Option<BlockPos>,
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Decode for TabComplete<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
};
Self {
text: v1,
block: v2,
}
})
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for TabComplete<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).text)?;
match &(*self).block {
Some(v1) => {
w.put_u8(1);
(*v1).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for TabComplete<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = if g.bool() { Some(g.position()) } else { None };
Self {
text: v1,
block: v2,
}
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct Settings<const V: i32> {
pub locale: ByteString,
pub view_distance: i8,
pub chat_flags: i8,
pub chat_colors: bool,
pub skin_parts: u8,
}
#[cfg(feature = "v1_8")]
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_i8()?;
let v4 = r.read_bool()?;
let v5 = r.read_u8()?;
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
}
})
}
}
#[cfg(feature = "v1_8")]
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_i8((*self).chat_flags);
w.put_bool((*self).chat_colors);
w.put_u8((*self).skin_parts);
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[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(-128, 127, &[]) as i8);
let v4 = g.bool();
let v5 = (g.int_in(0, 255, &[]) as u8);
Self {
locale: v1,
view_distance: v2,
chat_flags: v3,
chat_colors: v4,
skin_parts: v5,
}
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct ClientCommandPayload(pub i32);
#[cfg(feature = "v1_8")]
impl ClientCommandPayload {
pub const PERFORM_RESPAWN: Self = Self(0);
pub const REQUEST_STATS: Self = Self(1);
pub const OPEN_INVENTORY_ACHIEVEMENT: Self = Self(2);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("perform_respawn"),
1 => Some("request_stats"),
2 => Some("open_inventory_achievement"),
_ => None,
}
}
}
#[cfg(feature = "v1_8")]
impl std::fmt::Debug for ClientCommandPayload {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "ClientCommandPayload::{n}"),
None => write!(f, "ClientCommandPayload({})", self.0),
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct ClientCommand<const V: i32> {
pub payload: crate::defs::p47::play::serverbound::ClientCommandPayload,
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Decode for ClientCommand<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = crate::defs::p47::play::serverbound::ClientCommandPayload(r.read_varint()?);
Self { payload: v1 }
})
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for ClientCommand<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).payload.0);
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ClientCommand<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = crate::defs::p47::play::serverbound::ClientCommandPayload(g.int_in(
-2147483648,
2147483647,
&[0, 1, 2],
)
as i32);
Self { payload: v1 }
}
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[derive(Debug, Clone, PartialEq)]
pub struct CustomPayload<const V: i32> {
pub channel: ByteString,
pub data: Bytes,
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for CustomPayload<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_rest();
Self {
channel: v1,
data: v2,
}
})
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for CustomPayload<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).channel)?;
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for CustomPayload<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = g.bytes();
Self {
channel: v1,
data: v2,
}
}
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[derive(Debug, Clone, PartialEq)]
pub struct Spectate<const V: i32> {
pub target: Uuid,
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Decode for Spectate<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_uuid()?;
Self { target: v1 }
})
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
impl<const V: i32> Encode for Spectate<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).target);
Ok(())
}
}
#[cfg(any(
feature = "v1_8",
feature = "v1_12_2",
feature = "v1_16_5",
feature = "v26_1",
feature = "v26_2"
))]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for Spectate<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.uuid();
Self { target: v1 }
}
}
}
#[cfg(feature = "v1_8")]
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackReceive<const V: i32> {
pub hash: ByteString,
pub result: i32,
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Decode for ResourcePackReceive<V> {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1 = r.read_string()?;
let v2 = r.read_varint()?;
Self {
hash: v1,
result: v2,
}
})
}
}
#[cfg(feature = "v1_8")]
impl<const V: i32> Encode for ResourcePackReceive<V> {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).hash)?;
w.put_varint((*self).result);
Ok(())
}
}
#[cfg(feature = "v1_8")]
#[cfg(feature = "testgen")]
impl<const V: i32> Generate for ResourcePackReceive<V> {
fn generate(g: &mut Gen) -> Self {
{
let v1 = g.string();
let v2 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Self {
hash: v1,
result: v2,
}
}
}
}