#![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::RawNbt;
use crate::packet::{Direction, PacketSet, RawPacket, State};
#[cfg(feature = "testgen")]
use crate::testgen::{Gen, Generate};
use crate::types::{BlockPos, ByteString, PositionLayout, Uuid};
use crate::v1_8::types;
use bytes::{BufMut, Bytes, BytesMut};
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct EntityActionActionId(pub i32);
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,
}
}
}
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),
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct ClientCommandPayload(pub i32);
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,
}
}
}
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),
}
}
}
pub mod id {
pub const KEEP_ALIVE: i32 = 0x00;
pub const CHAT: i32 = 0x01;
pub const USE_ENTITY: i32 = 0x02;
pub const FLYING: i32 = 0x03;
pub const POSITION: i32 = 0x04;
pub const LOOK: i32 = 0x05;
pub const POSITION_LOOK: i32 = 0x06;
pub const BLOCK_DIG: i32 = 0x07;
pub const BLOCK_PLACE: i32 = 0x08;
pub const HELD_ITEM_SLOT: i32 = 0x09;
pub const ARM_ANIMATION: i32 = 0x0a;
pub const ENTITY_ACTION: i32 = 0x0b;
pub const STEER_VEHICLE: i32 = 0x0c;
pub const CLOSE_WINDOW: i32 = 0x0d;
pub const WINDOW_CLICK: i32 = 0x0e;
pub const TRANSACTION: i32 = 0x0f;
pub const SET_CREATIVE_SLOT: i32 = 0x10;
pub const ENCHANT_ITEM: i32 = 0x11;
pub const UPDATE_SIGN: i32 = 0x12;
pub const ABILITIES: i32 = 0x13;
pub const TAB_COMPLETE: i32 = 0x14;
pub const SETTINGS: i32 = 0x15;
pub const CLIENT_COMMAND: i32 = 0x16;
pub const CUSTOM_PAYLOAD: i32 = 0x17;
pub const SPECTATE: i32 = 0x18;
pub const RESOURCE_PACK_RECEIVE: i32 = 0x19;
}
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive {
pub keep_alive_id: i32,
}
impl crate::packet::Packet for KeepAlive {
const ID: i32 = id::KEEP_ALIVE;
const NAME: &'static str = "keep_alive";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for KeepAlive {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v887 = r.read_varint()?;
KeepAlive {
keep_alive_id: v887,
}
})
}
}
impl Encode for KeepAlive {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).keep_alive_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for KeepAlive {
fn generate(g: &mut Gen) -> Self {
{
let v888 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
KeepAlive {
keep_alive_id: v888,
}
}
}
}
impl From<KeepAlive> for ServerboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Chat {
pub message: ByteString,
}
impl crate::packet::Packet for Chat {
const ID: i32 = id::CHAT;
const NAME: &'static str = "chat";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Chat {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v889 = r.read_string()?;
Chat { message: v889 }
})
}
}
impl Encode for Chat {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).message)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Chat {
fn generate(g: &mut Gen) -> Self {
{
let v890 = g.string();
Chat { message: v890 }
}
}
}
impl From<Chat> for ServerboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UseEntity {
pub target: i32,
pub mouse: i32,
pub x: Option<f32>,
pub y: Option<f32>,
pub z: Option<f32>,
}
impl crate::packet::Packet for UseEntity {
const ID: i32 = id::USE_ENTITY;
const NAME: &'static str = "use_entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for UseEntity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v891 = r.read_varint()?;
let v892 = r.read_varint()?;
let v893 = if (v892 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v894 = if (v892 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v895 = if (v892 == 2) {
Some(r.read_f32()?)
} else {
None
};
UseEntity {
target: v891,
mouse: v892,
x: v893,
y: v894,
z: v895,
}
})
}
}
impl Encode for UseEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).target);
w.put_varint((*self).mouse);
match (&(*self).x, ((*self).mouse == 2)) {
(Some(v896), true) => {
w.put_f32((*v896));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
}
match (&(*self).y, ((*self).mouse == 2)) {
(Some(v897), true) => {
w.put_f32((*v897));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
}
match (&(*self).z, ((*self).mouse == 2)) {
(Some(v898), true) => {
w.put_f32((*v898));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UseEntity {
fn generate(g: &mut Gen) -> Self {
{
let v899 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v900 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2]) as i32);
let v901 = if (v900 == 2) { Some(g.f32()) } else { None };
let v902 = if (v900 == 2) { Some(g.f32()) } else { None };
let v903 = if (v900 == 2) { Some(g.f32()) } else { None };
UseEntity {
target: v899,
mouse: v900,
x: v901,
y: v902,
z: v903,
}
}
}
}
impl From<UseEntity> for ServerboundPlayPacket {
fn from(p: UseEntity) -> Self {
Self::UseEntity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Flying {
pub on_ground: bool,
}
impl crate::packet::Packet for Flying {
const ID: i32 = id::FLYING;
const NAME: &'static str = "flying";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Flying {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v904 = r.read_bool()?;
Flying { on_ground: v904 }
})
}
}
impl Encode for Flying {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Flying {
fn generate(g: &mut Gen) -> Self {
{
let v905 = g.bool();
Flying { on_ground: v905 }
}
}
}
impl From<Flying> for ServerboundPlayPacket {
fn from(p: Flying) -> Self {
Self::Flying(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Position {
pub x: f64,
pub y: f64,
pub z: f64,
pub on_ground: bool,
}
impl crate::packet::Packet for Position {
const ID: i32 = id::POSITION;
const NAME: &'static str = "position";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Position {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v906 = r.read_f64()?;
let v907 = r.read_f64()?;
let v908 = r.read_f64()?;
let v909 = r.read_bool()?;
Position {
x: v906,
y: v907,
z: v908,
on_ground: v909,
}
})
}
}
impl Encode for Position {
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(feature = "testgen")]
impl Generate for Position {
fn generate(g: &mut Gen) -> Self {
{
let v910 = g.f64();
let v911 = g.f64();
let v912 = g.f64();
let v913 = g.bool();
Position {
x: v910,
y: v911,
z: v912,
on_ground: v913,
}
}
}
}
impl From<Position> for ServerboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Look {
pub yaw: f32,
pub pitch: f32,
pub on_ground: bool,
}
impl crate::packet::Packet for Look {
const ID: i32 = id::LOOK;
const NAME: &'static str = "look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Look {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v914 = r.read_f32()?;
let v915 = r.read_f32()?;
let v916 = r.read_bool()?;
Look {
yaw: v914,
pitch: v915,
on_ground: v916,
}
})
}
}
impl Encode for Look {
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(feature = "testgen")]
impl Generate for Look {
fn generate(g: &mut Gen) -> Self {
{
let v917 = g.f32();
let v918 = g.f32();
let v919 = g.bool();
Look {
yaw: v917,
pitch: v918,
on_ground: v919,
}
}
}
}
impl From<Look> for ServerboundPlayPacket {
fn from(p: Look) -> Self {
Self::Look(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct PositionLook {
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
pub on_ground: bool,
}
impl crate::packet::Packet for PositionLook {
const ID: i32 = id::POSITION_LOOK;
const NAME: &'static str = "position_look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for PositionLook {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v920 = r.read_f64()?;
let v921 = r.read_f64()?;
let v922 = r.read_f64()?;
let v923 = r.read_f32()?;
let v924 = r.read_f32()?;
let v925 = r.read_bool()?;
PositionLook {
x: v920,
y: v921,
z: v922,
yaw: v923,
pitch: v924,
on_ground: v925,
}
})
}
}
impl Encode for PositionLook {
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(feature = "testgen")]
impl Generate for PositionLook {
fn generate(g: &mut Gen) -> Self {
{
let v926 = g.f64();
let v927 = g.f64();
let v928 = g.f64();
let v929 = g.f32();
let v930 = g.f32();
let v931 = g.bool();
PositionLook {
x: v926,
y: v927,
z: v928,
yaw: v929,
pitch: v930,
on_ground: v931,
}
}
}
}
impl From<PositionLook> for ServerboundPlayPacket {
fn from(p: PositionLook) -> Self {
Self::PositionLook(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockDig {
pub status: i32,
pub location: BlockPos,
pub face: i8,
}
impl crate::packet::Packet for BlockDig {
const ID: i32 = id::BLOCK_DIG;
const NAME: &'static str = "block_dig";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for BlockDig {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v932 = r.read_varint()?;
let v933 = BlockPos::read(r, PositionLayout::Xyz)?;
let v934 = r.read_i8()?;
BlockDig {
status: v932,
location: v933,
face: v934,
}
})
}
}
impl Encode for BlockDig {
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(feature = "testgen")]
impl Generate for BlockDig {
fn generate(g: &mut Gen) -> Self {
{
let v935 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v936 = g.position();
let v937 = (g.int_in(-128, 127, &[]) as i8);
BlockDig {
status: v935,
location: v936,
face: v937,
}
}
}
}
impl From<BlockDig> for ServerboundPlayPacket {
fn from(p: BlockDig) -> Self {
Self::BlockDig(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockPlace {
pub location: BlockPos,
pub direction: i8,
pub held_item: types::Slot,
pub cursor_x: i8,
pub cursor_y: i8,
pub cursor_z: i8,
}
impl crate::packet::Packet for BlockPlace {
const ID: i32 = id::BLOCK_PLACE;
const NAME: &'static str = "block_place";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for BlockPlace {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v938 = BlockPos::read(r, PositionLayout::Xyz)?;
let v939 = r.read_i8()?;
let v940 = <types::Slot as Decode>::decode(r)?;
let v941 = r.read_i8()?;
let v942 = r.read_i8()?;
let v943 = r.read_i8()?;
BlockPlace {
location: v938,
direction: v939,
held_item: v940,
cursor_x: v941,
cursor_y: v942,
cursor_z: v943,
}
})
}
}
impl Encode for BlockPlace {
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 = "testgen")]
impl Generate for BlockPlace {
fn generate(g: &mut Gen) -> Self {
{
let v944 = g.position();
let v945 = (g.int_in(-128, 127, &[]) as i8);
let v946 = <types::Slot as Generate>::generate(g);
let v947 = (g.int_in(-128, 127, &[]) as i8);
let v948 = (g.int_in(-128, 127, &[]) as i8);
let v949 = (g.int_in(-128, 127, &[]) as i8);
BlockPlace {
location: v944,
direction: v945,
held_item: v946,
cursor_x: v947,
cursor_y: v948,
cursor_z: v949,
}
}
}
}
impl From<BlockPlace> for ServerboundPlayPacket {
fn from(p: BlockPlace) -> Self {
Self::BlockPlace(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct HeldItemSlot {
pub slot_id: i16,
}
impl crate::packet::Packet for HeldItemSlot {
const ID: i32 = id::HELD_ITEM_SLOT;
const NAME: &'static str = "held_item_slot";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for HeldItemSlot {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v950 = r.read_i16()?;
HeldItemSlot { slot_id: v950 }
})
}
}
impl Encode for HeldItemSlot {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i16((*self).slot_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for HeldItemSlot {
fn generate(g: &mut Gen) -> Self {
{
let v951 = (g.int_in(-32768, 32767, &[]) as i16);
HeldItemSlot { slot_id: v951 }
}
}
}
impl From<HeldItemSlot> for ServerboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ArmAnimation {}
impl crate::packet::Packet for ArmAnimation {
const ID: i32 = id::ARM_ANIMATION;
const NAME: &'static str = "arm_animation";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for ArmAnimation {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({ ArmAnimation {} })
}
}
impl Encode for ArmAnimation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ArmAnimation {
fn generate(g: &mut Gen) -> Self {
{ ArmAnimation {} }
}
}
impl From<ArmAnimation> for ServerboundPlayPacket {
fn from(p: ArmAnimation) -> Self {
Self::ArmAnimation(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityAction {
pub entity_id: i32,
pub action_id: EntityActionActionId,
pub jump_boost: i32,
}
impl crate::packet::Packet for EntityAction {
const ID: i32 = id::ENTITY_ACTION;
const NAME: &'static str = "entity_action";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for EntityAction {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v952 = r.read_varint()?;
let v953 = EntityActionActionId(r.read_varint()?);
let v954 = r.read_varint()?;
EntityAction {
entity_id: v952,
action_id: v953,
jump_boost: v954,
}
})
}
}
impl Encode for EntityAction {
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 = "testgen")]
impl Generate for EntityAction {
fn generate(g: &mut Gen) -> Self {
{
let v955 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v956 =
EntityActionActionId(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6]) as i32
);
let v957 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
EntityAction {
entity_id: v955,
action_id: v956,
jump_boost: v957,
}
}
}
}
impl From<EntityAction> for ServerboundPlayPacket {
fn from(p: EntityAction) -> Self {
Self::EntityAction(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SteerVehicle {
pub sideways: f32,
pub forward: f32,
pub jump: u8,
}
impl crate::packet::Packet for SteerVehicle {
const ID: i32 = id::STEER_VEHICLE;
const NAME: &'static str = "steer_vehicle";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for SteerVehicle {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v958 = r.read_f32()?;
let v959 = r.read_f32()?;
let v960 = r.read_u8()?;
SteerVehicle {
sideways: v958,
forward: v959,
jump: v960,
}
})
}
}
impl Encode for SteerVehicle {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).sideways);
w.put_f32((*self).forward);
w.put_u8((*self).jump);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SteerVehicle {
fn generate(g: &mut Gen) -> Self {
{
let v961 = g.f32();
let v962 = g.f32();
let v963 = (g.int_in(0, 255, &[]) as u8);
SteerVehicle {
sideways: v961,
forward: v962,
jump: v963,
}
}
}
}
impl From<SteerVehicle> for ServerboundPlayPacket {
fn from(p: SteerVehicle) -> Self {
Self::SteerVehicle(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CloseWindow {
pub window_id: u8,
}
impl crate::packet::Packet for CloseWindow {
const ID: i32 = id::CLOSE_WINDOW;
const NAME: &'static str = "close_window";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for CloseWindow {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v964 = r.read_u8()?;
CloseWindow { window_id: v964 }
})
}
}
impl Encode for CloseWindow {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CloseWindow {
fn generate(g: &mut Gen) -> Self {
{
let v965 = (g.int_in(0, 255, &[]) as u8);
CloseWindow { window_id: v965 }
}
}
}
impl From<CloseWindow> for ServerboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct WindowClick {
pub window_id: u8,
pub slot: i16,
pub mouse_button: i8,
pub action: i16,
pub mode: i8,
pub item: types::Slot,
}
impl crate::packet::Packet for WindowClick {
const ID: i32 = id::WINDOW_CLICK;
const NAME: &'static str = "window_click";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for WindowClick {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v966 = r.read_u8()?;
let v967 = r.read_i16()?;
let v968 = r.read_i8()?;
let v969 = r.read_i16()?;
let v970 = r.read_i8()?;
let v971 = <types::Slot as Decode>::decode(r)?;
WindowClick {
window_id: v966,
slot: v967,
mouse_button: v968,
action: v969,
mode: v970,
item: v971,
}
})
}
}
impl Encode for WindowClick {
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 = "testgen")]
impl Generate for WindowClick {
fn generate(g: &mut Gen) -> Self {
{
let v972 = (g.int_in(0, 255, &[]) as u8);
let v973 = (g.int_in(-32768, 32767, &[]) as i16);
let v974 = (g.int_in(-128, 127, &[]) as i8);
let v975 = (g.int_in(-32768, 32767, &[]) as i16);
let v976 = (g.int_in(-128, 127, &[]) as i8);
let v977 = <types::Slot as Generate>::generate(g);
WindowClick {
window_id: v972,
slot: v973,
mouse_button: v974,
action: v975,
mode: v976,
item: v977,
}
}
}
}
impl From<WindowClick> for ServerboundPlayPacket {
fn from(p: WindowClick) -> Self {
Self::WindowClick(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Transaction {
pub window_id: i8,
pub action: i16,
pub accepted: bool,
}
impl crate::packet::Packet for Transaction {
const ID: i32 = id::TRANSACTION;
const NAME: &'static str = "transaction";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Transaction {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v978 = r.read_i8()?;
let v979 = r.read_i16()?;
let v980 = r.read_bool()?;
Transaction {
window_id: v978,
action: v979,
accepted: v980,
}
})
}
}
impl Encode for Transaction {
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(feature = "testgen")]
impl Generate for Transaction {
fn generate(g: &mut Gen) -> Self {
{
let v981 = (g.int_in(-128, 127, &[]) as i8);
let v982 = (g.int_in(-32768, 32767, &[]) as i16);
let v983 = g.bool();
Transaction {
window_id: v981,
action: v982,
accepted: v983,
}
}
}
}
impl From<Transaction> for ServerboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SetCreativeSlot {
pub slot: i16,
pub item: types::Slot,
}
impl crate::packet::Packet for SetCreativeSlot {
const ID: i32 = id::SET_CREATIVE_SLOT;
const NAME: &'static str = "set_creative_slot";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for SetCreativeSlot {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v984 = r.read_i16()?;
let v985 = <types::Slot as Decode>::decode(r)?;
SetCreativeSlot {
slot: v984,
item: v985,
}
})
}
}
impl Encode for SetCreativeSlot {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetCreativeSlot {
fn generate(g: &mut Gen) -> Self {
{
let v986 = (g.int_in(-32768, 32767, &[]) as i16);
let v987 = <types::Slot as Generate>::generate(g);
SetCreativeSlot {
slot: v986,
item: v987,
}
}
}
}
impl From<SetCreativeSlot> for ServerboundPlayPacket {
fn from(p: SetCreativeSlot) -> Self {
Self::SetCreativeSlot(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EnchantItem {
pub window_id: i8,
pub enchantment: i8,
}
impl crate::packet::Packet for EnchantItem {
const ID: i32 = id::ENCHANT_ITEM;
const NAME: &'static str = "enchant_item";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for EnchantItem {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v988 = r.read_i8()?;
let v989 = r.read_i8()?;
EnchantItem {
window_id: v988,
enchantment: v989,
}
})
}
}
impl Encode for EnchantItem {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_i8((*self).enchantment);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EnchantItem {
fn generate(g: &mut Gen) -> Self {
{
let v990 = (g.int_in(-128, 127, &[]) as i8);
let v991 = (g.int_in(-128, 127, &[]) as i8);
EnchantItem {
window_id: v990,
enchantment: v991,
}
}
}
}
impl From<EnchantItem> for ServerboundPlayPacket {
fn from(p: EnchantItem) -> Self {
Self::EnchantItem(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateSign {
pub location: BlockPos,
pub text1: ByteString,
pub text2: ByteString,
pub text3: ByteString,
pub text4: ByteString,
}
impl crate::packet::Packet for UpdateSign {
const ID: i32 = id::UPDATE_SIGN;
const NAME: &'static str = "update_sign";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for UpdateSign {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v992 = BlockPos::read(r, PositionLayout::Xyz)?;
let v993 = r.read_string()?;
let v994 = r.read_string()?;
let v995 = r.read_string()?;
let v996 = r.read_string()?;
UpdateSign {
location: v992,
text1: v993,
text2: v994,
text3: v995,
text4: v996,
}
})
}
}
impl Encode for UpdateSign {
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(feature = "testgen")]
impl Generate for UpdateSign {
fn generate(g: &mut Gen) -> Self {
{
let v997 = g.position();
let v998 = g.string();
let v999 = g.string();
let v1000 = g.string();
let v1001 = g.string();
UpdateSign {
location: v997,
text1: v998,
text2: v999,
text3: v1000,
text4: v1001,
}
}
}
}
impl From<UpdateSign> for ServerboundPlayPacket {
fn from(p: UpdateSign) -> Self {
Self::UpdateSign(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Abilities {
pub flags: i8,
pub flying_speed: f32,
pub walking_speed: f32,
}
impl crate::packet::Packet for Abilities {
const ID: i32 = id::ABILITIES;
const NAME: &'static str = "abilities";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Abilities {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1002 = r.read_i8()?;
let v1003 = r.read_f32()?;
let v1004 = r.read_f32()?;
Abilities {
flags: v1002,
flying_speed: v1003,
walking_speed: v1004,
}
})
}
}
impl Encode for Abilities {
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(feature = "testgen")]
impl Generate for Abilities {
fn generate(g: &mut Gen) -> Self {
{
let v1005 = (g.int_in(-128, 127, &[]) as i8);
let v1006 = g.f32();
let v1007 = g.f32();
Abilities {
flags: v1005,
flying_speed: v1006,
walking_speed: v1007,
}
}
}
}
impl From<Abilities> for ServerboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete {
pub text: ByteString,
pub block: Option<BlockPos>,
}
impl crate::packet::Packet for TabComplete {
const ID: i32 = id::TAB_COMPLETE;
const NAME: &'static str = "tab_complete";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for TabComplete {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1008 = r.read_string()?;
let v1009 = if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
};
TabComplete {
text: v1008,
block: v1009,
}
})
}
}
impl Encode for TabComplete {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).text)?;
match &(*self).block {
Some(v1010) => {
w.put_u8(1);
(*v1010).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TabComplete {
fn generate(g: &mut Gen) -> Self {
{
let v1011 = g.string();
let v1012 = if g.bool() { Some(g.position()) } else { None };
TabComplete {
text: v1011,
block: v1012,
}
}
}
}
impl From<TabComplete> for ServerboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Settings {
pub locale: ByteString,
pub view_distance: i8,
pub chat_flags: i8,
pub chat_colors: bool,
pub skin_parts: u8,
}
impl crate::packet::Packet for Settings {
const ID: i32 = id::SETTINGS;
const NAME: &'static str = "settings";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Settings {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1013 = r.read_string()?;
let v1014 = r.read_i8()?;
let v1015 = r.read_i8()?;
let v1016 = r.read_bool()?;
let v1017 = r.read_u8()?;
Settings {
locale: v1013,
view_distance: v1014,
chat_flags: v1015,
chat_colors: v1016,
skin_parts: v1017,
}
})
}
}
impl Encode for Settings {
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 = "testgen")]
impl Generate for Settings {
fn generate(g: &mut Gen) -> Self {
{
let v1018 = g.string();
let v1019 = (g.int_in(-128, 127, &[]) as i8);
let v1020 = (g.int_in(-128, 127, &[]) as i8);
let v1021 = g.bool();
let v1022 = (g.int_in(0, 255, &[]) as u8);
Settings {
locale: v1018,
view_distance: v1019,
chat_flags: v1020,
chat_colors: v1021,
skin_parts: v1022,
}
}
}
}
impl From<Settings> for ServerboundPlayPacket {
fn from(p: Settings) -> Self {
Self::Settings(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ClientCommand {
pub payload: ClientCommandPayload,
}
impl crate::packet::Packet for ClientCommand {
const ID: i32 = id::CLIENT_COMMAND;
const NAME: &'static str = "client_command";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for ClientCommand {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1023 = ClientCommandPayload(r.read_varint()?);
ClientCommand { payload: v1023 }
})
}
}
impl Encode for ClientCommand {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).payload.0);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ClientCommand {
fn generate(g: &mut Gen) -> Self {
{
let v1024 = ClientCommandPayload(g.int_in(-2147483648, 2147483647, &[0, 1, 2]) as i32);
ClientCommand { payload: v1024 }
}
}
}
impl From<ClientCommand> for ServerboundPlayPacket {
fn from(p: ClientCommand) -> Self {
Self::ClientCommand(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CustomPayload {
pub channel: ByteString,
pub data: Bytes,
}
impl crate::packet::Packet for CustomPayload {
const ID: i32 = id::CUSTOM_PAYLOAD;
const NAME: &'static str = "custom_payload";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for CustomPayload {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1025 = r.read_string()?;
let v1026 = r.read_rest();
CustomPayload {
channel: v1025,
data: v1026,
}
})
}
}
impl Encode for CustomPayload {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).channel)?;
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CustomPayload {
fn generate(g: &mut Gen) -> Self {
{
let v1027 = g.string();
let v1028 = g.bytes();
CustomPayload {
channel: v1027,
data: v1028,
}
}
}
}
impl From<CustomPayload> for ServerboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Spectate {
pub target: Uuid,
}
impl crate::packet::Packet for Spectate {
const ID: i32 = id::SPECTATE;
const NAME: &'static str = "spectate";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for Spectate {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1029 = r.read_uuid()?;
Spectate { target: v1029 }
})
}
}
impl Encode for Spectate {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).target);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Spectate {
fn generate(g: &mut Gen) -> Self {
{
let v1030 = g.uuid();
Spectate { target: v1030 }
}
}
}
impl From<Spectate> for ServerboundPlayPacket {
fn from(p: Spectate) -> Self {
Self::Spectate(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackReceive {
pub hash: ByteString,
pub result: i32,
}
impl crate::packet::Packet for ResourcePackReceive {
const ID: i32 = id::RESOURCE_PACK_RECEIVE;
const NAME: &'static str = "resource_pack_receive";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for ResourcePackReceive {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1031 = r.read_string()?;
let v1032 = r.read_varint()?;
ResourcePackReceive {
hash: v1031,
result: v1032,
}
})
}
}
impl Encode for ResourcePackReceive {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).hash)?;
w.put_varint((*self).result);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ResourcePackReceive {
fn generate(g: &mut Gen) -> Self {
{
let v1033 = g.string();
let v1034 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
ResourcePackReceive {
hash: v1033,
result: v1034,
}
}
}
}
impl From<ResourcePackReceive> for ServerboundPlayPacket {
fn from(p: ResourcePackReceive) -> Self {
Self::ResourcePackReceive(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ServerboundPlayPacket {
KeepAlive(KeepAlive),
Chat(Chat),
UseEntity(UseEntity),
Flying(Flying),
Position(Position),
Look(Look),
PositionLook(PositionLook),
BlockDig(BlockDig),
BlockPlace(BlockPlace),
HeldItemSlot(HeldItemSlot),
ArmAnimation(ArmAnimation),
EntityAction(EntityAction),
SteerVehicle(SteerVehicle),
CloseWindow(CloseWindow),
WindowClick(WindowClick),
Transaction(Transaction),
SetCreativeSlot(SetCreativeSlot),
EnchantItem(EnchantItem),
UpdateSign(UpdateSign),
Abilities(Abilities),
TabComplete(TabComplete),
Settings(Settings),
ClientCommand(ClientCommand),
CustomPayload(CustomPayload),
Spectate(Spectate),
ResourcePackReceive(ResourcePackReceive),
}
impl PacketSet for ServerboundPlayPacket {
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
match raw.id {
id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
id::FLYING => decode_exact(&raw.body).map(Self::Flying),
id::POSITION => decode_exact(&raw.body).map(Self::Position),
id::LOOK => decode_exact(&raw.body).map(Self::Look),
id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::Chat(_) => id::CHAT,
Self::UseEntity(_) => id::USE_ENTITY,
Self::Flying(_) => id::FLYING,
Self::Position(_) => id::POSITION,
Self::Look(_) => id::LOOK,
Self::PositionLook(_) => id::POSITION_LOOK,
Self::BlockDig(_) => id::BLOCK_DIG,
Self::BlockPlace(_) => id::BLOCK_PLACE,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
Self::ArmAnimation(_) => id::ARM_ANIMATION,
Self::EntityAction(_) => id::ENTITY_ACTION,
Self::SteerVehicle(_) => id::STEER_VEHICLE,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::WindowClick(_) => id::WINDOW_CLICK,
Self::Transaction(_) => id::TRANSACTION,
Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
Self::EnchantItem(_) => id::ENCHANT_ITEM,
Self::UpdateSign(_) => id::UPDATE_SIGN,
Self::Abilities(_) => id::ABILITIES,
Self::TabComplete(_) => id::TAB_COMPLETE,
Self::Settings(_) => id::SETTINGS,
Self::ClientCommand(_) => id::CLIENT_COMMAND,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::Spectate(_) => id::SPECTATE,
Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
}
}
fn name(&self) -> &'static str {
match *self {
Self::KeepAlive(_) => "keep_alive",
Self::Chat(_) => "chat",
Self::UseEntity(_) => "use_entity",
Self::Flying(_) => "flying",
Self::Position(_) => "position",
Self::Look(_) => "look",
Self::PositionLook(_) => "position_look",
Self::BlockDig(_) => "block_dig",
Self::BlockPlace(_) => "block_place",
Self::HeldItemSlot(_) => "held_item_slot",
Self::ArmAnimation(_) => "arm_animation",
Self::EntityAction(_) => "entity_action",
Self::SteerVehicle(_) => "steer_vehicle",
Self::CloseWindow(_) => "close_window",
Self::WindowClick(_) => "window_click",
Self::Transaction(_) => "transaction",
Self::SetCreativeSlot(_) => "set_creative_slot",
Self::EnchantItem(_) => "enchant_item",
Self::UpdateSign(_) => "update_sign",
Self::Abilities(_) => "abilities",
Self::TabComplete(_) => "tab_complete",
Self::Settings(_) => "settings",
Self::ClientCommand(_) => "client_command",
Self::CustomPayload(_) => "custom_payload",
Self::Spectate(_) => "spectate",
Self::ResourcePackReceive(_) => "resource_pack_receive",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::KeepAlive(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::UseEntity(ref p) => p.encode(w),
Self::Flying(ref p) => p.encode(w),
Self::Position(ref p) => p.encode(w),
Self::Look(ref p) => p.encode(w),
Self::PositionLook(ref p) => p.encode(w),
Self::BlockDig(ref p) => p.encode(w),
Self::BlockPlace(ref p) => p.encode(w),
Self::HeldItemSlot(ref p) => p.encode(w),
Self::ArmAnimation(ref p) => p.encode(w),
Self::EntityAction(ref p) => p.encode(w),
Self::SteerVehicle(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::WindowClick(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::SetCreativeSlot(ref p) => p.encode(w),
Self::EnchantItem(ref p) => p.encode(w),
Self::UpdateSign(ref p) => p.encode(w),
Self::Abilities(ref p) => p.encode(w),
Self::TabComplete(ref p) => p.encode(w),
Self::Settings(ref p) => p.encode(w),
Self::ClientCommand(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::Spectate(ref p) => p.encode(w),
Self::ResourcePackReceive(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::KEEP_ALIVE => Some("keep_alive"),
id::CHAT => Some("chat"),
id::USE_ENTITY => Some("use_entity"),
id::FLYING => Some("flying"),
id::POSITION => Some("position"),
id::LOOK => Some("look"),
id::POSITION_LOOK => Some("position_look"),
id::BLOCK_DIG => Some("block_dig"),
id::BLOCK_PLACE => Some("block_place"),
id::HELD_ITEM_SLOT => Some("held_item_slot"),
id::ARM_ANIMATION => Some("arm_animation"),
id::ENTITY_ACTION => Some("entity_action"),
id::STEER_VEHICLE => Some("steer_vehicle"),
id::CLOSE_WINDOW => Some("close_window"),
id::WINDOW_CLICK => Some("window_click"),
id::TRANSACTION => Some("transaction"),
id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
id::ENCHANT_ITEM => Some("enchant_item"),
id::UPDATE_SIGN => Some("update_sign"),
id::ABILITIES => Some("abilities"),
id::TAB_COMPLETE => Some("tab_complete"),
id::SETTINGS => Some("settings"),
id::CLIENT_COMMAND => Some("client_command"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::SPECTATE => Some("spectate"),
id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
_ => None,
}
}
}
impl ServerboundPlayPacket {
pub const IDS: &'static [i32] = &[
id::KEEP_ALIVE,
id::CHAT,
id::USE_ENTITY,
id::FLYING,
id::POSITION,
id::LOOK,
id::POSITION_LOOK,
id::BLOCK_DIG,
id::BLOCK_PLACE,
id::HELD_ITEM_SLOT,
id::ARM_ANIMATION,
id::ENTITY_ACTION,
id::STEER_VEHICLE,
id::CLOSE_WINDOW,
id::WINDOW_CLICK,
id::TRANSACTION,
id::SET_CREATIVE_SLOT,
id::ENCHANT_ITEM,
id::UPDATE_SIGN,
id::ABILITIES,
id::TAB_COMPLETE,
id::SETTINGS,
id::CLIENT_COMMAND,
id::CUSTOM_PAYLOAD,
id::SPECTATE,
id::RESOURCE_PACK_RECEIVE,
];
#[cfg(feature = "testgen")]
pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
match id {
id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
id::FLYING => Some(Self::Flying(<Flying as Generate>::generate(g))),
id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
id::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig as Generate>::generate(g))),
id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
id::ENTITY_ACTION => Some(Self::EntityAction(<EntityAction as Generate>::generate(g))),
id::STEER_VEHICLE => Some(Self::SteerVehicle(<SteerVehicle as Generate>::generate(g))),
id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
<SetCreativeSlot as Generate>::generate(g),
)),
id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
g,
))),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
<ResourcePackReceive as Generate>::generate(g),
)),
_ => None,
}
}
}