#![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_12_2::types;
use bytes::{BufMut, Bytes, BytesMut};
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct ClientCommandActionId(pub i32);
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,
}
}
}
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),
}
}
}
#[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 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,
}
}
}
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(Debug, Clone, PartialEq)]
pub struct CraftingBookDataBodyCase0 {
pub displayed_recipe: i32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct CraftingBookDataBodyCase1 {
pub crafting_book_open: bool,
pub crafting_filter: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CraftingBookDataBody {
Case0(CraftingBookDataBodyCase0),
Case1(CraftingBookDataBodyCase1),
Other,
}
pub mod id {
pub const TELEPORT_CONFIRM: i32 = 0x00;
pub const TAB_COMPLETE: i32 = 0x01;
pub const CHAT: i32 = 0x02;
pub const CLIENT_COMMAND: i32 = 0x03;
pub const SETTINGS: i32 = 0x04;
pub const TRANSACTION: i32 = 0x05;
pub const ENCHANT_ITEM: i32 = 0x06;
pub const WINDOW_CLICK: i32 = 0x07;
pub const CLOSE_WINDOW: i32 = 0x08;
pub const CUSTOM_PAYLOAD: i32 = 0x09;
pub const USE_ENTITY: i32 = 0x0a;
pub const KEEP_ALIVE: i32 = 0x0b;
pub const FLYING: i32 = 0x0c;
pub const POSITION: i32 = 0x0d;
pub const POSITION_LOOK: i32 = 0x0e;
pub const LOOK: i32 = 0x0f;
pub const VEHICLE_MOVE: i32 = 0x10;
pub const STEER_BOAT: i32 = 0x11;
pub const CRAFT_RECIPE_REQUEST: i32 = 0x12;
pub const ABILITIES: i32 = 0x13;
pub const BLOCK_DIG: i32 = 0x14;
pub const ENTITY_ACTION: i32 = 0x15;
pub const STEER_VEHICLE: i32 = 0x16;
pub const CRAFTING_BOOK_DATA: i32 = 0x17;
pub const RESOURCE_PACK_RECEIVE: i32 = 0x18;
pub const ADVANCEMENT_TAB: i32 = 0x19;
pub const HELD_ITEM_SLOT: i32 = 0x1a;
pub const SET_CREATIVE_SLOT: i32 = 0x1b;
pub const UPDATE_SIGN: i32 = 0x1c;
pub const ARM_ANIMATION: i32 = 0x1d;
pub const SPECTATE: i32 = 0x1e;
pub const BLOCK_PLACE: i32 = 0x1f;
pub const USE_ITEM: i32 = 0x20;
}
#[derive(Debug, Clone, PartialEq)]
pub struct TeleportConfirm {
pub teleport_id: i32,
}
impl crate::packet::Packet for TeleportConfirm {
const ID: i32 = id::TELEPORT_CONFIRM;
const NAME: &'static str = "teleport_confirm";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for TeleportConfirm {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1074 = r.read_varint()?;
TeleportConfirm { teleport_id: v1074 }
})
}
}
impl Encode for TeleportConfirm {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).teleport_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TeleportConfirm {
fn generate(g: &mut Gen) -> Self {
{
let v1075 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
TeleportConfirm { teleport_id: v1075 }
}
}
}
impl From<TeleportConfirm> for ServerboundPlayPacket {
fn from(p: TeleportConfirm) -> Self {
Self::TeleportConfirm(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete {
pub text: ByteString,
pub assume_command: bool,
pub looked_at_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 v1076 = r.read_string()?;
let v1077 = r.read_bool()?;
let v1078 = if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
};
TabComplete {
text: v1076,
assume_command: v1077,
looked_at_block: v1078,
}
})
}
}
impl Encode for TabComplete {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).text)?;
w.put_bool((*self).assume_command);
match &(*self).looked_at_block {
Some(v1079) => {
w.put_u8(1);
(*v1079).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TabComplete {
fn generate(g: &mut Gen) -> Self {
{
let v1080 = g.string();
let v1081 = g.bool();
let v1082 = if g.bool() { Some(g.position()) } else { None };
TabComplete {
text: v1080,
assume_command: v1081,
looked_at_block: v1082,
}
}
}
}
impl From<TabComplete> for ServerboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(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 v1083 = r.read_string()?;
Chat { message: v1083 }
})
}
}
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 v1084 = g.string();
Chat { message: v1084 }
}
}
}
impl From<Chat> for ServerboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ClientCommand {
pub action_id: ClientCommandActionId,
}
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 v1085 = ClientCommandActionId(r.read_varint()?);
ClientCommand { action_id: v1085 }
})
}
}
impl Encode for ClientCommand {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action_id.0);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ClientCommand {
fn generate(g: &mut Gen) -> Self {
{
let v1086 = ClientCommandActionId(g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
ClientCommand { action_id: v1086 }
}
}
}
impl From<ClientCommand> for ServerboundPlayPacket {
fn from(p: ClientCommand) -> Self {
Self::ClientCommand(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Settings {
pub locale: ByteString,
pub view_distance: i8,
pub chat_flags: i32,
pub chat_colors: bool,
pub skin_parts: u8,
pub main_hand: i32,
}
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 v1087 = r.read_string()?;
let v1088 = r.read_i8()?;
let v1089 = r.read_varint()?;
let v1090 = r.read_bool()?;
let v1091 = r.read_u8()?;
let v1092 = r.read_varint()?;
Settings {
locale: v1087,
view_distance: v1088,
chat_flags: v1089,
chat_colors: v1090,
skin_parts: v1091,
main_hand: v1092,
}
})
}
}
impl Encode for Settings {
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(feature = "testgen")]
impl Generate for Settings {
fn generate(g: &mut Gen) -> Self {
{
let v1093 = g.string();
let v1094 = (g.int_in(-128, 127, &[]) as i8);
let v1095 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1096 = g.bool();
let v1097 = (g.int_in(0, 255, &[]) as u8);
let v1098 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Settings {
locale: v1093,
view_distance: v1094,
chat_flags: v1095,
chat_colors: v1096,
skin_parts: v1097,
main_hand: v1098,
}
}
}
}
impl From<Settings> for ServerboundPlayPacket {
fn from(p: Settings) -> Self {
Self::Settings(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 v1099 = r.read_i8()?;
let v1100 = r.read_i16()?;
let v1101 = r.read_bool()?;
Transaction {
window_id: v1099,
action: v1100,
accepted: v1101,
}
})
}
}
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 v1102 = (g.int_in(-128, 127, &[]) as i8);
let v1103 = (g.int_in(-32768, 32767, &[]) as i16);
let v1104 = g.bool();
Transaction {
window_id: v1102,
action: v1103,
accepted: v1104,
}
}
}
}
impl From<Transaction> for ServerboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(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 v1105 = r.read_i8()?;
let v1106 = r.read_i8()?;
EnchantItem {
window_id: v1105,
enchantment: v1106,
}
})
}
}
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 v1107 = (g.int_in(-128, 127, &[]) as i8);
let v1108 = (g.int_in(-128, 127, &[]) as i8);
EnchantItem {
window_id: v1107,
enchantment: v1108,
}
}
}
}
impl From<EnchantItem> for ServerboundPlayPacket {
fn from(p: EnchantItem) -> Self {
Self::EnchantItem(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 v1109 = r.read_u8()?;
let v1110 = r.read_i16()?;
let v1111 = r.read_i8()?;
let v1112 = r.read_i16()?;
let v1113 = r.read_i8()?;
let v1114 = <types::Slot as Decode>::decode(r)?;
WindowClick {
window_id: v1109,
slot: v1110,
mouse_button: v1111,
action: v1112,
mode: v1113,
item: v1114,
}
})
}
}
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 v1115 = (g.int_in(0, 255, &[]) as u8);
let v1116 = (g.int_in(-32768, 32767, &[]) as i16);
let v1117 = (g.int_in(-128, 127, &[]) as i8);
let v1118 = (g.int_in(-32768, 32767, &[]) as i16);
let v1119 = (g.int_in(-128, 127, &[]) as i8);
let v1120 = <types::Slot as Generate>::generate(g);
WindowClick {
window_id: v1115,
slot: v1116,
mouse_button: v1117,
action: v1118,
mode: v1119,
item: v1120,
}
}
}
}
impl From<WindowClick> for ServerboundPlayPacket {
fn from(p: WindowClick) -> Self {
Self::WindowClick(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 v1121 = r.read_u8()?;
CloseWindow { window_id: v1121 }
})
}
}
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 v1122 = (g.int_in(0, 255, &[]) as u8);
CloseWindow { window_id: v1122 }
}
}
}
impl From<CloseWindow> for ServerboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(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 v1123 = r.read_string()?;
let v1124 = r.read_rest();
CustomPayload {
channel: v1123,
data: v1124,
}
})
}
}
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 v1125 = g.string();
let v1126 = g.bytes();
CustomPayload {
channel: v1125,
data: v1126,
}
}
}
}
impl From<CustomPayload> for ServerboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(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>,
pub hand: Option<i32>,
}
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 v1127 = r.read_varint()?;
let v1128 = r.read_varint()?;
let v1129 = if (v1128 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v1130 = if (v1128 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v1131 = if (v1128 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v1132 = if (v1128 == 0) || (v1128 == 2) {
Some(r.read_varint()?)
} else {
None
};
UseEntity {
target: v1127,
mouse: v1128,
x: v1129,
y: v1130,
z: v1131,
hand: v1132,
}
})
}
}
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(v1133), true) => {
w.put_f32((*v1133));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.x")),
}
match (&(*self).y, ((*self).mouse == 2)) {
(Some(v1134), true) => {
w.put_f32((*v1134));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.y")),
}
match (&(*self).z, ((*self).mouse == 2)) {
(Some(v1135), true) => {
w.put_f32((*v1135));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.serverbound.use_entity.z")),
}
match (&(*self).hand, ((*self).mouse == 0) || ((*self).mouse == 2)) {
(Some(v1136), true) => {
w.put_varint((*v1136));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.use_entity.hand",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UseEntity {
fn generate(g: &mut Gen) -> Self {
{
let v1137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1138 = (g.int_in(-2147483648, 2147483647, &[2, 2, 2, 0, 2]) as i32);
let v1139 = if (v1138 == 2) { Some(g.f32()) } else { None };
let v1140 = if (v1138 == 2) { Some(g.f32()) } else { None };
let v1141 = if (v1138 == 2) { Some(g.f32()) } else { None };
let v1142 = if (v1138 == 0) || (v1138 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
UseEntity {
target: v1137,
mouse: v1138,
x: v1139,
y: v1140,
z: v1141,
hand: v1142,
}
}
}
}
impl From<UseEntity> for ServerboundPlayPacket {
fn from(p: UseEntity) -> Self {
Self::UseEntity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive {
pub keep_alive_id: i64,
}
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 v1143 = r.read_i64()?;
KeepAlive {
keep_alive_id: v1143,
}
})
}
}
impl Encode for KeepAlive {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).keep_alive_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for KeepAlive {
fn generate(g: &mut Gen) -> Self {
{
let v1144 = g.i64();
KeepAlive {
keep_alive_id: v1144,
}
}
}
}
impl From<KeepAlive> for ServerboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(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 v1145 = r.read_bool()?;
Flying { on_ground: v1145 }
})
}
}
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 v1146 = g.bool();
Flying { on_ground: v1146 }
}
}
}
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 v1147 = r.read_f64()?;
let v1148 = r.read_f64()?;
let v1149 = r.read_f64()?;
let v1150 = r.read_bool()?;
Position {
x: v1147,
y: v1148,
z: v1149,
on_ground: v1150,
}
})
}
}
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 v1151 = g.f64();
let v1152 = g.f64();
let v1153 = g.f64();
let v1154 = g.bool();
Position {
x: v1151,
y: v1152,
z: v1153,
on_ground: v1154,
}
}
}
}
impl From<Position> for ServerboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(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 v1155 = r.read_f64()?;
let v1156 = r.read_f64()?;
let v1157 = r.read_f64()?;
let v1158 = r.read_f32()?;
let v1159 = r.read_f32()?;
let v1160 = r.read_bool()?;
PositionLook {
x: v1155,
y: v1156,
z: v1157,
yaw: v1158,
pitch: v1159,
on_ground: v1160,
}
})
}
}
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 v1161 = g.f64();
let v1162 = g.f64();
let v1163 = g.f64();
let v1164 = g.f32();
let v1165 = g.f32();
let v1166 = g.bool();
PositionLook {
x: v1161,
y: v1162,
z: v1163,
yaw: v1164,
pitch: v1165,
on_ground: v1166,
}
}
}
}
impl From<PositionLook> for ServerboundPlayPacket {
fn from(p: PositionLook) -> Self {
Self::PositionLook(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 v1167 = r.read_f32()?;
let v1168 = r.read_f32()?;
let v1169 = r.read_bool()?;
Look {
yaw: v1167,
pitch: v1168,
on_ground: v1169,
}
})
}
}
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 v1170 = g.f32();
let v1171 = g.f32();
let v1172 = g.bool();
Look {
yaw: v1170,
pitch: v1171,
on_ground: v1172,
}
}
}
}
impl From<Look> for ServerboundPlayPacket {
fn from(p: Look) -> Self {
Self::Look(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct VehicleMove {
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
}
impl crate::packet::Packet for VehicleMove {
const ID: i32 = id::VEHICLE_MOVE;
const NAME: &'static str = "vehicle_move";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for VehicleMove {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1173 = r.read_f64()?;
let v1174 = r.read_f64()?;
let v1175 = r.read_f64()?;
let v1176 = r.read_f32()?;
let v1177 = r.read_f32()?;
VehicleMove {
x: v1173,
y: v1174,
z: v1175,
yaw: v1176,
pitch: v1177,
}
})
}
}
impl Encode for VehicleMove {
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(feature = "testgen")]
impl Generate for VehicleMove {
fn generate(g: &mut Gen) -> Self {
{
let v1178 = g.f64();
let v1179 = g.f64();
let v1180 = g.f64();
let v1181 = g.f32();
let v1182 = g.f32();
VehicleMove {
x: v1178,
y: v1179,
z: v1180,
yaw: v1181,
pitch: v1182,
}
}
}
}
impl From<VehicleMove> for ServerboundPlayPacket {
fn from(p: VehicleMove) -> Self {
Self::VehicleMove(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SteerBoat {
pub left_paddle: bool,
pub right_paddle: bool,
}
impl crate::packet::Packet for SteerBoat {
const ID: i32 = id::STEER_BOAT;
const NAME: &'static str = "steer_boat";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for SteerBoat {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1183 = r.read_bool()?;
let v1184 = r.read_bool()?;
SteerBoat {
left_paddle: v1183,
right_paddle: v1184,
}
})
}
}
impl Encode for SteerBoat {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).left_paddle);
w.put_bool((*self).right_paddle);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SteerBoat {
fn generate(g: &mut Gen) -> Self {
{
let v1185 = g.bool();
let v1186 = g.bool();
SteerBoat {
left_paddle: v1185,
right_paddle: v1186,
}
}
}
}
impl From<SteerBoat> for ServerboundPlayPacket {
fn from(p: SteerBoat) -> Self {
Self::SteerBoat(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeRequest {
pub window_id: i8,
pub recipe: i32,
pub make_all: bool,
}
impl crate::packet::Packet for CraftRecipeRequest {
const ID: i32 = id::CRAFT_RECIPE_REQUEST;
const NAME: &'static str = "craft_recipe_request";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for CraftRecipeRequest {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1187 = r.read_i8()?;
let v1188 = r.read_varint()?;
let v1189 = r.read_bool()?;
CraftRecipeRequest {
window_id: v1187,
recipe: v1188,
make_all: v1189,
}
})
}
}
impl Encode for CraftRecipeRequest {
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 = "testgen")]
impl Generate for CraftRecipeRequest {
fn generate(g: &mut Gen) -> Self {
{
let v1190 = (g.int_in(-128, 127, &[]) as i8);
let v1191 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1192 = g.bool();
CraftRecipeRequest {
window_id: v1190,
recipe: v1191,
make_all: v1192,
}
}
}
}
impl From<CraftRecipeRequest> for ServerboundPlayPacket {
fn from(p: CraftRecipeRequest) -> Self {
Self::CraftRecipeRequest(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 v1193 = r.read_i8()?;
let v1194 = r.read_f32()?;
let v1195 = r.read_f32()?;
Abilities {
flags: v1193,
flying_speed: v1194,
walking_speed: v1195,
}
})
}
}
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 v1196 = (g.int_in(-128, 127, &[]) as i8);
let v1197 = g.f32();
let v1198 = g.f32();
Abilities {
flags: v1196,
flying_speed: v1197,
walking_speed: v1198,
}
}
}
}
impl From<Abilities> for ServerboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(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 v1199 = r.read_varint()?;
let v1200 = BlockPos::read(r, PositionLayout::Xyz)?;
let v1201 = r.read_i8()?;
BlockDig {
status: v1199,
location: v1200,
face: v1201,
}
})
}
}
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 v1202 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1203 = g.position();
let v1204 = (g.int_in(-128, 127, &[]) as i8);
BlockDig {
status: v1202,
location: v1203,
face: v1204,
}
}
}
}
impl From<BlockDig> for ServerboundPlayPacket {
fn from(p: BlockDig) -> Self {
Self::BlockDig(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 v1205 = r.read_varint()?;
let v1206 = EntityActionActionId(r.read_varint()?);
let v1207 = r.read_varint()?;
EntityAction {
entity_id: v1205,
action_id: v1206,
jump_boost: v1207,
}
})
}
}
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 v1208 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1209 =
EntityActionActionId(
g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4, 5, 6, 7, 8]) as i32,
);
let v1210 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
EntityAction {
entity_id: v1208,
action_id: v1209,
jump_boost: v1210,
}
}
}
}
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 v1211 = r.read_f32()?;
let v1212 = r.read_f32()?;
let v1213 = r.read_u8()?;
SteerVehicle {
sideways: v1211,
forward: v1212,
jump: v1213,
}
})
}
}
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 v1214 = g.f32();
let v1215 = g.f32();
let v1216 = (g.int_in(0, 255, &[]) as u8);
SteerVehicle {
sideways: v1214,
forward: v1215,
jump: v1216,
}
}
}
}
impl From<SteerVehicle> for ServerboundPlayPacket {
fn from(p: SteerVehicle) -> Self {
Self::SteerVehicle(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CraftingBookData {
pub r#type: i32,
pub body: CraftingBookDataBody,
}
impl crate::packet::Packet for CraftingBookData {
const ID: i32 = id::CRAFTING_BOOK_DATA;
const NAME: &'static str = "crafting_book_data";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for CraftingBookData {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1217 = r.read_varint()?;
let v1218 = (if (v1217 == 0) {
CraftingBookDataBody::Case0({
let v1219 = r.read_i32()?;
CraftingBookDataBodyCase0 {
displayed_recipe: v1219,
}
})
} else if (v1217 == 1) {
CraftingBookDataBody::Case1({
let v1220 = r.read_bool()?;
let v1221 = r.read_bool()?;
CraftingBookDataBodyCase1 {
crafting_book_open: v1220,
crafting_filter: v1221,
}
})
} else {
CraftingBookDataBody::Other
});
CraftingBookData {
r#type: v1217,
body: v1218,
}
})
}
}
impl Encode for CraftingBookData {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).r#type);
match &(*self).body {
CraftingBookDataBody::Case0(v1222) => {
if !((*self).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
w.put_i32((*v1222).displayed_recipe);
}
CraftingBookDataBody::Case1(v1223) => {
if !((*self).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
w.put_bool((*v1223).crafting_book_open);
w.put_bool((*v1223).crafting_filter);
}
CraftingBookDataBody::Other => {
if !(!(((*self).r#type == 0) || ((*self).r#type == 1))) {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.crafting_book_data.body",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CraftingBookData {
fn generate(g: &mut Gen) -> Self {
{
let v1224 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
let v1225 = (if (v1224 == 0) {
CraftingBookDataBody::Case0({
let v1226 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
CraftingBookDataBodyCase0 {
displayed_recipe: v1226,
}
})
} else if (v1224 == 1) {
CraftingBookDataBody::Case1({
let v1227 = g.bool();
let v1228 = g.bool();
CraftingBookDataBodyCase1 {
crafting_book_open: v1227,
crafting_filter: v1228,
}
})
} else {
CraftingBookDataBody::Other
});
CraftingBookData {
r#type: v1224,
body: v1225,
}
}
}
}
impl From<CraftingBookData> for ServerboundPlayPacket {
fn from(p: CraftingBookData) -> Self {
Self::CraftingBookData(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackReceive {
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 v1229 = r.read_varint()?;
ResourcePackReceive { result: v1229 }
})
}
}
impl Encode for ResourcePackReceive {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).result);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ResourcePackReceive {
fn generate(g: &mut Gen) -> Self {
{
let v1230 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
ResourcePackReceive { result: v1230 }
}
}
}
impl From<ResourcePackReceive> for ServerboundPlayPacket {
fn from(p: ResourcePackReceive) -> Self {
Self::ResourcePackReceive(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementTab {
pub action: i32,
pub tab_id: Option<ByteString>,
}
impl crate::packet::Packet for AdvancementTab {
const ID: i32 = id::ADVANCEMENT_TAB;
const NAME: &'static str = "advancement_tab";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for AdvancementTab {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1231 = r.read_varint()?;
let v1232 = if (v1231 == 0) {
Some(r.read_string()?)
} else {
None
};
AdvancementTab {
action: v1231,
tab_id: v1232,
}
})
}
}
impl Encode for AdvancementTab {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (&(*self).tab_id, ((*self).action == 0)) {
(Some(v1233), true) => {
w.put_string(&(*v1233))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.serverbound.advancement_tab.tabId",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for AdvancementTab {
fn generate(g: &mut Gen) -> Self {
{
let v1234 = (g.int_in(-2147483648, 2147483647, &[0, 1]) as i32);
let v1235 = if (v1234 == 0) { Some(g.string()) } else { None };
AdvancementTab {
action: v1234,
tab_id: v1235,
}
}
}
}
impl From<AdvancementTab> for ServerboundPlayPacket {
fn from(p: AdvancementTab) -> Self {
Self::AdvancementTab(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 v1236 = r.read_i16()?;
HeldItemSlot { slot_id: v1236 }
})
}
}
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 v1237 = (g.int_in(-32768, 32767, &[]) as i16);
HeldItemSlot { slot_id: v1237 }
}
}
}
impl From<HeldItemSlot> for ServerboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(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 v1238 = r.read_i16()?;
let v1239 = <types::Slot as Decode>::decode(r)?;
SetCreativeSlot {
slot: v1238,
item: v1239,
}
})
}
}
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 v1240 = (g.int_in(-32768, 32767, &[]) as i16);
let v1241 = <types::Slot as Generate>::generate(g);
SetCreativeSlot {
slot: v1240,
item: v1241,
}
}
}
}
impl From<SetCreativeSlot> for ServerboundPlayPacket {
fn from(p: SetCreativeSlot) -> Self {
Self::SetCreativeSlot(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 v1242 = BlockPos::read(r, PositionLayout::Xyz)?;
let v1243 = r.read_string()?;
let v1244 = r.read_string()?;
let v1245 = r.read_string()?;
let v1246 = r.read_string()?;
UpdateSign {
location: v1242,
text1: v1243,
text2: v1244,
text3: v1245,
text4: v1246,
}
})
}
}
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 v1247 = g.position();
let v1248 = g.string();
let v1249 = g.string();
let v1250 = g.string();
let v1251 = g.string();
UpdateSign {
location: v1247,
text1: v1248,
text2: v1249,
text3: v1250,
text4: v1251,
}
}
}
}
impl From<UpdateSign> for ServerboundPlayPacket {
fn from(p: UpdateSign) -> Self {
Self::UpdateSign(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ArmAnimation {
pub hand: i32,
}
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({
let v1252 = r.read_varint()?;
ArmAnimation { hand: v1252 }
})
}
}
impl Encode for ArmAnimation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ArmAnimation {
fn generate(g: &mut Gen) -> Self {
{
let v1253 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
ArmAnimation { hand: v1253 }
}
}
}
impl From<ArmAnimation> for ServerboundPlayPacket {
fn from(p: ArmAnimation) -> Self {
Self::ArmAnimation(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 v1254 = r.read_uuid()?;
Spectate { target: v1254 }
})
}
}
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 v1255 = g.uuid();
Spectate { target: v1255 }
}
}
}
impl From<Spectate> for ServerboundPlayPacket {
fn from(p: Spectate) -> Self {
Self::Spectate(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockPlace {
pub location: BlockPos,
pub direction: i32,
pub hand: i32,
pub cursor_x: f32,
pub cursor_y: f32,
pub cursor_z: f32,
}
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 v1256 = BlockPos::read(r, PositionLayout::Xyz)?;
let v1257 = r.read_varint()?;
let v1258 = r.read_varint()?;
let v1259 = r.read_f32()?;
let v1260 = r.read_f32()?;
let v1261 = r.read_f32()?;
BlockPlace {
location: v1256,
direction: v1257,
hand: v1258,
cursor_x: v1259,
cursor_y: v1260,
cursor_z: v1261,
}
})
}
}
impl Encode for BlockPlace {
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 = "testgen")]
impl Generate for BlockPlace {
fn generate(g: &mut Gen) -> Self {
{
let v1262 = g.position();
let v1263 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1264 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1265 = g.f32();
let v1266 = g.f32();
let v1267 = g.f32();
BlockPlace {
location: v1262,
direction: v1263,
hand: v1264,
cursor_x: v1265,
cursor_y: v1266,
cursor_z: v1267,
}
}
}
}
impl From<BlockPlace> for ServerboundPlayPacket {
fn from(p: BlockPlace) -> Self {
Self::BlockPlace(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UseItem {
pub hand: i32,
}
impl crate::packet::Packet for UseItem {
const ID: i32 = id::USE_ITEM;
const NAME: &'static str = "use_item";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Serverbound;
}
impl Decode for UseItem {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1268 = r.read_varint()?;
UseItem { hand: v1268 }
})
}
}
impl Encode for UseItem {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UseItem {
fn generate(g: &mut Gen) -> Self {
{
let v1269 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
UseItem { hand: v1269 }
}
}
}
impl From<UseItem> for ServerboundPlayPacket {
fn from(p: UseItem) -> Self {
Self::UseItem(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ServerboundPlayPacket {
TeleportConfirm(TeleportConfirm),
TabComplete(TabComplete),
Chat(Chat),
ClientCommand(ClientCommand),
Settings(Settings),
Transaction(Transaction),
EnchantItem(EnchantItem),
WindowClick(WindowClick),
CloseWindow(CloseWindow),
CustomPayload(CustomPayload),
UseEntity(UseEntity),
KeepAlive(KeepAlive),
Flying(Flying),
Position(Position),
PositionLook(PositionLook),
Look(Look),
VehicleMove(VehicleMove),
SteerBoat(SteerBoat),
CraftRecipeRequest(CraftRecipeRequest),
Abilities(Abilities),
BlockDig(BlockDig),
EntityAction(EntityAction),
SteerVehicle(SteerVehicle),
CraftingBookData(CraftingBookData),
ResourcePackReceive(ResourcePackReceive),
AdvancementTab(AdvancementTab),
HeldItemSlot(HeldItemSlot),
SetCreativeSlot(SetCreativeSlot),
UpdateSign(UpdateSign),
ArmAnimation(ArmAnimation),
Spectate(Spectate),
BlockPlace(BlockPlace),
UseItem(UseItem),
}
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::TELEPORT_CONFIRM => decode_exact(&raw.body).map(Self::TeleportConfirm),
id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::CLIENT_COMMAND => decode_exact(&raw.body).map(Self::ClientCommand),
id::SETTINGS => decode_exact(&raw.body).map(Self::Settings),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::ENCHANT_ITEM => decode_exact(&raw.body).map(Self::EnchantItem),
id::WINDOW_CLICK => decode_exact(&raw.body).map(Self::WindowClick),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::USE_ENTITY => decode_exact(&raw.body).map(Self::UseEntity),
id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::FLYING => decode_exact(&raw.body).map(Self::Flying),
id::POSITION => decode_exact(&raw.body).map(Self::Position),
id::POSITION_LOOK => decode_exact(&raw.body).map(Self::PositionLook),
id::LOOK => decode_exact(&raw.body).map(Self::Look),
id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
id::STEER_BOAT => decode_exact(&raw.body).map(Self::SteerBoat),
id::CRAFT_RECIPE_REQUEST => decode_exact(&raw.body).map(Self::CraftRecipeRequest),
id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
id::BLOCK_DIG => decode_exact(&raw.body).map(Self::BlockDig),
id::ENTITY_ACTION => decode_exact(&raw.body).map(Self::EntityAction),
id::STEER_VEHICLE => decode_exact(&raw.body).map(Self::SteerVehicle),
id::CRAFTING_BOOK_DATA => decode_exact(&raw.body).map(Self::CraftingBookData),
id::RESOURCE_PACK_RECEIVE => decode_exact(&raw.body).map(Self::ResourcePackReceive),
id::ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::AdvancementTab),
id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
id::SET_CREATIVE_SLOT => decode_exact(&raw.body).map(Self::SetCreativeSlot),
id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
id::ARM_ANIMATION => decode_exact(&raw.body).map(Self::ArmAnimation),
id::SPECTATE => decode_exact(&raw.body).map(Self::Spectate),
id::BLOCK_PLACE => decode_exact(&raw.body).map(Self::BlockPlace),
id::USE_ITEM => decode_exact(&raw.body).map(Self::UseItem),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::TeleportConfirm(_) => id::TELEPORT_CONFIRM,
Self::TabComplete(_) => id::TAB_COMPLETE,
Self::Chat(_) => id::CHAT,
Self::ClientCommand(_) => id::CLIENT_COMMAND,
Self::Settings(_) => id::SETTINGS,
Self::Transaction(_) => id::TRANSACTION,
Self::EnchantItem(_) => id::ENCHANT_ITEM,
Self::WindowClick(_) => id::WINDOW_CLICK,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::UseEntity(_) => id::USE_ENTITY,
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::Flying(_) => id::FLYING,
Self::Position(_) => id::POSITION,
Self::PositionLook(_) => id::POSITION_LOOK,
Self::Look(_) => id::LOOK,
Self::VehicleMove(_) => id::VEHICLE_MOVE,
Self::SteerBoat(_) => id::STEER_BOAT,
Self::CraftRecipeRequest(_) => id::CRAFT_RECIPE_REQUEST,
Self::Abilities(_) => id::ABILITIES,
Self::BlockDig(_) => id::BLOCK_DIG,
Self::EntityAction(_) => id::ENTITY_ACTION,
Self::SteerVehicle(_) => id::STEER_VEHICLE,
Self::CraftingBookData(_) => id::CRAFTING_BOOK_DATA,
Self::ResourcePackReceive(_) => id::RESOURCE_PACK_RECEIVE,
Self::AdvancementTab(_) => id::ADVANCEMENT_TAB,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
Self::SetCreativeSlot(_) => id::SET_CREATIVE_SLOT,
Self::UpdateSign(_) => id::UPDATE_SIGN,
Self::ArmAnimation(_) => id::ARM_ANIMATION,
Self::Spectate(_) => id::SPECTATE,
Self::BlockPlace(_) => id::BLOCK_PLACE,
Self::UseItem(_) => id::USE_ITEM,
}
}
fn name(&self) -> &'static str {
match *self {
Self::TeleportConfirm(_) => "teleport_confirm",
Self::TabComplete(_) => "tab_complete",
Self::Chat(_) => "chat",
Self::ClientCommand(_) => "client_command",
Self::Settings(_) => "settings",
Self::Transaction(_) => "transaction",
Self::EnchantItem(_) => "enchant_item",
Self::WindowClick(_) => "window_click",
Self::CloseWindow(_) => "close_window",
Self::CustomPayload(_) => "custom_payload",
Self::UseEntity(_) => "use_entity",
Self::KeepAlive(_) => "keep_alive",
Self::Flying(_) => "flying",
Self::Position(_) => "position",
Self::PositionLook(_) => "position_look",
Self::Look(_) => "look",
Self::VehicleMove(_) => "vehicle_move",
Self::SteerBoat(_) => "steer_boat",
Self::CraftRecipeRequest(_) => "craft_recipe_request",
Self::Abilities(_) => "abilities",
Self::BlockDig(_) => "block_dig",
Self::EntityAction(_) => "entity_action",
Self::SteerVehicle(_) => "steer_vehicle",
Self::CraftingBookData(_) => "crafting_book_data",
Self::ResourcePackReceive(_) => "resource_pack_receive",
Self::AdvancementTab(_) => "advancement_tab",
Self::HeldItemSlot(_) => "held_item_slot",
Self::SetCreativeSlot(_) => "set_creative_slot",
Self::UpdateSign(_) => "update_sign",
Self::ArmAnimation(_) => "arm_animation",
Self::Spectate(_) => "spectate",
Self::BlockPlace(_) => "block_place",
Self::UseItem(_) => "use_item",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::TeleportConfirm(ref p) => p.encode(w),
Self::TabComplete(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::ClientCommand(ref p) => p.encode(w),
Self::Settings(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::EnchantItem(ref p) => p.encode(w),
Self::WindowClick(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::UseEntity(ref p) => p.encode(w),
Self::KeepAlive(ref p) => p.encode(w),
Self::Flying(ref p) => p.encode(w),
Self::Position(ref p) => p.encode(w),
Self::PositionLook(ref p) => p.encode(w),
Self::Look(ref p) => p.encode(w),
Self::VehicleMove(ref p) => p.encode(w),
Self::SteerBoat(ref p) => p.encode(w),
Self::CraftRecipeRequest(ref p) => p.encode(w),
Self::Abilities(ref p) => p.encode(w),
Self::BlockDig(ref p) => p.encode(w),
Self::EntityAction(ref p) => p.encode(w),
Self::SteerVehicle(ref p) => p.encode(w),
Self::CraftingBookData(ref p) => p.encode(w),
Self::ResourcePackReceive(ref p) => p.encode(w),
Self::AdvancementTab(ref p) => p.encode(w),
Self::HeldItemSlot(ref p) => p.encode(w),
Self::SetCreativeSlot(ref p) => p.encode(w),
Self::UpdateSign(ref p) => p.encode(w),
Self::ArmAnimation(ref p) => p.encode(w),
Self::Spectate(ref p) => p.encode(w),
Self::BlockPlace(ref p) => p.encode(w),
Self::UseItem(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::TELEPORT_CONFIRM => Some("teleport_confirm"),
id::TAB_COMPLETE => Some("tab_complete"),
id::CHAT => Some("chat"),
id::CLIENT_COMMAND => Some("client_command"),
id::SETTINGS => Some("settings"),
id::TRANSACTION => Some("transaction"),
id::ENCHANT_ITEM => Some("enchant_item"),
id::WINDOW_CLICK => Some("window_click"),
id::CLOSE_WINDOW => Some("close_window"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::USE_ENTITY => Some("use_entity"),
id::KEEP_ALIVE => Some("keep_alive"),
id::FLYING => Some("flying"),
id::POSITION => Some("position"),
id::POSITION_LOOK => Some("position_look"),
id::LOOK => Some("look"),
id::VEHICLE_MOVE => Some("vehicle_move"),
id::STEER_BOAT => Some("steer_boat"),
id::CRAFT_RECIPE_REQUEST => Some("craft_recipe_request"),
id::ABILITIES => Some("abilities"),
id::BLOCK_DIG => Some("block_dig"),
id::ENTITY_ACTION => Some("entity_action"),
id::STEER_VEHICLE => Some("steer_vehicle"),
id::CRAFTING_BOOK_DATA => Some("crafting_book_data"),
id::RESOURCE_PACK_RECEIVE => Some("resource_pack_receive"),
id::ADVANCEMENT_TAB => Some("advancement_tab"),
id::HELD_ITEM_SLOT => Some("held_item_slot"),
id::SET_CREATIVE_SLOT => Some("set_creative_slot"),
id::UPDATE_SIGN => Some("update_sign"),
id::ARM_ANIMATION => Some("arm_animation"),
id::SPECTATE => Some("spectate"),
id::BLOCK_PLACE => Some("block_place"),
id::USE_ITEM => Some("use_item"),
_ => None,
}
}
}
impl ServerboundPlayPacket {
pub const IDS: &'static [i32] = &[
id::TELEPORT_CONFIRM,
id::TAB_COMPLETE,
id::CHAT,
id::CLIENT_COMMAND,
id::SETTINGS,
id::TRANSACTION,
id::ENCHANT_ITEM,
id::WINDOW_CLICK,
id::CLOSE_WINDOW,
id::CUSTOM_PAYLOAD,
id::USE_ENTITY,
id::KEEP_ALIVE,
id::FLYING,
id::POSITION,
id::POSITION_LOOK,
id::LOOK,
id::VEHICLE_MOVE,
id::STEER_BOAT,
id::CRAFT_RECIPE_REQUEST,
id::ABILITIES,
id::BLOCK_DIG,
id::ENTITY_ACTION,
id::STEER_VEHICLE,
id::CRAFTING_BOOK_DATA,
id::RESOURCE_PACK_RECEIVE,
id::ADVANCEMENT_TAB,
id::HELD_ITEM_SLOT,
id::SET_CREATIVE_SLOT,
id::UPDATE_SIGN,
id::ARM_ANIMATION,
id::SPECTATE,
id::BLOCK_PLACE,
id::USE_ITEM,
];
#[cfg(feature = "testgen")]
pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
match id {
id::TELEPORT_CONFIRM => Some(Self::TeleportConfirm(
<TeleportConfirm as Generate>::generate(g),
)),
id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::CLIENT_COMMAND => Some(Self::ClientCommand(<ClientCommand as Generate>::generate(
g,
))),
id::SETTINGS => Some(Self::Settings(<Settings as Generate>::generate(g))),
id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
id::ENCHANT_ITEM => Some(Self::EnchantItem(<EnchantItem as Generate>::generate(g))),
id::WINDOW_CLICK => Some(Self::WindowClick(<WindowClick as Generate>::generate(g))),
id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::USE_ENTITY => Some(Self::UseEntity(<UseEntity as Generate>::generate(g))),
id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive 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::POSITION_LOOK => Some(Self::PositionLook(<PositionLook as Generate>::generate(g))),
id::LOOK => Some(Self::Look(<Look as Generate>::generate(g))),
id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
id::STEER_BOAT => Some(Self::SteerBoat(<SteerBoat as Generate>::generate(g))),
id::CRAFT_RECIPE_REQUEST => Some(Self::CraftRecipeRequest(
<CraftRecipeRequest as Generate>::generate(g),
)),
id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
id::BLOCK_DIG => Some(Self::BlockDig(<BlockDig 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::CRAFTING_BOOK_DATA => Some(Self::CraftingBookData(
<CraftingBookData as Generate>::generate(g),
)),
id::RESOURCE_PACK_RECEIVE => Some(Self::ResourcePackReceive(
<ResourcePackReceive as Generate>::generate(g),
)),
id::ADVANCEMENT_TAB => Some(Self::AdvancementTab(
<AdvancementTab as Generate>::generate(g),
)),
id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
id::SET_CREATIVE_SLOT => Some(Self::SetCreativeSlot(
<SetCreativeSlot as Generate>::generate(g),
)),
id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
id::ARM_ANIMATION => Some(Self::ArmAnimation(<ArmAnimation as Generate>::generate(g))),
id::SPECTATE => Some(Self::Spectate(<Spectate as Generate>::generate(g))),
id::BLOCK_PLACE => Some(Self::BlockPlace(<BlockPlace as Generate>::generate(g))),
id::USE_ITEM => Some(Self::UseItem(<UseItem as Generate>::generate(g))),
_ => None,
}
}
}