#![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_16_5::types;
use bytes::{BufMut, Bytes, BytesMut};
#[derive(Debug, Clone, PartialEq)]
pub struct StatisticsEntries {
pub category_id: i32,
pub statistic_id: i32,
pub value: i32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct DifficultyDifficulty(pub u8);
impl DifficultyDifficulty {
pub const PEACEFUL: Self = Self(0);
pub const EASY: Self = Self(1);
pub const NORMAL: Self = Self(2);
pub const HARD: Self = Self(3);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("peaceful"),
1 => Some("easy"),
2 => Some("normal"),
3 => Some("hard"),
_ => None,
}
}
}
impl std::fmt::Debug for DifficultyDifficulty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "DifficultyDifficulty::{n}"),
None => write!(f, "DifficultyDifficulty({})", self.0),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TabCompleteMatches {
pub r#match: ByteString,
pub tooltip: Option<ByteString>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionAffectedBlockOffsets {
pub x: i8,
pub y: i8,
pub z: i8,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct GameStateChangeReason(pub u8);
impl GameStateChangeReason {
pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
pub const START_RAINING: Self = Self(1);
pub const STOP_RAINING: Self = Self(2);
pub const CHANGE_GAME_MODE: Self = Self(3);
pub const WIN_GAME: Self = Self(4);
pub const DEMO_EVENT: Self = Self(5);
pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
pub const RAIN_LEVEL_CHANGE: Self = Self(7);
pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
pub const PUFFER_FISH_STING: Self = Self(9);
pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
pub const IMMEDIATE_RESPAWN: Self = Self(11);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("no_respawn_block_available"),
1 => Some("start_raining"),
2 => Some("stop_raining"),
3 => Some("change_game_mode"),
4 => Some("win_game"),
5 => Some("demo_event"),
6 => Some("play_arrow_hit_sound"),
7 => Some("rain_level_change"),
8 => Some("thunder_level_change"),
9 => Some("puffer_fish_sting"),
10 => Some("guardian_elder_effect"),
11 => Some("immediate_respawn"),
_ => None,
}
}
}
impl std::fmt::Debug for GameStateChangeReason {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "GameStateChangeReason::{n}"),
None => write!(f, "GameStateChangeReason({})", self.0),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MapIcons {
pub r#type: i32,
pub x: i8,
pub z: i8,
pub direction: u8,
pub display_name: Option<ByteString>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TradeListTrades {
pub input_item1: types::Slot,
pub output_item: types::Slot,
pub input_item2: Option<types::Slot>,
pub trade_disabled: bool,
pub nb_trade_uses: i32,
pub maximum_nb_trade_uses: i32,
pub xp: i32,
pub special_price: i32,
pub price_multiplier: f32,
pub demand: i32,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct PlayerInfoAction(pub i32);
impl PlayerInfoAction {
pub const ADD_PLAYER: Self = Self(0);
pub const UPDATE_GAME_MODE: Self = Self(1);
pub const UPDATE_LATENCY: Self = Self(2);
pub const UPDATE_DISPLAY_NAME: Self = Self(3);
pub const REMOVE_PLAYER: Self = Self(4);
pub const fn name(self) -> Option<&'static str> {
match self.0 {
0 => Some("add_player"),
1 => Some("update_game_mode"),
2 => Some("update_latency"),
3 => Some("update_display_name"),
4 => Some("remove_player"),
_ => None,
}
}
}
impl std::fmt::Debug for PlayerInfoAction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.name() {
Some(n) => write!(f, "PlayerInfoAction::{n}"),
None => write!(f, "PlayerInfoAction({})", self.0),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyAddPlayerProperties {
pub name: ByteString,
pub value: ByteString,
pub signature: Option<ByteString>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyAddPlayer {
pub name: ByteString,
pub properties: Vec<PlayerInfoDataBodyAddPlayerProperties>,
pub gamemode: i32,
pub ping: i32,
pub display_name: Option<ByteString>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateGameMode {
pub gamemode: i32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateLatency {
pub ping: i32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateDisplayName {
pub display_name: Option<ByteString>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum PlayerInfoDataBody {
AddPlayer(PlayerInfoDataBodyAddPlayer),
UpdateGameMode(PlayerInfoDataBodyUpdateGameMode),
UpdateLatency(PlayerInfoDataBodyUpdateLatency),
UpdateDisplayName(PlayerInfoDataBodyUpdateDisplayName),
RemovePlayer,
Other,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoData {
pub uuid: Uuid,
pub body: PlayerInfoDataBody,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct MultiBlockChangeChunkCoordinates {
pub x: i32,
pub z: i32,
pub y: u32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipmentEquipments {
pub slot: i8,
pub item: types::Slot,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
pub _unused: u32,
pub hidden: u8,
pub show_toast: u8,
pub has_background_texture: u8,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
pub title: ByteString,
pub description: ByteString,
pub icon: types::Slot,
pub frame_type: i32,
pub flags: AdvancementsAdvancementMappingValueDisplayDataFlags,
pub background_texture: Option<ByteString>,
pub x_cord: f32,
pub y_cord: f32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueCriteria {
pub key: ByteString,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
pub parent_id: Option<ByteString>,
pub display_data: Option<AdvancementsAdvancementMappingValueDisplayData>,
pub criteria: Vec<AdvancementsAdvancementMappingValueCriteria>,
pub requirements: Vec<Vec<ByteString>>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
pub key: ByteString,
pub value: AdvancementsAdvancementMappingValue,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMappingValue {
pub criterion_identifier: ByteString,
pub criterion_progress: Option<i64>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMapping {
pub key: ByteString,
pub value: Vec<AdvancementsProgressMappingValue>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesPropertiesModifiers {
pub uuid: Uuid,
pub amount: f64,
pub operation: i8,
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesProperties {
pub key: ByteString,
pub value: f64,
pub modifiers: Vec<EntityUpdateAttributesPropertiesModifiers>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataCraftingShapeless {
pub group: ByteString,
pub ingredients: Vec<Vec<types::Slot>>,
pub result: types::Slot,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataCraftingShaped {
pub width: i32,
pub height: i32,
pub group: ByteString,
pub ingredients: Vec<Vec<Vec<types::Slot>>>,
pub result: types::Slot,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataStonecutting {
pub group: ByteString,
pub ingredient: Vec<types::Slot>,
pub result: types::Slot,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipesDataSmithing {
pub base: Vec<types::Slot>,
pub addition: Vec<types::Slot>,
pub result: types::Slot,
}
#[derive(Debug, Clone, PartialEq)]
pub enum DeclareRecipesRecipesData {
CraftingShapeless(DeclareRecipesRecipesDataCraftingShapeless),
CraftingShaped(DeclareRecipesRecipesDataCraftingShaped),
CraftingSpecialArmordye,
CraftingSpecialBookcloning,
CraftingSpecialMapcloning,
CraftingSpecialMapextending,
CraftingSpecialFireworkRocket,
CraftingSpecialFireworkStar,
CraftingSpecialFireworkStarFade,
CraftingSpecialRepairitem,
CraftingSpecialTippedarrow,
CraftingSpecialBannerduplicate,
CraftingSpecialBanneraddpattern,
CraftingSpecialShielddecoration,
CraftingSpecialShulkerboxcoloring,
CraftingSpecialSuspiciousstew,
Smelting(types::MinecraftSmeltingFormat),
Blasting(types::MinecraftSmeltingFormat),
Smoking(types::MinecraftSmeltingFormat),
CampfireCooking(types::MinecraftSmeltingFormat),
Stonecutting(DeclareRecipesRecipesDataStonecutting),
Smithing(DeclareRecipesRecipesDataSmithing),
Other,
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipesRecipes {
pub r#type: ByteString,
pub recipe_id: ByteString,
pub data: DeclareRecipesRecipesData,
}
pub mod id {
pub const SPAWN_ENTITY: i32 = 0x00;
pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x01;
pub const SPAWN_ENTITY_LIVING: i32 = 0x02;
pub const SPAWN_ENTITY_PAINTING: i32 = 0x03;
pub const NAMED_ENTITY_SPAWN: i32 = 0x04;
pub const ANIMATION: i32 = 0x05;
pub const STATISTICS: i32 = 0x06;
pub const ACKNOWLEDGE_PLAYER_DIGGING: i32 = 0x07;
pub const BLOCK_BREAK_ANIMATION: i32 = 0x08;
pub const TILE_ENTITY_DATA: i32 = 0x09;
pub const BLOCK_ACTION: i32 = 0x0a;
pub const BLOCK_CHANGE: i32 = 0x0b;
pub const BOSS_BAR: i32 = 0x0c;
pub const DIFFICULTY: i32 = 0x0d;
pub const CHAT: i32 = 0x0e;
pub const TAB_COMPLETE: i32 = 0x0f;
pub const DECLARE_COMMANDS: i32 = 0x10;
pub const TRANSACTION: i32 = 0x11;
pub const CLOSE_WINDOW: i32 = 0x12;
pub const WINDOW_ITEMS: i32 = 0x13;
pub const CRAFT_PROGRESS_BAR: i32 = 0x14;
pub const SET_SLOT: i32 = 0x15;
pub const SET_COOLDOWN: i32 = 0x16;
pub const CUSTOM_PAYLOAD: i32 = 0x17;
pub const NAMED_SOUND_EFFECT: i32 = 0x18;
pub const KICK_DISCONNECT: i32 = 0x19;
pub const ENTITY_STATUS: i32 = 0x1a;
pub const EXPLOSION: i32 = 0x1b;
pub const UNLOAD_CHUNK: i32 = 0x1c;
pub const GAME_STATE_CHANGE: i32 = 0x1d;
pub const OPEN_HORSE_WINDOW: i32 = 0x1e;
pub const KEEP_ALIVE: i32 = 0x1f;
pub const MAP_CHUNK: i32 = 0x20;
pub const WORLD_EVENT: i32 = 0x21;
pub const WORLD_PARTICLES: i32 = 0x22;
pub const UPDATE_LIGHT: i32 = 0x23;
pub const LOGIN: i32 = 0x24;
pub const MAP: i32 = 0x25;
pub const TRADE_LIST: i32 = 0x26;
pub const REL_ENTITY_MOVE: i32 = 0x27;
pub const ENTITY_MOVE_LOOK: i32 = 0x28;
pub const ENTITY_LOOK: i32 = 0x29;
pub const ENTITY: i32 = 0x2a;
pub const VEHICLE_MOVE: i32 = 0x2b;
pub const OPEN_BOOK: i32 = 0x2c;
pub const OPEN_WINDOW: i32 = 0x2d;
pub const OPEN_SIGN_ENTITY: i32 = 0x2e;
pub const CRAFT_RECIPE_RESPONSE: i32 = 0x2f;
pub const ABILITIES: i32 = 0x30;
pub const COMBAT_EVENT: i32 = 0x31;
pub const PLAYER_INFO: i32 = 0x32;
pub const FACE_PLAYER: i32 = 0x33;
pub const POSITION: i32 = 0x34;
pub const UNLOCK_RECIPES: i32 = 0x35;
pub const ENTITY_DESTROY: i32 = 0x36;
pub const REMOVE_ENTITY_EFFECT: i32 = 0x37;
pub const RESOURCE_PACK_SEND: i32 = 0x38;
pub const RESPAWN: i32 = 0x39;
pub const ENTITY_HEAD_ROTATION: i32 = 0x3a;
pub const MULTI_BLOCK_CHANGE: i32 = 0x3b;
pub const SELECT_ADVANCEMENT_TAB: i32 = 0x3c;
pub const WORLD_BORDER: i32 = 0x3d;
pub const CAMERA: i32 = 0x3e;
pub const HELD_ITEM_SLOT: i32 = 0x3f;
pub const UPDATE_VIEW_POSITION: i32 = 0x40;
pub const UPDATE_VIEW_DISTANCE: i32 = 0x41;
pub const SPAWN_POSITION: i32 = 0x42;
pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x43;
pub const ENTITY_METADATA: i32 = 0x44;
pub const ATTACH_ENTITY: i32 = 0x45;
pub const ENTITY_VELOCITY: i32 = 0x46;
pub const ENTITY_EQUIPMENT: i32 = 0x47;
pub const EXPERIENCE: i32 = 0x48;
pub const UPDATE_HEALTH: i32 = 0x49;
pub const SCOREBOARD_OBJECTIVE: i32 = 0x4a;
pub const SET_PASSENGERS: i32 = 0x4b;
pub const TEAMS: i32 = 0x4c;
pub const SCOREBOARD_SCORE: i32 = 0x4d;
pub const UPDATE_TIME: i32 = 0x4e;
pub const TITLE: i32 = 0x4f;
pub const ENTITY_SOUND_EFFECT: i32 = 0x50;
pub const SOUND_EFFECT: i32 = 0x51;
pub const STOP_SOUND: i32 = 0x52;
pub const PLAYERLIST_HEADER: i32 = 0x53;
pub const NBT_QUERY_RESPONSE: i32 = 0x54;
pub const COLLECT: i32 = 0x55;
pub const ENTITY_TELEPORT: i32 = 0x56;
pub const ADVANCEMENTS: i32 = 0x57;
pub const ENTITY_UPDATE_ATTRIBUTES: i32 = 0x58;
pub const ENTITY_EFFECT: i32 = 0x59;
pub const DECLARE_RECIPES: i32 = 0x5a;
pub const TAGS: i32 = 0x5b;
}
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity {
pub entity_id: i32,
pub object_uuid: Uuid,
pub r#type: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub pitch: i8,
pub yaw: i8,
pub object_data: i32,
pub velocity: types::Vec3i16,
}
impl crate::packet::Packet for SpawnEntity {
const ID: i32 = id::SPAWN_ENTITY;
const NAME: &'static str = "spawn_entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnEntity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v48 = r.read_varint()?;
let v49 = r.read_uuid()?;
let v50 = r.read_varint()?;
let v51 = r.read_f64()?;
let v52 = r.read_f64()?;
let v53 = r.read_f64()?;
let v54 = r.read_i8()?;
let v55 = r.read_i8()?;
let v56 = r.read_i32()?;
let v57 = <types::Vec3i16 as Decode>::decode(r)?;
SpawnEntity {
entity_id: v48,
object_uuid: v49,
r#type: v50,
x: v51,
y: v52,
z: v53,
pitch: v54,
yaw: v55,
object_data: v56,
velocity: v57,
}
})
}
}
impl Encode for SpawnEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).object_uuid);
w.put_varint((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).pitch);
w.put_i8((*self).yaw);
w.put_i32((*self).object_data);
(*self).velocity.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntity {
fn generate(g: &mut Gen) -> Self {
{
let v58 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v59 = g.uuid();
let v60 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v61 = g.f64();
let v62 = g.f64();
let v63 = g.f64();
let v64 = (g.int_in(-128, 127, &[]) as i8);
let v65 = (g.int_in(-128, 127, &[]) as i8);
let v66 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v67 = <types::Vec3i16 as Generate>::generate(g);
SpawnEntity {
entity_id: v58,
object_uuid: v59,
r#type: v60,
x: v61,
y: v62,
z: v63,
pitch: v64,
yaw: v65,
object_data: v66,
velocity: v67,
}
}
}
}
impl From<SpawnEntity> for ClientboundPlayPacket {
fn from(p: SpawnEntity) -> Self {
Self::SpawnEntity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityExperienceOrb {
pub entity_id: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub count: i16,
}
impl crate::packet::Packet for SpawnEntityExperienceOrb {
const ID: i32 = id::SPAWN_ENTITY_EXPERIENCE_ORB;
const NAME: &'static str = "spawn_entity_experience_orb";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnEntityExperienceOrb {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v68 = r.read_varint()?;
let v69 = r.read_f64()?;
let v70 = r.read_f64()?;
let v71 = r.read_f64()?;
let v72 = r.read_i16()?;
SpawnEntityExperienceOrb {
entity_id: v68,
x: v69,
y: v70,
z: v71,
count: v72,
}
})
}
}
impl Encode for SpawnEntityExperienceOrb {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i16((*self).count);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityExperienceOrb {
fn generate(g: &mut Gen) -> Self {
{
let v73 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v74 = g.f64();
let v75 = g.f64();
let v76 = g.f64();
let v77 = (g.int_in(-32768, 32767, &[]) as i16);
SpawnEntityExperienceOrb {
entity_id: v73,
x: v74,
y: v75,
z: v76,
count: v77,
}
}
}
}
impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
fn from(p: SpawnEntityExperienceOrb) -> Self {
Self::SpawnEntityExperienceOrb(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityLiving {
pub entity_id: i32,
pub entity_uuid: Uuid,
pub r#type: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: i8,
pub pitch: i8,
pub head_pitch: i8,
pub velocity: types::Vec3i16,
}
impl crate::packet::Packet for SpawnEntityLiving {
const ID: i32 = id::SPAWN_ENTITY_LIVING;
const NAME: &'static str = "spawn_entity_living";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnEntityLiving {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v78 = r.read_varint()?;
let v79 = r.read_uuid()?;
let v80 = r.read_varint()?;
let v81 = r.read_f64()?;
let v82 = r.read_f64()?;
let v83 = r.read_f64()?;
let v84 = r.read_i8()?;
let v85 = r.read_i8()?;
let v86 = r.read_i8()?;
let v87 = <types::Vec3i16 as Decode>::decode(r)?;
SpawnEntityLiving {
entity_id: v78,
entity_uuid: v79,
r#type: v80,
x: v81,
y: v82,
z: v83,
yaw: v84,
pitch: v85,
head_pitch: v86,
velocity: v87,
}
})
}
}
impl Encode for SpawnEntityLiving {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_i8((*self).head_pitch);
(*self).velocity.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityLiving {
fn generate(g: &mut Gen) -> Self {
{
let v88 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v89 = g.uuid();
let v90 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v91 = g.f64();
let v92 = g.f64();
let v93 = g.f64();
let v94 = (g.int_in(-128, 127, &[]) as i8);
let v95 = (g.int_in(-128, 127, &[]) as i8);
let v96 = (g.int_in(-128, 127, &[]) as i8);
let v97 = <types::Vec3i16 as Generate>::generate(g);
SpawnEntityLiving {
entity_id: v88,
entity_uuid: v89,
r#type: v90,
x: v91,
y: v92,
z: v93,
yaw: v94,
pitch: v95,
head_pitch: v96,
velocity: v97,
}
}
}
}
impl From<SpawnEntityLiving> for ClientboundPlayPacket {
fn from(p: SpawnEntityLiving) -> Self {
Self::SpawnEntityLiving(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityPainting {
pub entity_id: i32,
pub entity_uuid: Uuid,
pub title: i32,
pub location: BlockPos,
pub direction: u8,
}
impl crate::packet::Packet for SpawnEntityPainting {
const ID: i32 = id::SPAWN_ENTITY_PAINTING;
const NAME: &'static str = "spawn_entity_painting";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnEntityPainting {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v98 = r.read_varint()?;
let v99 = r.read_uuid()?;
let v100 = r.read_varint()?;
let v101 = BlockPos::read(r, PositionLayout::Xzy)?;
let v102 = r.read_u8()?;
SpawnEntityPainting {
entity_id: v98,
entity_uuid: v99,
title: v100,
location: v101,
direction: v102,
}
})
}
}
impl Encode for SpawnEntityPainting {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).title);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).direction);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityPainting {
fn generate(g: &mut Gen) -> Self {
{
let v103 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v104 = g.uuid();
let v105 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v106 = g.position();
let v107 = (g.int_in(0, 255, &[]) as u8);
SpawnEntityPainting {
entity_id: v103,
entity_uuid: v104,
title: v105,
location: v106,
direction: v107,
}
}
}
}
impl From<SpawnEntityPainting> for ClientboundPlayPacket {
fn from(p: SpawnEntityPainting) -> Self {
Self::SpawnEntityPainting(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct NamedEntitySpawn {
pub entity_id: i32,
pub player_uuid: Uuid,
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: i8,
pub pitch: i8,
}
impl crate::packet::Packet for NamedEntitySpawn {
const ID: i32 = id::NAMED_ENTITY_SPAWN;
const NAME: &'static str = "named_entity_spawn";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for NamedEntitySpawn {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v108 = r.read_varint()?;
let v109 = r.read_uuid()?;
let v110 = r.read_f64()?;
let v111 = r.read_f64()?;
let v112 = r.read_f64()?;
let v113 = r.read_i8()?;
let v114 = r.read_i8()?;
NamedEntitySpawn {
entity_id: v108,
player_uuid: v109,
x: v110,
y: v111,
z: v112,
yaw: v113,
pitch: v114,
}
})
}
}
impl Encode for NamedEntitySpawn {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_uuid(&(*self).player_uuid);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NamedEntitySpawn {
fn generate(g: &mut Gen) -> Self {
{
let v115 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v116 = g.uuid();
let v117 = g.f64();
let v118 = g.f64();
let v119 = g.f64();
let v120 = (g.int_in(-128, 127, &[]) as i8);
let v121 = (g.int_in(-128, 127, &[]) as i8);
NamedEntitySpawn {
entity_id: v115,
player_uuid: v116,
x: v117,
y: v118,
z: v119,
yaw: v120,
pitch: v121,
}
}
}
}
impl From<NamedEntitySpawn> for ClientboundPlayPacket {
fn from(p: NamedEntitySpawn) -> Self {
Self::NamedEntitySpawn(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Animation {
pub entity_id: i32,
pub animation: u8,
}
impl crate::packet::Packet for Animation {
const ID: i32 = id::ANIMATION;
const NAME: &'static str = "animation";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Animation {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v122 = r.read_varint()?;
let v123 = r.read_u8()?;
Animation {
entity_id: v122,
animation: v123,
}
})
}
}
impl Encode for Animation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_u8((*self).animation);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Animation {
fn generate(g: &mut Gen) -> Self {
{
let v124 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v125 = (g.int_in(0, 255, &[]) as u8);
Animation {
entity_id: v124,
animation: v125,
}
}
}
}
impl From<Animation> for ClientboundPlayPacket {
fn from(p: Animation) -> Self {
Self::Animation(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Statistics {
pub entries: Vec<StatisticsEntries>,
}
impl crate::packet::Packet for Statistics {
const ID: i32 = id::STATISTICS;
const NAME: &'static str = "statistics";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Statistics {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v126 = {
let v127 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v128 = Vec::with_capacity(v127.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v127 {
v128.push({
let v129 = r.read_varint()?;
let v130 = r.read_varint()?;
let v131 = r.read_varint()?;
StatisticsEntries {
category_id: v129,
statistic_id: v130,
value: v131,
}
});
}
v128
};
Statistics { entries: v126 }
})
}
}
impl Encode for Statistics {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entries.len())?;
for v132 in (*self).entries.iter() {
w.put_varint((*v132).category_id);
w.put_varint((*v132).statistic_id);
w.put_varint((*v132).value);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Statistics {
fn generate(g: &mut Gen) -> Self {
{
let v133 = {
let v134 = g.count();
let mut v135 = Vec::with_capacity(v134.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v134 {
v135.push({
let v136 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v138 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
StatisticsEntries {
category_id: v136,
statistic_id: v137,
value: v138,
}
});
}
v135
};
Statistics { entries: v133 }
}
}
}
impl From<Statistics> for ClientboundPlayPacket {
fn from(p: Statistics) -> Self {
Self::Statistics(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct AcknowledgePlayerDigging {
pub location: BlockPos,
pub block: i32,
pub status: i32,
pub successful: bool,
}
impl crate::packet::Packet for AcknowledgePlayerDigging {
const ID: i32 = id::ACKNOWLEDGE_PLAYER_DIGGING;
const NAME: &'static str = "acknowledge_player_digging";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for AcknowledgePlayerDigging {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v139 = BlockPos::read(r, PositionLayout::Xzy)?;
let v140 = r.read_varint()?;
let v141 = r.read_varint()?;
let v142 = r.read_bool()?;
AcknowledgePlayerDigging {
location: v139,
block: v140,
status: v141,
successful: v142,
}
})
}
}
impl Encode for AcknowledgePlayerDigging {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).block);
w.put_varint((*self).status);
w.put_bool((*self).successful);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for AcknowledgePlayerDigging {
fn generate(g: &mut Gen) -> Self {
{
let v143 = g.position();
let v144 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v145 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v146 = g.bool();
AcknowledgePlayerDigging {
location: v143,
block: v144,
status: v145,
successful: v146,
}
}
}
}
impl From<AcknowledgePlayerDigging> for ClientboundPlayPacket {
fn from(p: AcknowledgePlayerDigging) -> Self {
Self::AcknowledgePlayerDigging(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockBreakAnimation {
pub entity_id: i32,
pub location: BlockPos,
pub destroy_stage: i8,
}
impl crate::packet::Packet for BlockBreakAnimation {
const ID: i32 = id::BLOCK_BREAK_ANIMATION;
const NAME: &'static str = "block_break_animation";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for BlockBreakAnimation {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v147 = r.read_varint()?;
let v148 = BlockPos::read(r, PositionLayout::Xzy)?;
let v149 = r.read_i8()?;
BlockBreakAnimation {
entity_id: v147,
location: v148,
destroy_stage: v149,
}
})
}
}
impl Encode for BlockBreakAnimation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_i8((*self).destroy_stage);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BlockBreakAnimation {
fn generate(g: &mut Gen) -> Self {
{
let v150 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v151 = g.position();
let v152 = (g.int_in(-128, 127, &[]) as i8);
BlockBreakAnimation {
entity_id: v150,
location: v151,
destroy_stage: v152,
}
}
}
}
impl From<BlockBreakAnimation> for ClientboundPlayPacket {
fn from(p: BlockBreakAnimation) -> Self {
Self::BlockBreakAnimation(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TileEntityData {
pub location: BlockPos,
pub action: u8,
pub nbt_data: Option<RawNbt>,
}
impl crate::packet::Packet for TileEntityData {
const ID: i32 = id::TILE_ENTITY_DATA;
const NAME: &'static str = "tile_entity_data";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for TileEntityData {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v153 = BlockPos::read(r, PositionLayout::Xzy)?;
let v154 = r.read_u8()?;
let v155 = RawNbt::read_optional(r)?;
TileEntityData {
location: v153,
action: v154,
nbt_data: v155,
}
})
}
}
impl Encode for TileEntityData {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).action);
RawNbt::write_optional(&(*self).nbt_data, w);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TileEntityData {
fn generate(g: &mut Gen) -> Self {
{
let v156 = g.position();
let v157 = (g.int_in(0, 255, &[]) as u8);
let v158 = g.opt_nbt();
TileEntityData {
location: v156,
action: v157,
nbt_data: v158,
}
}
}
}
impl From<TileEntityData> for ClientboundPlayPacket {
fn from(p: TileEntityData) -> Self {
Self::TileEntityData(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockAction {
pub location: BlockPos,
pub byte1: u8,
pub byte2: u8,
pub block_id: i32,
}
impl crate::packet::Packet for BlockAction {
const ID: i32 = id::BLOCK_ACTION;
const NAME: &'static str = "block_action";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for BlockAction {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v159 = BlockPos::read(r, PositionLayout::Xzy)?;
let v160 = r.read_u8()?;
let v161 = r.read_u8()?;
let v162 = r.read_varint()?;
BlockAction {
location: v159,
byte1: v160,
byte2: v161,
block_id: v162,
}
})
}
}
impl Encode for BlockAction {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_u8((*self).byte1);
w.put_u8((*self).byte2);
w.put_varint((*self).block_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BlockAction {
fn generate(g: &mut Gen) -> Self {
{
let v163 = g.position();
let v164 = (g.int_in(0, 255, &[]) as u8);
let v165 = (g.int_in(0, 255, &[]) as u8);
let v166 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockAction {
location: v163,
byte1: v164,
byte2: v165,
block_id: v166,
}
}
}
}
impl From<BlockAction> for ClientboundPlayPacket {
fn from(p: BlockAction) -> Self {
Self::BlockAction(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BlockChange {
pub location: BlockPos,
pub r#type: i32,
}
impl crate::packet::Packet for BlockChange {
const ID: i32 = id::BLOCK_CHANGE;
const NAME: &'static str = "block_change";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for BlockChange {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v167 = BlockPos::read(r, PositionLayout::Xzy)?;
let v168 = r.read_varint()?;
BlockChange {
location: v167,
r#type: v168,
}
})
}
}
impl Encode for BlockChange {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_varint((*self).r#type);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BlockChange {
fn generate(g: &mut Gen) -> Self {
{
let v169 = g.position();
let v170 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockChange {
location: v169,
r#type: v170,
}
}
}
}
impl From<BlockChange> for ClientboundPlayPacket {
fn from(p: BlockChange) -> Self {
Self::BlockChange(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BossBar {
pub entity_uuid: Uuid,
pub action: i32,
pub title: Option<ByteString>,
pub health: Option<f32>,
pub color: Option<i32>,
pub dividers: Option<i32>,
pub flags: Option<u8>,
}
impl crate::packet::Packet for BossBar {
const ID: i32 = id::BOSS_BAR;
const NAME: &'static str = "boss_bar";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for BossBar {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v171 = r.read_uuid()?;
let v172 = r.read_varint()?;
let v173 = if (v172 == 0) || (v172 == 3) {
Some(r.read_string()?)
} else {
None
};
let v174 = if (v172 == 0) || (v172 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v175 = if (v172 == 0) || (v172 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v176 = if (v172 == 0) || (v172 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v177 = if (v172 == 0) || (v172 == 5) {
Some(r.read_u8()?)
} else {
None
};
BossBar {
entity_uuid: v171,
action: v172,
title: v173,
health: v174,
color: v175,
dividers: v176,
flags: v177,
}
})
}
}
impl Encode for BossBar {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_uuid(&(*self).entity_uuid);
w.put_varint((*self).action);
match (
&(*self).title,
((*self).action == 0) || ((*self).action == 3),
) {
(Some(v178), true) => {
w.put_string(&(*v178))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.title",
));
}
}
match (
&(*self).health,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v179), true) => {
w.put_f32((*v179));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.health",
));
}
}
match (
&(*self).color,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v180), true) => {
w.put_varint((*v180));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.color",
));
}
}
match (
&(*self).dividers,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v181), true) => {
w.put_varint((*v181));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.dividers",
));
}
}
match (
&(*self).flags,
((*self).action == 0) || ((*self).action == 5),
) {
(Some(v182), true) => {
w.put_u8((*v182));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.flags",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BossBar {
fn generate(g: &mut Gen) -> Self {
{
let v183 = g.uuid();
let v184 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
let v185 = if (v184 == 0) || (v184 == 3) {
Some(g.string())
} else {
None
};
let v186 = if (v184 == 0) || (v184 == 2) {
Some(g.f32())
} else {
None
};
let v187 = if (v184 == 0) || (v184 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v188 = if (v184 == 0) || (v184 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v189 = if (v184 == 0) || (v184 == 5) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
BossBar {
entity_uuid: v183,
action: v184,
title: v185,
health: v186,
color: v187,
dividers: v188,
flags: v189,
}
}
}
}
impl From<BossBar> for ClientboundPlayPacket {
fn from(p: BossBar) -> Self {
Self::BossBar(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Difficulty {
pub difficulty: DifficultyDifficulty,
pub difficulty_locked: bool,
}
impl crate::packet::Packet for Difficulty {
const ID: i32 = id::DIFFICULTY;
const NAME: &'static str = "difficulty";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Difficulty {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v190 = DifficultyDifficulty(r.read_u8()?);
let v191 = r.read_bool()?;
Difficulty {
difficulty: v190,
difficulty_locked: v191,
}
})
}
}
impl Encode for Difficulty {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).difficulty.0);
w.put_bool((*self).difficulty_locked);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Difficulty {
fn generate(g: &mut Gen) -> Self {
{
let v192 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
let v193 = g.bool();
Difficulty {
difficulty: v192,
difficulty_locked: v193,
}
}
}
}
impl From<Difficulty> for ClientboundPlayPacket {
fn from(p: Difficulty) -> Self {
Self::Difficulty(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Chat {
pub message: ByteString,
pub position: i8,
pub sender: Uuid,
}
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::Clientbound;
}
impl Decode for Chat {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v194 = r.read_string()?;
let v195 = r.read_i8()?;
let v196 = r.read_uuid()?;
Chat {
message: v194,
position: v195,
sender: v196,
}
})
}
}
impl Encode for Chat {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).message)?;
w.put_i8((*self).position);
w.put_uuid(&(*self).sender);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Chat {
fn generate(g: &mut Gen) -> Self {
{
let v197 = g.string();
let v198 = (g.int_in(-128, 127, &[]) as i8);
let v199 = g.uuid();
Chat {
message: v197,
position: v198,
sender: v199,
}
}
}
}
impl From<Chat> for ClientboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete {
pub transaction_id: i32,
pub start: i32,
pub length: i32,
pub matches: Vec<TabCompleteMatches>,
}
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::Clientbound;
}
impl Decode for TabComplete {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v200 = r.read_varint()?;
let v201 = r.read_varint()?;
let v202 = r.read_varint()?;
let v203 = {
let v204 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v205 = Vec::with_capacity(v204.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v204 {
v205.push({
let v206 = r.read_string()?;
let v207 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
TabCompleteMatches {
r#match: v206,
tooltip: v207,
}
});
}
v205
};
TabComplete {
transaction_id: v200,
start: v201,
length: v202,
matches: v203,
}
})
}
}
impl Encode for TabComplete {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
w.put_varint((*self).start);
w.put_varint((*self).length);
w.put_len_varint((*self).matches.len())?;
for v208 in (*self).matches.iter() {
w.put_string(&(*v208).r#match)?;
match &(*v208).tooltip {
Some(v209) => {
w.put_u8(1);
w.put_string(&(*v209))?;
}
None => w.put_u8(0),
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TabComplete {
fn generate(g: &mut Gen) -> Self {
{
let v210 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v211 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v212 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v213 = {
let v214 = g.count();
let mut v215 = Vec::with_capacity(v214.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v214 {
v215.push({
let v216 = g.string();
let v217 = if g.bool() { Some(g.string()) } else { None };
TabCompleteMatches {
r#match: v216,
tooltip: v217,
}
});
}
v215
};
TabComplete {
transaction_id: v210,
start: v211,
length: v212,
matches: v213,
}
}
}
}
impl From<TabComplete> for ClientboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareCommands {
pub nodes: Vec<types::CommandNode>,
pub root_index: i32,
}
impl crate::packet::Packet for DeclareCommands {
const ID: i32 = id::DECLARE_COMMANDS;
const NAME: &'static str = "declare_commands";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for DeclareCommands {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v218 = {
let v219 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v220 = Vec::with_capacity(v219.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v219 {
v220.push(<types::CommandNode as Decode>::decode(r)?);
}
v220
};
let v221 = r.read_varint()?;
DeclareCommands {
nodes: v218,
root_index: v221,
}
})
}
}
impl Encode for DeclareCommands {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).nodes.len())?;
for v222 in (*self).nodes.iter() {
(*v222).encode(w)?;
}
w.put_varint((*self).root_index);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for DeclareCommands {
fn generate(g: &mut Gen) -> Self {
{
let v223 = {
let v224 = g.count();
let mut v225 = Vec::with_capacity(v224.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v224 {
v225.push(<types::CommandNode as Generate>::generate(g));
}
v225
};
let v226 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
DeclareCommands {
nodes: v223,
root_index: v226,
}
}
}
}
impl From<DeclareCommands> for ClientboundPlayPacket {
fn from(p: DeclareCommands) -> Self {
Self::DeclareCommands(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::Clientbound;
}
impl Decode for Transaction {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v227 = r.read_i8()?;
let v228 = r.read_i16()?;
let v229 = r.read_bool()?;
Transaction {
window_id: v227,
action: v228,
accepted: v229,
}
})
}
}
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 v230 = (g.int_in(-128, 127, &[]) as i8);
let v231 = (g.int_in(-32768, 32767, &[]) as i16);
let v232 = g.bool();
Transaction {
window_id: v230,
action: v231,
accepted: v232,
}
}
}
}
impl From<Transaction> for ClientboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(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::Clientbound;
}
impl Decode for CloseWindow {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v233 = r.read_u8()?;
CloseWindow { window_id: v233 }
})
}
}
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 v234 = (g.int_in(0, 255, &[]) as u8);
CloseWindow { window_id: v234 }
}
}
}
impl From<CloseWindow> for ClientboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct WindowItems {
pub window_id: u8,
pub items: Vec<types::Slot>,
}
impl crate::packet::Packet for WindowItems {
const ID: i32 = id::WINDOW_ITEMS;
const NAME: &'static str = "window_items";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for WindowItems {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v235 = r.read_u8()?;
let v236 = {
let v237 = {
let c = r.read_i16()?;
r.check_count(i64::from(c), 1)?
};
let mut v238 = Vec::with_capacity(v237.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v237 {
v238.push(<types::Slot as Decode>::decode(r)?);
}
v238
};
WindowItems {
window_id: v235,
items: v236,
}
})
}
}
impl Encode for WindowItems {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_i16(crate::codec::count_i16((*self).items.len())?);
for v239 in (*self).items.iter() {
(*v239).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WindowItems {
fn generate(g: &mut Gen) -> Self {
{
let v240 = (g.int_in(0, 255, &[]) as u8);
let v241 = {
let v242 = g.count();
let mut v243 = Vec::with_capacity(v242.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v242 {
v243.push(<types::Slot as Generate>::generate(g));
}
v243
};
WindowItems {
window_id: v240,
items: v241,
}
}
}
}
impl From<WindowItems> for ClientboundPlayPacket {
fn from(p: WindowItems) -> Self {
Self::WindowItems(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CraftProgressBar {
pub window_id: u8,
pub property: i16,
pub value: i16,
}
impl crate::packet::Packet for CraftProgressBar {
const ID: i32 = id::CRAFT_PROGRESS_BAR;
const NAME: &'static str = "craft_progress_bar";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for CraftProgressBar {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v244 = r.read_u8()?;
let v245 = r.read_i16()?;
let v246 = r.read_i16()?;
CraftProgressBar {
window_id: v244,
property: v245,
value: v246,
}
})
}
}
impl Encode for CraftProgressBar {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_i16((*self).property);
w.put_i16((*self).value);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CraftProgressBar {
fn generate(g: &mut Gen) -> Self {
{
let v247 = (g.int_in(0, 255, &[]) as u8);
let v248 = (g.int_in(-32768, 32767, &[]) as i16);
let v249 = (g.int_in(-32768, 32767, &[]) as i16);
CraftProgressBar {
window_id: v247,
property: v248,
value: v249,
}
}
}
}
impl From<CraftProgressBar> for ClientboundPlayPacket {
fn from(p: CraftProgressBar) -> Self {
Self::CraftProgressBar(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SetSlot {
pub window_id: i8,
pub slot: i16,
pub item: types::Slot,
}
impl crate::packet::Packet for SetSlot {
const ID: i32 = id::SET_SLOT;
const NAME: &'static str = "set_slot";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SetSlot {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v250 = r.read_i8()?;
let v251 = r.read_i16()?;
let v252 = <types::Slot as Decode>::decode(r)?;
SetSlot {
window_id: v250,
slot: v251,
item: v252,
}
})
}
}
impl Encode for SetSlot {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetSlot {
fn generate(g: &mut Gen) -> Self {
{
let v253 = (g.int_in(-128, 127, &[]) as i8);
let v254 = (g.int_in(-32768, 32767, &[]) as i16);
let v255 = <types::Slot as Generate>::generate(g);
SetSlot {
window_id: v253,
slot: v254,
item: v255,
}
}
}
}
impl From<SetSlot> for ClientboundPlayPacket {
fn from(p: SetSlot) -> Self {
Self::SetSlot(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SetCooldown {
pub item_id: i32,
pub cooldown_ticks: i32,
}
impl crate::packet::Packet for SetCooldown {
const ID: i32 = id::SET_COOLDOWN;
const NAME: &'static str = "set_cooldown";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SetCooldown {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v256 = r.read_varint()?;
let v257 = r.read_varint()?;
SetCooldown {
item_id: v256,
cooldown_ticks: v257,
}
})
}
}
impl Encode for SetCooldown {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_id);
w.put_varint((*self).cooldown_ticks);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetCooldown {
fn generate(g: &mut Gen) -> Self {
{
let v258 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v259 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
SetCooldown {
item_id: v258,
cooldown_ticks: v259,
}
}
}
}
impl From<SetCooldown> for ClientboundPlayPacket {
fn from(p: SetCooldown) -> Self {
Self::SetCooldown(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::Clientbound;
}
impl Decode for CustomPayload {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v260 = r.read_string()?;
let v261 = r.read_rest();
CustomPayload {
channel: v260,
data: v261,
}
})
}
}
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 v262 = g.string();
let v263 = g.bytes();
CustomPayload {
channel: v262,
data: v263,
}
}
}
}
impl From<CustomPayload> for ClientboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct NamedSoundEffect {
pub sound_name: ByteString,
pub sound_category: i32,
pub x: i32,
pub y: i32,
pub z: i32,
pub volume: f32,
pub pitch: f32,
}
impl crate::packet::Packet for NamedSoundEffect {
const ID: i32 = id::NAMED_SOUND_EFFECT;
const NAME: &'static str = "named_sound_effect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for NamedSoundEffect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v264 = r.read_string()?;
let v265 = r.read_varint()?;
let v266 = r.read_i32()?;
let v267 = r.read_i32()?;
let v268 = r.read_i32()?;
let v269 = r.read_f32()?;
let v270 = r.read_f32()?;
NamedSoundEffect {
sound_name: v264,
sound_category: v265,
x: v266,
y: v267,
z: v268,
volume: v269,
pitch: v270,
}
})
}
}
impl Encode for NamedSoundEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).sound_name)?;
w.put_varint((*self).sound_category);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NamedSoundEffect {
fn generate(g: &mut Gen) -> Self {
{
let v271 = g.string();
let v272 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v273 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v274 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v275 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v276 = g.f32();
let v277 = g.f32();
NamedSoundEffect {
sound_name: v271,
sound_category: v272,
x: v273,
y: v274,
z: v275,
volume: v276,
pitch: v277,
}
}
}
}
impl From<NamedSoundEffect> for ClientboundPlayPacket {
fn from(p: NamedSoundEffect) -> Self {
Self::NamedSoundEffect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct KickDisconnect {
pub reason: ByteString,
}
impl crate::packet::Packet for KickDisconnect {
const ID: i32 = id::KICK_DISCONNECT;
const NAME: &'static str = "kick_disconnect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for KickDisconnect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v278 = r.read_string()?;
KickDisconnect { reason: v278 }
})
}
}
impl Encode for KickDisconnect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).reason)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for KickDisconnect {
fn generate(g: &mut Gen) -> Self {
{
let v279 = g.string();
KickDisconnect { reason: v279 }
}
}
}
impl From<KickDisconnect> for ClientboundPlayPacket {
fn from(p: KickDisconnect) -> Self {
Self::KickDisconnect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityStatus {
pub entity_id: i32,
pub entity_status: i8,
}
impl crate::packet::Packet for EntityStatus {
const ID: i32 = id::ENTITY_STATUS;
const NAME: &'static str = "entity_status";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityStatus {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v280 = r.read_i32()?;
let v281 = r.read_i8()?;
EntityStatus {
entity_id: v280,
entity_status: v281,
}
})
}
}
impl Encode for EntityStatus {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_i8((*self).entity_status);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityStatus {
fn generate(g: &mut Gen) -> Self {
{
let v282 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v283 = (g.int_in(-128, 127, &[]) as i8);
EntityStatus {
entity_id: v282,
entity_status: v283,
}
}
}
}
impl From<EntityStatus> for ClientboundPlayPacket {
fn from(p: EntityStatus) -> Self {
Self::EntityStatus(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Explosion {
pub x: f32,
pub y: f32,
pub z: f32,
pub radius: f32,
pub affected_block_offsets: Vec<ExplosionAffectedBlockOffsets>,
pub player_motion_x: f32,
pub player_motion_y: f32,
pub player_motion_z: f32,
}
impl crate::packet::Packet for Explosion {
const ID: i32 = id::EXPLOSION;
const NAME: &'static str = "explosion";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Explosion {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v284 = r.read_f32()?;
let v285 = r.read_f32()?;
let v286 = r.read_f32()?;
let v287 = r.read_f32()?;
let v288 = {
let v289 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 3)?
};
let mut v290 = Vec::with_capacity(v289.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v289 {
v290.push({
let v291 = r.read_i8()?;
let v292 = r.read_i8()?;
let v293 = r.read_i8()?;
ExplosionAffectedBlockOffsets {
x: v291,
y: v292,
z: v293,
}
});
}
v290
};
let v294 = r.read_f32()?;
let v295 = r.read_f32()?;
let v296 = r.read_f32()?;
Explosion {
x: v284,
y: v285,
z: v286,
radius: v287,
affected_block_offsets: v288,
player_motion_x: v294,
player_motion_y: v295,
player_motion_z: v296,
}
})
}
}
impl Encode for Explosion {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).x);
w.put_f32((*self).y);
w.put_f32((*self).z);
w.put_f32((*self).radius);
w.put_i32(crate::codec::count_i32(
(*self).affected_block_offsets.len(),
)?);
for v297 in (*self).affected_block_offsets.iter() {
w.put_i8((*v297).x);
w.put_i8((*v297).y);
w.put_i8((*v297).z);
}
w.put_f32((*self).player_motion_x);
w.put_f32((*self).player_motion_y);
w.put_f32((*self).player_motion_z);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Explosion {
fn generate(g: &mut Gen) -> Self {
{
let v298 = g.f32();
let v299 = g.f32();
let v300 = g.f32();
let v301 = g.f32();
let v302 = {
let v303 = g.count();
let mut v304 = Vec::with_capacity(v303.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v303 {
v304.push({
let v305 = (g.int_in(-128, 127, &[]) as i8);
let v306 = (g.int_in(-128, 127, &[]) as i8);
let v307 = (g.int_in(-128, 127, &[]) as i8);
ExplosionAffectedBlockOffsets {
x: v305,
y: v306,
z: v307,
}
});
}
v304
};
let v308 = g.f32();
let v309 = g.f32();
let v310 = g.f32();
Explosion {
x: v298,
y: v299,
z: v300,
radius: v301,
affected_block_offsets: v302,
player_motion_x: v308,
player_motion_y: v309,
player_motion_z: v310,
}
}
}
}
impl From<Explosion> for ClientboundPlayPacket {
fn from(p: Explosion) -> Self {
Self::Explosion(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UnloadChunk {
pub chunk_x: i32,
pub chunk_z: i32,
}
impl crate::packet::Packet for UnloadChunk {
const ID: i32 = id::UNLOAD_CHUNK;
const NAME: &'static str = "unload_chunk";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UnloadChunk {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v311 = r.read_i32()?;
let v312 = r.read_i32()?;
UnloadChunk {
chunk_x: v311,
chunk_z: v312,
}
})
}
}
impl Encode for UnloadChunk {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).chunk_x);
w.put_i32((*self).chunk_z);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UnloadChunk {
fn generate(g: &mut Gen) -> Self {
{
let v313 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v314 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
UnloadChunk {
chunk_x: v313,
chunk_z: v314,
}
}
}
}
impl From<UnloadChunk> for ClientboundPlayPacket {
fn from(p: UnloadChunk) -> Self {
Self::UnloadChunk(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct GameStateChange {
pub reason: GameStateChangeReason,
pub game_mode: f32,
}
impl crate::packet::Packet for GameStateChange {
const ID: i32 = id::GAME_STATE_CHANGE;
const NAME: &'static str = "game_state_change";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for GameStateChange {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v315 = GameStateChangeReason(r.read_u8()?);
let v316 = r.read_f32()?;
GameStateChange {
reason: v315,
game_mode: v316,
}
})
}
}
impl Encode for GameStateChange {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).reason.0);
w.put_f32((*self).game_mode);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for GameStateChange {
fn generate(g: &mut Gen) -> Self {
{
let v317 =
GameStateChangeReason(
g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) as u8
);
let v318 = g.f32();
GameStateChange {
reason: v317,
game_mode: v318,
}
}
}
}
impl From<GameStateChange> for ClientboundPlayPacket {
fn from(p: GameStateChange) -> Self {
Self::GameStateChange(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct OpenHorseWindow {
pub window_id: u8,
pub nb_slots: i32,
pub entity_id: i32,
}
impl crate::packet::Packet for OpenHorseWindow {
const ID: i32 = id::OPEN_HORSE_WINDOW;
const NAME: &'static str = "open_horse_window";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for OpenHorseWindow {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v319 = r.read_u8()?;
let v320 = r.read_varint()?;
let v321 = r.read_i32()?;
OpenHorseWindow {
window_id: v319,
nb_slots: v320,
entity_id: v321,
}
})
}
}
impl Encode for OpenHorseWindow {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_varint((*self).nb_slots);
w.put_i32((*self).entity_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenHorseWindow {
fn generate(g: &mut Gen) -> Self {
{
let v322 = (g.int_in(0, 255, &[]) as u8);
let v323 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v324 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
OpenHorseWindow {
window_id: v322,
nb_slots: v323,
entity_id: v324,
}
}
}
}
impl From<OpenHorseWindow> for ClientboundPlayPacket {
fn from(p: OpenHorseWindow) -> Self {
Self::OpenHorseWindow(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::Clientbound;
}
impl Decode for KeepAlive {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v325 = r.read_i64()?;
KeepAlive {
keep_alive_id: v325,
}
})
}
}
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 v326 = g.i64();
KeepAlive {
keep_alive_id: v326,
}
}
}
}
impl From<KeepAlive> for ClientboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunk {
pub x: i32,
pub z: i32,
pub ground_up: bool,
pub bit_map: i32,
pub heightmaps: RawNbt,
pub biomes: Option<Vec<i32>>,
pub chunk_data: Bytes,
pub block_entities: Vec<RawNbt>,
}
impl crate::packet::Packet for MapChunk {
const ID: i32 = id::MAP_CHUNK;
const NAME: &'static str = "map_chunk";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for MapChunk {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v327 = r.read_i32()?;
let v328 = r.read_i32()?;
let v329 = r.read_bool()?;
let v330 = r.read_varint()?;
let v331 = RawNbt::read(r)?;
let v332 = if v329 {
Some({
let v333 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v334 = Vec::with_capacity(v333.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v333 {
v334.push(r.read_varint()?);
}
v334
})
} else {
None
};
let v335 = r.read_byte_array()?;
let v336 = {
let v337 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v338 = Vec::with_capacity(v337.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v337 {
v338.push(RawNbt::read(r)?);
}
v338
};
MapChunk {
x: v327,
z: v328,
ground_up: v329,
bit_map: v330,
heightmaps: v331,
biomes: v332,
chunk_data: v335,
block_entities: v336,
}
})
}
}
impl Encode for MapChunk {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).x);
w.put_i32((*self).z);
w.put_bool((*self).ground_up);
w.put_varint((*self).bit_map);
(*self).heightmaps.write(w);
match (&(*self).biomes, (*self).ground_up) {
(Some(v339), true) => {
w.put_len_varint((*v339).len())?;
for v340 in (*v339).iter() {
w.put_varint((*v340));
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.map_chunk.biomes",
));
}
}
w.put_byte_array(&(*self).chunk_data)?;
w.put_len_varint((*self).block_entities.len())?;
for v341 in (*self).block_entities.iter() {
(*v341).write(w);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MapChunk {
fn generate(g: &mut Gen) -> Self {
{
let v342 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v343 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v344 = g.bool();
let v345 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v346 = g.nbt();
let v347 = if v344 {
Some({
let v348 = g.count();
let mut v349 = Vec::with_capacity(v348.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v348 {
v349.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v349
})
} else {
None
};
let v350 = g.bytes();
let v351 = {
let v352 = g.count();
let mut v353 = Vec::with_capacity(v352.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v352 {
v353.push(g.nbt());
}
v353
};
MapChunk {
x: v342,
z: v343,
ground_up: v344,
bit_map: v345,
heightmaps: v346,
biomes: v347,
chunk_data: v350,
block_entities: v351,
}
}
}
}
impl From<MapChunk> for ClientboundPlayPacket {
fn from(p: MapChunk) -> Self {
Self::MapChunk(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct WorldEvent {
pub effect_id: i32,
pub location: BlockPos,
pub data: i32,
pub global: bool,
}
impl crate::packet::Packet for WorldEvent {
const ID: i32 = id::WORLD_EVENT;
const NAME: &'static str = "world_event";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for WorldEvent {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v354 = r.read_i32()?;
let v355 = BlockPos::read(r, PositionLayout::Xzy)?;
let v356 = r.read_i32()?;
let v357 = r.read_bool()?;
WorldEvent {
effect_id: v354,
location: v355,
data: v356,
global: v357,
}
})
}
}
impl Encode for WorldEvent {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).effect_id);
(*self).location.write(w, PositionLayout::Xzy)?;
w.put_i32((*self).data);
w.put_bool((*self).global);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WorldEvent {
fn generate(g: &mut Gen) -> Self {
{
let v358 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v359 = g.position();
let v360 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v361 = g.bool();
WorldEvent {
effect_id: v358,
location: v359,
data: v360,
global: v361,
}
}
}
}
impl From<WorldEvent> for ClientboundPlayPacket {
fn from(p: WorldEvent) -> Self {
Self::WorldEvent(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct WorldParticles {
pub particle_id: i32,
pub long_distance: bool,
pub x: f64,
pub y: f64,
pub z: f64,
pub offset_x: f32,
pub offset_y: f32,
pub offset_z: f32,
pub particle_data: f32,
pub particles: i32,
pub data: types::ParticleData,
}
impl crate::packet::Packet for WorldParticles {
const ID: i32 = id::WORLD_PARTICLES;
const NAME: &'static str = "world_particles";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for WorldParticles {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v362 = r.read_i32()?;
let v363 = r.read_bool()?;
let v364 = r.read_f64()?;
let v365 = r.read_f64()?;
let v366 = r.read_f64()?;
let v367 = r.read_f32()?;
let v368 = r.read_f32()?;
let v369 = r.read_f32()?;
let v370 = r.read_f32()?;
let v371 = r.read_i32()?;
let v372 = (if (v362 == 3) {
types::ParticleData::Case3({
let v373 = r.read_varint()?;
types::ParticleDataCase3 { block_state: v373 }
})
} else if (v362 == 14) {
types::ParticleData::Case14({
let v374 = r.read_f32()?;
let v375 = r.read_f32()?;
let v376 = r.read_f32()?;
let v377 = r.read_f32()?;
types::ParticleDataCase14 {
red: v374,
green: v375,
blue: v376,
scale: v377,
}
})
} else if (v362 == 23) {
types::ParticleData::Case23({
let v378 = r.read_varint()?;
types::ParticleDataCase23 { block_state: v378 }
})
} else if (v362 == 34) {
types::ParticleData::Case34({
let v379 = <types::Slot as Decode>::decode(r)?;
types::ParticleDataCase34 { item: v379 }
})
} else {
types::ParticleData::Other
});
WorldParticles {
particle_id: v362,
long_distance: v363,
x: v364,
y: v365,
z: v366,
offset_x: v367,
offset_y: v368,
offset_z: v369,
particle_data: v370,
particles: v371,
data: v372,
}
})
}
}
impl Encode for WorldParticles {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).particle_id);
w.put_bool((*self).long_distance);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_f32((*self).offset_x);
w.put_f32((*self).offset_y);
w.put_f32((*self).offset_z);
w.put_f32((*self).particle_data);
w.put_i32((*self).particles);
match &(*self).data {
types::ParticleData::Case3(v380) => {
if !((*self).particle_id == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_varint((*v380).block_state);
}
types::ParticleData::Case14(v381) => {
if !((*self).particle_id == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_f32((*v381).red);
w.put_f32((*v381).green);
w.put_f32((*v381).blue);
w.put_f32((*v381).scale);
}
types::ParticleData::Case23(v382) => {
if !((*self).particle_id == 23) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
w.put_varint((*v382).block_state);
}
types::ParticleData::Case34(v383) => {
if !((*self).particle_id == 34) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
(*v383).item.encode(w)?;
}
types::ParticleData::Other => {
if !(!(((*self).particle_id == 3)
|| ((*self).particle_id == 14)
|| ((*self).particle_id == 23)
|| ((*self).particle_id == 34)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WorldParticles {
fn generate(g: &mut Gen) -> Self {
{
let v384 = (g.int_in(-2147483648, 2147483647, &[3, 14, 23, 34]) as i32);
let v385 = g.bool();
let v386 = g.f64();
let v387 = g.f64();
let v388 = g.f64();
let v389 = g.f32();
let v390 = g.f32();
let v391 = g.f32();
let v392 = g.f32();
let v393 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v394 = (if (v384 == 3) {
types::ParticleData::Case3({
let v395 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
types::ParticleDataCase3 { block_state: v395 }
})
} else if (v384 == 14) {
types::ParticleData::Case14({
let v396 = g.f32();
let v397 = g.f32();
let v398 = g.f32();
let v399 = g.f32();
types::ParticleDataCase14 {
red: v396,
green: v397,
blue: v398,
scale: v399,
}
})
} else if (v384 == 23) {
types::ParticleData::Case23({
let v400 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
types::ParticleDataCase23 { block_state: v400 }
})
} else if (v384 == 34) {
types::ParticleData::Case34({
let v401 = <types::Slot as Generate>::generate(g);
types::ParticleDataCase34 { item: v401 }
})
} else {
types::ParticleData::Other
});
WorldParticles {
particle_id: v384,
long_distance: v385,
x: v386,
y: v387,
z: v388,
offset_x: v389,
offset_y: v390,
offset_z: v391,
particle_data: v392,
particles: v393,
data: v394,
}
}
}
}
impl From<WorldParticles> for ClientboundPlayPacket {
fn from(p: WorldParticles) -> Self {
Self::WorldParticles(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateLight {
pub chunk_x: i32,
pub chunk_z: i32,
pub trust_edges: bool,
pub sky_light_mask: i32,
pub block_light_mask: i32,
pub empty_sky_light_mask: i32,
pub empty_block_light_mask: i32,
pub data: Bytes,
}
impl crate::packet::Packet for UpdateLight {
const ID: i32 = id::UPDATE_LIGHT;
const NAME: &'static str = "update_light";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateLight {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v402 = r.read_varint()?;
let v403 = r.read_varint()?;
let v404 = r.read_bool()?;
let v405 = r.read_varint()?;
let v406 = r.read_varint()?;
let v407 = r.read_varint()?;
let v408 = r.read_varint()?;
let v409 = r.read_rest();
UpdateLight {
chunk_x: v402,
chunk_z: v403,
trust_edges: v404,
sky_light_mask: v405,
block_light_mask: v406,
empty_sky_light_mask: v407,
empty_block_light_mask: v408,
data: v409,
}
})
}
}
impl Encode for UpdateLight {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).chunk_x);
w.put_varint((*self).chunk_z);
w.put_bool((*self).trust_edges);
w.put_varint((*self).sky_light_mask);
w.put_varint((*self).block_light_mask);
w.put_varint((*self).empty_sky_light_mask);
w.put_varint((*self).empty_block_light_mask);
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateLight {
fn generate(g: &mut Gen) -> Self {
{
let v410 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v411 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v412 = g.bool();
let v413 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v414 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v415 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v416 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v417 = g.bytes();
UpdateLight {
chunk_x: v410,
chunk_z: v411,
trust_edges: v412,
sky_light_mask: v413,
block_light_mask: v414,
empty_sky_light_mask: v415,
empty_block_light_mask: v416,
data: v417,
}
}
}
}
impl From<UpdateLight> for ClientboundPlayPacket {
fn from(p: UpdateLight) -> Self {
Self::UpdateLight(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Login {
pub entity_id: i32,
pub is_hardcore: bool,
pub game_mode: u8,
pub previous_game_mode: u8,
pub world_names: Vec<ByteString>,
pub dimension_codec: RawNbt,
pub dimension: RawNbt,
pub world_name: ByteString,
pub hashed_seed: i64,
pub max_players: i32,
pub view_distance: i32,
pub reduced_debug_info: bool,
pub enable_respawn_screen: bool,
pub is_debug: bool,
pub is_flat: bool,
}
impl crate::packet::Packet for Login {
const ID: i32 = id::LOGIN;
const NAME: &'static str = "login";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Login {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v418 = r.read_i32()?;
let v419 = r.read_bool()?;
let v420 = r.read_u8()?;
let v421 = r.read_u8()?;
let v422 = {
let v423 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v424 = Vec::with_capacity(v423.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v423 {
v424.push(r.read_string()?);
}
v424
};
let v425 = RawNbt::read(r)?;
let v426 = RawNbt::read(r)?;
let v427 = r.read_string()?;
let v428 = r.read_i64()?;
let v429 = r.read_varint()?;
let v430 = r.read_varint()?;
let v431 = r.read_bool()?;
let v432 = r.read_bool()?;
let v433 = r.read_bool()?;
let v434 = r.read_bool()?;
Login {
entity_id: v418,
is_hardcore: v419,
game_mode: v420,
previous_game_mode: v421,
world_names: v422,
dimension_codec: v425,
dimension: v426,
world_name: v427,
hashed_seed: v428,
max_players: v429,
view_distance: v430,
reduced_debug_info: v431,
enable_respawn_screen: v432,
is_debug: v433,
is_flat: v434,
}
})
}
}
impl Encode for Login {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_bool((*self).is_hardcore);
w.put_u8((*self).game_mode);
w.put_u8((*self).previous_game_mode);
w.put_len_varint((*self).world_names.len())?;
for v435 in (*self).world_names.iter() {
w.put_string(&(*v435))?;
}
(*self).dimension_codec.write(w);
(*self).dimension.write(w);
w.put_string(&(*self).world_name)?;
w.put_i64((*self).hashed_seed);
w.put_varint((*self).max_players);
w.put_varint((*self).view_distance);
w.put_bool((*self).reduced_debug_info);
w.put_bool((*self).enable_respawn_screen);
w.put_bool((*self).is_debug);
w.put_bool((*self).is_flat);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Login {
fn generate(g: &mut Gen) -> Self {
{
let v436 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v437 = g.bool();
let v438 = (g.int_in(0, 255, &[]) as u8);
let v439 = (g.int_in(0, 255, &[]) as u8);
let v440 = {
let v441 = g.count();
let mut v442 = Vec::with_capacity(v441.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v441 {
v442.push(g.string());
}
v442
};
let v443 = g.nbt();
let v444 = g.nbt();
let v445 = g.string();
let v446 = g.i64();
let v447 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v448 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v449 = g.bool();
let v450 = g.bool();
let v451 = g.bool();
let v452 = g.bool();
Login {
entity_id: v436,
is_hardcore: v437,
game_mode: v438,
previous_game_mode: v439,
world_names: v440,
dimension_codec: v443,
dimension: v444,
world_name: v445,
hashed_seed: v446,
max_players: v447,
view_distance: v448,
reduced_debug_info: v449,
enable_respawn_screen: v450,
is_debug: v451,
is_flat: v452,
}
}
}
}
impl From<Login> for ClientboundPlayPacket {
fn from(p: Login) -> Self {
Self::Login(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Map {
pub item_damage: i32,
pub scale: i8,
pub tracking_position: bool,
pub locked: bool,
pub icons: Vec<MapIcons>,
pub columns: i8,
pub rows: Option<i8>,
pub x: Option<i8>,
pub y: Option<i8>,
pub data: Option<Bytes>,
}
impl crate::packet::Packet for Map {
const ID: i32 = id::MAP;
const NAME: &'static str = "map";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Map {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v453 = r.read_varint()?;
let v454 = r.read_i8()?;
let v455 = r.read_bool()?;
let v456 = r.read_bool()?;
let v457 = {
let v458 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v459 = Vec::with_capacity(v458.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v458 {
v459.push({
let v460 = r.read_varint()?;
let v461 = r.read_i8()?;
let v462 = r.read_i8()?;
let v463 = r.read_u8()?;
let v464 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
MapIcons {
r#type: v460,
x: v461,
z: v462,
direction: v463,
display_name: v464,
}
});
}
v459
};
let v465 = r.read_i8()?;
let v466 = if !(v465 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v467 = if !(v465 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v468 = if !(v465 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v469 = if !(v465 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Map {
item_damage: v453,
scale: v454,
tracking_position: v455,
locked: v456,
icons: v457,
columns: v465,
rows: v466,
x: v467,
y: v468,
data: v469,
}
})
}
}
impl Encode for Map {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_damage);
w.put_i8((*self).scale);
w.put_bool((*self).tracking_position);
w.put_bool((*self).locked);
w.put_len_varint((*self).icons.len())?;
for v470 in (*self).icons.iter() {
w.put_varint((*v470).r#type);
w.put_i8((*v470).x);
w.put_i8((*v470).z);
w.put_u8((*v470).direction);
match &(*v470).display_name {
Some(v471) => {
w.put_u8(1);
w.put_string(&(*v471))?;
}
None => w.put_u8(0),
}
}
w.put_i8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v472), true) => {
w.put_i8((*v472));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v473), true) => {
w.put_i8((*v473));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v474), true) => {
w.put_i8((*v474));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v475), true) => {
w.put_byte_array(&(*v475))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.data")),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Map {
fn generate(g: &mut Gen) -> Self {
{
let v476 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v477 = (g.int_in(-128, 127, &[]) as i8);
let v478 = g.bool();
let v479 = g.bool();
let v480 = {
let v481 = g.count();
let mut v482 = Vec::with_capacity(v481.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v481 {
v482.push({
let v483 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v484 = (g.int_in(-128, 127, &[]) as i8);
let v485 = (g.int_in(-128, 127, &[]) as i8);
let v486 = (g.int_in(0, 255, &[]) as u8);
let v487 = if g.bool() { Some(g.string()) } else { None };
MapIcons {
r#type: v483,
x: v484,
z: v485,
direction: v486,
display_name: v487,
}
});
}
v482
};
let v488 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
let v489 = if !(v488 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v490 = if !(v488 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v491 = if !(v488 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v492 = if !(v488 == 0) { Some(g.bytes()) } else { None };
Map {
item_damage: v476,
scale: v477,
tracking_position: v478,
locked: v479,
icons: v480,
columns: v488,
rows: v489,
x: v490,
y: v491,
data: v492,
}
}
}
}
impl From<Map> for ClientboundPlayPacket {
fn from(p: Map) -> Self {
Self::Map(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TradeList {
pub window_id: i32,
pub trades: Vec<TradeListTrades>,
pub villager_level: i32,
pub experience: i32,
pub is_regular_villager: bool,
pub can_restock: bool,
}
impl crate::packet::Packet for TradeList {
const ID: i32 = id::TRADE_LIST;
const NAME: &'static str = "trade_list";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for TradeList {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v493 = r.read_varint()?;
let v494 = {
let v495 = {
let c = r.read_u8()?;
r.check_count(i64::from(c), 28)?
};
let mut v496 = Vec::with_capacity(v495.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v495 {
v496.push({
let v497 = <types::Slot as Decode>::decode(r)?;
let v498 = <types::Slot as Decode>::decode(r)?;
let v499 = if r.read_bool()? {
Some(<types::Slot as Decode>::decode(r)?)
} else {
None
};
let v500 = r.read_bool()?;
let v501 = r.read_i32()?;
let v502 = r.read_i32()?;
let v503 = r.read_i32()?;
let v504 = r.read_i32()?;
let v505 = r.read_f32()?;
let v506 = r.read_i32()?;
TradeListTrades {
input_item1: v497,
output_item: v498,
input_item2: v499,
trade_disabled: v500,
nb_trade_uses: v501,
maximum_nb_trade_uses: v502,
xp: v503,
special_price: v504,
price_multiplier: v505,
demand: v506,
}
});
}
v496
};
let v507 = r.read_varint()?;
let v508 = r.read_varint()?;
let v509 = r.read_bool()?;
let v510 = r.read_bool()?;
TradeList {
window_id: v493,
trades: v494,
villager_level: v507,
experience: v508,
is_regular_villager: v509,
can_restock: v510,
}
})
}
}
impl Encode for TradeList {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_u8(crate::codec::count_u8((*self).trades.len())?);
for v511 in (*self).trades.iter() {
(*v511).input_item1.encode(w)?;
(*v511).output_item.encode(w)?;
match &(*v511).input_item2 {
Some(v512) => {
w.put_u8(1);
(*v512).encode(w)?;
}
None => w.put_u8(0),
}
w.put_bool((*v511).trade_disabled);
w.put_i32((*v511).nb_trade_uses);
w.put_i32((*v511).maximum_nb_trade_uses);
w.put_i32((*v511).xp);
w.put_i32((*v511).special_price);
w.put_f32((*v511).price_multiplier);
w.put_i32((*v511).demand);
}
w.put_varint((*self).villager_level);
w.put_varint((*self).experience);
w.put_bool((*self).is_regular_villager);
w.put_bool((*self).can_restock);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TradeList {
fn generate(g: &mut Gen) -> Self {
{
let v513 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v514 = {
let v515 = g.count();
let mut v516 = Vec::with_capacity(v515.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v515 {
v516.push({
let v517 = <types::Slot as Generate>::generate(g);
let v518 = <types::Slot as Generate>::generate(g);
let v519 = if g.bool() {
Some(<types::Slot as Generate>::generate(g))
} else {
None
};
let v520 = g.bool();
let v521 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v522 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v523 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v524 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v525 = g.f32();
let v526 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
TradeListTrades {
input_item1: v517,
output_item: v518,
input_item2: v519,
trade_disabled: v520,
nb_trade_uses: v521,
maximum_nb_trade_uses: v522,
xp: v523,
special_price: v524,
price_multiplier: v525,
demand: v526,
}
});
}
v516
};
let v527 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v528 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v529 = g.bool();
let v530 = g.bool();
TradeList {
window_id: v513,
trades: v514,
villager_level: v527,
experience: v528,
is_regular_villager: v529,
can_restock: v530,
}
}
}
}
impl From<TradeList> for ClientboundPlayPacket {
fn from(p: TradeList) -> Self {
Self::TradeList(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct RelEntityMove {
pub entity_id: i32,
pub d_x: i16,
pub d_y: i16,
pub d_z: i16,
pub on_ground: bool,
}
impl crate::packet::Packet for RelEntityMove {
const ID: i32 = id::REL_ENTITY_MOVE;
const NAME: &'static str = "rel_entity_move";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for RelEntityMove {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v531 = r.read_varint()?;
let v532 = r.read_i16()?;
let v533 = r.read_i16()?;
let v534 = r.read_i16()?;
let v535 = r.read_bool()?;
RelEntityMove {
entity_id: v531,
d_x: v532,
d_y: v533,
d_z: v534,
on_ground: v535,
}
})
}
}
impl Encode for RelEntityMove {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i16((*self).d_x);
w.put_i16((*self).d_y);
w.put_i16((*self).d_z);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for RelEntityMove {
fn generate(g: &mut Gen) -> Self {
{
let v536 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v537 = (g.int_in(-32768, 32767, &[]) as i16);
let v538 = (g.int_in(-32768, 32767, &[]) as i16);
let v539 = (g.int_in(-32768, 32767, &[]) as i16);
let v540 = g.bool();
RelEntityMove {
entity_id: v536,
d_x: v537,
d_y: v538,
d_z: v539,
on_ground: v540,
}
}
}
}
impl From<RelEntityMove> for ClientboundPlayPacket {
fn from(p: RelEntityMove) -> Self {
Self::RelEntityMove(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMoveLook {
pub entity_id: i32,
pub d_x: i16,
pub d_y: i16,
pub d_z: i16,
pub yaw: i8,
pub pitch: i8,
pub on_ground: bool,
}
impl crate::packet::Packet for EntityMoveLook {
const ID: i32 = id::ENTITY_MOVE_LOOK;
const NAME: &'static str = "entity_move_look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityMoveLook {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v541 = r.read_varint()?;
let v542 = r.read_i16()?;
let v543 = r.read_i16()?;
let v544 = r.read_i16()?;
let v545 = r.read_i8()?;
let v546 = r.read_i8()?;
let v547 = r.read_bool()?;
EntityMoveLook {
entity_id: v541,
d_x: v542,
d_y: v543,
d_z: v544,
yaw: v545,
pitch: v546,
on_ground: v547,
}
})
}
}
impl Encode for EntityMoveLook {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i16((*self).d_x);
w.put_i16((*self).d_y);
w.put_i16((*self).d_z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityMoveLook {
fn generate(g: &mut Gen) -> Self {
{
let v548 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v549 = (g.int_in(-32768, 32767, &[]) as i16);
let v550 = (g.int_in(-32768, 32767, &[]) as i16);
let v551 = (g.int_in(-32768, 32767, &[]) as i16);
let v552 = (g.int_in(-128, 127, &[]) as i8);
let v553 = (g.int_in(-128, 127, &[]) as i8);
let v554 = g.bool();
EntityMoveLook {
entity_id: v548,
d_x: v549,
d_y: v550,
d_z: v551,
yaw: v552,
pitch: v553,
on_ground: v554,
}
}
}
}
impl From<EntityMoveLook> for ClientboundPlayPacket {
fn from(p: EntityMoveLook) -> Self {
Self::EntityMoveLook(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityLook {
pub entity_id: i32,
pub yaw: i8,
pub pitch: i8,
pub on_ground: bool,
}
impl crate::packet::Packet for EntityLook {
const ID: i32 = id::ENTITY_LOOK;
const NAME: &'static str = "entity_look";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityLook {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v555 = r.read_varint()?;
let v556 = r.read_i8()?;
let v557 = r.read_i8()?;
let v558 = r.read_bool()?;
EntityLook {
entity_id: v555,
yaw: v556,
pitch: v557,
on_ground: v558,
}
})
}
}
impl Encode for EntityLook {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityLook {
fn generate(g: &mut Gen) -> Self {
{
let v559 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v560 = (g.int_in(-128, 127, &[]) as i8);
let v561 = (g.int_in(-128, 127, &[]) as i8);
let v562 = g.bool();
EntityLook {
entity_id: v559,
yaw: v560,
pitch: v561,
on_ground: v562,
}
}
}
}
impl From<EntityLook> for ClientboundPlayPacket {
fn from(p: EntityLook) -> Self {
Self::EntityLook(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Entity {
pub entity_id: i32,
}
impl crate::packet::Packet for Entity {
const ID: i32 = id::ENTITY;
const NAME: &'static str = "entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Entity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v563 = r.read_varint()?;
Entity { entity_id: v563 }
})
}
}
impl Encode for Entity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Entity {
fn generate(g: &mut Gen) -> Self {
{
let v564 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Entity { entity_id: v564 }
}
}
}
impl From<Entity> for ClientboundPlayPacket {
fn from(p: Entity) -> Self {
Self::Entity(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::Clientbound;
}
impl Decode for VehicleMove {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v565 = r.read_f64()?;
let v566 = r.read_f64()?;
let v567 = r.read_f64()?;
let v568 = r.read_f32()?;
let v569 = r.read_f32()?;
VehicleMove {
x: v565,
y: v566,
z: v567,
yaw: v568,
pitch: v569,
}
})
}
}
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 v570 = g.f64();
let v571 = g.f64();
let v572 = g.f64();
let v573 = g.f32();
let v574 = g.f32();
VehicleMove {
x: v570,
y: v571,
z: v572,
yaw: v573,
pitch: v574,
}
}
}
}
impl From<VehicleMove> for ClientboundPlayPacket {
fn from(p: VehicleMove) -> Self {
Self::VehicleMove(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct OpenBook {
pub hand: i32,
}
impl crate::packet::Packet for OpenBook {
const ID: i32 = id::OPEN_BOOK;
const NAME: &'static str = "open_book";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for OpenBook {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v575 = r.read_varint()?;
OpenBook { hand: v575 }
})
}
}
impl Encode for OpenBook {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).hand);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenBook {
fn generate(g: &mut Gen) -> Self {
{
let v576 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
OpenBook { hand: v576 }
}
}
}
impl From<OpenBook> for ClientboundPlayPacket {
fn from(p: OpenBook) -> Self {
Self::OpenBook(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct OpenWindow {
pub window_id: i32,
pub inventory_type: i32,
pub window_title: ByteString,
}
impl crate::packet::Packet for OpenWindow {
const ID: i32 = id::OPEN_WINDOW;
const NAME: &'static str = "open_window";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for OpenWindow {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v577 = r.read_varint()?;
let v578 = r.read_varint()?;
let v579 = r.read_string()?;
OpenWindow {
window_id: v577,
inventory_type: v578,
window_title: v579,
}
})
}
}
impl Encode for OpenWindow {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).window_id);
w.put_varint((*self).inventory_type);
w.put_string(&(*self).window_title)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenWindow {
fn generate(g: &mut Gen) -> Self {
{
let v580 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v581 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v582 = g.string();
OpenWindow {
window_id: v580,
inventory_type: v581,
window_title: v582,
}
}
}
}
impl From<OpenWindow> for ClientboundPlayPacket {
fn from(p: OpenWindow) -> Self {
Self::OpenWindow(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct OpenSignEntity {
pub location: BlockPos,
}
impl crate::packet::Packet for OpenSignEntity {
const ID: i32 = id::OPEN_SIGN_ENTITY;
const NAME: &'static str = "open_sign_entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for OpenSignEntity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v583 = BlockPos::read(r, PositionLayout::Xzy)?;
OpenSignEntity { location: v583 }
})
}
}
impl Encode for OpenSignEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenSignEntity {
fn generate(g: &mut Gen) -> Self {
{
let v584 = g.position();
OpenSignEntity { location: v584 }
}
}
}
impl From<OpenSignEntity> for ClientboundPlayPacket {
fn from(p: OpenSignEntity) -> Self {
Self::OpenSignEntity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeResponse {
pub window_id: i8,
pub recipe: ByteString,
}
impl crate::packet::Packet for CraftRecipeResponse {
const ID: i32 = id::CRAFT_RECIPE_RESPONSE;
const NAME: &'static str = "craft_recipe_response";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for CraftRecipeResponse {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v585 = r.read_i8()?;
let v586 = r.read_string()?;
CraftRecipeResponse {
window_id: v585,
recipe: v586,
}
})
}
}
impl Encode for CraftRecipeResponse {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_string(&(*self).recipe)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CraftRecipeResponse {
fn generate(g: &mut Gen) -> Self {
{
let v587 = (g.int_in(-128, 127, &[]) as i8);
let v588 = g.string();
CraftRecipeResponse {
window_id: v587,
recipe: v588,
}
}
}
}
impl From<CraftRecipeResponse> for ClientboundPlayPacket {
fn from(p: CraftRecipeResponse) -> Self {
Self::CraftRecipeResponse(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::Clientbound;
}
impl Decode for Abilities {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v589 = r.read_i8()?;
let v590 = r.read_f32()?;
let v591 = r.read_f32()?;
Abilities {
flags: v589,
flying_speed: v590,
walking_speed: v591,
}
})
}
}
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 v592 = (g.int_in(-128, 127, &[]) as i8);
let v593 = g.f32();
let v594 = g.f32();
Abilities {
flags: v592,
flying_speed: v593,
walking_speed: v594,
}
}
}
}
impl From<Abilities> for ClientboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct CombatEvent {
pub event: i32,
pub duration: Option<i32>,
pub player_id: Option<i32>,
pub entity_id: Option<i32>,
pub message: Option<ByteString>,
}
impl crate::packet::Packet for CombatEvent {
const ID: i32 = id::COMBAT_EVENT;
const NAME: &'static str = "combat_event";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for CombatEvent {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v595 = r.read_varint()?;
let v596 = if (v595 == 1) {
Some(r.read_varint()?)
} else {
None
};
let v597 = if (v595 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v598 = if (v595 == 1) || (v595 == 2) {
Some(r.read_i32()?)
} else {
None
};
let v599 = if (v595 == 2) {
Some(r.read_string()?)
} else {
None
};
CombatEvent {
event: v595,
duration: v596,
player_id: v597,
entity_id: v598,
message: v599,
}
})
}
}
impl Encode for CombatEvent {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).event);
match (&(*self).duration, ((*self).event == 1)) {
(Some(v600), true) => {
w.put_varint((*v600));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.duration",
));
}
}
match (&(*self).player_id, ((*self).event == 2)) {
(Some(v601), true) => {
w.put_varint((*v601));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.playerId",
));
}
}
match (
&(*self).entity_id,
((*self).event == 1) || ((*self).event == 2),
) {
(Some(v602), true) => {
w.put_i32((*v602));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.entityId",
));
}
}
match (&(*self).message, ((*self).event == 2)) {
(Some(v603), true) => {
w.put_string(&(*v603))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.message",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CombatEvent {
fn generate(g: &mut Gen) -> Self {
{
let v604 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
let v605 = if (v604 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v606 = if (v604 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v607 = if (v604 == 1) || (v604 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v608 = if (v604 == 2) { Some(g.string()) } else { None };
CombatEvent {
event: v604,
duration: v605,
player_id: v606,
entity_id: v607,
message: v608,
}
}
}
}
impl From<CombatEvent> for ClientboundPlayPacket {
fn from(p: CombatEvent) -> Self {
Self::CombatEvent(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfo {
pub action: PlayerInfoAction,
pub data: Vec<PlayerInfoData>,
}
impl crate::packet::Packet for PlayerInfo {
const ID: i32 = id::PLAYER_INFO;
const NAME: &'static str = "player_info";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for PlayerInfo {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v609 = PlayerInfoAction(r.read_varint()?);
let v610 = {
let v611 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 16)?
};
let mut v612 = Vec::with_capacity(v611.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v611 {
v612.push({
let v613 = r.read_uuid()?;
let v614 = (if (v609.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v615 = r.read_string()?;
let v616 = {
let v617 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v618 =
Vec::with_capacity(v617.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v617 {
v618.push({
let v619 = r.read_string()?;
let v620 = r.read_string()?;
let v621 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayerProperties {
name: v619,
value: v620,
signature: v621,
}
});
}
v618
};
let v622 = r.read_varint()?;
let v623 = r.read_varint()?;
let v624 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayer {
name: v615,
properties: v616,
gamemode: v622,
ping: v623,
display_name: v624,
}
})
} else if (v609.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v625 = r.read_varint()?;
PlayerInfoDataBodyUpdateGameMode { gamemode: v625 }
})
} else if (v609.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v626 = r.read_varint()?;
PlayerInfoDataBodyUpdateLatency { ping: v626 }
})
} else if (v609.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v627 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyUpdateDisplayName { display_name: v627 }
})
} else if (v609.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v613,
body: v614,
}
});
}
v612
};
PlayerInfo {
action: v609,
data: v610,
}
})
}
}
impl Encode for PlayerInfo {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action.0);
w.put_len_varint((*self).data.len())?;
for v628 in (*self).data.iter() {
w.put_uuid(&(*v628).uuid);
match &(*v628).body {
PlayerInfoDataBody::AddPlayer(v629) => {
if !((*self).action.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_string(&(*v629).name)?;
w.put_len_varint((*v629).properties.len())?;
for v630 in (*v629).properties.iter() {
w.put_string(&(*v630).name)?;
w.put_string(&(*v630).value)?;
match &(*v630).signature {
Some(v631) => {
w.put_u8(1);
w.put_string(&(*v631))?;
}
None => w.put_u8(0),
}
}
w.put_varint((*v629).gamemode);
w.put_varint((*v629).ping);
match &(*v629).display_name {
Some(v632) => {
w.put_u8(1);
w.put_string(&(*v632))?;
}
None => w.put_u8(0),
}
}
PlayerInfoDataBody::UpdateGameMode(v633) => {
if !((*self).action.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v633).gamemode);
}
PlayerInfoDataBody::UpdateLatency(v634) => {
if !((*self).action.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v634).ping);
}
PlayerInfoDataBody::UpdateDisplayName(v635) => {
if !((*self).action.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
match &(*v635).display_name {
Some(v636) => {
w.put_u8(1);
w.put_string(&(*v636))?;
}
None => w.put_u8(0),
}
}
PlayerInfoDataBody::RemovePlayer => {
if !((*self).action.0 == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
}
PlayerInfoDataBody::Other => {
if !(!(((*self).action.0 == 0)
|| ((*self).action.0 == 1)
|| ((*self).action.0 == 2)
|| ((*self).action.0 == 3)
|| ((*self).action.0 == 4)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for PlayerInfo {
fn generate(g: &mut Gen) -> Self {
{
let v637 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
let v638 = {
let v639 = g.count();
let mut v640 = Vec::with_capacity(v639.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v639 {
v640.push({
let v641 = g.uuid();
let v642 = (if (v637.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v643 = g.string();
let v644 = {
let v645 = g.count();
let mut v646 =
Vec::with_capacity(v645.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v645 {
v646.push({
let v647 = g.string();
let v648 = g.string();
let v649 =
if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayerProperties {
name: v647,
value: v648,
signature: v649,
}
});
}
v646
};
let v650 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v651 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v652 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayer {
name: v643,
properties: v644,
gamemode: v650,
ping: v651,
display_name: v652,
}
})
} else if (v637.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v653 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateGameMode { gamemode: v653 }
})
} else if (v637.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v654 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateLatency { ping: v654 }
})
} else if (v637.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v655 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyUpdateDisplayName { display_name: v655 }
})
} else if (v637.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v641,
body: v642,
}
});
}
v640
};
PlayerInfo {
action: v637,
data: v638,
}
}
}
}
impl From<PlayerInfo> for ClientboundPlayPacket {
fn from(p: PlayerInfo) -> Self {
Self::PlayerInfo(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct FacePlayer {
pub feet_eyes: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub is_entity: bool,
pub entity_id: Option<i32>,
pub entity_feet_eyes: Option<ByteString>,
}
impl crate::packet::Packet for FacePlayer {
const ID: i32 = id::FACE_PLAYER;
const NAME: &'static str = "face_player";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for FacePlayer {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v656 = r.read_varint()?;
let v657 = r.read_f64()?;
let v658 = r.read_f64()?;
let v659 = r.read_f64()?;
let v660 = r.read_bool()?;
let v661 = if v660 { Some(r.read_varint()?) } else { None };
let v662 = if v660 { Some(r.read_string()?) } else { None };
FacePlayer {
feet_eyes: v656,
x: v657,
y: v658,
z: v659,
is_entity: v660,
entity_id: v661,
entity_feet_eyes: v662,
}
})
}
}
impl Encode for FacePlayer {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).feet_eyes);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_bool((*self).is_entity);
match (&(*self).entity_id, (*self).is_entity) {
(Some(v663), true) => {
w.put_varint((*v663));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entityId",
));
}
}
match (&(*self).entity_feet_eyes, (*self).is_entity) {
(Some(v664), true) => {
w.put_string(&(*v664))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.face_player.entity_feet_eyes",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for FacePlayer {
fn generate(g: &mut Gen) -> Self {
{
let v665 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v666 = g.f64();
let v667 = g.f64();
let v668 = g.f64();
let v669 = g.bool();
let v670 = if v669 {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v671 = if v669 { Some(g.string()) } else { None };
FacePlayer {
feet_eyes: v665,
x: v666,
y: v667,
z: v668,
is_entity: v669,
entity_id: v670,
entity_feet_eyes: v671,
}
}
}
}
impl From<FacePlayer> for ClientboundPlayPacket {
fn from(p: FacePlayer) -> Self {
Self::FacePlayer(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Position {
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
pub flags: i8,
pub teleport_id: i32,
}
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::Clientbound;
}
impl Decode for Position {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v672 = r.read_f64()?;
let v673 = r.read_f64()?;
let v674 = r.read_f64()?;
let v675 = r.read_f32()?;
let v676 = r.read_f32()?;
let v677 = r.read_i8()?;
let v678 = r.read_varint()?;
Position {
x: v672,
y: v673,
z: v674,
yaw: v675,
pitch: v676,
flags: v677,
teleport_id: v678,
}
})
}
}
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_f32((*self).yaw);
w.put_f32((*self).pitch);
w.put_i8((*self).flags);
w.put_varint((*self).teleport_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Position {
fn generate(g: &mut Gen) -> Self {
{
let v679 = g.f64();
let v680 = g.f64();
let v681 = g.f64();
let v682 = g.f32();
let v683 = g.f32();
let v684 = (g.int_in(-128, 127, &[]) as i8);
let v685 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Position {
x: v679,
y: v680,
z: v681,
yaw: v682,
pitch: v683,
flags: v684,
teleport_id: v685,
}
}
}
}
impl From<Position> for ClientboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UnlockRecipes {
pub action: i32,
pub crafting_book_open: bool,
pub filtering_craftable: bool,
pub smelting_book_open: bool,
pub filtering_smeltable: bool,
pub blast_furnace_open: bool,
pub filtering_blast_furnace: bool,
pub smoker_book_open: bool,
pub filtering_smoker: bool,
pub recipes1: Vec<ByteString>,
pub recipes2: Option<Vec<ByteString>>,
}
impl crate::packet::Packet for UnlockRecipes {
const ID: i32 = id::UNLOCK_RECIPES;
const NAME: &'static str = "unlock_recipes";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UnlockRecipes {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v686 = r.read_varint()?;
let v687 = r.read_bool()?;
let v688 = r.read_bool()?;
let v689 = r.read_bool()?;
let v690 = r.read_bool()?;
let v691 = r.read_bool()?;
let v692 = r.read_bool()?;
let v693 = r.read_bool()?;
let v694 = r.read_bool()?;
let v695 = {
let v696 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v697 = Vec::with_capacity(v696.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v696 {
v697.push(r.read_string()?);
}
v697
};
let v698 = if (v686 == 0) {
Some({
let v699 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v700 = Vec::with_capacity(v699.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v699 {
v700.push(r.read_string()?);
}
v700
})
} else {
None
};
UnlockRecipes {
action: v686,
crafting_book_open: v687,
filtering_craftable: v688,
smelting_book_open: v689,
filtering_smeltable: v690,
blast_furnace_open: v691,
filtering_blast_furnace: v692,
smoker_book_open: v693,
filtering_smoker: v694,
recipes1: v695,
recipes2: v698,
}
})
}
}
impl Encode for UnlockRecipes {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
w.put_bool((*self).crafting_book_open);
w.put_bool((*self).filtering_craftable);
w.put_bool((*self).smelting_book_open);
w.put_bool((*self).filtering_smeltable);
w.put_bool((*self).blast_furnace_open);
w.put_bool((*self).filtering_blast_furnace);
w.put_bool((*self).smoker_book_open);
w.put_bool((*self).filtering_smoker);
w.put_len_varint((*self).recipes1.len())?;
for v701 in (*self).recipes1.iter() {
w.put_string(&(*v701))?;
}
match (&(*self).recipes2, ((*self).action == 0)) {
(Some(v702), true) => {
w.put_len_varint((*v702).len())?;
for v703 in (*v702).iter() {
w.put_string(&(*v703))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.unlock_recipes.recipes2",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UnlockRecipes {
fn generate(g: &mut Gen) -> Self {
{
let v704 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
let v705 = g.bool();
let v706 = g.bool();
let v707 = g.bool();
let v708 = g.bool();
let v709 = g.bool();
let v710 = g.bool();
let v711 = g.bool();
let v712 = g.bool();
let v713 = {
let v714 = g.count();
let mut v715 = Vec::with_capacity(v714.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v714 {
v715.push(g.string());
}
v715
};
let v716 = if (v704 == 0) {
Some({
let v717 = g.count();
let mut v718 = Vec::with_capacity(v717.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v717 {
v718.push(g.string());
}
v718
})
} else {
None
};
UnlockRecipes {
action: v704,
crafting_book_open: v705,
filtering_craftable: v706,
smelting_book_open: v707,
filtering_smeltable: v708,
blast_furnace_open: v709,
filtering_blast_furnace: v710,
smoker_book_open: v711,
filtering_smoker: v712,
recipes1: v713,
recipes2: v716,
}
}
}
}
impl From<UnlockRecipes> for ClientboundPlayPacket {
fn from(p: UnlockRecipes) -> Self {
Self::UnlockRecipes(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityDestroy {
pub entity_ids: Vec<i32>,
}
impl crate::packet::Packet for EntityDestroy {
const ID: i32 = id::ENTITY_DESTROY;
const NAME: &'static str = "entity_destroy";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityDestroy {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v719 = {
let v720 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v721 = Vec::with_capacity(v720.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v720 {
v721.push(r.read_varint()?);
}
v721
};
EntityDestroy { entity_ids: v719 }
})
}
}
impl Encode for EntityDestroy {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entity_ids.len())?;
for v722 in (*self).entity_ids.iter() {
w.put_varint((*v722));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityDestroy {
fn generate(g: &mut Gen) -> Self {
{
let v723 = {
let v724 = g.count();
let mut v725 = Vec::with_capacity(v724.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v724 {
v725.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v725
};
EntityDestroy { entity_ids: v723 }
}
}
}
impl From<EntityDestroy> for ClientboundPlayPacket {
fn from(p: EntityDestroy) -> Self {
Self::EntityDestroy(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct RemoveEntityEffect {
pub entity_id: i32,
pub effect_id: i8,
}
impl crate::packet::Packet for RemoveEntityEffect {
const ID: i32 = id::REMOVE_ENTITY_EFFECT;
const NAME: &'static str = "remove_entity_effect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for RemoveEntityEffect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v726 = r.read_varint()?;
let v727 = r.read_i8()?;
RemoveEntityEffect {
entity_id: v726,
effect_id: v727,
}
})
}
}
impl Encode for RemoveEntityEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).effect_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for RemoveEntityEffect {
fn generate(g: &mut Gen) -> Self {
{
let v728 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v729 = (g.int_in(-128, 127, &[]) as i8);
RemoveEntityEffect {
entity_id: v728,
effect_id: v729,
}
}
}
}
impl From<RemoveEntityEffect> for ClientboundPlayPacket {
fn from(p: RemoveEntityEffect) -> Self {
Self::RemoveEntityEffect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackSend {
pub url: ByteString,
pub hash: ByteString,
}
impl crate::packet::Packet for ResourcePackSend {
const ID: i32 = id::RESOURCE_PACK_SEND;
const NAME: &'static str = "resource_pack_send";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for ResourcePackSend {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v730 = r.read_string()?;
let v731 = r.read_string()?;
ResourcePackSend {
url: v730,
hash: v731,
}
})
}
}
impl Encode for ResourcePackSend {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).url)?;
w.put_string(&(*self).hash)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ResourcePackSend {
fn generate(g: &mut Gen) -> Self {
{
let v732 = g.string();
let v733 = g.string();
ResourcePackSend {
url: v732,
hash: v733,
}
}
}
}
impl From<ResourcePackSend> for ClientboundPlayPacket {
fn from(p: ResourcePackSend) -> Self {
Self::ResourcePackSend(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Respawn {
pub dimension: RawNbt,
pub world_name: ByteString,
pub hashed_seed: i64,
pub gamemode: u8,
pub previous_gamemode: u8,
pub is_debug: bool,
pub is_flat: bool,
pub copy_metadata: bool,
}
impl crate::packet::Packet for Respawn {
const ID: i32 = id::RESPAWN;
const NAME: &'static str = "respawn";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Respawn {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v734 = RawNbt::read(r)?;
let v735 = r.read_string()?;
let v736 = r.read_i64()?;
let v737 = r.read_u8()?;
let v738 = r.read_u8()?;
let v739 = r.read_bool()?;
let v740 = r.read_bool()?;
let v741 = r.read_bool()?;
Respawn {
dimension: v734,
world_name: v735,
hashed_seed: v736,
gamemode: v737,
previous_gamemode: v738,
is_debug: v739,
is_flat: v740,
copy_metadata: v741,
}
})
}
}
impl Encode for Respawn {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).dimension.write(w);
w.put_string(&(*self).world_name)?;
w.put_i64((*self).hashed_seed);
w.put_u8((*self).gamemode);
w.put_u8((*self).previous_gamemode);
w.put_bool((*self).is_debug);
w.put_bool((*self).is_flat);
w.put_bool((*self).copy_metadata);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Respawn {
fn generate(g: &mut Gen) -> Self {
{
let v742 = g.nbt();
let v743 = g.string();
let v744 = g.i64();
let v745 = (g.int_in(0, 255, &[]) as u8);
let v746 = (g.int_in(0, 255, &[]) as u8);
let v747 = g.bool();
let v748 = g.bool();
let v749 = g.bool();
Respawn {
dimension: v742,
world_name: v743,
hashed_seed: v744,
gamemode: v745,
previous_gamemode: v746,
is_debug: v747,
is_flat: v748,
copy_metadata: v749,
}
}
}
}
impl From<Respawn> for ClientboundPlayPacket {
fn from(p: Respawn) -> Self {
Self::Respawn(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityHeadRotation {
pub entity_id: i32,
pub head_yaw: i8,
}
impl crate::packet::Packet for EntityHeadRotation {
const ID: i32 = id::ENTITY_HEAD_ROTATION;
const NAME: &'static str = "entity_head_rotation";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityHeadRotation {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v750 = r.read_varint()?;
let v751 = r.read_i8()?;
EntityHeadRotation {
entity_id: v750,
head_yaw: v751,
}
})
}
}
impl Encode for EntityHeadRotation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).head_yaw);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityHeadRotation {
fn generate(g: &mut Gen) -> Self {
{
let v752 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v753 = (g.int_in(-128, 127, &[]) as i8);
EntityHeadRotation {
entity_id: v752,
head_yaw: v753,
}
}
}
}
impl From<EntityHeadRotation> for ClientboundPlayPacket {
fn from(p: EntityHeadRotation) -> Self {
Self::EntityHeadRotation(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MultiBlockChange {
pub chunk_coordinates: MultiBlockChangeChunkCoordinates,
pub not_trust_edges: bool,
pub records: Vec<i64>,
}
impl crate::packet::Packet for MultiBlockChange {
const ID: i32 = id::MULTI_BLOCK_CHANGE;
const NAME: &'static str = "multi_block_change";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for MultiBlockChange {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v754 = {
let v755 = r.read_u64()?;
MultiBlockChangeChunkCoordinates {
x: ((((((v755 >> 42) & 0x3fffff) << 42) as i64) >> 42) as i32),
z: ((((((v755 >> 20) & 0x3fffff) << 42) as i64) >> 42) as i32),
y: (((v755 >> 0) & 0xfffff) as u32),
}
};
let v756 = r.read_bool()?;
let v757 = {
let v758 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v759 = Vec::with_capacity(v758.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v758 {
v759.push(r.read_varlong()?);
}
v759
};
MultiBlockChange {
chunk_coordinates: v754,
not_trust_edges: v756,
records: v757,
}
})
}
}
impl Encode for MultiBlockChange {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
{
let mut bits: u64 = 0;
{
let x = i128::from((*self).chunk_coordinates.x);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("x"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.z);
if x < -2097152 || x > 2097151 {
return Err(EncodeError::OutOfRange("z"));
}
bits = (bits << 22) | ((x as u64) & 0x3fffff);
}
{
let x = i128::from((*self).chunk_coordinates.y);
if x < 0 || x > 1048575 {
return Err(EncodeError::OutOfRange("y"));
}
bits = (bits << 20) | ((x as u64) & 0xfffff);
}
w.put_u64(bits);
}
w.put_bool((*self).not_trust_edges);
w.put_len_varint((*self).records.len())?;
for v760 in (*self).records.iter() {
w.put_varlong((*v760));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MultiBlockChange {
fn generate(g: &mut Gen) -> Self {
{
let v761 = {
MultiBlockChangeChunkCoordinates {
x: (g.int_in(-2097152, 2097151, &[]) as i32),
z: (g.int_in(-2097152, 2097151, &[]) as i32),
y: (g.int_in(0, 1048575, &[]) as u32),
}
};
let v763 = g.bool();
let v764 = {
let v765 = g.count();
let mut v766 = Vec::with_capacity(v765.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v765 {
v766.push(g.varlong());
}
v766
};
MultiBlockChange {
chunk_coordinates: v761,
not_trust_edges: v763,
records: v764,
}
}
}
}
impl From<MultiBlockChange> for ClientboundPlayPacket {
fn from(p: MultiBlockChange) -> Self {
Self::MultiBlockChange(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SelectAdvancementTab {
pub id: Option<ByteString>,
}
impl crate::packet::Packet for SelectAdvancementTab {
const ID: i32 = id::SELECT_ADVANCEMENT_TAB;
const NAME: &'static str = "select_advancement_tab";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SelectAdvancementTab {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v767 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
SelectAdvancementTab { id: v767 }
})
}
}
impl Encode for SelectAdvancementTab {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).id {
Some(v768) => {
w.put_u8(1);
w.put_string(&(*v768))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SelectAdvancementTab {
fn generate(g: &mut Gen) -> Self {
{
let v769 = if g.bool() { Some(g.string()) } else { None };
SelectAdvancementTab { id: v769 }
}
}
}
impl From<SelectAdvancementTab> for ClientboundPlayPacket {
fn from(p: SelectAdvancementTab) -> Self {
Self::SelectAdvancementTab(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorder {
pub action: i32,
pub radius: Option<f64>,
pub x: Option<f64>,
pub z: Option<f64>,
pub old_radius: Option<f64>,
pub new_radius: Option<f64>,
pub speed: Option<i64>,
pub portal_boundary: Option<i32>,
pub warning_time: Option<i32>,
pub warning_blocks: Option<i32>,
}
impl crate::packet::Packet for WorldBorder {
const ID: i32 = id::WORLD_BORDER;
const NAME: &'static str = "world_border";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for WorldBorder {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v770 = r.read_varint()?;
let v771 = if (v770 == 0) {
Some(r.read_f64()?)
} else {
None
};
let v772 = if (v770 == 2) || (v770 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v773 = if (v770 == 2) || (v770 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v774 = if (v770 == 1) || (v770 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v775 = if (v770 == 1) || (v770 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v776 = if (v770 == 1) || (v770 == 3) {
Some(r.read_varlong()?)
} else {
None
};
let v777 = if (v770 == 3) {
Some(r.read_varint()?)
} else {
None
};
let v778 = if (v770 == 3) || (v770 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v779 = if (v770 == 3) || (v770 == 5) {
Some(r.read_varint()?)
} else {
None
};
WorldBorder {
action: v770,
radius: v771,
x: v772,
z: v773,
old_radius: v774,
new_radius: v775,
speed: v776,
portal_boundary: v777,
warning_time: v778,
warning_blocks: v779,
}
})
}
}
impl Encode for WorldBorder {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (&(*self).radius, ((*self).action == 0)) {
(Some(v780), true) => {
w.put_f64((*v780));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.radius",
));
}
}
match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v781), true) => {
w.put_f64((*v781));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.x",
));
}
}
match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v782), true) => {
w.put_f64((*v782));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.z",
));
}
}
match (
&(*self).old_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v783), true) => {
w.put_f64((*v783));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.old_radius",
));
}
}
match (
&(*self).new_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v784), true) => {
w.put_f64((*v784));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.new_radius",
));
}
}
match (
&(*self).speed,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v785), true) => {
w.put_varlong((*v785));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.speed",
));
}
}
match (&(*self).portal_boundary, ((*self).action == 3)) {
(Some(v786), true) => {
w.put_varint((*v786));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.portalBoundary",
));
}
}
match (
&(*self).warning_time,
((*self).action == 3) || ((*self).action == 4),
) {
(Some(v787), true) => {
w.put_varint((*v787));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.warning_time",
));
}
}
match (
&(*self).warning_blocks,
((*self).action == 3) || ((*self).action == 5),
) {
(Some(v788), true) => {
w.put_varint((*v788));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.warning_blocks",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WorldBorder {
fn generate(g: &mut Gen) -> Self {
{
let v789 = (g.int_in(
-2147483648,
2147483647,
&[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
) as i32);
let v790 = if (v789 == 0) { Some(g.f64()) } else { None };
let v791 = if (v789 == 2) || (v789 == 3) {
Some(g.f64())
} else {
None
};
let v792 = if (v789 == 2) || (v789 == 3) {
Some(g.f64())
} else {
None
};
let v793 = if (v789 == 1) || (v789 == 3) {
Some(g.f64())
} else {
None
};
let v794 = if (v789 == 1) || (v789 == 3) {
Some(g.f64())
} else {
None
};
let v795 = if (v789 == 1) || (v789 == 3) {
Some(g.varlong())
} else {
None
};
let v796 = if (v789 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v797 = if (v789 == 3) || (v789 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v798 = if (v789 == 3) || (v789 == 5) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
WorldBorder {
action: v789,
radius: v790,
x: v791,
z: v792,
old_radius: v793,
new_radius: v794,
speed: v795,
portal_boundary: v796,
warning_time: v797,
warning_blocks: v798,
}
}
}
}
impl From<WorldBorder> for ClientboundPlayPacket {
fn from(p: WorldBorder) -> Self {
Self::WorldBorder(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Camera {
pub camera_id: i32,
}
impl crate::packet::Packet for Camera {
const ID: i32 = id::CAMERA;
const NAME: &'static str = "camera";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Camera {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v799 = r.read_varint()?;
Camera { camera_id: v799 }
})
}
}
impl Encode for Camera {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).camera_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Camera {
fn generate(g: &mut Gen) -> Self {
{
let v800 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Camera { camera_id: v800 }
}
}
}
impl From<Camera> for ClientboundPlayPacket {
fn from(p: Camera) -> Self {
Self::Camera(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct HeldItemSlot {
pub slot: i8,
}
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::Clientbound;
}
impl Decode for HeldItemSlot {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v801 = r.read_i8()?;
HeldItemSlot { slot: v801 }
})
}
}
impl Encode for HeldItemSlot {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).slot);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for HeldItemSlot {
fn generate(g: &mut Gen) -> Self {
{
let v802 = (g.int_in(-128, 127, &[]) as i8);
HeldItemSlot { slot: v802 }
}
}
}
impl From<HeldItemSlot> for ClientboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateViewPosition {
pub chunk_x: i32,
pub chunk_z: i32,
}
impl crate::packet::Packet for UpdateViewPosition {
const ID: i32 = id::UPDATE_VIEW_POSITION;
const NAME: &'static str = "update_view_position";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateViewPosition {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v803 = r.read_varint()?;
let v804 = r.read_varint()?;
UpdateViewPosition {
chunk_x: v803,
chunk_z: v804,
}
})
}
}
impl Encode for UpdateViewPosition {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).chunk_x);
w.put_varint((*self).chunk_z);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateViewPosition {
fn generate(g: &mut Gen) -> Self {
{
let v805 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v806 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
UpdateViewPosition {
chunk_x: v805,
chunk_z: v806,
}
}
}
}
impl From<UpdateViewPosition> for ClientboundPlayPacket {
fn from(p: UpdateViewPosition) -> Self {
Self::UpdateViewPosition(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateViewDistance {
pub view_distance: i32,
}
impl crate::packet::Packet for UpdateViewDistance {
const ID: i32 = id::UPDATE_VIEW_DISTANCE;
const NAME: &'static str = "update_view_distance";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateViewDistance {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v807 = r.read_varint()?;
UpdateViewDistance {
view_distance: v807,
}
})
}
}
impl Encode for UpdateViewDistance {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).view_distance);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateViewDistance {
fn generate(g: &mut Gen) -> Self {
{
let v808 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
UpdateViewDistance {
view_distance: v808,
}
}
}
}
impl From<UpdateViewDistance> for ClientboundPlayPacket {
fn from(p: UpdateViewDistance) -> Self {
Self::UpdateViewDistance(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnPosition {
pub location: BlockPos,
}
impl crate::packet::Packet for SpawnPosition {
const ID: i32 = id::SPAWN_POSITION;
const NAME: &'static str = "spawn_position";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnPosition {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v809 = BlockPos::read(r, PositionLayout::Xzy)?;
SpawnPosition { location: v809 }
})
}
}
impl Encode for SpawnPosition {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xzy)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnPosition {
fn generate(g: &mut Gen) -> Self {
{
let v810 = g.position();
SpawnPosition { location: v810 }
}
}
}
impl From<SpawnPosition> for ClientboundPlayPacket {
fn from(p: SpawnPosition) -> Self {
Self::SpawnPosition(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardDisplayObjective {
pub position: i8,
pub name: ByteString,
}
impl crate::packet::Packet for ScoreboardDisplayObjective {
const ID: i32 = id::SCOREBOARD_DISPLAY_OBJECTIVE;
const NAME: &'static str = "scoreboard_display_objective";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for ScoreboardDisplayObjective {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v811 = r.read_i8()?;
let v812 = r.read_string()?;
ScoreboardDisplayObjective {
position: v811,
name: v812,
}
})
}
}
impl Encode for ScoreboardDisplayObjective {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).position);
w.put_string(&(*self).name)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ScoreboardDisplayObjective {
fn generate(g: &mut Gen) -> Self {
{
let v813 = (g.int_in(-128, 127, &[]) as i8);
let v814 = g.string();
ScoreboardDisplayObjective {
position: v813,
name: v814,
}
}
}
}
impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardDisplayObjective) -> Self {
Self::ScoreboardDisplayObjective(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMetadata {
pub entity_id: i32,
pub metadata: Vec<types::EntityMetadataEntry>,
}
impl crate::packet::Packet for EntityMetadata {
const ID: i32 = id::ENTITY_METADATA;
const NAME: &'static str = "entity_metadata";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityMetadata {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v815 = r.read_varint()?;
let v816 = {
let mut v817 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v817.push({
let v818 = r.read_u8()?;
let v819 = r.read_varint()?;
let v820 = (if (v819 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v819 == 1) {
types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v819 == 2) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v819 == 3) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v819 == 4) {
types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v819 == 5) {
types::EntityMetadataValue::OptChat(if r.read_bool()? {
Some(r.read_string()?)
} else {
None
})
} else if (v819 == 6) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v819 == 7) {
types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v819 == 8) {
types::EntityMetadataValue::Rotation({
let v821 = r.read_f32()?;
let v822 = r.read_f32()?;
let v823 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v821,
yaw: v822,
roll: v823,
}
})
} else if (v819 == 9) {
types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xzy,
)?)
} else if (v819 == 10) {
types::EntityMetadataValue::OptPosition(if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xzy)?)
} else {
None
})
} else if (v819 == 11) {
types::EntityMetadataValue::Direction(r.read_varint()?)
} else if (v819 == 12) {
types::EntityMetadataValue::OptUuid(if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
})
} else if (v819 == 13) {
types::EntityMetadataValue::BlockState(r.read_varint()?)
} else if (v819 == 14) {
types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else if (v819 == 15) {
types::EntityMetadataValue::Particle(
<types::Particle as Decode>::decode(r)?,
)
} else if (v819 == 16) {
types::EntityMetadataValue::VillagerData({
let v824 = r.read_varint()?;
let v825 = r.read_varint()?;
let v826 = r.read_varint()?;
types::EntityMetadataValueVillagerData {
villager_type: v824,
villager_profession: v825,
level: v826,
}
})
} else if (v819 == 17) {
types::EntityMetadataValue::OptVarInt(r.read_varint()?)
} else if (v819 == 18) {
types::EntityMetadataValue::Pose(r.read_varint()?)
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v818,
r#type: v819,
value: v820,
}
});
}
v817
};
EntityMetadata {
entity_id: v815,
metadata: v816,
}
})
}
}
impl Encode for EntityMetadata {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
for v827 in (*self).metadata.iter() {
let v828 = w.len();
w.put_u8((*v827).key);
w.put_varint((*v827).r#type);
match &(*v827).value {
types::EntityMetadataValue::Byte(v829) => {
if !((*v827).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v829));
}
types::EntityMetadataValue::VarInt(v830) => {
if !((*v827).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v830));
}
types::EntityMetadataValue::Float(v831) => {
if !((*v827).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v831));
}
types::EntityMetadataValue::String(v832) => {
if !((*v827).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v832))?;
}
types::EntityMetadataValue::Chat(v833) => {
if !((*v827).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v833))?;
}
types::EntityMetadataValue::OptChat(v834) => {
if !((*v827).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v834) {
Some(v835) => {
w.put_u8(1);
w.put_string(&(*v835))?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Slot(v836) => {
if !((*v827).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v836).encode(w)?;
}
types::EntityMetadataValue::Boolean(v837) => {
if !((*v827).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v837));
}
types::EntityMetadataValue::Rotation(v838) => {
if !((*v827).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v838).pitch);
w.put_f32((*v838).yaw);
w.put_f32((*v838).roll);
}
types::EntityMetadataValue::Position(v839) => {
if !((*v827).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v839).write(w, PositionLayout::Xzy)?;
}
types::EntityMetadataValue::OptPosition(v840) => {
if !((*v827).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v840) {
Some(v841) => {
w.put_u8(1);
(*v841).write(w, PositionLayout::Xzy)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v842) => {
if !((*v827).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v842));
}
types::EntityMetadataValue::OptUuid(v843) => {
if !((*v827).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v843) {
Some(v844) => {
w.put_u8(1);
w.put_uuid(&(*v844));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v845) => {
if !((*v827).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v845));
}
types::EntityMetadataValue::Nbt(v846) => {
if !((*v827).r#type == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v846).write(w);
}
types::EntityMetadataValue::Particle(v847) => {
if !((*v827).r#type == 15) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v847).encode(w)?;
}
types::EntityMetadataValue::VillagerData(v848) => {
if !((*v827).r#type == 16) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v848).villager_type);
w.put_varint((*v848).villager_profession);
w.put_varint((*v848).level);
}
types::EntityMetadataValue::OptVarInt(v849) => {
if !((*v827).r#type == 17) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v849));
}
types::EntityMetadataValue::Pose(v850) => {
if !((*v827).r#type == 18) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v850));
}
types::EntityMetadataValue::Other => {
if !(!(((*v827).r#type == 0)
|| ((*v827).r#type == 1)
|| ((*v827).r#type == 2)
|| ((*v827).r#type == 3)
|| ((*v827).r#type == 4)
|| ((*v827).r#type == 5)
|| ((*v827).r#type == 6)
|| ((*v827).r#type == 7)
|| ((*v827).r#type == 8)
|| ((*v827).r#type == 9)
|| ((*v827).r#type == 10)
|| ((*v827).r#type == 11)
|| ((*v827).r#type == 12)
|| ((*v827).r#type == 13)
|| ((*v827).r#type == 14)
|| ((*v827).r#type == 15)
|| ((*v827).r#type == 16)
|| ((*v827).r#type == 17)
|| ((*v827).r#type == 18)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
if w.get(v828) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_metadata.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityMetadata {
fn generate(g: &mut Gen) -> Self {
{
let v851 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v852 = {
let n = g.count();
let mut v853 = Vec::with_capacity(n);
for _ in 0..n {
v853.push(loop {
let v854 = {
let v855 = (g.int_in(0, 255, &[]) as u8);
let v856 = (g.int_in(
-2147483648,
2147483647,
&[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18,
],
) as i32);
let v857 = (if (v856 == 0) {
types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
} else if (v856 == 1) {
types::EntityMetadataValue::VarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v856 == 2) {
types::EntityMetadataValue::Float(g.f32())
} else if (v856 == 3) {
types::EntityMetadataValue::String(g.string())
} else if (v856 == 4) {
types::EntityMetadataValue::Chat(g.string())
} else if (v856 == 5) {
types::EntityMetadataValue::OptChat(if g.bool() {
Some(g.string())
} else {
None
})
} else if (v856 == 6) {
types::EntityMetadataValue::Slot(
<types::Slot as Generate>::generate(g),
)
} else if (v856 == 7) {
types::EntityMetadataValue::Boolean(g.bool())
} else if (v856 == 8) {
types::EntityMetadataValue::Rotation({
let v858 = g.f32();
let v859 = g.f32();
let v860 = g.f32();
types::EntityMetadataValueRotation {
pitch: v858,
yaw: v859,
roll: v860,
}
})
} else if (v856 == 9) {
types::EntityMetadataValue::Position(g.position())
} else if (v856 == 10) {
types::EntityMetadataValue::OptPosition(if g.bool() {
Some(g.position())
} else {
None
})
} else if (v856 == 11) {
types::EntityMetadataValue::Direction(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v856 == 12) {
types::EntityMetadataValue::OptUuid(if g.bool() {
Some(g.uuid())
} else {
None
})
} else if (v856 == 13) {
types::EntityMetadataValue::BlockState(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v856 == 14) {
types::EntityMetadataValue::Nbt(g.nbt())
} else if (v856 == 15) {
types::EntityMetadataValue::Particle(
<types::Particle as Generate>::generate(g),
)
} else if (v856 == 16) {
types::EntityMetadataValue::VillagerData({
let v861 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v862 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v863 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
types::EntityMetadataValueVillagerData {
villager_type: v861,
villager_profession: v862,
level: v863,
}
})
} else if (v856 == 17) {
types::EntityMetadataValue::OptVarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v856 == 18) {
types::EntityMetadataValue::Pose(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v855,
r#type: v856,
value: v857,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_u8(v854.key);
w.put_varint(v854.r#type);
match &v854.value {
types::EntityMetadataValue::Byte(v864) => {
if !(v854.r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v864));
}
types::EntityMetadataValue::VarInt(v865) => {
if !(v854.r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v865));
}
types::EntityMetadataValue::Float(v866) => {
if !(v854.r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v866));
}
types::EntityMetadataValue::String(v867) => {
if !(v854.r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v867))?;
}
types::EntityMetadataValue::Chat(v868) => {
if !(v854.r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v868))?;
}
types::EntityMetadataValue::OptChat(v869) => {
if !(v854.r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v869) {
Some(v870) => {
w.put_u8(1);
w.put_string(&(*v870))?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Slot(v871) => {
if !(v854.r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v871).encode(w)?;
}
types::EntityMetadataValue::Boolean(v872) => {
if !(v854.r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v872));
}
types::EntityMetadataValue::Rotation(v873) => {
if !(v854.r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v873).pitch);
w.put_f32((*v873).yaw);
w.put_f32((*v873).roll);
}
types::EntityMetadataValue::Position(v874) => {
if !(v854.r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v874).write(w, PositionLayout::Xzy)?;
}
types::EntityMetadataValue::OptPosition(v875) => {
if !(v854.r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v875) {
Some(v876) => {
w.put_u8(1);
(*v876).write(w, PositionLayout::Xzy)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v877) => {
if !(v854.r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v877));
}
types::EntityMetadataValue::OptUuid(v878) => {
if !(v854.r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v878) {
Some(v879) => {
w.put_u8(1);
w.put_uuid(&(*v879));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v880) => {
if !(v854.r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v880));
}
types::EntityMetadataValue::Nbt(v881) => {
if !(v854.r#type == 14) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v881).write(w);
}
types::EntityMetadataValue::Particle(v882) => {
if !(v854.r#type == 15) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v882).encode(w)?;
}
types::EntityMetadataValue::VillagerData(v883) => {
if !(v854.r#type == 16) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v883).villager_type);
w.put_varint((*v883).villager_profession);
w.put_varint((*v883).level);
}
types::EntityMetadataValue::OptVarInt(v884) => {
if !(v854.r#type == 17) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v884));
}
types::EntityMetadataValue::Pose(v885) => {
if !(v854.r#type == 18) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v885));
}
types::EntityMetadataValue::Other => {
if !(!((v854.r#type == 0)
|| (v854.r#type == 1)
|| (v854.r#type == 2)
|| (v854.r#type == 3)
|| (v854.r#type == 4)
|| (v854.r#type == 5)
|| (v854.r#type == 6)
|| (v854.r#type == 7)
|| (v854.r#type == 8)
|| (v854.r#type == 9)
|| (v854.r#type == 10)
|| (v854.r#type == 11)
|| (v854.r#type == 12)
|| (v854.r#type == 13)
|| (v854.r#type == 14)
|| (v854.r#type == 15)
|| (v854.r#type == 16)
|| (v854.r#type == 17)
|| (v854.r#type == 18)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
Ok(())
},
|b| b != 255,
) {
break v854;
}
});
}
v853
};
EntityMetadata {
entity_id: v851,
metadata: v852,
}
}
}
}
impl From<EntityMetadata> for ClientboundPlayPacket {
fn from(p: EntityMetadata) -> Self {
Self::EntityMetadata(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct AttachEntity {
pub entity_id: i32,
pub vehicle_id: i32,
}
impl crate::packet::Packet for AttachEntity {
const ID: i32 = id::ATTACH_ENTITY;
const NAME: &'static str = "attach_entity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for AttachEntity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v886 = r.read_i32()?;
let v887 = r.read_i32()?;
AttachEntity {
entity_id: v886,
vehicle_id: v887,
}
})
}
}
impl Encode for AttachEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_i32((*self).vehicle_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for AttachEntity {
fn generate(g: &mut Gen) -> Self {
{
let v888 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v889 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
AttachEntity {
entity_id: v888,
vehicle_id: v889,
}
}
}
}
impl From<AttachEntity> for ClientboundPlayPacket {
fn from(p: AttachEntity) -> Self {
Self::AttachEntity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityVelocity {
pub entity_id: i32,
pub velocity: types::Vec3i16,
}
impl crate::packet::Packet for EntityVelocity {
const ID: i32 = id::ENTITY_VELOCITY;
const NAME: &'static str = "entity_velocity";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityVelocity {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v890 = r.read_varint()?;
let v891 = <types::Vec3i16 as Decode>::decode(r)?;
EntityVelocity {
entity_id: v890,
velocity: v891,
}
})
}
}
impl Encode for EntityVelocity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).velocity.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityVelocity {
fn generate(g: &mut Gen) -> Self {
{
let v892 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v893 = <types::Vec3i16 as Generate>::generate(g);
EntityVelocity {
entity_id: v892,
velocity: v893,
}
}
}
}
impl From<EntityVelocity> for ClientboundPlayPacket {
fn from(p: EntityVelocity) -> Self {
Self::EntityVelocity(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment {
pub entity_id: i32,
pub equipments: Vec<EntityEquipmentEquipments>,
}
impl crate::packet::Packet for EntityEquipment {
const ID: i32 = id::ENTITY_EQUIPMENT;
const NAME: &'static str = "entity_equipment";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityEquipment {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v894 = r.read_varint()?;
let v895 = {
let mut v896 = Vec::new();
loop {
let v897 = r.read_u8()?;
v896.push({
let v898 = ((v897 & 0x7f) as i8);
let v899 = <types::Slot as Decode>::decode(r)?;
EntityEquipmentEquipments {
slot: v898,
item: v899,
}
});
if v897 & 0x80 == 0 {
break;
}
}
v896
};
EntityEquipment {
entity_id: v894,
equipments: v895,
}
})
}
}
impl Encode for EntityEquipment {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
if (*self).equipments.is_empty() {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.entity_equipment.equipments",
expected: 1,
actual: 0,
});
}
for (v901, v900) in (*self).equipments.iter().enumerate() {
let v902 = w.len();
w.put_i8((*v900).slot);
(*v900).item.encode(w)?;
match w.get_mut(v902) {
Some(b) if *b & 0x80 == 0 => {
if v901 + 1 < (*self).equipments.len() {
*b |= 0x80;
}
}
_ => {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_equipment.equipments",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityEquipment {
fn generate(g: &mut Gen) -> Self {
{
let v903 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v904 = {
let n = 1 + g.count();
let mut v905 = Vec::with_capacity(n);
for _ in 0..n {
v905.push(loop {
let v906 = {
let v907 = (g.int_in(-128, 127, &[]) as i8);
let v908 = <types::Slot as Generate>::generate(g);
EntityEquipmentEquipments {
slot: v907,
item: v908,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_i8(v906.slot);
v906.item.encode(w)?;
Ok(())
},
|b| b & 0x80 == 0,
) {
break v906;
}
});
}
v905
};
EntityEquipment {
entity_id: v903,
equipments: v904,
}
}
}
}
impl From<EntityEquipment> for ClientboundPlayPacket {
fn from(p: EntityEquipment) -> Self {
Self::EntityEquipment(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Experience {
pub experience_bar: f32,
pub level: i32,
pub total_experience: i32,
}
impl crate::packet::Packet for Experience {
const ID: i32 = id::EXPERIENCE;
const NAME: &'static str = "experience";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Experience {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v909 = r.read_f32()?;
let v910 = r.read_varint()?;
let v911 = r.read_varint()?;
Experience {
experience_bar: v909,
level: v910,
total_experience: v911,
}
})
}
}
impl Encode for Experience {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).experience_bar);
w.put_varint((*self).level);
w.put_varint((*self).total_experience);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Experience {
fn generate(g: &mut Gen) -> Self {
{
let v912 = g.f32();
let v913 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v914 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Experience {
experience_bar: v912,
level: v913,
total_experience: v914,
}
}
}
}
impl From<Experience> for ClientboundPlayPacket {
fn from(p: Experience) -> Self {
Self::Experience(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateHealth {
pub health: f32,
pub food: i32,
pub food_saturation: f32,
}
impl crate::packet::Packet for UpdateHealth {
const ID: i32 = id::UPDATE_HEALTH;
const NAME: &'static str = "update_health";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateHealth {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v915 = r.read_f32()?;
let v916 = r.read_varint()?;
let v917 = r.read_f32()?;
UpdateHealth {
health: v915,
food: v916,
food_saturation: v917,
}
})
}
}
impl Encode for UpdateHealth {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_f32((*self).health);
w.put_varint((*self).food);
w.put_f32((*self).food_saturation);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateHealth {
fn generate(g: &mut Gen) -> Self {
{
let v918 = g.f32();
let v919 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v920 = g.f32();
UpdateHealth {
health: v918,
food: v919,
food_saturation: v920,
}
}
}
}
impl From<UpdateHealth> for ClientboundPlayPacket {
fn from(p: UpdateHealth) -> Self {
Self::UpdateHealth(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardObjective {
pub name: ByteString,
pub action: i8,
pub display_text: Option<ByteString>,
pub r#type: Option<i32>,
}
impl crate::packet::Packet for ScoreboardObjective {
const ID: i32 = id::SCOREBOARD_OBJECTIVE;
const NAME: &'static str = "scoreboard_objective";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for ScoreboardObjective {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v921 = r.read_string()?;
let v922 = r.read_i8()?;
let v923 = if (v922 == 0) || (v922 == 2) {
Some(r.read_string()?)
} else {
None
};
let v924 = if (v922 == 0) || (v922 == 2) {
Some(r.read_varint()?)
} else {
None
};
ScoreboardObjective {
name: v921,
action: v922,
display_text: v923,
r#type: v924,
}
})
}
}
impl Encode for ScoreboardObjective {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).name)?;
w.put_i8((*self).action);
match (
&(*self).display_text,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v925), true) => {
w.put_string(&(*v925))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.displayText",
));
}
}
match (
&(*self).r#type,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v926), true) => {
w.put_varint((*v926));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.type",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ScoreboardObjective {
fn generate(g: &mut Gen) -> Self {
{
let v927 = g.string();
let v928 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
let v929 = if (v928 == 0) || (v928 == 2) {
Some(g.string())
} else {
None
};
let v930 = if (v928 == 0) || (v928 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
ScoreboardObjective {
name: v927,
action: v928,
display_text: v929,
r#type: v930,
}
}
}
}
impl From<ScoreboardObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardObjective) -> Self {
Self::ScoreboardObjective(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SetPassengers {
pub entity_id: i32,
pub passengers: Vec<i32>,
}
impl crate::packet::Packet for SetPassengers {
const ID: i32 = id::SET_PASSENGERS;
const NAME: &'static str = "set_passengers";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SetPassengers {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v931 = r.read_varint()?;
let v932 = {
let v933 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v934 = Vec::with_capacity(v933.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v933 {
v934.push(r.read_varint()?);
}
v934
};
SetPassengers {
entity_id: v931,
passengers: v932,
}
})
}
}
impl Encode for SetPassengers {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_len_varint((*self).passengers.len())?;
for v935 in (*self).passengers.iter() {
w.put_varint((*v935));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetPassengers {
fn generate(g: &mut Gen) -> Self {
{
let v936 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v937 = {
let v938 = g.count();
let mut v939 = Vec::with_capacity(v938.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v938 {
v939.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v939
};
SetPassengers {
entity_id: v936,
passengers: v937,
}
}
}
}
impl From<SetPassengers> for ClientboundPlayPacket {
fn from(p: SetPassengers) -> Self {
Self::SetPassengers(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Teams {
pub team: ByteString,
pub mode: i8,
pub name: Option<ByteString>,
pub friendly_fire: Option<i8>,
pub name_tag_visibility: Option<ByteString>,
pub collision_rule: Option<ByteString>,
pub formatting: Option<i32>,
pub prefix: Option<ByteString>,
pub suffix: Option<ByteString>,
pub players: Option<Vec<ByteString>>,
}
impl crate::packet::Packet for Teams {
const ID: i32 = id::TEAMS;
const NAME: &'static str = "teams";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Teams {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v940 = r.read_string()?;
let v941 = r.read_i8()?;
let v942 = if (v941 == 0) || (v941 == 2) {
Some(r.read_string()?)
} else {
None
};
let v943 = if (v941 == 0) || (v941 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v944 = if (v941 == 0) || (v941 == 2) {
Some(r.read_string()?)
} else {
None
};
let v945 = if (v941 == 0) || (v941 == 2) {
Some(r.read_string()?)
} else {
None
};
let v946 = if (v941 == 0) || (v941 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v947 = if (v941 == 0) || (v941 == 2) {
Some(r.read_string()?)
} else {
None
};
let v948 = if (v941 == 0) || (v941 == 2) {
Some(r.read_string()?)
} else {
None
};
let v949 = if (v941 == 0) || (v941 == 3) || (v941 == 4) {
Some({
let v950 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v951 = Vec::with_capacity(v950.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v950 {
v951.push(r.read_string()?);
}
v951
})
} else {
None
};
Teams {
team: v940,
mode: v941,
name: v942,
friendly_fire: v943,
name_tag_visibility: v944,
collision_rule: v945,
formatting: v946,
prefix: v947,
suffix: v948,
players: v949,
}
})
}
}
impl Encode for Teams {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).team)?;
w.put_i8((*self).mode);
match (&(*self).name, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v952), true) => {
w.put_string(&(*v952))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
}
match (
&(*self).friendly_fire,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v953), true) => {
w.put_i8((*v953));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.friendlyFire",
));
}
}
match (
&(*self).name_tag_visibility,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v954), true) => {
w.put_string(&(*v954))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.nameTagVisibility",
));
}
}
match (
&(*self).collision_rule,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v955), true) => {
w.put_string(&(*v955))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.collisionRule",
));
}
}
match (
&(*self).formatting,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v956), true) => {
w.put_varint((*v956));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.formatting",
));
}
}
match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v957), true) => {
w.put_string(&(*v957))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
}
match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v958), true) => {
w.put_string(&(*v958))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
}
match (
&(*self).players,
((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
) {
(Some(v959), true) => {
w.put_len_varint((*v959).len())?;
for v960 in (*v959).iter() {
w.put_string(&(*v960))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.players",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Teams {
fn generate(g: &mut Gen) -> Self {
{
let v961 = g.string();
let v962 = (g.int_in(
-128,
127,
&[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4],
) as i8);
let v963 = if (v962 == 0) || (v962 == 2) {
Some(g.string())
} else {
None
};
let v964 = if (v962 == 0) || (v962 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v965 = if (v962 == 0) || (v962 == 2) {
Some(g.string())
} else {
None
};
let v966 = if (v962 == 0) || (v962 == 2) {
Some(g.string())
} else {
None
};
let v967 = if (v962 == 0) || (v962 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v968 = if (v962 == 0) || (v962 == 2) {
Some(g.string())
} else {
None
};
let v969 = if (v962 == 0) || (v962 == 2) {
Some(g.string())
} else {
None
};
let v970 = if (v962 == 0) || (v962 == 3) || (v962 == 4) {
Some({
let v971 = g.count();
let mut v972 = Vec::with_capacity(v971.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v971 {
v972.push(g.string());
}
v972
})
} else {
None
};
Teams {
team: v961,
mode: v962,
name: v963,
friendly_fire: v964,
name_tag_visibility: v965,
collision_rule: v966,
formatting: v967,
prefix: v968,
suffix: v969,
players: v970,
}
}
}
}
impl From<Teams> for ClientboundPlayPacket {
fn from(p: Teams) -> Self {
Self::Teams(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardScore {
pub item_name: ByteString,
pub action: i32,
pub score_name: ByteString,
pub value: Option<i32>,
}
impl crate::packet::Packet for ScoreboardScore {
const ID: i32 = id::SCOREBOARD_SCORE;
const NAME: &'static str = "scoreboard_score";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for ScoreboardScore {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v973 = r.read_string()?;
let v974 = r.read_varint()?;
let v975 = r.read_string()?;
let v976 = if !(v974 == 1) {
Some(r.read_varint()?)
} else {
None
};
ScoreboardScore {
item_name: v973,
action: v974,
score_name: v975,
value: v976,
}
})
}
}
impl Encode for ScoreboardScore {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).item_name)?;
w.put_varint((*self).action);
w.put_string(&(*self).score_name)?;
match (&(*self).value, !((*self).action == 1)) {
(Some(v977), true) => {
w.put_varint((*v977));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_score.value",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ScoreboardScore {
fn generate(g: &mut Gen) -> Self {
{
let v978 = g.string();
let v979 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
let v980 = g.string();
let v981 = if !(v979 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
ScoreboardScore {
item_name: v978,
action: v979,
score_name: v980,
value: v981,
}
}
}
}
impl From<ScoreboardScore> for ClientboundPlayPacket {
fn from(p: ScoreboardScore) -> Self {
Self::ScoreboardScore(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateTime {
pub age: i64,
pub time: i64,
}
impl crate::packet::Packet for UpdateTime {
const ID: i32 = id::UPDATE_TIME;
const NAME: &'static str = "update_time";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateTime {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v982 = r.read_i64()?;
let v983 = r.read_i64()?;
UpdateTime {
age: v982,
time: v983,
}
})
}
}
impl Encode for UpdateTime {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i64((*self).age);
w.put_i64((*self).time);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateTime {
fn generate(g: &mut Gen) -> Self {
{
let v984 = g.i64();
let v985 = g.i64();
UpdateTime {
age: v984,
time: v985,
}
}
}
}
impl From<UpdateTime> for ClientboundPlayPacket {
fn from(p: UpdateTime) -> Self {
Self::UpdateTime(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Title {
pub action: i32,
pub text: Option<ByteString>,
pub fade_in: Option<i32>,
pub stay: Option<i32>,
pub fade_out: Option<i32>,
}
impl crate::packet::Packet for Title {
const ID: i32 = id::TITLE;
const NAME: &'static str = "title";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Title {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v986 = r.read_varint()?;
let v987 = if (v986 == 0) || (v986 == 1) || (v986 == 2) {
Some(r.read_string()?)
} else {
None
};
let v988 = if (v986 == 3) {
Some(r.read_i32()?)
} else {
None
};
let v989 = if (v986 == 3) {
Some(r.read_i32()?)
} else {
None
};
let v990 = if (v986 == 3) {
Some(r.read_i32()?)
} else {
None
};
Title {
action: v986,
text: v987,
fade_in: v988,
stay: v989,
fade_out: v990,
}
})
}
}
impl Encode for Title {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (
&(*self).text,
((*self).action == 0) || ((*self).action == 1) || ((*self).action == 2),
) {
(Some(v991), true) => {
w.put_string(&(*v991))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
}
match (&(*self).fade_in, ((*self).action == 3)) {
(Some(v992), true) => {
w.put_i32((*v992));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
}
match (&(*self).stay, ((*self).action == 3)) {
(Some(v993), true) => {
w.put_i32((*v993));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
}
match (&(*self).fade_out, ((*self).action == 3)) {
(Some(v994), true) => {
w.put_i32((*v994));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.title.fadeOut",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Title {
fn generate(g: &mut Gen) -> Self {
{
let v995 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 3, 3]) as i32);
let v996 = if (v995 == 0) || (v995 == 1) || (v995 == 2) {
Some(g.string())
} else {
None
};
let v997 = if (v995 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v998 = if (v995 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v999 = if (v995 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Title {
action: v995,
text: v996,
fade_in: v997,
stay: v998,
fade_out: v999,
}
}
}
}
impl From<Title> for ClientboundPlayPacket {
fn from(p: Title) -> Self {
Self::Title(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntitySoundEffect {
pub sound_id: i32,
pub sound_category: i32,
pub entity_id: i32,
pub volume: f32,
pub pitch: f32,
}
impl crate::packet::Packet for EntitySoundEffect {
const ID: i32 = id::ENTITY_SOUND_EFFECT;
const NAME: &'static str = "entity_sound_effect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntitySoundEffect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1000 = r.read_varint()?;
let v1001 = r.read_varint()?;
let v1002 = r.read_varint()?;
let v1003 = r.read_f32()?;
let v1004 = r.read_f32()?;
EntitySoundEffect {
sound_id: v1000,
sound_category: v1001,
entity_id: v1002,
volume: v1003,
pitch: v1004,
}
})
}
}
impl Encode for EntitySoundEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).sound_id);
w.put_varint((*self).sound_category);
w.put_varint((*self).entity_id);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntitySoundEffect {
fn generate(g: &mut Gen) -> Self {
{
let v1005 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1006 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1007 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1008 = g.f32();
let v1009 = g.f32();
EntitySoundEffect {
sound_id: v1005,
sound_category: v1006,
entity_id: v1007,
volume: v1008,
pitch: v1009,
}
}
}
}
impl From<EntitySoundEffect> for ClientboundPlayPacket {
fn from(p: EntitySoundEffect) -> Self {
Self::EntitySoundEffect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct SoundEffect {
pub sound_id: i32,
pub sound_category: i32,
pub x: i32,
pub y: i32,
pub z: i32,
pub volume: f32,
pub pitch: f32,
}
impl crate::packet::Packet for SoundEffect {
const ID: i32 = id::SOUND_EFFECT;
const NAME: &'static str = "sound_effect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SoundEffect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1010 = r.read_varint()?;
let v1011 = r.read_varint()?;
let v1012 = r.read_i32()?;
let v1013 = r.read_i32()?;
let v1014 = r.read_i32()?;
let v1015 = r.read_f32()?;
let v1016 = r.read_f32()?;
SoundEffect {
sound_id: v1010,
sound_category: v1011,
x: v1012,
y: v1013,
z: v1014,
volume: v1015,
pitch: v1016,
}
})
}
}
impl Encode for SoundEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).sound_id);
w.put_varint((*self).sound_category);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_f32((*self).pitch);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SoundEffect {
fn generate(g: &mut Gen) -> Self {
{
let v1017 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1018 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1019 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1020 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1021 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1022 = g.f32();
let v1023 = g.f32();
SoundEffect {
sound_id: v1017,
sound_category: v1018,
x: v1019,
y: v1020,
z: v1021,
volume: v1022,
pitch: v1023,
}
}
}
}
impl From<SoundEffect> for ClientboundPlayPacket {
fn from(p: SoundEffect) -> Self {
Self::SoundEffect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct StopSound {
pub flags: i8,
pub source: Option<i32>,
pub sound: Option<ByteString>,
}
impl crate::packet::Packet for StopSound {
const ID: i32 = id::STOP_SOUND;
const NAME: &'static str = "stop_sound";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for StopSound {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1024 = r.read_i8()?;
let v1025 = if (v1024 == 1) || (v1024 == 3) {
Some(r.read_varint()?)
} else {
None
};
let v1026 = if (v1024 == 2) || (v1024 == 3) {
Some(r.read_string()?)
} else {
None
};
StopSound {
flags: v1024,
source: v1025,
sound: v1026,
}
})
}
}
impl Encode for StopSound {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).flags);
match (
&(*self).source,
((*self).flags == 1) || ((*self).flags == 3),
) {
(Some(v1027), true) => {
w.put_varint((*v1027));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.stop_sound.source",
));
}
}
match (&(*self).sound, ((*self).flags == 2) || ((*self).flags == 3)) {
(Some(v1028), true) => {
w.put_string(&(*v1028))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.stop_sound.sound",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for StopSound {
fn generate(g: &mut Gen) -> Self {
{
let v1029 = (g.int_in(-128, 127, &[1, 3, 2, 3]) as i8);
let v1030 = if (v1029 == 1) || (v1029 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v1031 = if (v1029 == 2) || (v1029 == 3) {
Some(g.string())
} else {
None
};
StopSound {
flags: v1029,
source: v1030,
sound: v1031,
}
}
}
}
impl From<StopSound> for ClientboundPlayPacket {
fn from(p: StopSound) -> Self {
Self::StopSound(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerlistHeader {
pub header: ByteString,
pub footer: ByteString,
}
impl crate::packet::Packet for PlayerlistHeader {
const ID: i32 = id::PLAYERLIST_HEADER;
const NAME: &'static str = "playerlist_header";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for PlayerlistHeader {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1032 = r.read_string()?;
let v1033 = r.read_string()?;
PlayerlistHeader {
header: v1032,
footer: v1033,
}
})
}
}
impl Encode for PlayerlistHeader {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).header)?;
w.put_string(&(*self).footer)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for PlayerlistHeader {
fn generate(g: &mut Gen) -> Self {
{
let v1034 = g.string();
let v1035 = g.string();
PlayerlistHeader {
header: v1034,
footer: v1035,
}
}
}
}
impl From<PlayerlistHeader> for ClientboundPlayPacket {
fn from(p: PlayerlistHeader) -> Self {
Self::PlayerlistHeader(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct NbtQueryResponse {
pub transaction_id: i32,
pub nbt: Option<RawNbt>,
}
impl crate::packet::Packet for NbtQueryResponse {
const ID: i32 = id::NBT_QUERY_RESPONSE;
const NAME: &'static str = "nbt_query_response";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for NbtQueryResponse {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1036 = r.read_varint()?;
let v1037 = RawNbt::read_optional(r)?;
NbtQueryResponse {
transaction_id: v1036,
nbt: v1037,
}
})
}
}
impl Encode for NbtQueryResponse {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).transaction_id);
RawNbt::write_optional(&(*self).nbt, w);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NbtQueryResponse {
fn generate(g: &mut Gen) -> Self {
{
let v1038 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1039 = g.opt_nbt();
NbtQueryResponse {
transaction_id: v1038,
nbt: v1039,
}
}
}
}
impl From<NbtQueryResponse> for ClientboundPlayPacket {
fn from(p: NbtQueryResponse) -> Self {
Self::NbtQueryResponse(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Collect {
pub collected_entity_id: i32,
pub collector_entity_id: i32,
pub pickup_item_count: i32,
}
impl crate::packet::Packet for Collect {
const ID: i32 = id::COLLECT;
const NAME: &'static str = "collect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Collect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1040 = r.read_varint()?;
let v1041 = r.read_varint()?;
let v1042 = r.read_varint()?;
Collect {
collected_entity_id: v1040,
collector_entity_id: v1041,
pickup_item_count: v1042,
}
})
}
}
impl Encode for Collect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).collected_entity_id);
w.put_varint((*self).collector_entity_id);
w.put_varint((*self).pickup_item_count);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Collect {
fn generate(g: &mut Gen) -> Self {
{
let v1043 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1044 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1045 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Collect {
collected_entity_id: v1043,
collector_entity_id: v1044,
pickup_item_count: v1045,
}
}
}
}
impl From<Collect> for ClientboundPlayPacket {
fn from(p: Collect) -> Self {
Self::Collect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityTeleport {
pub entity_id: i32,
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: i8,
pub pitch: i8,
pub on_ground: bool,
}
impl crate::packet::Packet for EntityTeleport {
const ID: i32 = id::ENTITY_TELEPORT;
const NAME: &'static str = "entity_teleport";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityTeleport {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1046 = r.read_varint()?;
let v1047 = r.read_f64()?;
let v1048 = r.read_f64()?;
let v1049 = r.read_f64()?;
let v1050 = r.read_i8()?;
let v1051 = r.read_i8()?;
let v1052 = r.read_bool()?;
EntityTeleport {
entity_id: v1046,
x: v1047,
y: v1048,
z: v1049,
yaw: v1050,
pitch: v1051,
on_ground: v1052,
}
})
}
}
impl Encode for EntityTeleport {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityTeleport {
fn generate(g: &mut Gen) -> Self {
{
let v1053 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1054 = g.f64();
let v1055 = g.f64();
let v1056 = g.f64();
let v1057 = (g.int_in(-128, 127, &[]) as i8);
let v1058 = (g.int_in(-128, 127, &[]) as i8);
let v1059 = g.bool();
EntityTeleport {
entity_id: v1053,
x: v1054,
y: v1055,
z: v1056,
yaw: v1057,
pitch: v1058,
on_ground: v1059,
}
}
}
}
impl From<EntityTeleport> for ClientboundPlayPacket {
fn from(p: EntityTeleport) -> Self {
Self::EntityTeleport(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements {
pub reset: bool,
pub advancement_mapping: Vec<AdvancementsAdvancementMapping>,
pub identifiers: Vec<ByteString>,
pub progress_mapping: Vec<AdvancementsProgressMapping>,
}
impl crate::packet::Packet for Advancements {
const ID: i32 = id::ADVANCEMENTS;
const NAME: &'static str = "advancements";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Advancements {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1060 = r.read_bool()?;
let v1061 = {
let v1062 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v1063 = Vec::with_capacity(v1062.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1062 {
v1063.push({
let v1064 = r.read_string()?;
let v1065 = {
let v1066 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
let v1067 = if r.read_bool()? {
Some({
let v1068 = r.read_string()?;
let v1069 = r.read_string()?;
let v1070 = <types::Slot as Decode>::decode(r)?;
let v1071 = r.read_varint()?;
let v1072 = {
let v1073 = u64::from(r.read_i32()? as u32);
AdvancementsAdvancementMappingValueDisplayDataFlags {
_unused: (((v1073 >> 3) & 0x1fffffff) as u32),
hidden: (((v1073 >> 2) & 0x1) as u8),
show_toast: (((v1073 >> 1) & 0x1) as u8),
has_background_texture: (((v1073 >> 0) & 0x1) as u8),
}
};
let v1074 = if (v1072.has_background_texture == 1) {
Some(r.read_string()?)
} else {
None
};
let v1075 = r.read_f32()?;
let v1076 = r.read_f32()?;
AdvancementsAdvancementMappingValueDisplayData {
title: v1068,
description: v1069,
icon: v1070,
frame_type: v1071,
flags: v1072,
background_texture: v1074,
x_cord: v1075,
y_cord: v1076,
}
})
} else {
None
};
let v1077 = {
let v1078 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1079 =
Vec::with_capacity(v1078.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1078 {
v1079.push({
let v1080 = r.read_string()?;
AdvancementsAdvancementMappingValueCriteria { key: v1080 }
});
}
v1079
};
let v1082 = {
let v1083 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1084 =
Vec::with_capacity(v1083.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1083 {
v1084.push({
let v1085 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1086 = Vec::with_capacity(
v1085.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1085 {
v1086.push(r.read_string()?);
}
v1086
});
}
v1084
};
AdvancementsAdvancementMappingValue {
parent_id: v1066,
display_data: v1067,
criteria: v1077,
requirements: v1082,
}
};
AdvancementsAdvancementMapping {
key: v1064,
value: v1065,
}
});
}
v1063
};
let v1087 = {
let v1088 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1089 = Vec::with_capacity(v1088.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1088 {
v1089.push(r.read_string()?);
}
v1089
};
let v1090 = {
let v1091 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1092 = Vec::with_capacity(v1091.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1091 {
v1092.push({
let v1093 = r.read_string()?;
let v1094 = {
let v1095 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1096 =
Vec::with_capacity(v1095.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1095 {
v1096.push({
let v1097 = r.read_string()?;
let v1098 = if r.read_bool()? {
Some(r.read_i64()?)
} else {
None
};
AdvancementsProgressMappingValue {
criterion_identifier: v1097,
criterion_progress: v1098,
}
});
}
v1096
};
AdvancementsProgressMapping {
key: v1093,
value: v1094,
}
});
}
v1092
};
Advancements {
reset: v1060,
advancement_mapping: v1061,
identifiers: v1087,
progress_mapping: v1090,
}
})
}
}
impl Encode for Advancements {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).reset);
w.put_len_varint((*self).advancement_mapping.len())?;
for v1099 in (*self).advancement_mapping.iter() {
w.put_string(&(*v1099).key)?;
match &(*v1099).value.parent_id {
Some(v1100) => {
w.put_u8(1);
w.put_string(&(*v1100))?;
}
None => w.put_u8(0),
}
match &(*v1099).value.display_data {
Some(v1101) => {
w.put_u8(1);
w.put_string(&(*v1101).title)?;
w.put_string(&(*v1101).description)?;
(*v1101).icon.encode(w)?;
w.put_varint((*v1101).frame_type);
{
let mut bits: u64 = 0;
{
let x = i128::from((*v1101).flags._unused);
if x < 0 || x > 536870911 {
return Err(EncodeError::OutOfRange("_unused"));
}
bits = (bits << 29) | ((x as u64) & 0x1fffffff);
}
{
let x = i128::from((*v1101).flags.hidden);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("hidden"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v1101).flags.show_toast);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("show_toast"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v1101).flags.has_background_texture);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("has_background_texture"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
w.put_u32(bits as u32);
}
match (
&(*v1101).background_texture,
((*v1101).flags.has_background_texture == 1),
) {
(Some(v1102), true) => {
w.put_string(&(*v1102))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
));
}
}
w.put_f32((*v1101).x_cord);
w.put_f32((*v1101).y_cord);
}
None => w.put_u8(0),
}
w.put_len_varint((*v1099).value.criteria.len())?;
for v1103 in (*v1099).value.criteria.iter() {
w.put_string(&(*v1103).key)?;
}
w.put_len_varint((*v1099).value.requirements.len())?;
for v1104 in (*v1099).value.requirements.iter() {
w.put_len_varint((*v1104).len())?;
for v1105 in (*v1104).iter() {
w.put_string(&(*v1105))?;
}
}
}
w.put_len_varint((*self).identifiers.len())?;
for v1106 in (*self).identifiers.iter() {
w.put_string(&(*v1106))?;
}
w.put_len_varint((*self).progress_mapping.len())?;
for v1107 in (*self).progress_mapping.iter() {
w.put_string(&(*v1107).key)?;
w.put_len_varint((*v1107).value.len())?;
for v1108 in (*v1107).value.iter() {
w.put_string(&(*v1108).criterion_identifier)?;
match &(*v1108).criterion_progress {
Some(v1109) => {
w.put_u8(1);
w.put_i64((*v1109));
}
None => w.put_u8(0),
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Advancements {
fn generate(g: &mut Gen) -> Self {
{
let v1110 = g.bool();
let v1111 = {
let v1112 = g.count();
let mut v1113 = Vec::with_capacity(v1112.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1112 {
v1113.push({
let v1114 = g.string();
let v1115 = {
let v1116 = if g.bool() { Some(g.string()) } else { None };
let v1117 = if g.bool() {
Some({
let v1118 = g.string();
let v1119 = g.string();
let v1120 = <types::Slot as Generate>::generate(g);
let v1121 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1122 = {
AdvancementsAdvancementMappingValueDisplayDataFlags {
_unused: (g.int_in(0, 536870911, &[]) as u32),
hidden: (g.int_in(0, 1, &[]) as u8),
show_toast: (g.int_in(0, 1, &[]) as u8),
has_background_texture: (g.int_in(0, 1, &[1]) as u8),
}
};
let v1124 = if (v1122.has_background_texture == 1) {
Some(g.string())
} else {
None
};
let v1125 = g.f32();
let v1126 = g.f32();
AdvancementsAdvancementMappingValueDisplayData {
title: v1118,
description: v1119,
icon: v1120,
frame_type: v1121,
flags: v1122,
background_texture: v1124,
x_cord: v1125,
y_cord: v1126,
}
})
} else {
None
};
let v1127 = {
let v1128 = g.count();
let mut v1129 =
Vec::with_capacity(v1128.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1128 {
v1129.push({
let v1130 = g.string();
AdvancementsAdvancementMappingValueCriteria { key: v1130 }
});
}
v1129
};
let v1132 = {
let v1133 = g.count();
let mut v1134 =
Vec::with_capacity(v1133.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1133 {
v1134.push({
let v1135 = g.count();
let mut v1136 = Vec::with_capacity(
v1135.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1135 {
v1136.push(g.string());
}
v1136
});
}
v1134
};
AdvancementsAdvancementMappingValue {
parent_id: v1116,
display_data: v1117,
criteria: v1127,
requirements: v1132,
}
};
AdvancementsAdvancementMapping {
key: v1114,
value: v1115,
}
});
}
v1113
};
let v1137 = {
let v1138 = g.count();
let mut v1139 = Vec::with_capacity(v1138.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1138 {
v1139.push(g.string());
}
v1139
};
let v1140 = {
let v1141 = g.count();
let mut v1142 = Vec::with_capacity(v1141.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1141 {
v1142.push({
let v1143 = g.string();
let v1144 = {
let v1145 = g.count();
let mut v1146 =
Vec::with_capacity(v1145.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1145 {
v1146.push({
let v1147 = g.string();
let v1148 = if g.bool() { Some(g.i64()) } else { None };
AdvancementsProgressMappingValue {
criterion_identifier: v1147,
criterion_progress: v1148,
}
});
}
v1146
};
AdvancementsProgressMapping {
key: v1143,
value: v1144,
}
});
}
v1142
};
Advancements {
reset: v1110,
advancement_mapping: v1111,
identifiers: v1137,
progress_mapping: v1140,
}
}
}
}
impl From<Advancements> for ClientboundPlayPacket {
fn from(p: Advancements) -> Self {
Self::Advancements(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributes {
pub entity_id: i32,
pub properties: Vec<EntityUpdateAttributesProperties>,
}
impl crate::packet::Packet for EntityUpdateAttributes {
const ID: i32 = id::ENTITY_UPDATE_ATTRIBUTES;
const NAME: &'static str = "entity_update_attributes";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityUpdateAttributes {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1149 = r.read_varint()?;
let v1150 = {
let v1151 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 10)?
};
let mut v1152 = Vec::with_capacity(v1151.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1151 {
v1152.push({
let v1153 = r.read_string()?;
let v1154 = r.read_f64()?;
let v1155 = {
let v1156 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 25)?
};
let mut v1157 =
Vec::with_capacity(v1156.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1156 {
v1157.push({
let v1158 = r.read_uuid()?;
let v1159 = r.read_f64()?;
let v1160 = r.read_i8()?;
EntityUpdateAttributesPropertiesModifiers {
uuid: v1158,
amount: v1159,
operation: v1160,
}
});
}
v1157
};
EntityUpdateAttributesProperties {
key: v1153,
value: v1154,
modifiers: v1155,
}
});
}
v1152
};
EntityUpdateAttributes {
entity_id: v1149,
properties: v1150,
}
})
}
}
impl Encode for EntityUpdateAttributes {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i32(crate::codec::count_i32((*self).properties.len())?);
for v1161 in (*self).properties.iter() {
w.put_string(&(*v1161).key)?;
w.put_f64((*v1161).value);
w.put_len_varint((*v1161).modifiers.len())?;
for v1162 in (*v1161).modifiers.iter() {
w.put_uuid(&(*v1162).uuid);
w.put_f64((*v1162).amount);
w.put_i8((*v1162).operation);
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityUpdateAttributes {
fn generate(g: &mut Gen) -> Self {
{
let v1163 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1164 = {
let v1165 = g.count();
let mut v1166 = Vec::with_capacity(v1165.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1165 {
v1166.push({
let v1167 = g.string();
let v1168 = g.f64();
let v1169 = {
let v1170 = g.count();
let mut v1171 =
Vec::with_capacity(v1170.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1170 {
v1171.push({
let v1172 = g.uuid();
let v1173 = g.f64();
let v1174 = (g.int_in(-128, 127, &[]) as i8);
EntityUpdateAttributesPropertiesModifiers {
uuid: v1172,
amount: v1173,
operation: v1174,
}
});
}
v1171
};
EntityUpdateAttributesProperties {
key: v1167,
value: v1168,
modifiers: v1169,
}
});
}
v1166
};
EntityUpdateAttributes {
entity_id: v1163,
properties: v1164,
}
}
}
}
impl From<EntityUpdateAttributes> for ClientboundPlayPacket {
fn from(p: EntityUpdateAttributes) -> Self {
Self::EntityUpdateAttributes(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEffect {
pub entity_id: i32,
pub effect_id: i8,
pub amplifier: i8,
pub duration: i32,
pub hide_particles: i8,
}
impl crate::packet::Packet for EntityEffect {
const ID: i32 = id::ENTITY_EFFECT;
const NAME: &'static str = "entity_effect";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for EntityEffect {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1175 = r.read_varint()?;
let v1176 = r.read_i8()?;
let v1177 = r.read_i8()?;
let v1178 = r.read_varint()?;
let v1179 = r.read_i8()?;
EntityEffect {
entity_id: v1175,
effect_id: v1176,
amplifier: v1177,
duration: v1178,
hide_particles: v1179,
}
})
}
}
impl Encode for EntityEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).effect_id);
w.put_i8((*self).amplifier);
w.put_varint((*self).duration);
w.put_i8((*self).hide_particles);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityEffect {
fn generate(g: &mut Gen) -> Self {
{
let v1180 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1181 = (g.int_in(-128, 127, &[]) as i8);
let v1182 = (g.int_in(-128, 127, &[]) as i8);
let v1183 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1184 = (g.int_in(-128, 127, &[]) as i8);
EntityEffect {
entity_id: v1180,
effect_id: v1181,
amplifier: v1182,
duration: v1183,
hide_particles: v1184,
}
}
}
}
impl From<EntityEffect> for ClientboundPlayPacket {
fn from(p: EntityEffect) -> Self {
Self::EntityEffect(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct DeclareRecipes {
pub recipes: Vec<DeclareRecipesRecipes>,
}
impl crate::packet::Packet for DeclareRecipes {
const ID: i32 = id::DECLARE_RECIPES;
const NAME: &'static str = "declare_recipes";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for DeclareRecipes {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1185 = {
let v1186 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1187 = Vec::with_capacity(v1186.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1186 {
v1187.push({
let v1188 = r.read_string()?;
let v1189 = r.read_string()?;
let v1190 = (if (&*v1188 == "minecraft:crafting_shapeless") {
DeclareRecipesRecipesData::CraftingShapeless({
let v1191 = r.read_string()?;
let v1192 = {
let v1193 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1194 =
Vec::with_capacity(v1193.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1193 {
v1194.push({
let v1195 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1196 = Vec::with_capacity(
v1195.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1195 {
v1196.push(<types::Slot as Decode>::decode(r)?);
}
v1196
});
}
v1194
};
let v1197 = <types::Slot as Decode>::decode(r)?;
DeclareRecipesRecipesDataCraftingShapeless {
group: v1191,
ingredients: v1192,
result: v1197,
}
})
} else if (&*v1188 == "minecraft:crafting_shaped") {
DeclareRecipesRecipesData::CraftingShaped({
let v1198 = r.read_varint()?;
let v1199 = r.read_varint()?;
let v1200 = r.read_string()?;
let v1201 = {
let v1202 = r.check_count(i64::from(v1199), 0)?;
let mut v1203 =
Vec::with_capacity(v1202.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1202 {
v1203.push({
let v1204 = r.check_count(i64::from(v1198), 1)?;
let mut v1205 = Vec::with_capacity(
v1204.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1204 {
v1205.push({
let v1206 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1207 = Vec::with_capacity(
v1206.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1206 {
v1207.push(
<types::Slot as Decode>::decode(r)?,
);
}
v1207
});
}
v1205
});
}
v1203
};
let v1208 = <types::Slot as Decode>::decode(r)?;
DeclareRecipesRecipesDataCraftingShaped {
width: v1198,
height: v1199,
group: v1200,
ingredients: v1201,
result: v1208,
}
})
} else if (&*v1188 == "minecraft:crafting_special_armordye") {
DeclareRecipesRecipesData::CraftingSpecialArmordye
} else if (&*v1188 == "minecraft:crafting_special_bookcloning") {
DeclareRecipesRecipesData::CraftingSpecialBookcloning
} else if (&*v1188 == "minecraft:crafting_special_mapcloning") {
DeclareRecipesRecipesData::CraftingSpecialMapcloning
} else if (&*v1188 == "minecraft:crafting_special_mapextending") {
DeclareRecipesRecipesData::CraftingSpecialMapextending
} else if (&*v1188 == "minecraft:crafting_special_firework_rocket") {
DeclareRecipesRecipesData::CraftingSpecialFireworkRocket
} else if (&*v1188 == "minecraft:crafting_special_firework_star") {
DeclareRecipesRecipesData::CraftingSpecialFireworkStar
} else if (&*v1188 == "minecraft:crafting_special_firework_star_fade") {
DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade
} else if (&*v1188 == "minecraft:crafting_special_repairitem") {
DeclareRecipesRecipesData::CraftingSpecialRepairitem
} else if (&*v1188 == "minecraft:crafting_special_tippedarrow") {
DeclareRecipesRecipesData::CraftingSpecialTippedarrow
} else if (&*v1188 == "minecraft:crafting_special_bannerduplicate") {
DeclareRecipesRecipesData::CraftingSpecialBannerduplicate
} else if (&*v1188 == "minecraft:crafting_special_banneraddpattern") {
DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern
} else if (&*v1188 == "minecraft:crafting_special_shielddecoration") {
DeclareRecipesRecipesData::CraftingSpecialShielddecoration
} else if (&*v1188 == "minecraft:crafting_special_shulkerboxcoloring") {
DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring
} else if (&*v1188 == "minecraft:crafting_special_suspiciousstew") {
DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew
} else if (&*v1188 == "minecraft:smelting") {
DeclareRecipesRecipesData::Smelting(
<types::MinecraftSmeltingFormat as Decode>::decode(r)?,
)
} else if (&*v1188 == "minecraft:blasting") {
DeclareRecipesRecipesData::Blasting(
<types::MinecraftSmeltingFormat as Decode>::decode(r)?,
)
} else if (&*v1188 == "minecraft:smoking") {
DeclareRecipesRecipesData::Smoking(
<types::MinecraftSmeltingFormat as Decode>::decode(r)?,
)
} else if (&*v1188 == "minecraft:campfire_cooking") {
DeclareRecipesRecipesData::CampfireCooking(
<types::MinecraftSmeltingFormat as Decode>::decode(r)?,
)
} else if (&*v1188 == "minecraft:stonecutting") {
DeclareRecipesRecipesData::Stonecutting({
let v1209 = r.read_string()?;
let v1210 = {
let v1211 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1212 =
Vec::with_capacity(v1211.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1211 {
v1212.push(<types::Slot as Decode>::decode(r)?);
}
v1212
};
let v1213 = <types::Slot as Decode>::decode(r)?;
DeclareRecipesRecipesDataStonecutting {
group: v1209,
ingredient: v1210,
result: v1213,
}
})
} else if (&*v1188 == "minecraft:smithing") {
DeclareRecipesRecipesData::Smithing({
let v1214 = {
let v1215 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1216 =
Vec::with_capacity(v1215.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1215 {
v1216.push(<types::Slot as Decode>::decode(r)?);
}
v1216
};
let v1217 = {
let v1218 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1219 =
Vec::with_capacity(v1218.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1218 {
v1219.push(<types::Slot as Decode>::decode(r)?);
}
v1219
};
let v1220 = <types::Slot as Decode>::decode(r)?;
DeclareRecipesRecipesDataSmithing {
base: v1214,
addition: v1217,
result: v1220,
}
})
} else {
DeclareRecipesRecipesData::Other
});
DeclareRecipesRecipes {
r#type: v1188,
recipe_id: v1189,
data: v1190,
}
});
}
v1187
};
DeclareRecipes { recipes: v1185 }
})
}
}
impl Encode for DeclareRecipes {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).recipes.len())?;
for v1221 in (*self).recipes.iter() {
w.put_string(&(*v1221).r#type)?;
w.put_string(&(*v1221).recipe_id)?;
match &(*v1221).data {
DeclareRecipesRecipesData::CraftingShapeless(v1222) => {
if !(&*(*v1221).r#type == "minecraft:crafting_shapeless") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
w.put_string(&(*v1222).group)?;
w.put_len_varint((*v1222).ingredients.len())?;
for v1223 in (*v1222).ingredients.iter() {
w.put_len_varint((*v1223).len())?;
for v1224 in (*v1223).iter() {
(*v1224).encode(w)?;
}
}
(*v1222).result.encode(w)?;
}
DeclareRecipesRecipesData::CraftingShaped(v1225) => {
if !(&*(*v1221).r#type == "minecraft:crafting_shaped") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
w.put_varint((*v1225).width);
w.put_varint((*v1225).height);
w.put_string(&(*v1225).group)?;
if usize::try_from((*v1225).height).ok() != Some((*v1225).ingredients.len()) {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.declare_recipes.recipes.data.ingredients",
expected: usize::try_from((*v1225).height).unwrap_or(0),
actual: (*v1225).ingredients.len(),
});
}
for v1226 in (*v1225).ingredients.iter() {
if usize::try_from((*v1225).width).ok() != Some((*v1226).len()) {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.declare_recipes.recipes.data.ingredients",
expected: usize::try_from((*v1225).width).unwrap_or(0),
actual: (*v1226).len(),
});
}
for v1227 in (*v1226).iter() {
w.put_len_varint((*v1227).len())?;
for v1228 in (*v1227).iter() {
(*v1228).encode(w)?;
}
}
}
(*v1225).result.encode(w)?;
}
DeclareRecipesRecipesData::CraftingSpecialArmordye => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_armordye") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialBookcloning => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_bookcloning") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialMapcloning => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_mapcloning") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialMapextending => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_mapextending") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialFireworkRocket => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_rocket") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialFireworkStar => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_star") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_firework_star_fade") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialRepairitem => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_repairitem") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialTippedarrow => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_tippedarrow") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialBannerduplicate => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_bannerduplicate") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_banneraddpattern") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialShielddecoration => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_shielddecoration") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_shulkerboxcoloring") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew => {
if !(&*(*v1221).r#type == "minecraft:crafting_special_suspiciousstew") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
DeclareRecipesRecipesData::Smelting(v1229) => {
if !(&*(*v1221).r#type == "minecraft:smelting") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
(*v1229).encode(w)?;
}
DeclareRecipesRecipesData::Blasting(v1230) => {
if !(&*(*v1221).r#type == "minecraft:blasting") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
(*v1230).encode(w)?;
}
DeclareRecipesRecipesData::Smoking(v1231) => {
if !(&*(*v1221).r#type == "minecraft:smoking") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
(*v1231).encode(w)?;
}
DeclareRecipesRecipesData::CampfireCooking(v1232) => {
if !(&*(*v1221).r#type == "minecraft:campfire_cooking") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
(*v1232).encode(w)?;
}
DeclareRecipesRecipesData::Stonecutting(v1233) => {
if !(&*(*v1221).r#type == "minecraft:stonecutting") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
w.put_string(&(*v1233).group)?;
w.put_len_varint((*v1233).ingredient.len())?;
for v1234 in (*v1233).ingredient.iter() {
(*v1234).encode(w)?;
}
(*v1233).result.encode(w)?;
}
DeclareRecipesRecipesData::Smithing(v1235) => {
if !(&*(*v1221).r#type == "minecraft:smithing") {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
w.put_len_varint((*v1235).base.len())?;
for v1236 in (*v1235).base.iter() {
(*v1236).encode(w)?;
}
w.put_len_varint((*v1235).addition.len())?;
for v1237 in (*v1235).addition.iter() {
(*v1237).encode(w)?;
}
(*v1235).result.encode(w)?;
}
DeclareRecipesRecipesData::Other => {
if !(!((&*(*v1221).r#type == "minecraft:crafting_shapeless")
|| (&*(*v1221).r#type == "minecraft:crafting_shaped")
|| (&*(*v1221).r#type == "minecraft:crafting_special_armordye")
|| (&*(*v1221).r#type == "minecraft:crafting_special_bookcloning")
|| (&*(*v1221).r#type == "minecraft:crafting_special_mapcloning")
|| (&*(*v1221).r#type == "minecraft:crafting_special_mapextending")
|| (&*(*v1221).r#type == "minecraft:crafting_special_firework_rocket")
|| (&*(*v1221).r#type == "minecraft:crafting_special_firework_star")
|| (&*(*v1221).r#type == "minecraft:crafting_special_firework_star_fade")
|| (&*(*v1221).r#type == "minecraft:crafting_special_repairitem")
|| (&*(*v1221).r#type == "minecraft:crafting_special_tippedarrow")
|| (&*(*v1221).r#type == "minecraft:crafting_special_bannerduplicate")
|| (&*(*v1221).r#type == "minecraft:crafting_special_banneraddpattern")
|| (&*(*v1221).r#type == "minecraft:crafting_special_shielddecoration")
|| (&*(*v1221).r#type == "minecraft:crafting_special_shulkerboxcoloring")
|| (&*(*v1221).r#type == "minecraft:crafting_special_suspiciousstew")
|| (&*(*v1221).r#type == "minecraft:smelting")
|| (&*(*v1221).r#type == "minecraft:blasting")
|| (&*(*v1221).r#type == "minecraft:smoking")
|| (&*(*v1221).r#type == "minecraft:campfire_cooking")
|| (&*(*v1221).r#type == "minecraft:stonecutting")
|| (&*(*v1221).r#type == "minecraft:smithing")))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.declare_recipes.recipes.data",
));
}
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for DeclareRecipes {
fn generate(g: &mut Gen) -> Self {
{
let v1238 = {
let v1239 = g.count();
let mut v1240 = Vec::with_capacity(v1239.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1239 {
v1240.push({
let v1241 = g.string_in(&[
"minecraft:crafting_shapeless",
"minecraft:crafting_shaped",
"minecraft:crafting_special_armordye",
"minecraft:crafting_special_bookcloning",
"minecraft:crafting_special_mapcloning",
"minecraft:crafting_special_mapextending",
"minecraft:crafting_special_firework_rocket",
"minecraft:crafting_special_firework_star",
"minecraft:crafting_special_firework_star_fade",
"minecraft:crafting_special_repairitem",
"minecraft:crafting_special_tippedarrow",
"minecraft:crafting_special_bannerduplicate",
"minecraft:crafting_special_banneraddpattern",
"minecraft:crafting_special_shielddecoration",
"minecraft:crafting_special_shulkerboxcoloring",
"minecraft:crafting_special_suspiciousstew",
"minecraft:smelting",
"minecraft:blasting",
"minecraft:smoking",
"minecraft:campfire_cooking",
"minecraft:stonecutting",
"minecraft:smithing",
]);
let v1242 = g.string();
let v1243 = (if (&*v1241 == "minecraft:crafting_shapeless") {
DeclareRecipesRecipesData::CraftingShapeless({
let v1244 = g.string();
let v1245 = {
let v1246 = g.count();
let mut v1247 =
Vec::with_capacity(v1246.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1246 {
v1247.push({
let v1248 = g.count();
let mut v1249 = Vec::with_capacity(
v1248.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1248 {
v1249.push(<types::Slot as Generate>::generate(g));
}
v1249
});
}
v1247
};
let v1250 = <types::Slot as Generate>::generate(g);
DeclareRecipesRecipesDataCraftingShapeless {
group: v1244,
ingredients: v1245,
result: v1250,
}
})
} else if (&*v1241 == "minecraft:crafting_shaped") {
DeclareRecipesRecipesData::CraftingShaped({
let v1251 = (g.small_count() as i32);
let v1252 = (g.small_count() as i32);
let v1253 = g.string();
let v1254 = {
let v1255 = usize::try_from(v1252).unwrap_or(0);
let mut v1256 =
Vec::with_capacity(v1255.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1255 {
v1256.push({
let v1257 = usize::try_from(v1251).unwrap_or(0);
let mut v1258 = Vec::with_capacity(
v1257.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1257 {
v1258.push({
let v1259 = g.count();
let mut v1260 = Vec::with_capacity(
v1259.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1259 {
v1260.push(
<types::Slot as Generate>::generate(g),
);
}
v1260
});
}
v1258
});
}
v1256
};
let v1261 = <types::Slot as Generate>::generate(g);
DeclareRecipesRecipesDataCraftingShaped {
width: v1251,
height: v1252,
group: v1253,
ingredients: v1254,
result: v1261,
}
})
} else if (&*v1241 == "minecraft:crafting_special_armordye") {
DeclareRecipesRecipesData::CraftingSpecialArmordye
} else if (&*v1241 == "minecraft:crafting_special_bookcloning") {
DeclareRecipesRecipesData::CraftingSpecialBookcloning
} else if (&*v1241 == "minecraft:crafting_special_mapcloning") {
DeclareRecipesRecipesData::CraftingSpecialMapcloning
} else if (&*v1241 == "minecraft:crafting_special_mapextending") {
DeclareRecipesRecipesData::CraftingSpecialMapextending
} else if (&*v1241 == "minecraft:crafting_special_firework_rocket") {
DeclareRecipesRecipesData::CraftingSpecialFireworkRocket
} else if (&*v1241 == "minecraft:crafting_special_firework_star") {
DeclareRecipesRecipesData::CraftingSpecialFireworkStar
} else if (&*v1241 == "minecraft:crafting_special_firework_star_fade") {
DeclareRecipesRecipesData::CraftingSpecialFireworkStarFade
} else if (&*v1241 == "minecraft:crafting_special_repairitem") {
DeclareRecipesRecipesData::CraftingSpecialRepairitem
} else if (&*v1241 == "minecraft:crafting_special_tippedarrow") {
DeclareRecipesRecipesData::CraftingSpecialTippedarrow
} else if (&*v1241 == "minecraft:crafting_special_bannerduplicate") {
DeclareRecipesRecipesData::CraftingSpecialBannerduplicate
} else if (&*v1241 == "minecraft:crafting_special_banneraddpattern") {
DeclareRecipesRecipesData::CraftingSpecialBanneraddpattern
} else if (&*v1241 == "minecraft:crafting_special_shielddecoration") {
DeclareRecipesRecipesData::CraftingSpecialShielddecoration
} else if (&*v1241 == "minecraft:crafting_special_shulkerboxcoloring") {
DeclareRecipesRecipesData::CraftingSpecialShulkerboxcoloring
} else if (&*v1241 == "minecraft:crafting_special_suspiciousstew") {
DeclareRecipesRecipesData::CraftingSpecialSuspiciousstew
} else if (&*v1241 == "minecraft:smelting") {
DeclareRecipesRecipesData::Smelting(
<types::MinecraftSmeltingFormat as Generate>::generate(g),
)
} else if (&*v1241 == "minecraft:blasting") {
DeclareRecipesRecipesData::Blasting(
<types::MinecraftSmeltingFormat as Generate>::generate(g),
)
} else if (&*v1241 == "minecraft:smoking") {
DeclareRecipesRecipesData::Smoking(
<types::MinecraftSmeltingFormat as Generate>::generate(g),
)
} else if (&*v1241 == "minecraft:campfire_cooking") {
DeclareRecipesRecipesData::CampfireCooking(
<types::MinecraftSmeltingFormat as Generate>::generate(g),
)
} else if (&*v1241 == "minecraft:stonecutting") {
DeclareRecipesRecipesData::Stonecutting({
let v1262 = g.string();
let v1263 = {
let v1264 = g.count();
let mut v1265 =
Vec::with_capacity(v1264.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1264 {
v1265.push(<types::Slot as Generate>::generate(g));
}
v1265
};
let v1266 = <types::Slot as Generate>::generate(g);
DeclareRecipesRecipesDataStonecutting {
group: v1262,
ingredient: v1263,
result: v1266,
}
})
} else if (&*v1241 == "minecraft:smithing") {
DeclareRecipesRecipesData::Smithing({
let v1267 = {
let v1268 = g.count();
let mut v1269 =
Vec::with_capacity(v1268.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1268 {
v1269.push(<types::Slot as Generate>::generate(g));
}
v1269
};
let v1270 = {
let v1271 = g.count();
let mut v1272 =
Vec::with_capacity(v1271.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1271 {
v1272.push(<types::Slot as Generate>::generate(g));
}
v1272
};
let v1273 = <types::Slot as Generate>::generate(g);
DeclareRecipesRecipesDataSmithing {
base: v1267,
addition: v1270,
result: v1273,
}
})
} else {
DeclareRecipesRecipesData::Other
});
DeclareRecipesRecipes {
r#type: v1241,
recipe_id: v1242,
data: v1243,
}
});
}
v1240
};
DeclareRecipes { recipes: v1238 }
}
}
}
impl From<DeclareRecipes> for ClientboundPlayPacket {
fn from(p: DeclareRecipes) -> Self {
Self::DeclareRecipes(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Tags {
pub block_tags: Vec<types::Tags>,
pub item_tags: Vec<types::Tags>,
pub fluid_tags: Vec<types::Tags>,
pub entity_tags: Vec<types::Tags>,
}
impl crate::packet::Packet for Tags {
const ID: i32 = id::TAGS;
const NAME: &'static str = "tags";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Tags {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v1274 = {
let v1275 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1276 = Vec::with_capacity(v1275.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1275 {
v1276.push({
let v1277 = r.read_string()?;
let v1278 = {
let v1279 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1280 =
Vec::with_capacity(v1279.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1279 {
v1280.push(r.read_varint()?);
}
v1280
};
types::Tags {
tag_name: v1277,
entries: v1278,
}
});
}
v1276
};
let v1281 = {
let v1282 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1283 = Vec::with_capacity(v1282.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1282 {
v1283.push({
let v1284 = r.read_string()?;
let v1285 = {
let v1286 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1287 =
Vec::with_capacity(v1286.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1286 {
v1287.push(r.read_varint()?);
}
v1287
};
types::Tags {
tag_name: v1284,
entries: v1285,
}
});
}
v1283
};
let v1288 = {
let v1289 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1290 = Vec::with_capacity(v1289.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1289 {
v1290.push({
let v1291 = r.read_string()?;
let v1292 = {
let v1293 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1294 =
Vec::with_capacity(v1293.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1293 {
v1294.push(r.read_varint()?);
}
v1294
};
types::Tags {
tag_name: v1291,
entries: v1292,
}
});
}
v1290
};
let v1295 = {
let v1296 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v1297 = Vec::with_capacity(v1296.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1296 {
v1297.push({
let v1298 = r.read_string()?;
let v1299 = {
let v1300 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v1301 =
Vec::with_capacity(v1300.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1300 {
v1301.push(r.read_varint()?);
}
v1301
};
types::Tags {
tag_name: v1298,
entries: v1299,
}
});
}
v1297
};
Tags {
block_tags: v1274,
item_tags: v1281,
fluid_tags: v1288,
entity_tags: v1295,
}
})
}
}
impl Encode for Tags {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).block_tags.len())?;
for v1302 in (*self).block_tags.iter() {
w.put_string(&(*v1302).tag_name)?;
w.put_len_varint((*v1302).entries.len())?;
for v1303 in (*v1302).entries.iter() {
w.put_varint((*v1303));
}
}
w.put_len_varint((*self).item_tags.len())?;
for v1304 in (*self).item_tags.iter() {
w.put_string(&(*v1304).tag_name)?;
w.put_len_varint((*v1304).entries.len())?;
for v1305 in (*v1304).entries.iter() {
w.put_varint((*v1305));
}
}
w.put_len_varint((*self).fluid_tags.len())?;
for v1306 in (*self).fluid_tags.iter() {
w.put_string(&(*v1306).tag_name)?;
w.put_len_varint((*v1306).entries.len())?;
for v1307 in (*v1306).entries.iter() {
w.put_varint((*v1307));
}
}
w.put_len_varint((*self).entity_tags.len())?;
for v1308 in (*self).entity_tags.iter() {
w.put_string(&(*v1308).tag_name)?;
w.put_len_varint((*v1308).entries.len())?;
for v1309 in (*v1308).entries.iter() {
w.put_varint((*v1309));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Tags {
fn generate(g: &mut Gen) -> Self {
{
let v1310 = {
let v1311 = g.count();
let mut v1312 = Vec::with_capacity(v1311.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1311 {
v1312.push({
let v1313 = g.string();
let v1314 = {
let v1315 = g.count();
let mut v1316 =
Vec::with_capacity(v1315.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1315 {
v1316.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v1316
};
types::Tags {
tag_name: v1313,
entries: v1314,
}
});
}
v1312
};
let v1317 = {
let v1318 = g.count();
let mut v1319 = Vec::with_capacity(v1318.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1318 {
v1319.push({
let v1320 = g.string();
let v1321 = {
let v1322 = g.count();
let mut v1323 =
Vec::with_capacity(v1322.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1322 {
v1323.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v1323
};
types::Tags {
tag_name: v1320,
entries: v1321,
}
});
}
v1319
};
let v1324 = {
let v1325 = g.count();
let mut v1326 = Vec::with_capacity(v1325.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1325 {
v1326.push({
let v1327 = g.string();
let v1328 = {
let v1329 = g.count();
let mut v1330 =
Vec::with_capacity(v1329.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1329 {
v1330.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v1330
};
types::Tags {
tag_name: v1327,
entries: v1328,
}
});
}
v1326
};
let v1331 = {
let v1332 = g.count();
let mut v1333 = Vec::with_capacity(v1332.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1332 {
v1333.push({
let v1334 = g.string();
let v1335 = {
let v1336 = g.count();
let mut v1337 =
Vec::with_capacity(v1336.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1336 {
v1337.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v1337
};
types::Tags {
tag_name: v1334,
entries: v1335,
}
});
}
v1333
};
Tags {
block_tags: v1310,
item_tags: v1317,
fluid_tags: v1324,
entity_tags: v1331,
}
}
}
}
impl From<Tags> for ClientboundPlayPacket {
fn from(p: Tags) -> Self {
Self::Tags(p)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ClientboundPlayPacket {
SpawnEntity(SpawnEntity),
SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
SpawnEntityLiving(SpawnEntityLiving),
SpawnEntityPainting(SpawnEntityPainting),
NamedEntitySpawn(NamedEntitySpawn),
Animation(Animation),
Statistics(Statistics),
AcknowledgePlayerDigging(AcknowledgePlayerDigging),
BlockBreakAnimation(BlockBreakAnimation),
TileEntityData(TileEntityData),
BlockAction(BlockAction),
BlockChange(BlockChange),
BossBar(BossBar),
Difficulty(Difficulty),
Chat(Chat),
TabComplete(TabComplete),
DeclareCommands(DeclareCommands),
Transaction(Transaction),
CloseWindow(CloseWindow),
WindowItems(WindowItems),
CraftProgressBar(CraftProgressBar),
SetSlot(SetSlot),
SetCooldown(SetCooldown),
CustomPayload(CustomPayload),
NamedSoundEffect(NamedSoundEffect),
KickDisconnect(KickDisconnect),
EntityStatus(EntityStatus),
Explosion(Explosion),
UnloadChunk(UnloadChunk),
GameStateChange(GameStateChange),
OpenHorseWindow(OpenHorseWindow),
KeepAlive(KeepAlive),
MapChunk(MapChunk),
WorldEvent(WorldEvent),
WorldParticles(WorldParticles),
UpdateLight(UpdateLight),
Login(Login),
Map(Map),
TradeList(TradeList),
RelEntityMove(RelEntityMove),
EntityMoveLook(EntityMoveLook),
EntityLook(EntityLook),
Entity(Entity),
VehicleMove(VehicleMove),
OpenBook(OpenBook),
OpenWindow(OpenWindow),
OpenSignEntity(OpenSignEntity),
CraftRecipeResponse(CraftRecipeResponse),
Abilities(Abilities),
CombatEvent(CombatEvent),
PlayerInfo(PlayerInfo),
FacePlayer(FacePlayer),
Position(Position),
UnlockRecipes(UnlockRecipes),
EntityDestroy(EntityDestroy),
RemoveEntityEffect(RemoveEntityEffect),
ResourcePackSend(ResourcePackSend),
Respawn(Respawn),
EntityHeadRotation(EntityHeadRotation),
MultiBlockChange(MultiBlockChange),
SelectAdvancementTab(SelectAdvancementTab),
WorldBorder(WorldBorder),
Camera(Camera),
HeldItemSlot(HeldItemSlot),
UpdateViewPosition(UpdateViewPosition),
UpdateViewDistance(UpdateViewDistance),
SpawnPosition(SpawnPosition),
ScoreboardDisplayObjective(ScoreboardDisplayObjective),
EntityMetadata(EntityMetadata),
AttachEntity(AttachEntity),
EntityVelocity(EntityVelocity),
EntityEquipment(EntityEquipment),
Experience(Experience),
UpdateHealth(UpdateHealth),
ScoreboardObjective(ScoreboardObjective),
SetPassengers(SetPassengers),
Teams(Teams),
ScoreboardScore(ScoreboardScore),
UpdateTime(UpdateTime),
Title(Title),
EntitySoundEffect(EntitySoundEffect),
SoundEffect(SoundEffect),
StopSound(StopSound),
PlayerlistHeader(PlayerlistHeader),
NbtQueryResponse(NbtQueryResponse),
Collect(Collect),
EntityTeleport(EntityTeleport),
Advancements(Advancements),
EntityUpdateAttributes(EntityUpdateAttributes),
EntityEffect(EntityEffect),
DeclareRecipes(DeclareRecipes),
Tags(Tags),
}
impl PacketSet for ClientboundPlayPacket {
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
fn decode_raw(raw: &RawPacket) -> DecodeResult<Self> {
match raw.id {
id::SPAWN_ENTITY => decode_exact(&raw.body).map(Self::SpawnEntity),
id::SPAWN_ENTITY_EXPERIENCE_ORB => {
decode_exact(&raw.body).map(Self::SpawnEntityExperienceOrb)
}
id::SPAWN_ENTITY_LIVING => decode_exact(&raw.body).map(Self::SpawnEntityLiving),
id::SPAWN_ENTITY_PAINTING => decode_exact(&raw.body).map(Self::SpawnEntityPainting),
id::NAMED_ENTITY_SPAWN => decode_exact(&raw.body).map(Self::NamedEntitySpawn),
id::ANIMATION => decode_exact(&raw.body).map(Self::Animation),
id::STATISTICS => decode_exact(&raw.body).map(Self::Statistics),
id::ACKNOWLEDGE_PLAYER_DIGGING => {
decode_exact(&raw.body).map(Self::AcknowledgePlayerDigging)
}
id::BLOCK_BREAK_ANIMATION => decode_exact(&raw.body).map(Self::BlockBreakAnimation),
id::TILE_ENTITY_DATA => decode_exact(&raw.body).map(Self::TileEntityData),
id::BLOCK_ACTION => decode_exact(&raw.body).map(Self::BlockAction),
id::BLOCK_CHANGE => decode_exact(&raw.body).map(Self::BlockChange),
id::BOSS_BAR => decode_exact(&raw.body).map(Self::BossBar),
id::DIFFICULTY => decode_exact(&raw.body).map(Self::Difficulty),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::DECLARE_COMMANDS => decode_exact(&raw.body).map(Self::DeclareCommands),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::WINDOW_ITEMS => decode_exact(&raw.body).map(Self::WindowItems),
id::CRAFT_PROGRESS_BAR => decode_exact(&raw.body).map(Self::CraftProgressBar),
id::SET_SLOT => decode_exact(&raw.body).map(Self::SetSlot),
id::SET_COOLDOWN => decode_exact(&raw.body).map(Self::SetCooldown),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::NAMED_SOUND_EFFECT => decode_exact(&raw.body).map(Self::NamedSoundEffect),
id::KICK_DISCONNECT => decode_exact(&raw.body).map(Self::KickDisconnect),
id::ENTITY_STATUS => decode_exact(&raw.body).map(Self::EntityStatus),
id::EXPLOSION => decode_exact(&raw.body).map(Self::Explosion),
id::UNLOAD_CHUNK => decode_exact(&raw.body).map(Self::UnloadChunk),
id::GAME_STATE_CHANGE => decode_exact(&raw.body).map(Self::GameStateChange),
id::OPEN_HORSE_WINDOW => decode_exact(&raw.body).map(Self::OpenHorseWindow),
id::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::MAP_CHUNK => decode_exact(&raw.body).map(Self::MapChunk),
id::WORLD_EVENT => decode_exact(&raw.body).map(Self::WorldEvent),
id::WORLD_PARTICLES => decode_exact(&raw.body).map(Self::WorldParticles),
id::UPDATE_LIGHT => decode_exact(&raw.body).map(Self::UpdateLight),
id::LOGIN => decode_exact(&raw.body).map(Self::Login),
id::MAP => decode_exact(&raw.body).map(Self::Map),
id::TRADE_LIST => decode_exact(&raw.body).map(Self::TradeList),
id::REL_ENTITY_MOVE => decode_exact(&raw.body).map(Self::RelEntityMove),
id::ENTITY_MOVE_LOOK => decode_exact(&raw.body).map(Self::EntityMoveLook),
id::ENTITY_LOOK => decode_exact(&raw.body).map(Self::EntityLook),
id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
id::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
id::OPEN_BOOK => decode_exact(&raw.body).map(Self::OpenBook),
id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
id::OPEN_SIGN_ENTITY => decode_exact(&raw.body).map(Self::OpenSignEntity),
id::CRAFT_RECIPE_RESPONSE => decode_exact(&raw.body).map(Self::CraftRecipeResponse),
id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
id::COMBAT_EVENT => decode_exact(&raw.body).map(Self::CombatEvent),
id::PLAYER_INFO => decode_exact(&raw.body).map(Self::PlayerInfo),
id::FACE_PLAYER => decode_exact(&raw.body).map(Self::FacePlayer),
id::POSITION => decode_exact(&raw.body).map(Self::Position),
id::UNLOCK_RECIPES => decode_exact(&raw.body).map(Self::UnlockRecipes),
id::ENTITY_DESTROY => decode_exact(&raw.body).map(Self::EntityDestroy),
id::REMOVE_ENTITY_EFFECT => decode_exact(&raw.body).map(Self::RemoveEntityEffect),
id::RESOURCE_PACK_SEND => decode_exact(&raw.body).map(Self::ResourcePackSend),
id::RESPAWN => decode_exact(&raw.body).map(Self::Respawn),
id::ENTITY_HEAD_ROTATION => decode_exact(&raw.body).map(Self::EntityHeadRotation),
id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
id::SELECT_ADVANCEMENT_TAB => decode_exact(&raw.body).map(Self::SelectAdvancementTab),
id::WORLD_BORDER => decode_exact(&raw.body).map(Self::WorldBorder),
id::CAMERA => decode_exact(&raw.body).map(Self::Camera),
id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
id::UPDATE_VIEW_POSITION => decode_exact(&raw.body).map(Self::UpdateViewPosition),
id::UPDATE_VIEW_DISTANCE => decode_exact(&raw.body).map(Self::UpdateViewDistance),
id::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
id::SCOREBOARD_DISPLAY_OBJECTIVE => {
decode_exact(&raw.body).map(Self::ScoreboardDisplayObjective)
}
id::ENTITY_METADATA => decode_exact(&raw.body).map(Self::EntityMetadata),
id::ATTACH_ENTITY => decode_exact(&raw.body).map(Self::AttachEntity),
id::ENTITY_VELOCITY => decode_exact(&raw.body).map(Self::EntityVelocity),
id::ENTITY_EQUIPMENT => decode_exact(&raw.body).map(Self::EntityEquipment),
id::EXPERIENCE => decode_exact(&raw.body).map(Self::Experience),
id::UPDATE_HEALTH => decode_exact(&raw.body).map(Self::UpdateHealth),
id::SCOREBOARD_OBJECTIVE => decode_exact(&raw.body).map(Self::ScoreboardObjective),
id::SET_PASSENGERS => decode_exact(&raw.body).map(Self::SetPassengers),
id::TEAMS => decode_exact(&raw.body).map(Self::Teams),
id::SCOREBOARD_SCORE => decode_exact(&raw.body).map(Self::ScoreboardScore),
id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
id::TITLE => decode_exact(&raw.body).map(Self::Title),
id::ENTITY_SOUND_EFFECT => decode_exact(&raw.body).map(Self::EntitySoundEffect),
id::SOUND_EFFECT => decode_exact(&raw.body).map(Self::SoundEffect),
id::STOP_SOUND => decode_exact(&raw.body).map(Self::StopSound),
id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
id::NBT_QUERY_RESPONSE => decode_exact(&raw.body).map(Self::NbtQueryResponse),
id::COLLECT => decode_exact(&raw.body).map(Self::Collect),
id::ENTITY_TELEPORT => decode_exact(&raw.body).map(Self::EntityTeleport),
id::ADVANCEMENTS => decode_exact(&raw.body).map(Self::Advancements),
id::ENTITY_UPDATE_ATTRIBUTES => {
decode_exact(&raw.body).map(Self::EntityUpdateAttributes)
}
id::ENTITY_EFFECT => decode_exact(&raw.body).map(Self::EntityEffect),
id::DECLARE_RECIPES => decode_exact(&raw.body).map(Self::DeclareRecipes),
id::TAGS => decode_exact(&raw.body).map(Self::Tags),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::SpawnEntity(_) => id::SPAWN_ENTITY,
Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
Self::SpawnEntityLiving(_) => id::SPAWN_ENTITY_LIVING,
Self::SpawnEntityPainting(_) => id::SPAWN_ENTITY_PAINTING,
Self::NamedEntitySpawn(_) => id::NAMED_ENTITY_SPAWN,
Self::Animation(_) => id::ANIMATION,
Self::Statistics(_) => id::STATISTICS,
Self::AcknowledgePlayerDigging(_) => id::ACKNOWLEDGE_PLAYER_DIGGING,
Self::BlockBreakAnimation(_) => id::BLOCK_BREAK_ANIMATION,
Self::TileEntityData(_) => id::TILE_ENTITY_DATA,
Self::BlockAction(_) => id::BLOCK_ACTION,
Self::BlockChange(_) => id::BLOCK_CHANGE,
Self::BossBar(_) => id::BOSS_BAR,
Self::Difficulty(_) => id::DIFFICULTY,
Self::Chat(_) => id::CHAT,
Self::TabComplete(_) => id::TAB_COMPLETE,
Self::DeclareCommands(_) => id::DECLARE_COMMANDS,
Self::Transaction(_) => id::TRANSACTION,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::WindowItems(_) => id::WINDOW_ITEMS,
Self::CraftProgressBar(_) => id::CRAFT_PROGRESS_BAR,
Self::SetSlot(_) => id::SET_SLOT,
Self::SetCooldown(_) => id::SET_COOLDOWN,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::NamedSoundEffect(_) => id::NAMED_SOUND_EFFECT,
Self::KickDisconnect(_) => id::KICK_DISCONNECT,
Self::EntityStatus(_) => id::ENTITY_STATUS,
Self::Explosion(_) => id::EXPLOSION,
Self::UnloadChunk(_) => id::UNLOAD_CHUNK,
Self::GameStateChange(_) => id::GAME_STATE_CHANGE,
Self::OpenHorseWindow(_) => id::OPEN_HORSE_WINDOW,
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::MapChunk(_) => id::MAP_CHUNK,
Self::WorldEvent(_) => id::WORLD_EVENT,
Self::WorldParticles(_) => id::WORLD_PARTICLES,
Self::UpdateLight(_) => id::UPDATE_LIGHT,
Self::Login(_) => id::LOGIN,
Self::Map(_) => id::MAP,
Self::TradeList(_) => id::TRADE_LIST,
Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
Self::EntityLook(_) => id::ENTITY_LOOK,
Self::Entity(_) => id::ENTITY,
Self::VehicleMove(_) => id::VEHICLE_MOVE,
Self::OpenBook(_) => id::OPEN_BOOK,
Self::OpenWindow(_) => id::OPEN_WINDOW,
Self::OpenSignEntity(_) => id::OPEN_SIGN_ENTITY,
Self::CraftRecipeResponse(_) => id::CRAFT_RECIPE_RESPONSE,
Self::Abilities(_) => id::ABILITIES,
Self::CombatEvent(_) => id::COMBAT_EVENT,
Self::PlayerInfo(_) => id::PLAYER_INFO,
Self::FacePlayer(_) => id::FACE_PLAYER,
Self::Position(_) => id::POSITION,
Self::UnlockRecipes(_) => id::UNLOCK_RECIPES,
Self::EntityDestroy(_) => id::ENTITY_DESTROY,
Self::RemoveEntityEffect(_) => id::REMOVE_ENTITY_EFFECT,
Self::ResourcePackSend(_) => id::RESOURCE_PACK_SEND,
Self::Respawn(_) => id::RESPAWN,
Self::EntityHeadRotation(_) => id::ENTITY_HEAD_ROTATION,
Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
Self::SelectAdvancementTab(_) => id::SELECT_ADVANCEMENT_TAB,
Self::WorldBorder(_) => id::WORLD_BORDER,
Self::Camera(_) => id::CAMERA,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
Self::UpdateViewPosition(_) => id::UPDATE_VIEW_POSITION,
Self::UpdateViewDistance(_) => id::UPDATE_VIEW_DISTANCE,
Self::SpawnPosition(_) => id::SPAWN_POSITION,
Self::ScoreboardDisplayObjective(_) => id::SCOREBOARD_DISPLAY_OBJECTIVE,
Self::EntityMetadata(_) => id::ENTITY_METADATA,
Self::AttachEntity(_) => id::ATTACH_ENTITY,
Self::EntityVelocity(_) => id::ENTITY_VELOCITY,
Self::EntityEquipment(_) => id::ENTITY_EQUIPMENT,
Self::Experience(_) => id::EXPERIENCE,
Self::UpdateHealth(_) => id::UPDATE_HEALTH,
Self::ScoreboardObjective(_) => id::SCOREBOARD_OBJECTIVE,
Self::SetPassengers(_) => id::SET_PASSENGERS,
Self::Teams(_) => id::TEAMS,
Self::ScoreboardScore(_) => id::SCOREBOARD_SCORE,
Self::UpdateTime(_) => id::UPDATE_TIME,
Self::Title(_) => id::TITLE,
Self::EntitySoundEffect(_) => id::ENTITY_SOUND_EFFECT,
Self::SoundEffect(_) => id::SOUND_EFFECT,
Self::StopSound(_) => id::STOP_SOUND,
Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
Self::NbtQueryResponse(_) => id::NBT_QUERY_RESPONSE,
Self::Collect(_) => id::COLLECT,
Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
Self::Advancements(_) => id::ADVANCEMENTS,
Self::EntityUpdateAttributes(_) => id::ENTITY_UPDATE_ATTRIBUTES,
Self::EntityEffect(_) => id::ENTITY_EFFECT,
Self::DeclareRecipes(_) => id::DECLARE_RECIPES,
Self::Tags(_) => id::TAGS,
}
}
fn name(&self) -> &'static str {
match *self {
Self::SpawnEntity(_) => "spawn_entity",
Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
Self::SpawnEntityLiving(_) => "spawn_entity_living",
Self::SpawnEntityPainting(_) => "spawn_entity_painting",
Self::NamedEntitySpawn(_) => "named_entity_spawn",
Self::Animation(_) => "animation",
Self::Statistics(_) => "statistics",
Self::AcknowledgePlayerDigging(_) => "acknowledge_player_digging",
Self::BlockBreakAnimation(_) => "block_break_animation",
Self::TileEntityData(_) => "tile_entity_data",
Self::BlockAction(_) => "block_action",
Self::BlockChange(_) => "block_change",
Self::BossBar(_) => "boss_bar",
Self::Difficulty(_) => "difficulty",
Self::Chat(_) => "chat",
Self::TabComplete(_) => "tab_complete",
Self::DeclareCommands(_) => "declare_commands",
Self::Transaction(_) => "transaction",
Self::CloseWindow(_) => "close_window",
Self::WindowItems(_) => "window_items",
Self::CraftProgressBar(_) => "craft_progress_bar",
Self::SetSlot(_) => "set_slot",
Self::SetCooldown(_) => "set_cooldown",
Self::CustomPayload(_) => "custom_payload",
Self::NamedSoundEffect(_) => "named_sound_effect",
Self::KickDisconnect(_) => "kick_disconnect",
Self::EntityStatus(_) => "entity_status",
Self::Explosion(_) => "explosion",
Self::UnloadChunk(_) => "unload_chunk",
Self::GameStateChange(_) => "game_state_change",
Self::OpenHorseWindow(_) => "open_horse_window",
Self::KeepAlive(_) => "keep_alive",
Self::MapChunk(_) => "map_chunk",
Self::WorldEvent(_) => "world_event",
Self::WorldParticles(_) => "world_particles",
Self::UpdateLight(_) => "update_light",
Self::Login(_) => "login",
Self::Map(_) => "map",
Self::TradeList(_) => "trade_list",
Self::RelEntityMove(_) => "rel_entity_move",
Self::EntityMoveLook(_) => "entity_move_look",
Self::EntityLook(_) => "entity_look",
Self::Entity(_) => "entity",
Self::VehicleMove(_) => "vehicle_move",
Self::OpenBook(_) => "open_book",
Self::OpenWindow(_) => "open_window",
Self::OpenSignEntity(_) => "open_sign_entity",
Self::CraftRecipeResponse(_) => "craft_recipe_response",
Self::Abilities(_) => "abilities",
Self::CombatEvent(_) => "combat_event",
Self::PlayerInfo(_) => "player_info",
Self::FacePlayer(_) => "face_player",
Self::Position(_) => "position",
Self::UnlockRecipes(_) => "unlock_recipes",
Self::EntityDestroy(_) => "entity_destroy",
Self::RemoveEntityEffect(_) => "remove_entity_effect",
Self::ResourcePackSend(_) => "resource_pack_send",
Self::Respawn(_) => "respawn",
Self::EntityHeadRotation(_) => "entity_head_rotation",
Self::MultiBlockChange(_) => "multi_block_change",
Self::SelectAdvancementTab(_) => "select_advancement_tab",
Self::WorldBorder(_) => "world_border",
Self::Camera(_) => "camera",
Self::HeldItemSlot(_) => "held_item_slot",
Self::UpdateViewPosition(_) => "update_view_position",
Self::UpdateViewDistance(_) => "update_view_distance",
Self::SpawnPosition(_) => "spawn_position",
Self::ScoreboardDisplayObjective(_) => "scoreboard_display_objective",
Self::EntityMetadata(_) => "entity_metadata",
Self::AttachEntity(_) => "attach_entity",
Self::EntityVelocity(_) => "entity_velocity",
Self::EntityEquipment(_) => "entity_equipment",
Self::Experience(_) => "experience",
Self::UpdateHealth(_) => "update_health",
Self::ScoreboardObjective(_) => "scoreboard_objective",
Self::SetPassengers(_) => "set_passengers",
Self::Teams(_) => "teams",
Self::ScoreboardScore(_) => "scoreboard_score",
Self::UpdateTime(_) => "update_time",
Self::Title(_) => "title",
Self::EntitySoundEffect(_) => "entity_sound_effect",
Self::SoundEffect(_) => "sound_effect",
Self::StopSound(_) => "stop_sound",
Self::PlayerlistHeader(_) => "playerlist_header",
Self::NbtQueryResponse(_) => "nbt_query_response",
Self::Collect(_) => "collect",
Self::EntityTeleport(_) => "entity_teleport",
Self::Advancements(_) => "advancements",
Self::EntityUpdateAttributes(_) => "entity_update_attributes",
Self::EntityEffect(_) => "entity_effect",
Self::DeclareRecipes(_) => "declare_recipes",
Self::Tags(_) => "tags",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::SpawnEntity(ref p) => p.encode(w),
Self::SpawnEntityExperienceOrb(ref p) => p.encode(w),
Self::SpawnEntityLiving(ref p) => p.encode(w),
Self::SpawnEntityPainting(ref p) => p.encode(w),
Self::NamedEntitySpawn(ref p) => p.encode(w),
Self::Animation(ref p) => p.encode(w),
Self::Statistics(ref p) => p.encode(w),
Self::AcknowledgePlayerDigging(ref p) => p.encode(w),
Self::BlockBreakAnimation(ref p) => p.encode(w),
Self::TileEntityData(ref p) => p.encode(w),
Self::BlockAction(ref p) => p.encode(w),
Self::BlockChange(ref p) => p.encode(w),
Self::BossBar(ref p) => p.encode(w),
Self::Difficulty(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::TabComplete(ref p) => p.encode(w),
Self::DeclareCommands(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::WindowItems(ref p) => p.encode(w),
Self::CraftProgressBar(ref p) => p.encode(w),
Self::SetSlot(ref p) => p.encode(w),
Self::SetCooldown(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::NamedSoundEffect(ref p) => p.encode(w),
Self::KickDisconnect(ref p) => p.encode(w),
Self::EntityStatus(ref p) => p.encode(w),
Self::Explosion(ref p) => p.encode(w),
Self::UnloadChunk(ref p) => p.encode(w),
Self::GameStateChange(ref p) => p.encode(w),
Self::OpenHorseWindow(ref p) => p.encode(w),
Self::KeepAlive(ref p) => p.encode(w),
Self::MapChunk(ref p) => p.encode(w),
Self::WorldEvent(ref p) => p.encode(w),
Self::WorldParticles(ref p) => p.encode(w),
Self::UpdateLight(ref p) => p.encode(w),
Self::Login(ref p) => p.encode(w),
Self::Map(ref p) => p.encode(w),
Self::TradeList(ref p) => p.encode(w),
Self::RelEntityMove(ref p) => p.encode(w),
Self::EntityMoveLook(ref p) => p.encode(w),
Self::EntityLook(ref p) => p.encode(w),
Self::Entity(ref p) => p.encode(w),
Self::VehicleMove(ref p) => p.encode(w),
Self::OpenBook(ref p) => p.encode(w),
Self::OpenWindow(ref p) => p.encode(w),
Self::OpenSignEntity(ref p) => p.encode(w),
Self::CraftRecipeResponse(ref p) => p.encode(w),
Self::Abilities(ref p) => p.encode(w),
Self::CombatEvent(ref p) => p.encode(w),
Self::PlayerInfo(ref p) => p.encode(w),
Self::FacePlayer(ref p) => p.encode(w),
Self::Position(ref p) => p.encode(w),
Self::UnlockRecipes(ref p) => p.encode(w),
Self::EntityDestroy(ref p) => p.encode(w),
Self::RemoveEntityEffect(ref p) => p.encode(w),
Self::ResourcePackSend(ref p) => p.encode(w),
Self::Respawn(ref p) => p.encode(w),
Self::EntityHeadRotation(ref p) => p.encode(w),
Self::MultiBlockChange(ref p) => p.encode(w),
Self::SelectAdvancementTab(ref p) => p.encode(w),
Self::WorldBorder(ref p) => p.encode(w),
Self::Camera(ref p) => p.encode(w),
Self::HeldItemSlot(ref p) => p.encode(w),
Self::UpdateViewPosition(ref p) => p.encode(w),
Self::UpdateViewDistance(ref p) => p.encode(w),
Self::SpawnPosition(ref p) => p.encode(w),
Self::ScoreboardDisplayObjective(ref p) => p.encode(w),
Self::EntityMetadata(ref p) => p.encode(w),
Self::AttachEntity(ref p) => p.encode(w),
Self::EntityVelocity(ref p) => p.encode(w),
Self::EntityEquipment(ref p) => p.encode(w),
Self::Experience(ref p) => p.encode(w),
Self::UpdateHealth(ref p) => p.encode(w),
Self::ScoreboardObjective(ref p) => p.encode(w),
Self::SetPassengers(ref p) => p.encode(w),
Self::Teams(ref p) => p.encode(w),
Self::ScoreboardScore(ref p) => p.encode(w),
Self::UpdateTime(ref p) => p.encode(w),
Self::Title(ref p) => p.encode(w),
Self::EntitySoundEffect(ref p) => p.encode(w),
Self::SoundEffect(ref p) => p.encode(w),
Self::StopSound(ref p) => p.encode(w),
Self::PlayerlistHeader(ref p) => p.encode(w),
Self::NbtQueryResponse(ref p) => p.encode(w),
Self::Collect(ref p) => p.encode(w),
Self::EntityTeleport(ref p) => p.encode(w),
Self::Advancements(ref p) => p.encode(w),
Self::EntityUpdateAttributes(ref p) => p.encode(w),
Self::EntityEffect(ref p) => p.encode(w),
Self::DeclareRecipes(ref p) => p.encode(w),
Self::Tags(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::SPAWN_ENTITY => Some("spawn_entity"),
id::SPAWN_ENTITY_EXPERIENCE_ORB => Some("spawn_entity_experience_orb"),
id::SPAWN_ENTITY_LIVING => Some("spawn_entity_living"),
id::SPAWN_ENTITY_PAINTING => Some("spawn_entity_painting"),
id::NAMED_ENTITY_SPAWN => Some("named_entity_spawn"),
id::ANIMATION => Some("animation"),
id::STATISTICS => Some("statistics"),
id::ACKNOWLEDGE_PLAYER_DIGGING => Some("acknowledge_player_digging"),
id::BLOCK_BREAK_ANIMATION => Some("block_break_animation"),
id::TILE_ENTITY_DATA => Some("tile_entity_data"),
id::BLOCK_ACTION => Some("block_action"),
id::BLOCK_CHANGE => Some("block_change"),
id::BOSS_BAR => Some("boss_bar"),
id::DIFFICULTY => Some("difficulty"),
id::CHAT => Some("chat"),
id::TAB_COMPLETE => Some("tab_complete"),
id::DECLARE_COMMANDS => Some("declare_commands"),
id::TRANSACTION => Some("transaction"),
id::CLOSE_WINDOW => Some("close_window"),
id::WINDOW_ITEMS => Some("window_items"),
id::CRAFT_PROGRESS_BAR => Some("craft_progress_bar"),
id::SET_SLOT => Some("set_slot"),
id::SET_COOLDOWN => Some("set_cooldown"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::NAMED_SOUND_EFFECT => Some("named_sound_effect"),
id::KICK_DISCONNECT => Some("kick_disconnect"),
id::ENTITY_STATUS => Some("entity_status"),
id::EXPLOSION => Some("explosion"),
id::UNLOAD_CHUNK => Some("unload_chunk"),
id::GAME_STATE_CHANGE => Some("game_state_change"),
id::OPEN_HORSE_WINDOW => Some("open_horse_window"),
id::KEEP_ALIVE => Some("keep_alive"),
id::MAP_CHUNK => Some("map_chunk"),
id::WORLD_EVENT => Some("world_event"),
id::WORLD_PARTICLES => Some("world_particles"),
id::UPDATE_LIGHT => Some("update_light"),
id::LOGIN => Some("login"),
id::MAP => Some("map"),
id::TRADE_LIST => Some("trade_list"),
id::REL_ENTITY_MOVE => Some("rel_entity_move"),
id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
id::ENTITY_LOOK => Some("entity_look"),
id::ENTITY => Some("entity"),
id::VEHICLE_MOVE => Some("vehicle_move"),
id::OPEN_BOOK => Some("open_book"),
id::OPEN_WINDOW => Some("open_window"),
id::OPEN_SIGN_ENTITY => Some("open_sign_entity"),
id::CRAFT_RECIPE_RESPONSE => Some("craft_recipe_response"),
id::ABILITIES => Some("abilities"),
id::COMBAT_EVENT => Some("combat_event"),
id::PLAYER_INFO => Some("player_info"),
id::FACE_PLAYER => Some("face_player"),
id::POSITION => Some("position"),
id::UNLOCK_RECIPES => Some("unlock_recipes"),
id::ENTITY_DESTROY => Some("entity_destroy"),
id::REMOVE_ENTITY_EFFECT => Some("remove_entity_effect"),
id::RESOURCE_PACK_SEND => Some("resource_pack_send"),
id::RESPAWN => Some("respawn"),
id::ENTITY_HEAD_ROTATION => Some("entity_head_rotation"),
id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
id::SELECT_ADVANCEMENT_TAB => Some("select_advancement_tab"),
id::WORLD_BORDER => Some("world_border"),
id::CAMERA => Some("camera"),
id::HELD_ITEM_SLOT => Some("held_item_slot"),
id::UPDATE_VIEW_POSITION => Some("update_view_position"),
id::UPDATE_VIEW_DISTANCE => Some("update_view_distance"),
id::SPAWN_POSITION => Some("spawn_position"),
id::SCOREBOARD_DISPLAY_OBJECTIVE => Some("scoreboard_display_objective"),
id::ENTITY_METADATA => Some("entity_metadata"),
id::ATTACH_ENTITY => Some("attach_entity"),
id::ENTITY_VELOCITY => Some("entity_velocity"),
id::ENTITY_EQUIPMENT => Some("entity_equipment"),
id::EXPERIENCE => Some("experience"),
id::UPDATE_HEALTH => Some("update_health"),
id::SCOREBOARD_OBJECTIVE => Some("scoreboard_objective"),
id::SET_PASSENGERS => Some("set_passengers"),
id::TEAMS => Some("teams"),
id::SCOREBOARD_SCORE => Some("scoreboard_score"),
id::UPDATE_TIME => Some("update_time"),
id::TITLE => Some("title"),
id::ENTITY_SOUND_EFFECT => Some("entity_sound_effect"),
id::SOUND_EFFECT => Some("sound_effect"),
id::STOP_SOUND => Some("stop_sound"),
id::PLAYERLIST_HEADER => Some("playerlist_header"),
id::NBT_QUERY_RESPONSE => Some("nbt_query_response"),
id::COLLECT => Some("collect"),
id::ENTITY_TELEPORT => Some("entity_teleport"),
id::ADVANCEMENTS => Some("advancements"),
id::ENTITY_UPDATE_ATTRIBUTES => Some("entity_update_attributes"),
id::ENTITY_EFFECT => Some("entity_effect"),
id::DECLARE_RECIPES => Some("declare_recipes"),
id::TAGS => Some("tags"),
_ => None,
}
}
}
impl ClientboundPlayPacket {
pub const IDS: &'static [i32] = &[
id::SPAWN_ENTITY,
id::SPAWN_ENTITY_EXPERIENCE_ORB,
id::SPAWN_ENTITY_LIVING,
id::SPAWN_ENTITY_PAINTING,
id::NAMED_ENTITY_SPAWN,
id::ANIMATION,
id::STATISTICS,
id::ACKNOWLEDGE_PLAYER_DIGGING,
id::BLOCK_BREAK_ANIMATION,
id::TILE_ENTITY_DATA,
id::BLOCK_ACTION,
id::BLOCK_CHANGE,
id::BOSS_BAR,
id::DIFFICULTY,
id::CHAT,
id::TAB_COMPLETE,
id::DECLARE_COMMANDS,
id::TRANSACTION,
id::CLOSE_WINDOW,
id::WINDOW_ITEMS,
id::CRAFT_PROGRESS_BAR,
id::SET_SLOT,
id::SET_COOLDOWN,
id::CUSTOM_PAYLOAD,
id::NAMED_SOUND_EFFECT,
id::KICK_DISCONNECT,
id::ENTITY_STATUS,
id::EXPLOSION,
id::UNLOAD_CHUNK,
id::GAME_STATE_CHANGE,
id::OPEN_HORSE_WINDOW,
id::KEEP_ALIVE,
id::MAP_CHUNK,
id::WORLD_EVENT,
id::WORLD_PARTICLES,
id::UPDATE_LIGHT,
id::LOGIN,
id::MAP,
id::TRADE_LIST,
id::REL_ENTITY_MOVE,
id::ENTITY_MOVE_LOOK,
id::ENTITY_LOOK,
id::ENTITY,
id::VEHICLE_MOVE,
id::OPEN_BOOK,
id::OPEN_WINDOW,
id::OPEN_SIGN_ENTITY,
id::CRAFT_RECIPE_RESPONSE,
id::ABILITIES,
id::COMBAT_EVENT,
id::PLAYER_INFO,
id::FACE_PLAYER,
id::POSITION,
id::UNLOCK_RECIPES,
id::ENTITY_DESTROY,
id::REMOVE_ENTITY_EFFECT,
id::RESOURCE_PACK_SEND,
id::RESPAWN,
id::ENTITY_HEAD_ROTATION,
id::MULTI_BLOCK_CHANGE,
id::SELECT_ADVANCEMENT_TAB,
id::WORLD_BORDER,
id::CAMERA,
id::HELD_ITEM_SLOT,
id::UPDATE_VIEW_POSITION,
id::UPDATE_VIEW_DISTANCE,
id::SPAWN_POSITION,
id::SCOREBOARD_DISPLAY_OBJECTIVE,
id::ENTITY_METADATA,
id::ATTACH_ENTITY,
id::ENTITY_VELOCITY,
id::ENTITY_EQUIPMENT,
id::EXPERIENCE,
id::UPDATE_HEALTH,
id::SCOREBOARD_OBJECTIVE,
id::SET_PASSENGERS,
id::TEAMS,
id::SCOREBOARD_SCORE,
id::UPDATE_TIME,
id::TITLE,
id::ENTITY_SOUND_EFFECT,
id::SOUND_EFFECT,
id::STOP_SOUND,
id::PLAYERLIST_HEADER,
id::NBT_QUERY_RESPONSE,
id::COLLECT,
id::ENTITY_TELEPORT,
id::ADVANCEMENTS,
id::ENTITY_UPDATE_ATTRIBUTES,
id::ENTITY_EFFECT,
id::DECLARE_RECIPES,
id::TAGS,
];
#[cfg(feature = "testgen")]
pub fn generate_by_id(id: i32, g: &mut Gen) -> Option<Self> {
match id {
id::SPAWN_ENTITY => Some(Self::SpawnEntity(<SpawnEntity as Generate>::generate(g))),
id::SPAWN_ENTITY_EXPERIENCE_ORB => Some(Self::SpawnEntityExperienceOrb(
<SpawnEntityExperienceOrb as Generate>::generate(g),
)),
id::SPAWN_ENTITY_LIVING => Some(Self::SpawnEntityLiving(
<SpawnEntityLiving as Generate>::generate(g),
)),
id::SPAWN_ENTITY_PAINTING => Some(Self::SpawnEntityPainting(
<SpawnEntityPainting as Generate>::generate(g),
)),
id::NAMED_ENTITY_SPAWN => Some(Self::NamedEntitySpawn(
<NamedEntitySpawn as Generate>::generate(g),
)),
id::ANIMATION => Some(Self::Animation(<Animation as Generate>::generate(g))),
id::STATISTICS => Some(Self::Statistics(<Statistics as Generate>::generate(g))),
id::ACKNOWLEDGE_PLAYER_DIGGING => Some(Self::AcknowledgePlayerDigging(
<AcknowledgePlayerDigging as Generate>::generate(g),
)),
id::BLOCK_BREAK_ANIMATION => Some(Self::BlockBreakAnimation(
<BlockBreakAnimation as Generate>::generate(g),
)),
id::TILE_ENTITY_DATA => Some(Self::TileEntityData(
<TileEntityData as Generate>::generate(g),
)),
id::BLOCK_ACTION => Some(Self::BlockAction(<BlockAction as Generate>::generate(g))),
id::BLOCK_CHANGE => Some(Self::BlockChange(<BlockChange as Generate>::generate(g))),
id::BOSS_BAR => Some(Self::BossBar(<BossBar as Generate>::generate(g))),
id::DIFFICULTY => Some(Self::Difficulty(<Difficulty as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::DECLARE_COMMANDS => Some(Self::DeclareCommands(
<DeclareCommands as Generate>::generate(g),
)),
id::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
id::WINDOW_ITEMS => Some(Self::WindowItems(<WindowItems as Generate>::generate(g))),
id::CRAFT_PROGRESS_BAR => Some(Self::CraftProgressBar(
<CraftProgressBar as Generate>::generate(g),
)),
id::SET_SLOT => Some(Self::SetSlot(<SetSlot as Generate>::generate(g))),
id::SET_COOLDOWN => Some(Self::SetCooldown(<SetCooldown as Generate>::generate(g))),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::NAMED_SOUND_EFFECT => Some(Self::NamedSoundEffect(
<NamedSoundEffect as Generate>::generate(g),
)),
id::KICK_DISCONNECT => Some(Self::KickDisconnect(
<KickDisconnect as Generate>::generate(g),
)),
id::ENTITY_STATUS => Some(Self::EntityStatus(<EntityStatus as Generate>::generate(g))),
id::EXPLOSION => Some(Self::Explosion(<Explosion as Generate>::generate(g))),
id::UNLOAD_CHUNK => Some(Self::UnloadChunk(<UnloadChunk as Generate>::generate(g))),
id::GAME_STATE_CHANGE => Some(Self::GameStateChange(
<GameStateChange as Generate>::generate(g),
)),
id::OPEN_HORSE_WINDOW => Some(Self::OpenHorseWindow(
<OpenHorseWindow as Generate>::generate(g),
)),
id::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
id::MAP_CHUNK => Some(Self::MapChunk(<MapChunk as Generate>::generate(g))),
id::WORLD_EVENT => Some(Self::WorldEvent(<WorldEvent as Generate>::generate(g))),
id::WORLD_PARTICLES => Some(Self::WorldParticles(
<WorldParticles as Generate>::generate(g),
)),
id::UPDATE_LIGHT => Some(Self::UpdateLight(<UpdateLight as Generate>::generate(g))),
id::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
id::TRADE_LIST => Some(Self::TradeList(<TradeList as Generate>::generate(g))),
id::REL_ENTITY_MOVE => Some(Self::RelEntityMove(
<RelEntityMove as Generate>::generate(g),
)),
id::ENTITY_MOVE_LOOK => Some(Self::EntityMoveLook(
<EntityMoveLook as Generate>::generate(g),
)),
id::ENTITY_LOOK => Some(Self::EntityLook(<EntityLook as Generate>::generate(g))),
id::ENTITY => Some(Self::Entity(<Entity as Generate>::generate(g))),
id::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove as Generate>::generate(g))),
id::OPEN_BOOK => Some(Self::OpenBook(<OpenBook as Generate>::generate(g))),
id::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow as Generate>::generate(g))),
id::OPEN_SIGN_ENTITY => Some(Self::OpenSignEntity(
<OpenSignEntity as Generate>::generate(g),
)),
id::CRAFT_RECIPE_RESPONSE => Some(Self::CraftRecipeResponse(
<CraftRecipeResponse as Generate>::generate(g),
)),
id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
id::COMBAT_EVENT => Some(Self::CombatEvent(<CombatEvent as Generate>::generate(g))),
id::PLAYER_INFO => Some(Self::PlayerInfo(<PlayerInfo as Generate>::generate(g))),
id::FACE_PLAYER => Some(Self::FacePlayer(<FacePlayer as Generate>::generate(g))),
id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
id::UNLOCK_RECIPES => Some(Self::UnlockRecipes(<UnlockRecipes as Generate>::generate(
g,
))),
id::ENTITY_DESTROY => Some(Self::EntityDestroy(<EntityDestroy as Generate>::generate(
g,
))),
id::REMOVE_ENTITY_EFFECT => Some(Self::RemoveEntityEffect(
<RemoveEntityEffect as Generate>::generate(g),
)),
id::RESOURCE_PACK_SEND => Some(Self::ResourcePackSend(
<ResourcePackSend as Generate>::generate(g),
)),
id::RESPAWN => Some(Self::Respawn(<Respawn as Generate>::generate(g))),
id::ENTITY_HEAD_ROTATION => Some(Self::EntityHeadRotation(
<EntityHeadRotation as Generate>::generate(g),
)),
id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
<MultiBlockChange as Generate>::generate(g),
)),
id::SELECT_ADVANCEMENT_TAB => Some(Self::SelectAdvancementTab(
<SelectAdvancementTab as Generate>::generate(g),
)),
id::WORLD_BORDER => Some(Self::WorldBorder(<WorldBorder as Generate>::generate(g))),
id::CAMERA => Some(Self::Camera(<Camera as Generate>::generate(g))),
id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
id::UPDATE_VIEW_POSITION => Some(Self::UpdateViewPosition(
<UpdateViewPosition as Generate>::generate(g),
)),
id::UPDATE_VIEW_DISTANCE => Some(Self::UpdateViewDistance(
<UpdateViewDistance as Generate>::generate(g),
)),
id::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition as Generate>::generate(
g,
))),
id::SCOREBOARD_DISPLAY_OBJECTIVE => Some(Self::ScoreboardDisplayObjective(
<ScoreboardDisplayObjective as Generate>::generate(g),
)),
id::ENTITY_METADATA => Some(Self::EntityMetadata(
<EntityMetadata as Generate>::generate(g),
)),
id::ATTACH_ENTITY => Some(Self::AttachEntity(<AttachEntity as Generate>::generate(g))),
id::ENTITY_VELOCITY => Some(Self::EntityVelocity(
<EntityVelocity as Generate>::generate(g),
)),
id::ENTITY_EQUIPMENT => Some(Self::EntityEquipment(
<EntityEquipment as Generate>::generate(g),
)),
id::EXPERIENCE => Some(Self::Experience(<Experience as Generate>::generate(g))),
id::UPDATE_HEALTH => Some(Self::UpdateHealth(<UpdateHealth as Generate>::generate(g))),
id::SCOREBOARD_OBJECTIVE => Some(Self::ScoreboardObjective(
<ScoreboardObjective as Generate>::generate(g),
)),
id::SET_PASSENGERS => Some(Self::SetPassengers(<SetPassengers as Generate>::generate(
g,
))),
id::TEAMS => Some(Self::Teams(<Teams as Generate>::generate(g))),
id::SCOREBOARD_SCORE => Some(Self::ScoreboardScore(
<ScoreboardScore as Generate>::generate(g),
)),
id::UPDATE_TIME => Some(Self::UpdateTime(<UpdateTime as Generate>::generate(g))),
id::TITLE => Some(Self::Title(<Title as Generate>::generate(g))),
id::ENTITY_SOUND_EFFECT => Some(Self::EntitySoundEffect(
<EntitySoundEffect as Generate>::generate(g),
)),
id::SOUND_EFFECT => Some(Self::SoundEffect(<SoundEffect as Generate>::generate(g))),
id::STOP_SOUND => Some(Self::StopSound(<StopSound as Generate>::generate(g))),
id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
<PlayerlistHeader as Generate>::generate(g),
)),
id::NBT_QUERY_RESPONSE => Some(Self::NbtQueryResponse(
<NbtQueryResponse as Generate>::generate(g),
)),
id::COLLECT => Some(Self::Collect(<Collect as Generate>::generate(g))),
id::ENTITY_TELEPORT => Some(Self::EntityTeleport(
<EntityTeleport as Generate>::generate(g),
)),
id::ADVANCEMENTS => Some(Self::Advancements(<Advancements as Generate>::generate(g))),
id::ENTITY_UPDATE_ATTRIBUTES => Some(Self::EntityUpdateAttributes(
<EntityUpdateAttributes as Generate>::generate(g),
)),
id::ENTITY_EFFECT => Some(Self::EntityEffect(<EntityEffect as Generate>::generate(g))),
id::DECLARE_RECIPES => Some(Self::DeclareRecipes(
<DeclareRecipes as Generate>::generate(g),
)),
id::TAGS => Some(Self::Tags(<Tags as Generate>::generate(g))),
_ => None,
}
}
}