// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/1.12.2/protocol.json, Minecraft 1.12.2). Do not edit; run `cargo run -p ghast-codegen-protocol`.
// minecraft-data is MIT licensed, Copyright (c) 2015 PrismarineJS; see ../NOTICE.
//! Clientbound packets of the play state.
#![allow(
unused_imports,
unused_variables,
unused_mut,
unused_parens,
unused_braces,
clippy::all,
clippy::pedantic,
non_camel_case_types,
non_snake_case
)]
use crate::codec::{Decode, DecodeResult, Encode, EncodeResult, McWrite, Reader, decode_exact};
use crate::error::{DecodeError, EncodeError};
use crate::nbt::RawNbt;
use crate::packet::{Direction, PacketSet, RawPacket, State};
#[cfg(feature = "testgen")]
use crate::testgen::{Gen, Generate};
use crate::types::{BlockPos, ByteString, PositionLayout, Uuid};
use crate::v1_12_2::types;
use bytes::{BufMut, Bytes, BytesMut};
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct StatisticsEntries {
/// `name`
pub name: ByteString,
/// `value`
pub value: i32,
}
/// Mapped `u8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct DifficultyDifficulty(pub u8);
impl DifficultyDifficulty {
/// `peaceful`
pub const PEACEFUL: Self = Self(0);
/// `easy`
pub const EASY: Self = Self(1);
/// `normal`
pub const NORMAL: Self = Self(2);
/// `hard`
pub const HARD: Self = Self(3);
/// minecraft-data name of the value, if known.
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),
}
}
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MultiBlockChangeRecords {
/// `horizontalPos`
pub horizontal_pos: u8,
/// `y`
pub y: u8,
/// `blockId`
pub block_id: i32,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionAffectedBlockOffsets {
/// `x`
pub x: i8,
/// `y`
pub y: i8,
/// `z`
pub z: i8,
}
/// Mapped `u8` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct GameStateChangeReason(pub u8);
impl GameStateChangeReason {
/// `no_respawn_block_available`
pub const NO_RESPAWN_BLOCK_AVAILABLE: Self = Self(0);
/// `start_raining`
pub const START_RAINING: Self = Self(1);
/// `stop_raining`
pub const STOP_RAINING: Self = Self(2);
/// `change_game_mode`
pub const CHANGE_GAME_MODE: Self = Self(3);
/// `win_game`
pub const WIN_GAME: Self = Self(4);
/// `demo_event`
pub const DEMO_EVENT: Self = Self(5);
/// `play_arrow_hit_sound`
pub const PLAY_ARROW_HIT_SOUND: Self = Self(6);
/// `rain_level_change`
pub const RAIN_LEVEL_CHANGE: Self = Self(7);
/// `thunder_level_change`
pub const THUNDER_LEVEL_CHANGE: Self = Self(8);
/// `guardian_elder_effect`
pub const GUARDIAN_ELDER_EFFECT: Self = Self(10);
/// minecraft-data name of the value, if known.
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"),
10 => Some("guardian_elder_effect"),
_ => 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),
}
}
}
/// Switch on `particleId`.
#[derive(Debug, Clone, PartialEq)]
pub enum WorldParticlesData {
/// Case(s) `36`.
Case36(Vec<i32>),
/// Case(s) `37`.
Case37(Vec<i32>),
/// Case(s) `38`.
Case38(Vec<i32>),
/// Any other value.
Other,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MapIcons {
/// `directionAndType`
pub direction_and_type: i8,
/// `x`
pub x: i8,
/// `z`
pub z: i8,
}
/// Mapped `i32` value; unknown values are kept as-is.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
pub struct PlayerInfoAction(pub i32);
impl PlayerInfoAction {
/// `add_player`
pub const ADD_PLAYER: Self = Self(0);
/// `update_game_mode`
pub const UPDATE_GAME_MODE: Self = Self(1);
/// `update_latency`
pub const UPDATE_LATENCY: Self = Self(2);
/// `update_display_name`
pub const UPDATE_DISPLAY_NAME: Self = Self(3);
/// `remove_player`
pub const REMOVE_PLAYER: Self = Self(4);
/// minecraft-data name of the value, if known.
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),
}
}
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyAddPlayerProperties {
/// `name`
pub name: ByteString,
/// `value`
pub value: ByteString,
/// `signature`
pub signature: Option<ByteString>,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyAddPlayer {
/// `name`
pub name: ByteString,
/// `properties`
pub properties: Vec<PlayerInfoDataBodyAddPlayerProperties>,
/// `gamemode`
pub gamemode: i32,
/// `ping`
pub ping: i32,
/// `displayName`
pub display_name: Option<ByteString>,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateGameMode {
/// `gamemode`
pub gamemode: i32,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateLatency {
/// `ping`
pub ping: i32,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoDataBodyUpdateDisplayName {
/// `displayName`
pub display_name: Option<ByteString>,
}
/// Switch on `../action`.
#[derive(Debug, Clone, PartialEq)]
pub enum PlayerInfoDataBody {
/// Case(s) `add_player`.
AddPlayer(PlayerInfoDataBodyAddPlayer),
/// Case(s) `update_game_mode`.
UpdateGameMode(PlayerInfoDataBodyUpdateGameMode),
/// Case(s) `update_latency`.
UpdateLatency(PlayerInfoDataBodyUpdateLatency),
/// Case(s) `update_display_name`.
UpdateDisplayName(PlayerInfoDataBodyUpdateDisplayName),
/// Case(s) `remove_player`.
RemovePlayer,
/// Any other value.
Other,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfoData {
/// `uuid`
pub uuid: Uuid,
/// Anonymous switch
pub body: PlayerInfoDataBody,
}
/// Packed bit field.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct AdvancementsAdvancementMappingValueDisplayDataFlags {
/// `_unused` (29 bits)
pub _unused: u32,
/// `hidden` (1 bits)
pub hidden: u8,
/// `show_toast` (1 bits)
pub show_toast: u8,
/// `has_background_texture` (1 bits)
pub has_background_texture: u8,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueDisplayData {
/// `title`
pub title: ByteString,
/// `description`
pub description: ByteString,
/// `icon`
pub icon: types::Slot,
/// `frameType`
pub frame_type: i32,
/// `flags`
pub flags: AdvancementsAdvancementMappingValueDisplayDataFlags,
/// `backgroundTexture`
pub background_texture: Option<ByteString>,
/// `xCord`
pub x_cord: f32,
/// `yCord`
pub y_cord: f32,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValueCriteria {
/// `key`
pub key: ByteString,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMappingValue {
/// `parentId`
pub parent_id: Option<ByteString>,
/// `displayData`
pub display_data: Option<AdvancementsAdvancementMappingValueDisplayData>,
/// `criteria`
pub criteria: Vec<AdvancementsAdvancementMappingValueCriteria>,
/// `requirements`
pub requirements: Vec<Vec<ByteString>>,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsAdvancementMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: AdvancementsAdvancementMappingValue,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMappingValue {
/// `criterionIdentifier`
pub criterion_identifier: ByteString,
/// `criterionProgress`
pub criterion_progress: Option<i64>,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct AdvancementsProgressMapping {
/// `key`
pub key: ByteString,
/// `value`
pub value: Vec<AdvancementsProgressMappingValue>,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesPropertiesModifiers {
/// `uuid`
pub uuid: Uuid,
/// `amount`
pub amount: f64,
/// `operation`
pub operation: i8,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributesProperties {
/// `key`
pub key: ByteString,
/// `value`
pub value: f64,
/// `modifiers`
pub modifiers: Vec<EntityUpdateAttributesPropertiesModifiers>,
}
/// Packet ids.
pub mod id {
/// `spawn_entity`
pub const SPAWN_ENTITY: i32 = 0x00;
/// `spawn_entity_experience_orb`
pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x01;
/// `spawn_entity_weather`
pub const SPAWN_ENTITY_WEATHER: i32 = 0x02;
/// `spawn_entity_living`
pub const SPAWN_ENTITY_LIVING: i32 = 0x03;
/// `spawn_entity_painting`
pub const SPAWN_ENTITY_PAINTING: i32 = 0x04;
/// `named_entity_spawn`
pub const NAMED_ENTITY_SPAWN: i32 = 0x05;
/// `animation`
pub const ANIMATION: i32 = 0x06;
/// `statistics`
pub const STATISTICS: i32 = 0x07;
/// `block_break_animation`
pub const BLOCK_BREAK_ANIMATION: i32 = 0x08;
/// `tile_entity_data`
pub const TILE_ENTITY_DATA: i32 = 0x09;
/// `block_action`
pub const BLOCK_ACTION: i32 = 0x0a;
/// `block_change`
pub const BLOCK_CHANGE: i32 = 0x0b;
/// `boss_bar`
pub const BOSS_BAR: i32 = 0x0c;
/// `difficulty`
pub const DIFFICULTY: i32 = 0x0d;
/// `tab_complete`
pub const TAB_COMPLETE: i32 = 0x0e;
/// `chat`
pub const CHAT: i32 = 0x0f;
/// `multi_block_change`
pub const MULTI_BLOCK_CHANGE: i32 = 0x10;
/// `transaction`
pub const TRANSACTION: i32 = 0x11;
/// `close_window`
pub const CLOSE_WINDOW: i32 = 0x12;
/// `open_window`
pub const OPEN_WINDOW: i32 = 0x13;
/// `window_items`
pub const WINDOW_ITEMS: i32 = 0x14;
/// `craft_progress_bar`
pub const CRAFT_PROGRESS_BAR: i32 = 0x15;
/// `set_slot`
pub const SET_SLOT: i32 = 0x16;
/// `set_cooldown`
pub const SET_COOLDOWN: i32 = 0x17;
/// `custom_payload`
pub const CUSTOM_PAYLOAD: i32 = 0x18;
/// `named_sound_effect`
pub const NAMED_SOUND_EFFECT: i32 = 0x19;
/// `kick_disconnect`
pub const KICK_DISCONNECT: i32 = 0x1a;
/// `entity_status`
pub const ENTITY_STATUS: i32 = 0x1b;
/// `explosion`
pub const EXPLOSION: i32 = 0x1c;
/// `unload_chunk`
pub const UNLOAD_CHUNK: i32 = 0x1d;
/// `game_state_change`
pub const GAME_STATE_CHANGE: i32 = 0x1e;
/// `keep_alive`
pub const KEEP_ALIVE: i32 = 0x1f;
/// `map_chunk`
pub const MAP_CHUNK: i32 = 0x20;
/// `world_event`
pub const WORLD_EVENT: i32 = 0x21;
/// `world_particles`
pub const WORLD_PARTICLES: i32 = 0x22;
/// `login`
pub const LOGIN: i32 = 0x23;
/// `map`
pub const MAP: i32 = 0x24;
/// `entity`
pub const ENTITY: i32 = 0x25;
/// `rel_entity_move`
pub const REL_ENTITY_MOVE: i32 = 0x26;
/// `entity_move_look`
pub const ENTITY_MOVE_LOOK: i32 = 0x27;
/// `entity_look`
pub const ENTITY_LOOK: i32 = 0x28;
/// `vehicle_move`
pub const VEHICLE_MOVE: i32 = 0x29;
/// `open_sign_entity`
pub const OPEN_SIGN_ENTITY: i32 = 0x2a;
/// `craft_recipe_response`
pub const CRAFT_RECIPE_RESPONSE: i32 = 0x2b;
/// `abilities`
pub const ABILITIES: i32 = 0x2c;
/// `combat_event`
pub const COMBAT_EVENT: i32 = 0x2d;
/// `player_info`
pub const PLAYER_INFO: i32 = 0x2e;
/// `position`
pub const POSITION: i32 = 0x2f;
/// `bed`
pub const BED: i32 = 0x30;
/// `unlock_recipes`
pub const UNLOCK_RECIPES: i32 = 0x31;
/// `entity_destroy`
pub const ENTITY_DESTROY: i32 = 0x32;
/// `remove_entity_effect`
pub const REMOVE_ENTITY_EFFECT: i32 = 0x33;
/// `resource_pack_send`
pub const RESOURCE_PACK_SEND: i32 = 0x34;
/// `respawn`
pub const RESPAWN: i32 = 0x35;
/// `entity_head_rotation`
pub const ENTITY_HEAD_ROTATION: i32 = 0x36;
/// `select_advancement_tab`
pub const SELECT_ADVANCEMENT_TAB: i32 = 0x37;
/// `world_border`
pub const WORLD_BORDER: i32 = 0x38;
/// `camera`
pub const CAMERA: i32 = 0x39;
/// `held_item_slot`
pub const HELD_ITEM_SLOT: i32 = 0x3a;
/// `scoreboard_display_objective`
pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x3b;
/// `entity_metadata`
pub const ENTITY_METADATA: i32 = 0x3c;
/// `attach_entity`
pub const ATTACH_ENTITY: i32 = 0x3d;
/// `entity_velocity`
pub const ENTITY_VELOCITY: i32 = 0x3e;
/// `entity_equipment`
pub const ENTITY_EQUIPMENT: i32 = 0x3f;
/// `experience`
pub const EXPERIENCE: i32 = 0x40;
/// `update_health`
pub const UPDATE_HEALTH: i32 = 0x41;
/// `scoreboard_objective`
pub const SCOREBOARD_OBJECTIVE: i32 = 0x42;
/// `set_passengers`
pub const SET_PASSENGERS: i32 = 0x43;
/// `teams`
pub const TEAMS: i32 = 0x44;
/// `scoreboard_score`
pub const SCOREBOARD_SCORE: i32 = 0x45;
/// `spawn_position`
pub const SPAWN_POSITION: i32 = 0x46;
/// `update_time`
pub const UPDATE_TIME: i32 = 0x47;
/// `title`
pub const TITLE: i32 = 0x48;
/// `sound_effect`
pub const SOUND_EFFECT: i32 = 0x49;
/// `playerlist_header`
pub const PLAYERLIST_HEADER: i32 = 0x4a;
/// `collect`
pub const COLLECT: i32 = 0x4b;
/// `entity_teleport`
pub const ENTITY_TELEPORT: i32 = 0x4c;
/// `advancements`
pub const ADVANCEMENTS: i32 = 0x4d;
/// `entity_update_attributes`
pub const ENTITY_UPDATE_ATTRIBUTES: i32 = 0x4e;
/// `entity_effect`
pub const ENTITY_EFFECT: i32 = 0x4f;
}
/// `spawn_entity` (clientbound play, id 0x00).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity {
/// `entityId`
pub entity_id: i32,
/// `objectUUID`
pub object_uuid: Uuid,
/// `type`
pub r#type: i8,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `pitch`
pub pitch: i8,
/// `yaw`
pub yaw: i8,
/// `objectData`
pub object_data: i32,
/// `velocity`
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 v37 = r.read_varint()?;
let v38 = r.read_uuid()?;
let v39 = r.read_i8()?;
let v40 = r.read_f64()?;
let v41 = r.read_f64()?;
let v42 = r.read_f64()?;
let v43 = r.read_i8()?;
let v44 = r.read_i8()?;
let v45 = r.read_i32()?;
let v46 = <types::Vec3i16 as Decode>::decode(r)?;
SpawnEntity {
entity_id: v37,
object_uuid: v38,
r#type: v39,
x: v40,
y: v41,
z: v42,
pitch: v43,
yaw: v44,
object_data: v45,
velocity: v46,
}
})
}
}
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_i8((*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 v47 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v48 = g.uuid();
let v49 = (g.int_in(-128, 127, &[]) as i8);
let v50 = g.f64();
let v51 = g.f64();
let v52 = g.f64();
let v53 = (g.int_in(-128, 127, &[]) as i8);
let v54 = (g.int_in(-128, 127, &[]) as i8);
let v55 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v56 = <types::Vec3i16 as Generate>::generate(g);
SpawnEntity {
entity_id: v47,
object_uuid: v48,
r#type: v49,
x: v50,
y: v51,
z: v52,
pitch: v53,
yaw: v54,
object_data: v55,
velocity: v56,
}
}
}
}
impl From<SpawnEntity> for ClientboundPlayPacket {
fn from(p: SpawnEntity) -> Self {
Self::SpawnEntity(p)
}
}
/// `spawn_entity_experience_orb` (clientbound play, id 0x01).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityExperienceOrb {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `count`
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 v57 = r.read_varint()?;
let v58 = r.read_f64()?;
let v59 = r.read_f64()?;
let v60 = r.read_f64()?;
let v61 = r.read_i16()?;
SpawnEntityExperienceOrb {
entity_id: v57,
x: v58,
y: v59,
z: v60,
count: v61,
}
})
}
}
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 v62 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v63 = g.f64();
let v64 = g.f64();
let v65 = g.f64();
let v66 = (g.int_in(-32768, 32767, &[]) as i16);
SpawnEntityExperienceOrb {
entity_id: v62,
x: v63,
y: v64,
z: v65,
count: v66,
}
}
}
}
impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
fn from(p: SpawnEntityExperienceOrb) -> Self {
Self::SpawnEntityExperienceOrb(p)
}
}
/// `spawn_entity_weather` (clientbound play, id 0x02).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityWeather {
/// `entityId`
pub entity_id: i32,
/// `type`
pub r#type: i8,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
}
impl crate::packet::Packet for SpawnEntityWeather {
const ID: i32 = id::SPAWN_ENTITY_WEATHER;
const NAME: &'static str = "spawn_entity_weather";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SpawnEntityWeather {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v67 = r.read_varint()?;
let v68 = r.read_i8()?;
let v69 = r.read_f64()?;
let v70 = r.read_f64()?;
let v71 = r.read_f64()?;
SpawnEntityWeather {
entity_id: v67,
r#type: v68,
x: v69,
y: v70,
z: v71,
}
})
}
}
impl Encode for SpawnEntityWeather {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).r#type);
w.put_f64((*self).x);
w.put_f64((*self).y);
w.put_f64((*self).z);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityWeather {
fn generate(g: &mut Gen) -> Self {
{
let v72 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v73 = (g.int_in(-128, 127, &[]) as i8);
let v74 = g.f64();
let v75 = g.f64();
let v76 = g.f64();
SpawnEntityWeather {
entity_id: v72,
r#type: v73,
x: v74,
y: v75,
z: v76,
}
}
}
}
impl From<SpawnEntityWeather> for ClientboundPlayPacket {
fn from(p: SpawnEntityWeather) -> Self {
Self::SpawnEntityWeather(p)
}
}
/// `spawn_entity_living` (clientbound play, id 0x03).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityLiving {
/// `entityId`
pub entity_id: i32,
/// `entityUUID`
pub entity_uuid: Uuid,
/// `type`
pub r#type: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `headPitch`
pub head_pitch: i8,
/// `velocity`
pub velocity: types::Vec3i16,
/// `metadata`
pub metadata: Vec<types::EntityMetadataEntry>,
}
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 v77 = r.read_varint()?;
let v78 = r.read_uuid()?;
let v79 = r.read_varint()?;
let v80 = r.read_f64()?;
let v81 = r.read_f64()?;
let v82 = r.read_f64()?;
let v83 = r.read_i8()?;
let v84 = r.read_i8()?;
let v85 = r.read_i8()?;
let v86 = <types::Vec3i16 as Decode>::decode(r)?;
let v87 = {
let mut v88 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v88.push({
let v89 = r.read_u8()?;
let v90 = r.read_i8()?;
let v91 = (if (v90 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v90 == 1) {
types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v90 == 2) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v90 == 3) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v90 == 4) {
types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v90 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v90 == 6) {
types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v90 == 7) {
types::EntityMetadataValue::Rotation({
let v92 = r.read_f32()?;
let v93 = r.read_f32()?;
let v94 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v92,
yaw: v93,
roll: v94,
}
})
} else if (v90 == 8) {
types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v90 == 9) {
types::EntityMetadataValue::OptPosition(if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
})
} else if (v90 == 10) {
types::EntityMetadataValue::Direction(r.read_varint()?)
} else if (v90 == 11) {
types::EntityMetadataValue::OptUuid(if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
})
} else if (v90 == 12) {
types::EntityMetadataValue::BlockState(r.read_varint()?)
} else if (v90 == 13) {
types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v89,
r#type: v90,
value: v91,
}
});
}
v88
};
SpawnEntityLiving {
entity_id: v77,
entity_uuid: v78,
r#type: v79,
x: v80,
y: v81,
z: v82,
yaw: v83,
pitch: v84,
head_pitch: v85,
velocity: v86,
metadata: 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)?;
for v95 in (*self).metadata.iter() {
let v96 = w.len();
w.put_u8((*v95).key);
w.put_i8((*v95).r#type);
match &(*v95).value {
types::EntityMetadataValue::Byte(v97) => {
if !((*v95).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i8((*v97));
}
types::EntityMetadataValue::VarInt(v98) => {
if !((*v95).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v98));
}
types::EntityMetadataValue::Float(v99) => {
if !((*v95).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v99));
}
types::EntityMetadataValue::String(v100) => {
if !((*v95).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_string(&(*v100))?;
}
types::EntityMetadataValue::Chat(v101) => {
if !((*v95).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_string(&(*v101))?;
}
types::EntityMetadataValue::Slot(v102) => {
if !((*v95).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v102).encode(w)?;
}
types::EntityMetadataValue::Boolean(v103) => {
if !((*v95).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_bool((*v103));
}
types::EntityMetadataValue::Rotation(v104) => {
if !((*v95).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v104).pitch);
w.put_f32((*v104).yaw);
w.put_f32((*v104).roll);
}
types::EntityMetadataValue::Position(v105) => {
if !((*v95).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v105).write(w, PositionLayout::Xyz)?;
}
types::EntityMetadataValue::OptPosition(v106) => {
if !((*v95).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
match &(*v106) {
Some(v107) => {
w.put_u8(1);
(*v107).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v108) => {
if !((*v95).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v108));
}
types::EntityMetadataValue::OptUuid(v109) => {
if !((*v95).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
match &(*v109) {
Some(v110) => {
w.put_u8(1);
w.put_uuid(&(*v110));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v111) => {
if !((*v95).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_varint((*v111));
}
types::EntityMetadataValue::Nbt(v112) => {
if !((*v95).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v112).write(w);
}
types::EntityMetadataValue::Other => {
if !(!(((*v95).r#type == 0)
|| ((*v95).r#type == 1)
|| ((*v95).r#type == 2)
|| ((*v95).r#type == 3)
|| ((*v95).r#type == 4)
|| ((*v95).r#type == 5)
|| ((*v95).r#type == 6)
|| ((*v95).r#type == 7)
|| ((*v95).r#type == 8)
|| ((*v95).r#type == 9)
|| ((*v95).r#type == 10)
|| ((*v95).r#type == 11)
|| ((*v95).r#type == 12)
|| ((*v95).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
}
}
if w.get(v96) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.spawn_entity_living.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityLiving {
fn generate(g: &mut Gen) -> Self {
{
let v113 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v114 = g.uuid();
let v115 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v116 = g.f64();
let v117 = g.f64();
let v118 = g.f64();
let v119 = (g.int_in(-128, 127, &[]) as i8);
let v120 = (g.int_in(-128, 127, &[]) as i8);
let v121 = (g.int_in(-128, 127, &[]) as i8);
let v122 = <types::Vec3i16 as Generate>::generate(g);
let v123 = {
let n = g.count();
let mut v124 = Vec::with_capacity(n);
for _ in 0..n {
v124.push(loop { let v125 = { let v126 = (g.int_in(0, 255, &[]) as u8);let v127 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v128 = (if (v127 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v127 == 1) { types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 2) { types::EntityMetadataValue::Float(g.f32()) } else if (v127 == 3) { types::EntityMetadataValue::String(g.string()) } else if (v127 == 4) { types::EntityMetadataValue::Chat(g.string()) } else if (v127 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v127 == 6) { types::EntityMetadataValue::Boolean(g.bool()) } else if (v127 == 7) { types::EntityMetadataValue::Rotation({ let v129 = g.f32();let v130 = g.f32();let v131 = g.f32(); types::EntityMetadataValueRotation { pitch: v129, yaw: v130, roll: v131 } }) } else if (v127 == 8) { types::EntityMetadataValue::Position(g.position()) } else if (v127 == 9) { types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v127 == 10) { types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 11) { types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v127 == 12) { types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v127 == 13) { types::EntityMetadataValue::Nbt(g.nbt()) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { key: v126, r#type: v127, value: v128 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v125.key);w.put_i8(v125.r#type);match &v125.value { types::EntityMetadataValue::Byte(v132) => { if !((v125.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v132)); }types::EntityMetadataValue::VarInt(v133) => { if !((v125.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v133)); }types::EntityMetadataValue::Float(v134) => { if !((v125.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v134)); }types::EntityMetadataValue::String(v135) => { if !((v125.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v135))?; }types::EntityMetadataValue::Chat(v136) => { if !((v125.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v136))?; }types::EntityMetadataValue::Slot(v137) => { if !((v125.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v137).encode(w)?; }types::EntityMetadataValue::Boolean(v138) => { if !((v125.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_bool((*v138)); }types::EntityMetadataValue::Rotation(v139) => { if !((v125.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v139).pitch);w.put_f32((*v139).yaw);w.put_f32((*v139).roll); }types::EntityMetadataValue::Position(v140) => { if !((v125.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v140).write(w, PositionLayout::Xyz)?; }types::EntityMetadataValue::OptPosition(v141) => { if !((v125.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v141) { Some(v142) => { w.put_u8(1); (*v142).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }types::EntityMetadataValue::Direction(v143) => { if !((v125.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v143)); }types::EntityMetadataValue::OptUuid(v144) => { if !((v125.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } match &(*v144) { Some(v145) => { w.put_u8(1); w.put_uuid(&(*v145)); } None => w.put_u8(0), } }types::EntityMetadataValue::BlockState(v146) => { if !((v125.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_varint((*v146)); }types::EntityMetadataValue::Nbt(v147) => { if !((v125.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v147).write(w); }types::EntityMetadataValue::Other => { if !(!((v125.r#type == 0) || (v125.r#type == 1) || (v125.r#type == 2) || (v125.r#type == 3) || (v125.r#type == 4) || (v125.r#type == 5) || (v125.r#type == 6) || (v125.r#type == 7) || (v125.r#type == 8) || (v125.r#type == 9) || (v125.r#type == 10) || (v125.r#type == 11) || (v125.r#type == 12) || (v125.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v125; } });
}
v124
};
SpawnEntityLiving {
entity_id: v113,
entity_uuid: v114,
r#type: v115,
x: v116,
y: v117,
z: v118,
yaw: v119,
pitch: v120,
head_pitch: v121,
velocity: v122,
metadata: v123,
}
}
}
}
impl From<SpawnEntityLiving> for ClientboundPlayPacket {
fn from(p: SpawnEntityLiving) -> Self {
Self::SpawnEntityLiving(p)
}
}
/// `spawn_entity_painting` (clientbound play, id 0x04).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityPainting {
/// `entityId`
pub entity_id: i32,
/// `entityUUID`
pub entity_uuid: Uuid,
/// `title`
pub title: ByteString,
/// `location`
pub location: BlockPos,
/// `direction`
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 v148 = r.read_varint()?;
let v149 = r.read_uuid()?;
let v150 = r.read_string()?;
let v151 = BlockPos::read(r, PositionLayout::Xyz)?;
let v152 = r.read_u8()?;
SpawnEntityPainting {
entity_id: v148,
entity_uuid: v149,
title: v150,
location: v151,
direction: v152,
}
})
}
}
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_string(&(*self).title)?;
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_u8((*self).direction);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityPainting {
fn generate(g: &mut Gen) -> Self {
{
let v153 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v154 = g.uuid();
let v155 = g.string();
let v156 = g.position();
let v157 = (g.int_in(0, 255, &[]) as u8);
SpawnEntityPainting {
entity_id: v153,
entity_uuid: v154,
title: v155,
location: v156,
direction: v157,
}
}
}
}
impl From<SpawnEntityPainting> for ClientboundPlayPacket {
fn from(p: SpawnEntityPainting) -> Self {
Self::SpawnEntityPainting(p)
}
}
/// `named_entity_spawn` (clientbound play, id 0x05).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedEntitySpawn {
/// `entityId`
pub entity_id: i32,
/// `playerUUID`
pub player_uuid: Uuid,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `metadata`
pub metadata: Vec<types::EntityMetadataEntry>,
}
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 v158 = r.read_varint()?;
let v159 = r.read_uuid()?;
let v160 = r.read_f64()?;
let v161 = r.read_f64()?;
let v162 = r.read_f64()?;
let v163 = r.read_i8()?;
let v164 = r.read_i8()?;
let v165 = {
let mut v166 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v166.push({
let v167 = r.read_u8()?;
let v168 = r.read_i8()?;
let v169 = (if (v168 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v168 == 1) {
types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v168 == 2) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v168 == 3) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v168 == 4) {
types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v168 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v168 == 6) {
types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v168 == 7) {
types::EntityMetadataValue::Rotation({
let v170 = r.read_f32()?;
let v171 = r.read_f32()?;
let v172 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v170,
yaw: v171,
roll: v172,
}
})
} else if (v168 == 8) {
types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v168 == 9) {
types::EntityMetadataValue::OptPosition(if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
})
} else if (v168 == 10) {
types::EntityMetadataValue::Direction(r.read_varint()?)
} else if (v168 == 11) {
types::EntityMetadataValue::OptUuid(if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
})
} else if (v168 == 12) {
types::EntityMetadataValue::BlockState(r.read_varint()?)
} else if (v168 == 13) {
types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v167,
r#type: v168,
value: v169,
}
});
}
v166
};
NamedEntitySpawn {
entity_id: v158,
player_uuid: v159,
x: v160,
y: v161,
z: v162,
yaw: v163,
pitch: v164,
metadata: v165,
}
})
}
}
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);
for v173 in (*self).metadata.iter() {
let v174 = w.len();
w.put_u8((*v173).key);
w.put_i8((*v173).r#type);
match &(*v173).value {
types::EntityMetadataValue::Byte(v175) => {
if !((*v173).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i8((*v175));
}
types::EntityMetadataValue::VarInt(v176) => {
if !((*v173).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v176));
}
types::EntityMetadataValue::Float(v177) => {
if !((*v173).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v177));
}
types::EntityMetadataValue::String(v178) => {
if !((*v173).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_string(&(*v178))?;
}
types::EntityMetadataValue::Chat(v179) => {
if !((*v173).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_string(&(*v179))?;
}
types::EntityMetadataValue::Slot(v180) => {
if !((*v173).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v180).encode(w)?;
}
types::EntityMetadataValue::Boolean(v181) => {
if !((*v173).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_bool((*v181));
}
types::EntityMetadataValue::Rotation(v182) => {
if !((*v173).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v182).pitch);
w.put_f32((*v182).yaw);
w.put_f32((*v182).roll);
}
types::EntityMetadataValue::Position(v183) => {
if !((*v173).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v183).write(w, PositionLayout::Xyz)?;
}
types::EntityMetadataValue::OptPosition(v184) => {
if !((*v173).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
match &(*v184) {
Some(v185) => {
w.put_u8(1);
(*v185).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v186) => {
if !((*v173).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v186));
}
types::EntityMetadataValue::OptUuid(v187) => {
if !((*v173).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
match &(*v187) {
Some(v188) => {
w.put_u8(1);
w.put_uuid(&(*v188));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v189) => {
if !((*v173).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_varint((*v189));
}
types::EntityMetadataValue::Nbt(v190) => {
if !((*v173).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v190).write(w);
}
types::EntityMetadataValue::Other => {
if !(!(((*v173).r#type == 0)
|| ((*v173).r#type == 1)
|| ((*v173).r#type == 2)
|| ((*v173).r#type == 3)
|| ((*v173).r#type == 4)
|| ((*v173).r#type == 5)
|| ((*v173).r#type == 6)
|| ((*v173).r#type == 7)
|| ((*v173).r#type == 8)
|| ((*v173).r#type == 9)
|| ((*v173).r#type == 10)
|| ((*v173).r#type == 11)
|| ((*v173).r#type == 12)
|| ((*v173).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
}
}
if w.get(v174) == Some(&255) {
return Err(EncodeError::OutOfRange(
"play.clientbound.named_entity_spawn.metadata",
));
}
}
w.put_u8(255);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NamedEntitySpawn {
fn generate(g: &mut Gen) -> Self {
{
let v191 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v192 = g.uuid();
let v193 = g.f64();
let v194 = g.f64();
let v195 = g.f64();
let v196 = (g.int_in(-128, 127, &[]) as i8);
let v197 = (g.int_in(-128, 127, &[]) as i8);
let v198 = {
let n = g.count();
let mut v199 = Vec::with_capacity(n);
for _ in 0..n {
v199.push(loop { let v200 = { let v201 = (g.int_in(0, 255, &[]) as u8);let v202 = (g.int_in(-128, 127, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) as i8);let v203 = (if (v202 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v202 == 1) { types::EntityMetadataValue::VarInt((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 2) { types::EntityMetadataValue::Float(g.f32()) } else if (v202 == 3) { types::EntityMetadataValue::String(g.string()) } else if (v202 == 4) { types::EntityMetadataValue::Chat(g.string()) } else if (v202 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v202 == 6) { types::EntityMetadataValue::Boolean(g.bool()) } else if (v202 == 7) { types::EntityMetadataValue::Rotation({ let v204 = g.f32();let v205 = g.f32();let v206 = g.f32(); types::EntityMetadataValueRotation { pitch: v204, yaw: v205, roll: v206 } }) } else if (v202 == 8) { types::EntityMetadataValue::Position(g.position()) } else if (v202 == 9) { types::EntityMetadataValue::OptPosition(if g.bool() { Some(g.position()) } else { None }) } else if (v202 == 10) { types::EntityMetadataValue::Direction((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 11) { types::EntityMetadataValue::OptUuid(if g.bool() { Some(g.uuid()) } else { None }) } else if (v202 == 12) { types::EntityMetadataValue::BlockState((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v202 == 13) { types::EntityMetadataValue::Nbt(g.nbt()) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { key: v201, r#type: v202, value: v203 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { w.put_u8(v200.key);w.put_i8(v200.r#type);match &v200.value { types::EntityMetadataValue::Byte(v207) => { if !((v200.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v207)); }types::EntityMetadataValue::VarInt(v208) => { if !((v200.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v208)); }types::EntityMetadataValue::Float(v209) => { if !((v200.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v209)); }types::EntityMetadataValue::String(v210) => { if !((v200.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v210))?; }types::EntityMetadataValue::Chat(v211) => { if !((v200.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v211))?; }types::EntityMetadataValue::Slot(v212) => { if !((v200.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v212).encode(w)?; }types::EntityMetadataValue::Boolean(v213) => { if !((v200.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_bool((*v213)); }types::EntityMetadataValue::Rotation(v214) => { if !((v200.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v214).pitch);w.put_f32((*v214).yaw);w.put_f32((*v214).roll); }types::EntityMetadataValue::Position(v215) => { if !((v200.r#type == 8)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v215).write(w, PositionLayout::Xyz)?; }types::EntityMetadataValue::OptPosition(v216) => { if !((v200.r#type == 9)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v216) { Some(v217) => { w.put_u8(1); (*v217).write(w, PositionLayout::Xyz)?; } None => w.put_u8(0), } }types::EntityMetadataValue::Direction(v218) => { if !((v200.r#type == 10)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v218)); }types::EntityMetadataValue::OptUuid(v219) => { if !((v200.r#type == 11)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } match &(*v219) { Some(v220) => { w.put_u8(1); w.put_uuid(&(*v220)); } None => w.put_u8(0), } }types::EntityMetadataValue::BlockState(v221) => { if !((v200.r#type == 12)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_varint((*v221)); }types::EntityMetadataValue::Nbt(v222) => { if !((v200.r#type == 13)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v222).write(w); }types::EntityMetadataValue::Other => { if !(!((v200.r#type == 0) || (v200.r#type == 1) || (v200.r#type == 2) || (v200.r#type == 3) || (v200.r#type == 4) || (v200.r#type == 5) || (v200.r#type == 6) || (v200.r#type == 7) || (v200.r#type == 8) || (v200.r#type == 9) || (v200.r#type == 10) || (v200.r#type == 11) || (v200.r#type == 12) || (v200.r#type == 13))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 255) { break v200; } });
}
v199
};
NamedEntitySpawn {
entity_id: v191,
player_uuid: v192,
x: v193,
y: v194,
z: v195,
yaw: v196,
pitch: v197,
metadata: v198,
}
}
}
}
impl From<NamedEntitySpawn> for ClientboundPlayPacket {
fn from(p: NamedEntitySpawn) -> Self {
Self::NamedEntitySpawn(p)
}
}
/// `animation` (clientbound play, id 0x06).
#[derive(Debug, Clone, PartialEq)]
pub struct Animation {
/// `entityId`
pub entity_id: i32,
/// `animation`
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 v223 = r.read_varint()?;
let v224 = r.read_u8()?;
Animation {
entity_id: v223,
animation: v224,
}
})
}
}
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 v225 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v226 = (g.int_in(0, 255, &[]) as u8);
Animation {
entity_id: v225,
animation: v226,
}
}
}
}
impl From<Animation> for ClientboundPlayPacket {
fn from(p: Animation) -> Self {
Self::Animation(p)
}
}
/// `statistics` (clientbound play, id 0x07).
#[derive(Debug, Clone, PartialEq)]
pub struct Statistics {
/// `entries`
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 v227 = {
let v228 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v229 = Vec::with_capacity(v228.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v228 {
v229.push({
let v230 = r.read_string()?;
let v231 = r.read_varint()?;
StatisticsEntries {
name: v230,
value: v231,
}
});
}
v229
};
Statistics { entries: v227 }
})
}
}
impl Encode for Statistics {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entries.len())?;
for v232 in (*self).entries.iter() {
w.put_string(&(*v232).name)?;
w.put_varint((*v232).value);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Statistics {
fn generate(g: &mut Gen) -> Self {
{
let v233 = {
let v234 = g.count();
let mut v235 = Vec::with_capacity(v234.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v234 {
v235.push({
let v236 = g.string();
let v237 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
StatisticsEntries {
name: v236,
value: v237,
}
});
}
v235
};
Statistics { entries: v233 }
}
}
}
impl From<Statistics> for ClientboundPlayPacket {
fn from(p: Statistics) -> Self {
Self::Statistics(p)
}
}
/// `block_break_animation` (clientbound play, id 0x08).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockBreakAnimation {
/// `entityId`
pub entity_id: i32,
/// `location`
pub location: BlockPos,
/// `destroyStage`
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 v238 = r.read_varint()?;
let v239 = BlockPos::read(r, PositionLayout::Xyz)?;
let v240 = r.read_i8()?;
BlockBreakAnimation {
entity_id: v238,
location: v239,
destroy_stage: v240,
}
})
}
}
impl Encode for BlockBreakAnimation {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_i8((*self).destroy_stage);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BlockBreakAnimation {
fn generate(g: &mut Gen) -> Self {
{
let v241 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v242 = g.position();
let v243 = (g.int_in(-128, 127, &[]) as i8);
BlockBreakAnimation {
entity_id: v241,
location: v242,
destroy_stage: v243,
}
}
}
}
impl From<BlockBreakAnimation> for ClientboundPlayPacket {
fn from(p: BlockBreakAnimation) -> Self {
Self::BlockBreakAnimation(p)
}
}
/// `tile_entity_data` (clientbound play, id 0x09).
#[derive(Debug, Clone, PartialEq)]
pub struct TileEntityData {
/// `location`
pub location: BlockPos,
/// `action`
pub action: u8,
/// `nbtData`
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 v244 = BlockPos::read(r, PositionLayout::Xyz)?;
let v245 = r.read_u8()?;
let v246 = RawNbt::read_optional(r)?;
TileEntityData {
location: v244,
action: v245,
nbt_data: v246,
}
})
}
}
impl Encode for TileEntityData {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
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 v247 = g.position();
let v248 = (g.int_in(0, 255, &[]) as u8);
let v249 = g.opt_nbt();
TileEntityData {
location: v247,
action: v248,
nbt_data: v249,
}
}
}
}
impl From<TileEntityData> for ClientboundPlayPacket {
fn from(p: TileEntityData) -> Self {
Self::TileEntityData(p)
}
}
/// `block_action` (clientbound play, id 0x0a).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockAction {
/// `location`
pub location: BlockPos,
/// `byte1`
pub byte1: u8,
/// `byte2`
pub byte2: u8,
/// `blockId`
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 v250 = BlockPos::read(r, PositionLayout::Xyz)?;
let v251 = r.read_u8()?;
let v252 = r.read_u8()?;
let v253 = r.read_varint()?;
BlockAction {
location: v250,
byte1: v251,
byte2: v252,
block_id: v253,
}
})
}
}
impl Encode for BlockAction {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
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 v254 = g.position();
let v255 = (g.int_in(0, 255, &[]) as u8);
let v256 = (g.int_in(0, 255, &[]) as u8);
let v257 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockAction {
location: v254,
byte1: v255,
byte2: v256,
block_id: v257,
}
}
}
}
impl From<BlockAction> for ClientboundPlayPacket {
fn from(p: BlockAction) -> Self {
Self::BlockAction(p)
}
}
/// `block_change` (clientbound play, id 0x0b).
#[derive(Debug, Clone, PartialEq)]
pub struct BlockChange {
/// `location`
pub location: BlockPos,
/// `type`
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 v258 = BlockPos::read(r, PositionLayout::Xyz)?;
let v259 = r.read_varint()?;
BlockChange {
location: v258,
r#type: v259,
}
})
}
}
impl Encode for BlockChange {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_varint((*self).r#type);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for BlockChange {
fn generate(g: &mut Gen) -> Self {
{
let v260 = g.position();
let v261 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockChange {
location: v260,
r#type: v261,
}
}
}
}
impl From<BlockChange> for ClientboundPlayPacket {
fn from(p: BlockChange) -> Self {
Self::BlockChange(p)
}
}
/// `boss_bar` (clientbound play, id 0x0c).
#[derive(Debug, Clone, PartialEq)]
pub struct BossBar {
/// `entityUUID`
pub entity_uuid: Uuid,
/// `action`
pub action: i32,
/// `title`
pub title: Option<ByteString>,
/// `health`
pub health: Option<f32>,
/// `color`
pub color: Option<i32>,
/// `dividers`
pub dividers: Option<i32>,
/// `flags`
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 v262 = r.read_uuid()?;
let v263 = r.read_varint()?;
let v264 = if (v263 == 0) || (v263 == 3) {
Some(r.read_string()?)
} else {
None
};
let v265 = if (v263 == 0) || (v263 == 2) {
Some(r.read_f32()?)
} else {
None
};
let v266 = if (v263 == 0) || (v263 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v267 = if (v263 == 0) || (v263 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v268 = if (v263 == 0) || (v263 == 5) {
Some(r.read_u8()?)
} else {
None
};
BossBar {
entity_uuid: v262,
action: v263,
title: v264,
health: v265,
color: v266,
dividers: v267,
flags: v268,
}
})
}
}
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(v269), true) => {
w.put_string(&(*v269))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.title",
));
}
}
match (
&(*self).health,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v270), true) => {
w.put_f32((*v270));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.health",
));
}
}
match (
&(*self).color,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v271), true) => {
w.put_varint((*v271));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.color",
));
}
}
match (
&(*self).dividers,
((*self).action == 0) || ((*self).action == 4),
) {
(Some(v272), true) => {
w.put_varint((*v272));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.boss_bar.dividers",
));
}
}
match (
&(*self).flags,
((*self).action == 0) || ((*self).action == 5),
) {
(Some(v273), true) => {
w.put_u8((*v273));
}
(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 v274 = g.uuid();
let v275 = (g.int_in(-2147483648, 2147483647, &[0, 3, 0, 2, 0, 4, 0, 4, 0, 5]) as i32);
let v276 = if (v275 == 0) || (v275 == 3) {
Some(g.string())
} else {
None
};
let v277 = if (v275 == 0) || (v275 == 2) {
Some(g.f32())
} else {
None
};
let v278 = if (v275 == 0) || (v275 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v279 = if (v275 == 0) || (v275 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v280 = if (v275 == 0) || (v275 == 5) {
Some((g.int_in(0, 255, &[]) as u8))
} else {
None
};
BossBar {
entity_uuid: v274,
action: v275,
title: v276,
health: v277,
color: v278,
dividers: v279,
flags: v280,
}
}
}
}
impl From<BossBar> for ClientboundPlayPacket {
fn from(p: BossBar) -> Self {
Self::BossBar(p)
}
}
/// `difficulty` (clientbound play, id 0x0d).
#[derive(Debug, Clone, PartialEq)]
pub struct Difficulty {
/// `difficulty`
pub difficulty: DifficultyDifficulty,
}
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 v281 = DifficultyDifficulty(r.read_u8()?);
Difficulty { difficulty: v281 }
})
}
}
impl Encode for Difficulty {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).difficulty.0);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Difficulty {
fn generate(g: &mut Gen) -> Self {
{
let v282 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
Difficulty { difficulty: v282 }
}
}
}
impl From<Difficulty> for ClientboundPlayPacket {
fn from(p: Difficulty) -> Self {
Self::Difficulty(p)
}
}
/// `tab_complete` (clientbound play, id 0x0e).
#[derive(Debug, Clone, PartialEq)]
pub struct TabComplete {
/// `matches`
pub matches: Vec<ByteString>,
}
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 v283 = {
let v284 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v285 = Vec::with_capacity(v284.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v284 {
v285.push(r.read_string()?);
}
v285
};
TabComplete { matches: v283 }
})
}
}
impl Encode for TabComplete {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).matches.len())?;
for v286 in (*self).matches.iter() {
w.put_string(&(*v286))?;
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TabComplete {
fn generate(g: &mut Gen) -> Self {
{
let v287 = {
let v288 = g.count();
let mut v289 = Vec::with_capacity(v288.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v288 {
v289.push(g.string());
}
v289
};
TabComplete { matches: v287 }
}
}
}
impl From<TabComplete> for ClientboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(p)
}
}
/// `chat` (clientbound play, id 0x0f).
#[derive(Debug, Clone, PartialEq)]
pub struct Chat {
/// `message`
pub message: ByteString,
/// `position`
pub position: i8,
}
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 v290 = r.read_string()?;
let v291 = r.read_i8()?;
Chat {
message: v290,
position: v291,
}
})
}
}
impl Encode for Chat {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).message)?;
w.put_i8((*self).position);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Chat {
fn generate(g: &mut Gen) -> Self {
{
let v292 = g.string();
let v293 = (g.int_in(-128, 127, &[]) as i8);
Chat {
message: v292,
position: v293,
}
}
}
}
impl From<Chat> for ClientboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
/// `multi_block_change` (clientbound play, id 0x10).
#[derive(Debug, Clone, PartialEq)]
pub struct MultiBlockChange {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
pub chunk_z: i32,
/// `records`
pub records: Vec<MultiBlockChangeRecords>,
}
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 v294 = r.read_i32()?;
let v295 = r.read_i32()?;
let v296 = {
let v297 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v298 = Vec::with_capacity(v297.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v297 {
v298.push({
let v299 = r.read_u8()?;
let v300 = r.read_u8()?;
let v301 = r.read_varint()?;
MultiBlockChangeRecords {
horizontal_pos: v299,
y: v300,
block_id: v301,
}
});
}
v298
};
MultiBlockChange {
chunk_x: v294,
chunk_z: v295,
records: v296,
}
})
}
}
impl Encode for MultiBlockChange {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).chunk_x);
w.put_i32((*self).chunk_z);
w.put_len_varint((*self).records.len())?;
for v302 in (*self).records.iter() {
w.put_u8((*v302).horizontal_pos);
w.put_u8((*v302).y);
w.put_varint((*v302).block_id);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MultiBlockChange {
fn generate(g: &mut Gen) -> Self {
{
let v303 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v304 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v305 = {
let v306 = g.count();
let mut v307 = Vec::with_capacity(v306.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v306 {
v307.push({
let v308 = (g.int_in(0, 255, &[]) as u8);
let v309 = (g.int_in(0, 255, &[]) as u8);
let v310 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
MultiBlockChangeRecords {
horizontal_pos: v308,
y: v309,
block_id: v310,
}
});
}
v307
};
MultiBlockChange {
chunk_x: v303,
chunk_z: v304,
records: v305,
}
}
}
}
impl From<MultiBlockChange> for ClientboundPlayPacket {
fn from(p: MultiBlockChange) -> Self {
Self::MultiBlockChange(p)
}
}
/// `transaction` (clientbound play, id 0x11).
#[derive(Debug, Clone, PartialEq)]
pub struct Transaction {
/// `windowId`
pub window_id: i8,
/// `action`
pub action: i16,
/// `accepted`
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 v311 = r.read_i8()?;
let v312 = r.read_i16()?;
let v313 = r.read_bool()?;
Transaction {
window_id: v311,
action: v312,
accepted: v313,
}
})
}
}
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 v314 = (g.int_in(-128, 127, &[]) as i8);
let v315 = (g.int_in(-32768, 32767, &[]) as i16);
let v316 = g.bool();
Transaction {
window_id: v314,
action: v315,
accepted: v316,
}
}
}
}
impl From<Transaction> for ClientboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(p)
}
}
/// `close_window` (clientbound play, id 0x12).
#[derive(Debug, Clone, PartialEq)]
pub struct CloseWindow {
/// `windowId`
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 v317 = r.read_u8()?;
CloseWindow { window_id: v317 }
})
}
}
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 v318 = (g.int_in(0, 255, &[]) as u8);
CloseWindow { window_id: v318 }
}
}
}
impl From<CloseWindow> for ClientboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(p)
}
}
/// `open_window` (clientbound play, id 0x13).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenWindow {
/// `windowId`
pub window_id: u8,
/// `inventoryType`
pub inventory_type: ByteString,
/// `windowTitle`
pub window_title: ByteString,
/// `slotCount`
pub slot_count: u8,
/// `entityId`
pub entity_id: Option<i32>,
}
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 v319 = r.read_u8()?;
let v320 = r.read_string()?;
let v321 = r.read_string()?;
let v322 = r.read_u8()?;
let v323 = if (&*v320 == "EntityHorse") {
Some(r.read_i32()?)
} else {
None
};
OpenWindow {
window_id: v319,
inventory_type: v320,
window_title: v321,
slot_count: v322,
entity_id: v323,
}
})
}
}
impl Encode for OpenWindow {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_u8((*self).window_id);
w.put_string(&(*self).inventory_type)?;
w.put_string(&(*self).window_title)?;
w.put_u8((*self).slot_count);
match (
&(*self).entity_id,
(&*(*self).inventory_type == "EntityHorse"),
) {
(Some(v324), true) => {
w.put_i32((*v324));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.open_window.entityId",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenWindow {
fn generate(g: &mut Gen) -> Self {
{
let v325 = (g.int_in(0, 255, &[]) as u8);
let v326 = g.string_in(&["EntityHorse"]);
let v327 = g.string();
let v328 = (g.int_in(0, 255, &[]) as u8);
let v329 = if (&*v326 == "EntityHorse") {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
OpenWindow {
window_id: v325,
inventory_type: v326,
window_title: v327,
slot_count: v328,
entity_id: v329,
}
}
}
}
impl From<OpenWindow> for ClientboundPlayPacket {
fn from(p: OpenWindow) -> Self {
Self::OpenWindow(p)
}
}
/// `window_items` (clientbound play, id 0x14).
#[derive(Debug, Clone, PartialEq)]
pub struct WindowItems {
/// `windowId`
pub window_id: u8,
/// `items`
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 v330 = r.read_u8()?;
let v331 = {
let v332 = {
let c = r.read_i16()?;
r.check_count(i64::from(c), 1)?
};
let mut v333 = Vec::with_capacity(v332.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v332 {
v333.push(<types::Slot as Decode>::decode(r)?);
}
v333
};
WindowItems {
window_id: v330,
items: v331,
}
})
}
}
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 v334 in (*self).items.iter() {
(*v334).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WindowItems {
fn generate(g: &mut Gen) -> Self {
{
let v335 = (g.int_in(0, 255, &[]) as u8);
let v336 = {
let v337 = g.count();
let mut v338 = Vec::with_capacity(v337.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v337 {
v338.push(<types::Slot as Generate>::generate(g));
}
v338
};
WindowItems {
window_id: v335,
items: v336,
}
}
}
}
impl From<WindowItems> for ClientboundPlayPacket {
fn from(p: WindowItems) -> Self {
Self::WindowItems(p)
}
}
/// `craft_progress_bar` (clientbound play, id 0x15).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftProgressBar {
/// `windowId`
pub window_id: u8,
/// `property`
pub property: i16,
/// `value`
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 v339 = r.read_u8()?;
let v340 = r.read_i16()?;
let v341 = r.read_i16()?;
CraftProgressBar {
window_id: v339,
property: v340,
value: v341,
}
})
}
}
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 v342 = (g.int_in(0, 255, &[]) as u8);
let v343 = (g.int_in(-32768, 32767, &[]) as i16);
let v344 = (g.int_in(-32768, 32767, &[]) as i16);
CraftProgressBar {
window_id: v342,
property: v343,
value: v344,
}
}
}
}
impl From<CraftProgressBar> for ClientboundPlayPacket {
fn from(p: CraftProgressBar) -> Self {
Self::CraftProgressBar(p)
}
}
/// `set_slot` (clientbound play, id 0x16).
#[derive(Debug, Clone, PartialEq)]
pub struct SetSlot {
/// `windowId`
pub window_id: i8,
/// `slot`
pub slot: i16,
/// `item`
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 v345 = r.read_i8()?;
let v346 = r.read_i16()?;
let v347 = <types::Slot as Decode>::decode(r)?;
SetSlot {
window_id: v345,
slot: v346,
item: v347,
}
})
}
}
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 v348 = (g.int_in(-128, 127, &[]) as i8);
let v349 = (g.int_in(-32768, 32767, &[]) as i16);
let v350 = <types::Slot as Generate>::generate(g);
SetSlot {
window_id: v348,
slot: v349,
item: v350,
}
}
}
}
impl From<SetSlot> for ClientboundPlayPacket {
fn from(p: SetSlot) -> Self {
Self::SetSlot(p)
}
}
/// `set_cooldown` (clientbound play, id 0x17).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCooldown {
/// `itemID`
pub item_id: i32,
/// `cooldownTicks`
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 v351 = r.read_varint()?;
let v352 = r.read_varint()?;
SetCooldown {
item_id: v351,
cooldown_ticks: v352,
}
})
}
}
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 v353 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v354 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
SetCooldown {
item_id: v353,
cooldown_ticks: v354,
}
}
}
}
impl From<SetCooldown> for ClientboundPlayPacket {
fn from(p: SetCooldown) -> Self {
Self::SetCooldown(p)
}
}
/// `custom_payload` (clientbound play, id 0x18).
#[derive(Debug, Clone, PartialEq)]
pub struct CustomPayload {
/// `channel`
pub channel: ByteString,
/// `data`
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 v355 = r.read_string()?;
let v356 = r.read_rest();
CustomPayload {
channel: v355,
data: v356,
}
})
}
}
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 v357 = g.string();
let v358 = g.bytes();
CustomPayload {
channel: v357,
data: v358,
}
}
}
}
impl From<CustomPayload> for ClientboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
/// `named_sound_effect` (clientbound play, id 0x19).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedSoundEffect {
/// `soundName`
pub sound_name: ByteString,
/// `soundCategory`
pub sound_category: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
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 v359 = r.read_string()?;
let v360 = r.read_varint()?;
let v361 = r.read_i32()?;
let v362 = r.read_i32()?;
let v363 = r.read_i32()?;
let v364 = r.read_f32()?;
let v365 = r.read_f32()?;
NamedSoundEffect {
sound_name: v359,
sound_category: v360,
x: v361,
y: v362,
z: v363,
volume: v364,
pitch: v365,
}
})
}
}
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 v366 = g.string();
let v367 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v368 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v369 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v370 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v371 = g.f32();
let v372 = g.f32();
NamedSoundEffect {
sound_name: v366,
sound_category: v367,
x: v368,
y: v369,
z: v370,
volume: v371,
pitch: v372,
}
}
}
}
impl From<NamedSoundEffect> for ClientboundPlayPacket {
fn from(p: NamedSoundEffect) -> Self {
Self::NamedSoundEffect(p)
}
}
/// `kick_disconnect` (clientbound play, id 0x1a).
#[derive(Debug, Clone, PartialEq)]
pub struct KickDisconnect {
/// `reason`
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 v373 = r.read_string()?;
KickDisconnect { reason: v373 }
})
}
}
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 v374 = g.string();
KickDisconnect { reason: v374 }
}
}
}
impl From<KickDisconnect> for ClientboundPlayPacket {
fn from(p: KickDisconnect) -> Self {
Self::KickDisconnect(p)
}
}
/// `entity_status` (clientbound play, id 0x1b).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityStatus {
/// `entityId`
pub entity_id: i32,
/// `entityStatus`
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 v375 = r.read_i32()?;
let v376 = r.read_i8()?;
EntityStatus {
entity_id: v375,
entity_status: v376,
}
})
}
}
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 v377 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v378 = (g.int_in(-128, 127, &[]) as i8);
EntityStatus {
entity_id: v377,
entity_status: v378,
}
}
}
}
impl From<EntityStatus> for ClientboundPlayPacket {
fn from(p: EntityStatus) -> Self {
Self::EntityStatus(p)
}
}
/// `explosion` (clientbound play, id 0x1c).
#[derive(Debug, Clone, PartialEq)]
pub struct Explosion {
/// `x`
pub x: f32,
/// `y`
pub y: f32,
/// `z`
pub z: f32,
/// `radius`
pub radius: f32,
/// `affectedBlockOffsets`
pub affected_block_offsets: Vec<ExplosionAffectedBlockOffsets>,
/// `playerMotionX`
pub player_motion_x: f32,
/// `playerMotionY`
pub player_motion_y: f32,
/// `playerMotionZ`
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 v379 = r.read_f32()?;
let v380 = r.read_f32()?;
let v381 = r.read_f32()?;
let v382 = r.read_f32()?;
let v383 = {
let v384 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 3)?
};
let mut v385 = Vec::with_capacity(v384.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v384 {
v385.push({
let v386 = r.read_i8()?;
let v387 = r.read_i8()?;
let v388 = r.read_i8()?;
ExplosionAffectedBlockOffsets {
x: v386,
y: v387,
z: v388,
}
});
}
v385
};
let v389 = r.read_f32()?;
let v390 = r.read_f32()?;
let v391 = r.read_f32()?;
Explosion {
x: v379,
y: v380,
z: v381,
radius: v382,
affected_block_offsets: v383,
player_motion_x: v389,
player_motion_y: v390,
player_motion_z: v391,
}
})
}
}
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 v392 in (*self).affected_block_offsets.iter() {
w.put_i8((*v392).x);
w.put_i8((*v392).y);
w.put_i8((*v392).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 v393 = g.f32();
let v394 = g.f32();
let v395 = g.f32();
let v396 = g.f32();
let v397 = {
let v398 = g.count();
let mut v399 = Vec::with_capacity(v398.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v398 {
v399.push({
let v400 = (g.int_in(-128, 127, &[]) as i8);
let v401 = (g.int_in(-128, 127, &[]) as i8);
let v402 = (g.int_in(-128, 127, &[]) as i8);
ExplosionAffectedBlockOffsets {
x: v400,
y: v401,
z: v402,
}
});
}
v399
};
let v403 = g.f32();
let v404 = g.f32();
let v405 = g.f32();
Explosion {
x: v393,
y: v394,
z: v395,
radius: v396,
affected_block_offsets: v397,
player_motion_x: v403,
player_motion_y: v404,
player_motion_z: v405,
}
}
}
}
impl From<Explosion> for ClientboundPlayPacket {
fn from(p: Explosion) -> Self {
Self::Explosion(p)
}
}
/// `unload_chunk` (clientbound play, id 0x1d).
#[derive(Debug, Clone, PartialEq)]
pub struct UnloadChunk {
/// `chunkX`
pub chunk_x: i32,
/// `chunkZ`
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 v406 = r.read_i32()?;
let v407 = r.read_i32()?;
UnloadChunk {
chunk_x: v406,
chunk_z: v407,
}
})
}
}
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 v408 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v409 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
UnloadChunk {
chunk_x: v408,
chunk_z: v409,
}
}
}
}
impl From<UnloadChunk> for ClientboundPlayPacket {
fn from(p: UnloadChunk) -> Self {
Self::UnloadChunk(p)
}
}
/// `game_state_change` (clientbound play, id 0x1e).
#[derive(Debug, Clone, PartialEq)]
pub struct GameStateChange {
/// `reason`
pub reason: GameStateChangeReason,
/// `gameMode`
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 v410 = GameStateChangeReason(r.read_u8()?);
let v411 = r.read_f32()?;
GameStateChange {
reason: v410,
game_mode: v411,
}
})
}
}
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 v412 =
GameStateChangeReason(g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) as u8);
let v413 = g.f32();
GameStateChange {
reason: v412,
game_mode: v413,
}
}
}
}
impl From<GameStateChange> for ClientboundPlayPacket {
fn from(p: GameStateChange) -> Self {
Self::GameStateChange(p)
}
}
/// `keep_alive` (clientbound play, id 0x1f).
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive {
/// `keepAliveId`
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 v414 = r.read_i64()?;
KeepAlive {
keep_alive_id: v414,
}
})
}
}
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 v415 = g.i64();
KeepAlive {
keep_alive_id: v415,
}
}
}
}
impl From<KeepAlive> for ClientboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
/// `map_chunk` (clientbound play, id 0x20).
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunk {
/// `x`
pub x: i32,
/// `z`
pub z: i32,
/// `groundUp`
pub ground_up: bool,
/// `bitMap`
pub bit_map: i32,
/// `chunkData`
pub chunk_data: Bytes,
/// `blockEntities`
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 v416 = r.read_i32()?;
let v417 = r.read_i32()?;
let v418 = r.read_bool()?;
let v419 = r.read_varint()?;
let v420 = r.read_byte_array()?;
let v421 = {
let v422 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v423 = Vec::with_capacity(v422.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v422 {
v423.push(RawNbt::read(r)?);
}
v423
};
MapChunk {
x: v416,
z: v417,
ground_up: v418,
bit_map: v419,
chunk_data: v420,
block_entities: v421,
}
})
}
}
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);
w.put_byte_array(&(*self).chunk_data)?;
w.put_len_varint((*self).block_entities.len())?;
for v424 in (*self).block_entities.iter() {
(*v424).write(w);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MapChunk {
fn generate(g: &mut Gen) -> Self {
{
let v425 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v426 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v427 = g.bool();
let v428 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v429 = g.bytes();
let v430 = {
let v431 = g.count();
let mut v432 = Vec::with_capacity(v431.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v431 {
v432.push(g.nbt());
}
v432
};
MapChunk {
x: v425,
z: v426,
ground_up: v427,
bit_map: v428,
chunk_data: v429,
block_entities: v430,
}
}
}
}
impl From<MapChunk> for ClientboundPlayPacket {
fn from(p: MapChunk) -> Self {
Self::MapChunk(p)
}
}
/// `world_event` (clientbound play, id 0x21).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldEvent {
/// `effectId`
pub effect_id: i32,
/// `location`
pub location: BlockPos,
/// `data`
pub data: i32,
/// `global`
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 v433 = r.read_i32()?;
let v434 = BlockPos::read(r, PositionLayout::Xyz)?;
let v435 = r.read_i32()?;
let v436 = r.read_bool()?;
WorldEvent {
effect_id: v433,
location: v434,
data: v435,
global: v436,
}
})
}
}
impl Encode for WorldEvent {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).effect_id);
(*self).location.write(w, PositionLayout::Xyz)?;
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 v437 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v438 = g.position();
let v439 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v440 = g.bool();
WorldEvent {
effect_id: v437,
location: v438,
data: v439,
global: v440,
}
}
}
}
impl From<WorldEvent> for ClientboundPlayPacket {
fn from(p: WorldEvent) -> Self {
Self::WorldEvent(p)
}
}
/// `world_particles` (clientbound play, id 0x22).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldParticles {
/// `particleId`
pub particle_id: i32,
/// `longDistance`
pub long_distance: bool,
/// `x`
pub x: f32,
/// `y`
pub y: f32,
/// `z`
pub z: f32,
/// `offsetX`
pub offset_x: f32,
/// `offsetY`
pub offset_y: f32,
/// `offsetZ`
pub offset_z: f32,
/// `particleData`
pub particle_data: f32,
/// `particles`
pub particles: i32,
/// `data`
pub data: WorldParticlesData,
}
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 v441 = r.read_i32()?;
let v442 = r.read_bool()?;
let v443 = r.read_f32()?;
let v444 = r.read_f32()?;
let v445 = r.read_f32()?;
let v446 = r.read_f32()?;
let v447 = r.read_f32()?;
let v448 = r.read_f32()?;
let v449 = r.read_f32()?;
let v450 = r.read_i32()?;
let v451 = (if (v441 == 36) {
WorldParticlesData::Case36({
let v452 = 2;
let mut v453 = Vec::with_capacity(v452.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v452 {
v453.push(r.read_varint()?);
}
v453
})
} else if (v441 == 37) {
WorldParticlesData::Case37({
let v454 = 1;
let mut v455 = Vec::with_capacity(v454.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v454 {
v455.push(r.read_varint()?);
}
v455
})
} else if (v441 == 38) {
WorldParticlesData::Case38({
let v456 = 1;
let mut v457 = Vec::with_capacity(v456.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v456 {
v457.push(r.read_varint()?);
}
v457
})
} else {
WorldParticlesData::Other
});
WorldParticles {
particle_id: v441,
long_distance: v442,
x: v443,
y: v444,
z: v445,
offset_x: v446,
offset_y: v447,
offset_z: v448,
particle_data: v449,
particles: v450,
data: v451,
}
})
}
}
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_f32((*self).x);
w.put_f32((*self).y);
w.put_f32((*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 {
WorldParticlesData::Case36(v458) => {
if !((*self).particle_id == 36) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v458).len() != 2 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 2,
actual: (*v458).len(),
});
}
for v459 in (*v458).iter() {
w.put_varint((*v459));
}
}
WorldParticlesData::Case37(v460) => {
if !((*self).particle_id == 37) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v460).len() != 1 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 1,
actual: (*v460).len(),
});
}
for v461 in (*v460).iter() {
w.put_varint((*v461));
}
}
WorldParticlesData::Case38(v462) => {
if !((*self).particle_id == 38) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v462).len() != 1 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 1,
actual: (*v462).len(),
});
}
for v463 in (*v462).iter() {
w.put_varint((*v463));
}
}
WorldParticlesData::Other => {
if !(!(((*self).particle_id == 36)
|| ((*self).particle_id == 37)
|| ((*self).particle_id == 38)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WorldParticles {
fn generate(g: &mut Gen) -> Self {
{
let v464 = (g.int_in(-2147483648, 2147483647, &[36, 37, 38]) as i32);
let v465 = g.bool();
let v466 = g.f32();
let v467 = g.f32();
let v468 = g.f32();
let v469 = g.f32();
let v470 = g.f32();
let v471 = g.f32();
let v472 = g.f32();
let v473 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v474 = (if (v464 == 36) {
WorldParticlesData::Case36({
let v475 = 2;
let mut v476 = Vec::with_capacity(v475.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v475 {
v476.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v476
})
} else if (v464 == 37) {
WorldParticlesData::Case37({
let v477 = 1;
let mut v478 = Vec::with_capacity(v477.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v477 {
v478.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v478
})
} else if (v464 == 38) {
WorldParticlesData::Case38({
let v479 = 1;
let mut v480 = Vec::with_capacity(v479.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v479 {
v480.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v480
})
} else {
WorldParticlesData::Other
});
WorldParticles {
particle_id: v464,
long_distance: v465,
x: v466,
y: v467,
z: v468,
offset_x: v469,
offset_y: v470,
offset_z: v471,
particle_data: v472,
particles: v473,
data: v474,
}
}
}
}
impl From<WorldParticles> for ClientboundPlayPacket {
fn from(p: WorldParticles) -> Self {
Self::WorldParticles(p)
}
}
/// `login` (clientbound play, id 0x23).
#[derive(Debug, Clone, PartialEq)]
pub struct Login {
/// `entityId`
pub entity_id: i32,
/// `gameMode`
pub game_mode: u8,
/// `dimension`
pub dimension: i32,
/// `difficulty`
pub difficulty: u8,
/// `maxPlayers`
pub max_players: u8,
/// `levelType`
pub level_type: ByteString,
/// `reducedDebugInfo`
pub reduced_debug_info: 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 v481 = r.read_i32()?;
let v482 = r.read_u8()?;
let v483 = r.read_i32()?;
let v484 = r.read_u8()?;
let v485 = r.read_u8()?;
let v486 = r.read_string()?;
let v487 = r.read_bool()?;
Login {
entity_id: v481,
game_mode: v482,
dimension: v483,
difficulty: v484,
max_players: v485,
level_type: v486,
reduced_debug_info: v487,
}
})
}
}
impl Encode for Login {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_u8((*self).game_mode);
w.put_i32((*self).dimension);
w.put_u8((*self).difficulty);
w.put_u8((*self).max_players);
w.put_string(&(*self).level_type)?;
w.put_bool((*self).reduced_debug_info);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Login {
fn generate(g: &mut Gen) -> Self {
{
let v488 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v489 = (g.int_in(0, 255, &[]) as u8);
let v490 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v491 = (g.int_in(0, 255, &[]) as u8);
let v492 = (g.int_in(0, 255, &[]) as u8);
let v493 = g.string();
let v494 = g.bool();
Login {
entity_id: v488,
game_mode: v489,
dimension: v490,
difficulty: v491,
max_players: v492,
level_type: v493,
reduced_debug_info: v494,
}
}
}
}
impl From<Login> for ClientboundPlayPacket {
fn from(p: Login) -> Self {
Self::Login(p)
}
}
/// `map` (clientbound play, id 0x24).
#[derive(Debug, Clone, PartialEq)]
pub struct Map {
/// `itemDamage`
pub item_damage: i32,
/// `scale`
pub scale: i8,
/// `trackingPosition`
pub tracking_position: bool,
/// `icons`
pub icons: Vec<MapIcons>,
/// `columns`
pub columns: i8,
/// `rows`
pub rows: Option<i8>,
/// `x`
pub x: Option<i8>,
/// `y`
pub y: Option<i8>,
/// `data`
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 v495 = r.read_varint()?;
let v496 = r.read_i8()?;
let v497 = r.read_bool()?;
let v498 = {
let v499 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v500 = Vec::with_capacity(v499.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v499 {
v500.push({
let v501 = r.read_i8()?;
let v502 = r.read_i8()?;
let v503 = r.read_i8()?;
MapIcons {
direction_and_type: v501,
x: v502,
z: v503,
}
});
}
v500
};
let v504 = r.read_i8()?;
let v505 = if !(v504 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v506 = if !(v504 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v507 = if !(v504 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v508 = if !(v504 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Map {
item_damage: v495,
scale: v496,
tracking_position: v497,
icons: v498,
columns: v504,
rows: v505,
x: v506,
y: v507,
data: v508,
}
})
}
}
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_len_varint((*self).icons.len())?;
for v509 in (*self).icons.iter() {
w.put_i8((*v509).direction_and_type);
w.put_i8((*v509).x);
w.put_i8((*v509).z);
}
w.put_i8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v510), true) => {
w.put_i8((*v510));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v511), true) => {
w.put_i8((*v511));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v512), true) => {
w.put_i8((*v512));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v513), true) => {
w.put_byte_array(&(*v513))?;
}
(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 v514 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v515 = (g.int_in(-128, 127, &[]) as i8);
let v516 = g.bool();
let v517 = {
let v518 = g.count();
let mut v519 = Vec::with_capacity(v518.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v518 {
v519.push({
let v520 = (g.int_in(-128, 127, &[]) as i8);
let v521 = (g.int_in(-128, 127, &[]) as i8);
let v522 = (g.int_in(-128, 127, &[]) as i8);
MapIcons {
direction_and_type: v520,
x: v521,
z: v522,
}
});
}
v519
};
let v523 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
let v524 = if !(v523 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v525 = if !(v523 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v526 = if !(v523 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v527 = if !(v523 == 0) { Some(g.bytes()) } else { None };
Map {
item_damage: v514,
scale: v515,
tracking_position: v516,
icons: v517,
columns: v523,
rows: v524,
x: v525,
y: v526,
data: v527,
}
}
}
}
impl From<Map> for ClientboundPlayPacket {
fn from(p: Map) -> Self {
Self::Map(p)
}
}
/// `entity` (clientbound play, id 0x25).
#[derive(Debug, Clone, PartialEq)]
pub struct Entity {
/// `entityId`
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 v528 = r.read_varint()?;
Entity { entity_id: v528 }
})
}
}
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 v529 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Entity { entity_id: v529 }
}
}
}
impl From<Entity> for ClientboundPlayPacket {
fn from(p: Entity) -> Self {
Self::Entity(p)
}
}
/// `rel_entity_move` (clientbound play, id 0x26).
#[derive(Debug, Clone, PartialEq)]
pub struct RelEntityMove {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i16,
/// `dY`
pub d_y: i16,
/// `dZ`
pub d_z: i16,
/// `onGround`
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 v530 = r.read_varint()?;
let v531 = r.read_i16()?;
let v532 = r.read_i16()?;
let v533 = r.read_i16()?;
let v534 = r.read_bool()?;
RelEntityMove {
entity_id: v530,
d_x: v531,
d_y: v532,
d_z: v533,
on_ground: v534,
}
})
}
}
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 v535 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v536 = (g.int_in(-32768, 32767, &[]) as i16);
let v537 = (g.int_in(-32768, 32767, &[]) as i16);
let v538 = (g.int_in(-32768, 32767, &[]) as i16);
let v539 = g.bool();
RelEntityMove {
entity_id: v535,
d_x: v536,
d_y: v537,
d_z: v538,
on_ground: v539,
}
}
}
}
impl From<RelEntityMove> for ClientboundPlayPacket {
fn from(p: RelEntityMove) -> Self {
Self::RelEntityMove(p)
}
}
/// `entity_move_look` (clientbound play, id 0x27).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMoveLook {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i16,
/// `dY`
pub d_y: i16,
/// `dZ`
pub d_z: i16,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `onGround`
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 v540 = r.read_varint()?;
let v541 = r.read_i16()?;
let v542 = r.read_i16()?;
let v543 = r.read_i16()?;
let v544 = r.read_i8()?;
let v545 = r.read_i8()?;
let v546 = r.read_bool()?;
EntityMoveLook {
entity_id: v540,
d_x: v541,
d_y: v542,
d_z: v543,
yaw: v544,
pitch: v545,
on_ground: v546,
}
})
}
}
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 v547 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v548 = (g.int_in(-32768, 32767, &[]) as i16);
let v549 = (g.int_in(-32768, 32767, &[]) as i16);
let v550 = (g.int_in(-32768, 32767, &[]) as i16);
let v551 = (g.int_in(-128, 127, &[]) as i8);
let v552 = (g.int_in(-128, 127, &[]) as i8);
let v553 = g.bool();
EntityMoveLook {
entity_id: v547,
d_x: v548,
d_y: v549,
d_z: v550,
yaw: v551,
pitch: v552,
on_ground: v553,
}
}
}
}
impl From<EntityMoveLook> for ClientboundPlayPacket {
fn from(p: EntityMoveLook) -> Self {
Self::EntityMoveLook(p)
}
}
/// `entity_look` (clientbound play, id 0x28).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityLook {
/// `entityId`
pub entity_id: i32,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `onGround`
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 v554 = r.read_varint()?;
let v555 = r.read_i8()?;
let v556 = r.read_i8()?;
let v557 = r.read_bool()?;
EntityLook {
entity_id: v554,
yaw: v555,
pitch: v556,
on_ground: v557,
}
})
}
}
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 v558 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v559 = (g.int_in(-128, 127, &[]) as i8);
let v560 = (g.int_in(-128, 127, &[]) as i8);
let v561 = g.bool();
EntityLook {
entity_id: v558,
yaw: v559,
pitch: v560,
on_ground: v561,
}
}
}
}
impl From<EntityLook> for ClientboundPlayPacket {
fn from(p: EntityLook) -> Self {
Self::EntityLook(p)
}
}
/// `vehicle_move` (clientbound play, id 0x29).
#[derive(Debug, Clone, PartialEq)]
pub struct VehicleMove {
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
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 v562 = r.read_f64()?;
let v563 = r.read_f64()?;
let v564 = r.read_f64()?;
let v565 = r.read_f32()?;
let v566 = r.read_f32()?;
VehicleMove {
x: v562,
y: v563,
z: v564,
yaw: v565,
pitch: v566,
}
})
}
}
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 v567 = g.f64();
let v568 = g.f64();
let v569 = g.f64();
let v570 = g.f32();
let v571 = g.f32();
VehicleMove {
x: v567,
y: v568,
z: v569,
yaw: v570,
pitch: v571,
}
}
}
}
impl From<VehicleMove> for ClientboundPlayPacket {
fn from(p: VehicleMove) -> Self {
Self::VehicleMove(p)
}
}
/// `open_sign_entity` (clientbound play, id 0x2a).
#[derive(Debug, Clone, PartialEq)]
pub struct OpenSignEntity {
/// `location`
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 v572 = BlockPos::read(r, PositionLayout::Xyz)?;
OpenSignEntity { location: v572 }
})
}
}
impl Encode for OpenSignEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for OpenSignEntity {
fn generate(g: &mut Gen) -> Self {
{
let v573 = g.position();
OpenSignEntity { location: v573 }
}
}
}
impl From<OpenSignEntity> for ClientboundPlayPacket {
fn from(p: OpenSignEntity) -> Self {
Self::OpenSignEntity(p)
}
}
/// `craft_recipe_response` (clientbound play, id 0x2b).
#[derive(Debug, Clone, PartialEq)]
pub struct CraftRecipeResponse {
/// `windowId`
pub window_id: i8,
/// `recipe`
pub recipe: i32,
}
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 v574 = r.read_i8()?;
let v575 = r.read_varint()?;
CraftRecipeResponse {
window_id: v574,
recipe: v575,
}
})
}
}
impl Encode for CraftRecipeResponse {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i8((*self).window_id);
w.put_varint((*self).recipe);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for CraftRecipeResponse {
fn generate(g: &mut Gen) -> Self {
{
let v576 = (g.int_in(-128, 127, &[]) as i8);
let v577 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
CraftRecipeResponse {
window_id: v576,
recipe: v577,
}
}
}
}
impl From<CraftRecipeResponse> for ClientboundPlayPacket {
fn from(p: CraftRecipeResponse) -> Self {
Self::CraftRecipeResponse(p)
}
}
/// `abilities` (clientbound play, id 0x2c).
#[derive(Debug, Clone, PartialEq)]
pub struct Abilities {
/// `flags`
pub flags: i8,
/// `flyingSpeed`
pub flying_speed: f32,
/// `walkingSpeed`
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 v578 = r.read_i8()?;
let v579 = r.read_f32()?;
let v580 = r.read_f32()?;
Abilities {
flags: v578,
flying_speed: v579,
walking_speed: v580,
}
})
}
}
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 v581 = (g.int_in(-128, 127, &[]) as i8);
let v582 = g.f32();
let v583 = g.f32();
Abilities {
flags: v581,
flying_speed: v582,
walking_speed: v583,
}
}
}
}
impl From<Abilities> for ClientboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(p)
}
}
/// `combat_event` (clientbound play, id 0x2d).
#[derive(Debug, Clone, PartialEq)]
pub struct CombatEvent {
/// `event`
pub event: i32,
/// `duration`
pub duration: Option<i32>,
/// `playerId`
pub player_id: Option<i32>,
/// `entityId`
pub entity_id: Option<i32>,
/// `message`
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 v584 = r.read_varint()?;
let v585 = if (v584 == 1) {
Some(r.read_varint()?)
} else {
None
};
let v586 = if (v584 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v587 = if (v584 == 1) || (v584 == 2) {
Some(r.read_i32()?)
} else {
None
};
let v588 = if (v584 == 2) {
Some(r.read_string()?)
} else {
None
};
CombatEvent {
event: v584,
duration: v585,
player_id: v586,
entity_id: v587,
message: v588,
}
})
}
}
impl Encode for CombatEvent {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).event);
match (&(*self).duration, ((*self).event == 1)) {
(Some(v589), true) => {
w.put_varint((*v589));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.duration",
));
}
}
match (&(*self).player_id, ((*self).event == 2)) {
(Some(v590), true) => {
w.put_varint((*v590));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.playerId",
));
}
}
match (
&(*self).entity_id,
((*self).event == 1) || ((*self).event == 2),
) {
(Some(v591), true) => {
w.put_i32((*v591));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.entityId",
));
}
}
match (&(*self).message, ((*self).event == 2)) {
(Some(v592), true) => {
w.put_string(&(*v592))?;
}
(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 v593 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
let v594 = if (v593 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v595 = if (v593 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v596 = if (v593 == 1) || (v593 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v597 = if (v593 == 2) { Some(g.string()) } else { None };
CombatEvent {
event: v593,
duration: v594,
player_id: v595,
entity_id: v596,
message: v597,
}
}
}
}
impl From<CombatEvent> for ClientboundPlayPacket {
fn from(p: CombatEvent) -> Self {
Self::CombatEvent(p)
}
}
/// `player_info` (clientbound play, id 0x2e).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInfo {
/// `action`
pub action: PlayerInfoAction,
/// `data`
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 v598 = PlayerInfoAction(r.read_varint()?);
let v599 = {
let v600 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 16)?
};
let mut v601 = Vec::with_capacity(v600.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v600 {
v601.push({
let v602 = r.read_uuid()?;
let v603 = (if (v598.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v604 = r.read_string()?;
let v605 = {
let v606 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v607 =
Vec::with_capacity(v606.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v606 {
v607.push({
let v608 = r.read_string()?;
let v609 = r.read_string()?;
let v610 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayerProperties {
name: v608,
value: v609,
signature: v610,
}
});
}
v607
};
let v611 = r.read_varint()?;
let v612 = r.read_varint()?;
let v613 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayer {
name: v604,
properties: v605,
gamemode: v611,
ping: v612,
display_name: v613,
}
})
} else if (v598.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v614 = r.read_varint()?;
PlayerInfoDataBodyUpdateGameMode { gamemode: v614 }
})
} else if (v598.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v615 = r.read_varint()?;
PlayerInfoDataBodyUpdateLatency { ping: v615 }
})
} else if (v598.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v616 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyUpdateDisplayName { display_name: v616 }
})
} else if (v598.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v602,
body: v603,
}
});
}
v601
};
PlayerInfo {
action: v598,
data: v599,
}
})
}
}
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 v617 in (*self).data.iter() {
w.put_uuid(&(*v617).uuid);
match &(*v617).body {
PlayerInfoDataBody::AddPlayer(v618) => {
if !((*self).action.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_string(&(*v618).name)?;
w.put_len_varint((*v618).properties.len())?;
for v619 in (*v618).properties.iter() {
w.put_string(&(*v619).name)?;
w.put_string(&(*v619).value)?;
match &(*v619).signature {
Some(v620) => {
w.put_u8(1);
w.put_string(&(*v620))?;
}
None => w.put_u8(0),
}
}
w.put_varint((*v618).gamemode);
w.put_varint((*v618).ping);
match &(*v618).display_name {
Some(v621) => {
w.put_u8(1);
w.put_string(&(*v621))?;
}
None => w.put_u8(0),
}
}
PlayerInfoDataBody::UpdateGameMode(v622) => {
if !((*self).action.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v622).gamemode);
}
PlayerInfoDataBody::UpdateLatency(v623) => {
if !((*self).action.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v623).ping);
}
PlayerInfoDataBody::UpdateDisplayName(v624) => {
if !((*self).action.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
match &(*v624).display_name {
Some(v625) => {
w.put_u8(1);
w.put_string(&(*v625))?;
}
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 v626 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
let v627 = {
let v628 = g.count();
let mut v629 = Vec::with_capacity(v628.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v628 {
v629.push({
let v630 = g.uuid();
let v631 = (if (v626.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v632 = g.string();
let v633 = {
let v634 = g.count();
let mut v635 =
Vec::with_capacity(v634.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v634 {
v635.push({
let v636 = g.string();
let v637 = g.string();
let v638 =
if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayerProperties {
name: v636,
value: v637,
signature: v638,
}
});
}
v635
};
let v639 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v640 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v641 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayer {
name: v632,
properties: v633,
gamemode: v639,
ping: v640,
display_name: v641,
}
})
} else if (v626.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v642 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateGameMode { gamemode: v642 }
})
} else if (v626.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v643 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateLatency { ping: v643 }
})
} else if (v626.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v644 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyUpdateDisplayName { display_name: v644 }
})
} else if (v626.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v630,
body: v631,
}
});
}
v629
};
PlayerInfo {
action: v626,
data: v627,
}
}
}
}
impl From<PlayerInfo> for ClientboundPlayPacket {
fn from(p: PlayerInfo) -> Self {
Self::PlayerInfo(p)
}
}
/// `position` (clientbound play, id 0x2f).
#[derive(Debug, Clone, PartialEq)]
pub struct Position {
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: f32,
/// `pitch`
pub pitch: f32,
/// `flags`
pub flags: i8,
/// `teleportId`
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 v645 = r.read_f64()?;
let v646 = r.read_f64()?;
let v647 = r.read_f64()?;
let v648 = r.read_f32()?;
let v649 = r.read_f32()?;
let v650 = r.read_i8()?;
let v651 = r.read_varint()?;
Position {
x: v645,
y: v646,
z: v647,
yaw: v648,
pitch: v649,
flags: v650,
teleport_id: v651,
}
})
}
}
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 v652 = g.f64();
let v653 = g.f64();
let v654 = g.f64();
let v655 = g.f32();
let v656 = g.f32();
let v657 = (g.int_in(-128, 127, &[]) as i8);
let v658 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Position {
x: v652,
y: v653,
z: v654,
yaw: v655,
pitch: v656,
flags: v657,
teleport_id: v658,
}
}
}
}
impl From<Position> for ClientboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(p)
}
}
/// `bed` (clientbound play, id 0x30).
#[derive(Debug, Clone, PartialEq)]
pub struct Bed {
/// `entityId`
pub entity_id: i32,
/// `location`
pub location: BlockPos,
}
impl crate::packet::Packet for Bed {
const ID: i32 = id::BED;
const NAME: &'static str = "bed";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for Bed {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v659 = r.read_varint()?;
let v660 = BlockPos::read(r, PositionLayout::Xyz)?;
Bed {
entity_id: v659,
location: v660,
}
})
}
}
impl Encode for Bed {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).location.write(w, PositionLayout::Xyz)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Bed {
fn generate(g: &mut Gen) -> Self {
{
let v661 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v662 = g.position();
Bed {
entity_id: v661,
location: v662,
}
}
}
}
impl From<Bed> for ClientboundPlayPacket {
fn from(p: Bed) -> Self {
Self::Bed(p)
}
}
/// `unlock_recipes` (clientbound play, id 0x31).
#[derive(Debug, Clone, PartialEq)]
pub struct UnlockRecipes {
/// `action`
pub action: i32,
/// `craftingBookOpen`
pub crafting_book_open: bool,
/// `filteringCraftable`
pub filtering_craftable: bool,
/// `recipes1`
pub recipes1: Vec<i32>,
/// `recipes2`
pub recipes2: Option<Vec<i32>>,
}
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 v663 = r.read_varint()?;
let v664 = r.read_bool()?;
let v665 = r.read_bool()?;
let v666 = {
let v667 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v668 = Vec::with_capacity(v667.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v667 {
v668.push(r.read_varint()?);
}
v668
};
let v669 = if (v663 == 0) {
Some({
let v670 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v671 = Vec::with_capacity(v670.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v670 {
v671.push(r.read_varint()?);
}
v671
})
} else {
None
};
UnlockRecipes {
action: v663,
crafting_book_open: v664,
filtering_craftable: v665,
recipes1: v666,
recipes2: v669,
}
})
}
}
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_len_varint((*self).recipes1.len())?;
for v672 in (*self).recipes1.iter() {
w.put_varint((*v672));
}
match (&(*self).recipes2, ((*self).action == 0)) {
(Some(v673), true) => {
w.put_len_varint((*v673).len())?;
for v674 in (*v673).iter() {
w.put_varint((*v674));
}
}
(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 v675 = (g.int_in(-2147483648, 2147483647, &[0]) as i32);
let v676 = g.bool();
let v677 = g.bool();
let v678 = {
let v679 = g.count();
let mut v680 = Vec::with_capacity(v679.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v679 {
v680.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v680
};
let v681 = if (v675 == 0) {
Some({
let v682 = g.count();
let mut v683 = Vec::with_capacity(v682.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v682 {
v683.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v683
})
} else {
None
};
UnlockRecipes {
action: v675,
crafting_book_open: v676,
filtering_craftable: v677,
recipes1: v678,
recipes2: v681,
}
}
}
}
impl From<UnlockRecipes> for ClientboundPlayPacket {
fn from(p: UnlockRecipes) -> Self {
Self::UnlockRecipes(p)
}
}
/// `entity_destroy` (clientbound play, id 0x32).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityDestroy {
/// `entityIds`
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 v684 = {
let v685 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v686 = Vec::with_capacity(v685.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v685 {
v686.push(r.read_varint()?);
}
v686
};
EntityDestroy { entity_ids: v684 }
})
}
}
impl Encode for EntityDestroy {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entity_ids.len())?;
for v687 in (*self).entity_ids.iter() {
w.put_varint((*v687));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityDestroy {
fn generate(g: &mut Gen) -> Self {
{
let v688 = {
let v689 = g.count();
let mut v690 = Vec::with_capacity(v689.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v689 {
v690.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v690
};
EntityDestroy { entity_ids: v688 }
}
}
}
impl From<EntityDestroy> for ClientboundPlayPacket {
fn from(p: EntityDestroy) -> Self {
Self::EntityDestroy(p)
}
}
/// `remove_entity_effect` (clientbound play, id 0x33).
#[derive(Debug, Clone, PartialEq)]
pub struct RemoveEntityEffect {
/// `entityId`
pub entity_id: i32,
/// `effectId`
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 v691 = r.read_varint()?;
let v692 = r.read_i8()?;
RemoveEntityEffect {
entity_id: v691,
effect_id: v692,
}
})
}
}
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 v693 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v694 = (g.int_in(-128, 127, &[]) as i8);
RemoveEntityEffect {
entity_id: v693,
effect_id: v694,
}
}
}
}
impl From<RemoveEntityEffect> for ClientboundPlayPacket {
fn from(p: RemoveEntityEffect) -> Self {
Self::RemoveEntityEffect(p)
}
}
/// `resource_pack_send` (clientbound play, id 0x34).
#[derive(Debug, Clone, PartialEq)]
pub struct ResourcePackSend {
/// `url`
pub url: ByteString,
/// `hash`
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 v695 = r.read_string()?;
let v696 = r.read_string()?;
ResourcePackSend {
url: v695,
hash: v696,
}
})
}
}
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 v697 = g.string();
let v698 = g.string();
ResourcePackSend {
url: v697,
hash: v698,
}
}
}
}
impl From<ResourcePackSend> for ClientboundPlayPacket {
fn from(p: ResourcePackSend) -> Self {
Self::ResourcePackSend(p)
}
}
/// `respawn` (clientbound play, id 0x35).
#[derive(Debug, Clone, PartialEq)]
pub struct Respawn {
/// `dimension`
pub dimension: i32,
/// `difficulty`
pub difficulty: u8,
/// `gamemode`
pub gamemode: u8,
/// `levelType`
pub level_type: ByteString,
}
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 v699 = r.read_i32()?;
let v700 = r.read_u8()?;
let v701 = r.read_u8()?;
let v702 = r.read_string()?;
Respawn {
dimension: v699,
difficulty: v700,
gamemode: v701,
level_type: v702,
}
})
}
}
impl Encode for Respawn {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).dimension);
w.put_u8((*self).difficulty);
w.put_u8((*self).gamemode);
w.put_string(&(*self).level_type)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Respawn {
fn generate(g: &mut Gen) -> Self {
{
let v703 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v704 = (g.int_in(0, 255, &[]) as u8);
let v705 = (g.int_in(0, 255, &[]) as u8);
let v706 = g.string();
Respawn {
dimension: v703,
difficulty: v704,
gamemode: v705,
level_type: v706,
}
}
}
}
impl From<Respawn> for ClientboundPlayPacket {
fn from(p: Respawn) -> Self {
Self::Respawn(p)
}
}
/// `entity_head_rotation` (clientbound play, id 0x36).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityHeadRotation {
/// `entityId`
pub entity_id: i32,
/// `headYaw`
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 v707 = r.read_varint()?;
let v708 = r.read_i8()?;
EntityHeadRotation {
entity_id: v707,
head_yaw: v708,
}
})
}
}
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 v709 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v710 = (g.int_in(-128, 127, &[]) as i8);
EntityHeadRotation {
entity_id: v709,
head_yaw: v710,
}
}
}
}
impl From<EntityHeadRotation> for ClientboundPlayPacket {
fn from(p: EntityHeadRotation) -> Self {
Self::EntityHeadRotation(p)
}
}
/// `select_advancement_tab` (clientbound play, id 0x37).
#[derive(Debug, Clone, PartialEq)]
pub struct SelectAdvancementTab {
/// `id`
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 v711 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
SelectAdvancementTab { id: v711 }
})
}
}
impl Encode for SelectAdvancementTab {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
match &(*self).id {
Some(v712) => {
w.put_u8(1);
w.put_string(&(*v712))?;
}
None => w.put_u8(0),
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SelectAdvancementTab {
fn generate(g: &mut Gen) -> Self {
{
let v713 = if g.bool() { Some(g.string()) } else { None };
SelectAdvancementTab { id: v713 }
}
}
}
impl From<SelectAdvancementTab> for ClientboundPlayPacket {
fn from(p: SelectAdvancementTab) -> Self {
Self::SelectAdvancementTab(p)
}
}
/// `world_border` (clientbound play, id 0x38).
#[derive(Debug, Clone, PartialEq)]
pub struct WorldBorder {
/// `action`
pub action: i32,
/// `radius`
pub radius: Option<f64>,
/// `x`
pub x: Option<f64>,
/// `z`
pub z: Option<f64>,
/// `old_radius`
pub old_radius: Option<f64>,
/// `new_radius`
pub new_radius: Option<f64>,
/// `speed`
pub speed: Option<i64>,
/// `portalBoundary`
pub portal_boundary: Option<i32>,
/// `warning_time`
pub warning_time: Option<i32>,
/// `warning_blocks`
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 v714 = r.read_varint()?;
let v715 = if (v714 == 0) {
Some(r.read_f64()?)
} else {
None
};
let v716 = if (v714 == 2) || (v714 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v717 = if (v714 == 2) || (v714 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v718 = if (v714 == 1) || (v714 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v719 = if (v714 == 1) || (v714 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v720 = if (v714 == 1) || (v714 == 3) {
Some(r.read_varlong()?)
} else {
None
};
let v721 = if (v714 == 3) {
Some(r.read_varint()?)
} else {
None
};
let v722 = if (v714 == 3) || (v714 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v723 = if (v714 == 3) || (v714 == 5) {
Some(r.read_varint()?)
} else {
None
};
WorldBorder {
action: v714,
radius: v715,
x: v716,
z: v717,
old_radius: v718,
new_radius: v719,
speed: v720,
portal_boundary: v721,
warning_time: v722,
warning_blocks: v723,
}
})
}
}
impl Encode for WorldBorder {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (&(*self).radius, ((*self).action == 0)) {
(Some(v724), true) => {
w.put_f64((*v724));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.radius",
));
}
}
match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v725), true) => {
w.put_f64((*v725));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.x",
));
}
}
match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v726), true) => {
w.put_f64((*v726));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.z",
));
}
}
match (
&(*self).old_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v727), true) => {
w.put_f64((*v727));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.old_radius",
));
}
}
match (
&(*self).new_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v728), true) => {
w.put_f64((*v728));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.new_radius",
));
}
}
match (
&(*self).speed,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v729), true) => {
w.put_varlong((*v729));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.speed",
));
}
}
match (&(*self).portal_boundary, ((*self).action == 3)) {
(Some(v730), true) => {
w.put_varint((*v730));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.portalBoundary",
));
}
}
match (
&(*self).warning_time,
((*self).action == 3) || ((*self).action == 4),
) {
(Some(v731), true) => {
w.put_varint((*v731));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.warning_time",
));
}
}
match (
&(*self).warning_blocks,
((*self).action == 3) || ((*self).action == 5),
) {
(Some(v732), true) => {
w.put_varint((*v732));
}
(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 v733 = (g.int_in(
-2147483648,
2147483647,
&[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
) as i32);
let v734 = if (v733 == 0) { Some(g.f64()) } else { None };
let v735 = if (v733 == 2) || (v733 == 3) {
Some(g.f64())
} else {
None
};
let v736 = if (v733 == 2) || (v733 == 3) {
Some(g.f64())
} else {
None
};
let v737 = if (v733 == 1) || (v733 == 3) {
Some(g.f64())
} else {
None
};
let v738 = if (v733 == 1) || (v733 == 3) {
Some(g.f64())
} else {
None
};
let v739 = if (v733 == 1) || (v733 == 3) {
Some(g.varlong())
} else {
None
};
let v740 = if (v733 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v741 = if (v733 == 3) || (v733 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v742 = if (v733 == 3) || (v733 == 5) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
WorldBorder {
action: v733,
radius: v734,
x: v735,
z: v736,
old_radius: v737,
new_radius: v738,
speed: v739,
portal_boundary: v740,
warning_time: v741,
warning_blocks: v742,
}
}
}
}
impl From<WorldBorder> for ClientboundPlayPacket {
fn from(p: WorldBorder) -> Self {
Self::WorldBorder(p)
}
}
/// `camera` (clientbound play, id 0x39).
#[derive(Debug, Clone, PartialEq)]
pub struct Camera {
/// `cameraId`
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 v743 = r.read_varint()?;
Camera { camera_id: v743 }
})
}
}
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 v744 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Camera { camera_id: v744 }
}
}
}
impl From<Camera> for ClientboundPlayPacket {
fn from(p: Camera) -> Self {
Self::Camera(p)
}
}
/// `held_item_slot` (clientbound play, id 0x3a).
#[derive(Debug, Clone, PartialEq)]
pub struct HeldItemSlot {
/// `slot`
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 v745 = r.read_i8()?;
HeldItemSlot { slot: v745 }
})
}
}
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 v746 = (g.int_in(-128, 127, &[]) as i8);
HeldItemSlot { slot: v746 }
}
}
}
impl From<HeldItemSlot> for ClientboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(p)
}
}
/// `scoreboard_display_objective` (clientbound play, id 0x3b).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardDisplayObjective {
/// `position`
pub position: i8,
/// `name`
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 v747 = r.read_i8()?;
let v748 = r.read_string()?;
ScoreboardDisplayObjective {
position: v747,
name: v748,
}
})
}
}
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 v749 = (g.int_in(-128, 127, &[]) as i8);
let v750 = g.string();
ScoreboardDisplayObjective {
position: v749,
name: v750,
}
}
}
}
impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardDisplayObjective) -> Self {
Self::ScoreboardDisplayObjective(p)
}
}
/// `entity_metadata` (clientbound play, id 0x3c).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMetadata {
/// `entityId`
pub entity_id: i32,
/// `metadata`
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 v751 = r.read_varint()?;
let v752 = {
let mut v753 = Vec::new();
loop {
if r.peek_u8()? == 255 {
r.skip(1)?;
break;
}
v753.push({
let v754 = r.read_u8()?;
let v755 = r.read_i8()?;
let v756 = (if (v755 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v755 == 1) {
types::EntityMetadataValue::VarInt(r.read_varint()?)
} else if (v755 == 2) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v755 == 3) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v755 == 4) {
types::EntityMetadataValue::Chat(r.read_string()?)
} else if (v755 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v755 == 6) {
types::EntityMetadataValue::Boolean(r.read_bool()?)
} else if (v755 == 7) {
types::EntityMetadataValue::Rotation({
let v757 = r.read_f32()?;
let v758 = r.read_f32()?;
let v759 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v757,
yaw: v758,
roll: v759,
}
})
} else if (v755 == 8) {
types::EntityMetadataValue::Position(BlockPos::read(
r,
PositionLayout::Xyz,
)?)
} else if (v755 == 9) {
types::EntityMetadataValue::OptPosition(if r.read_bool()? {
Some(BlockPos::read(r, PositionLayout::Xyz)?)
} else {
None
})
} else if (v755 == 10) {
types::EntityMetadataValue::Direction(r.read_varint()?)
} else if (v755 == 11) {
types::EntityMetadataValue::OptUuid(if r.read_bool()? {
Some(r.read_uuid()?)
} else {
None
})
} else if (v755 == 12) {
types::EntityMetadataValue::BlockState(r.read_varint()?)
} else if (v755 == 13) {
types::EntityMetadataValue::Nbt(RawNbt::read(r)?)
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v754,
r#type: v755,
value: v756,
}
});
}
v753
};
EntityMetadata {
entity_id: v751,
metadata: v752,
}
})
}
}
impl Encode for EntityMetadata {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
for v760 in (*self).metadata.iter() {
let v761 = w.len();
w.put_u8((*v760).key);
w.put_i8((*v760).r#type);
match &(*v760).value {
types::EntityMetadataValue::Byte(v762) => {
if !((*v760).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v762));
}
types::EntityMetadataValue::VarInt(v763) => {
if !((*v760).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v763));
}
types::EntityMetadataValue::Float(v764) => {
if !((*v760).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v764));
}
types::EntityMetadataValue::String(v765) => {
if !((*v760).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v765))?;
}
types::EntityMetadataValue::Chat(v766) => {
if !((*v760).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v766))?;
}
types::EntityMetadataValue::Slot(v767) => {
if !((*v760).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v767).encode(w)?;
}
types::EntityMetadataValue::Boolean(v768) => {
if !((*v760).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v768));
}
types::EntityMetadataValue::Rotation(v769) => {
if !((*v760).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v769).pitch);
w.put_f32((*v769).yaw);
w.put_f32((*v769).roll);
}
types::EntityMetadataValue::Position(v770) => {
if !((*v760).r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v770).write(w, PositionLayout::Xyz)?;
}
types::EntityMetadataValue::OptPosition(v771) => {
if !((*v760).r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v771) {
Some(v772) => {
w.put_u8(1);
(*v772).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v773) => {
if !((*v760).r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v773));
}
types::EntityMetadataValue::OptUuid(v774) => {
if !((*v760).r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v774) {
Some(v775) => {
w.put_u8(1);
w.put_uuid(&(*v775));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v776) => {
if !((*v760).r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v776));
}
types::EntityMetadataValue::Nbt(v777) => {
if !((*v760).r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v777).write(w);
}
types::EntityMetadataValue::Other => {
if !(!(((*v760).r#type == 0)
|| ((*v760).r#type == 1)
|| ((*v760).r#type == 2)
|| ((*v760).r#type == 3)
|| ((*v760).r#type == 4)
|| ((*v760).r#type == 5)
|| ((*v760).r#type == 6)
|| ((*v760).r#type == 7)
|| ((*v760).r#type == 8)
|| ((*v760).r#type == 9)
|| ((*v760).r#type == 10)
|| ((*v760).r#type == 11)
|| ((*v760).r#type == 12)
|| ((*v760).r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
if w.get(v761) == 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 v778 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v779 = {
let n = g.count();
let mut v780 = Vec::with_capacity(n);
for _ in 0..n {
v780.push(loop {
let v781 = {
let v782 = (g.int_in(0, 255, &[]) as u8);
let v783 = (g.int_in(
-128,
127,
&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
) as i8);
let v784 = (if (v783 == 0) {
types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
} else if (v783 == 1) {
types::EntityMetadataValue::VarInt(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v783 == 2) {
types::EntityMetadataValue::Float(g.f32())
} else if (v783 == 3) {
types::EntityMetadataValue::String(g.string())
} else if (v783 == 4) {
types::EntityMetadataValue::Chat(g.string())
} else if (v783 == 5) {
types::EntityMetadataValue::Slot(
<types::Slot as Generate>::generate(g),
)
} else if (v783 == 6) {
types::EntityMetadataValue::Boolean(g.bool())
} else if (v783 == 7) {
types::EntityMetadataValue::Rotation({
let v785 = g.f32();
let v786 = g.f32();
let v787 = g.f32();
types::EntityMetadataValueRotation {
pitch: v785,
yaw: v786,
roll: v787,
}
})
} else if (v783 == 8) {
types::EntityMetadataValue::Position(g.position())
} else if (v783 == 9) {
types::EntityMetadataValue::OptPosition(if g.bool() {
Some(g.position())
} else {
None
})
} else if (v783 == 10) {
types::EntityMetadataValue::Direction(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v783 == 11) {
types::EntityMetadataValue::OptUuid(if g.bool() {
Some(g.uuid())
} else {
None
})
} else if (v783 == 12) {
types::EntityMetadataValue::BlockState(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v783 == 13) {
types::EntityMetadataValue::Nbt(g.nbt())
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
key: v782,
r#type: v783,
value: v784,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
w.put_u8(v781.key);
w.put_i8(v781.r#type);
match &v781.value {
types::EntityMetadataValue::Byte(v788) => {
if !(v781.r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v788));
}
types::EntityMetadataValue::VarInt(v789) => {
if !(v781.r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v789));
}
types::EntityMetadataValue::Float(v790) => {
if !(v781.r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v790));
}
types::EntityMetadataValue::String(v791) => {
if !(v781.r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v791))?;
}
types::EntityMetadataValue::Chat(v792) => {
if !(v781.r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v792))?;
}
types::EntityMetadataValue::Slot(v793) => {
if !(v781.r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v793).encode(w)?;
}
types::EntityMetadataValue::Boolean(v794) => {
if !(v781.r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_bool((*v794));
}
types::EntityMetadataValue::Rotation(v795) => {
if !(v781.r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v795).pitch);
w.put_f32((*v795).yaw);
w.put_f32((*v795).roll);
}
types::EntityMetadataValue::Position(v796) => {
if !(v781.r#type == 8) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v796).write(w, PositionLayout::Xyz)?;
}
types::EntityMetadataValue::OptPosition(v797) => {
if !(v781.r#type == 9) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v797) {
Some(v798) => {
w.put_u8(1);
(*v798).write(w, PositionLayout::Xyz)?;
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::Direction(v799) => {
if !(v781.r#type == 10) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v799));
}
types::EntityMetadataValue::OptUuid(v800) => {
if !(v781.r#type == 11) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
match &(*v800) {
Some(v801) => {
w.put_u8(1);
w.put_uuid(&(*v801));
}
None => w.put_u8(0),
}
}
types::EntityMetadataValue::BlockState(v802) => {
if !(v781.r#type == 12) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_varint((*v802));
}
types::EntityMetadataValue::Nbt(v803) => {
if !(v781.r#type == 13) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v803).write(w);
}
types::EntityMetadataValue::Other => {
if !(!((v781.r#type == 0)
|| (v781.r#type == 1)
|| (v781.r#type == 2)
|| (v781.r#type == 3)
|| (v781.r#type == 4)
|| (v781.r#type == 5)
|| (v781.r#type == 6)
|| (v781.r#type == 7)
|| (v781.r#type == 8)
|| (v781.r#type == 9)
|| (v781.r#type == 10)
|| (v781.r#type == 11)
|| (v781.r#type == 12)
|| (v781.r#type == 13)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
Ok(())
},
|b| b != 255,
) {
break v781;
}
});
}
v780
};
EntityMetadata {
entity_id: v778,
metadata: v779,
}
}
}
}
impl From<EntityMetadata> for ClientboundPlayPacket {
fn from(p: EntityMetadata) -> Self {
Self::EntityMetadata(p)
}
}
/// `attach_entity` (clientbound play, id 0x3d).
#[derive(Debug, Clone, PartialEq)]
pub struct AttachEntity {
/// `entityId`
pub entity_id: i32,
/// `vehicleId`
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 v804 = r.read_i32()?;
let v805 = r.read_i32()?;
AttachEntity {
entity_id: v804,
vehicle_id: v805,
}
})
}
}
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 v806 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v807 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
AttachEntity {
entity_id: v806,
vehicle_id: v807,
}
}
}
}
impl From<AttachEntity> for ClientboundPlayPacket {
fn from(p: AttachEntity) -> Self {
Self::AttachEntity(p)
}
}
/// `entity_velocity` (clientbound play, id 0x3e).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityVelocity {
/// `entityId`
pub entity_id: i32,
/// `velocity`
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 v808 = r.read_varint()?;
let v809 = <types::Vec3i16 as Decode>::decode(r)?;
EntityVelocity {
entity_id: v808,
velocity: v809,
}
})
}
}
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 v810 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v811 = <types::Vec3i16 as Generate>::generate(g);
EntityVelocity {
entity_id: v810,
velocity: v811,
}
}
}
}
impl From<EntityVelocity> for ClientboundPlayPacket {
fn from(p: EntityVelocity) -> Self {
Self::EntityVelocity(p)
}
}
/// `entity_equipment` (clientbound play, id 0x3f).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment {
/// `entityId`
pub entity_id: i32,
/// `slot`
pub slot: i32,
/// `item`
pub item: types::Slot,
}
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 v812 = r.read_varint()?;
let v813 = r.read_varint()?;
let v814 = <types::Slot as Decode>::decode(r)?;
EntityEquipment {
entity_id: v812,
slot: v813,
item: v814,
}
})
}
}
impl Encode for EntityEquipment {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_varint((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityEquipment {
fn generate(g: &mut Gen) -> Self {
{
let v815 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v816 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v817 = <types::Slot as Generate>::generate(g);
EntityEquipment {
entity_id: v815,
slot: v816,
item: v817,
}
}
}
}
impl From<EntityEquipment> for ClientboundPlayPacket {
fn from(p: EntityEquipment) -> Self {
Self::EntityEquipment(p)
}
}
/// `experience` (clientbound play, id 0x40).
#[derive(Debug, Clone, PartialEq)]
pub struct Experience {
/// `experienceBar`
pub experience_bar: f32,
/// `level`
pub level: i32,
/// `totalExperience`
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 v818 = r.read_f32()?;
let v819 = r.read_varint()?;
let v820 = r.read_varint()?;
Experience {
experience_bar: v818,
level: v819,
total_experience: v820,
}
})
}
}
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 v821 = g.f32();
let v822 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v823 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Experience {
experience_bar: v821,
level: v822,
total_experience: v823,
}
}
}
}
impl From<Experience> for ClientboundPlayPacket {
fn from(p: Experience) -> Self {
Self::Experience(p)
}
}
/// `update_health` (clientbound play, id 0x41).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateHealth {
/// `health`
pub health: f32,
/// `food`
pub food: i32,
/// `foodSaturation`
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 v824 = r.read_f32()?;
let v825 = r.read_varint()?;
let v826 = r.read_f32()?;
UpdateHealth {
health: v824,
food: v825,
food_saturation: v826,
}
})
}
}
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 v827 = g.f32();
let v828 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v829 = g.f32();
UpdateHealth {
health: v827,
food: v828,
food_saturation: v829,
}
}
}
}
impl From<UpdateHealth> for ClientboundPlayPacket {
fn from(p: UpdateHealth) -> Self {
Self::UpdateHealth(p)
}
}
/// `scoreboard_objective` (clientbound play, id 0x42).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardObjective {
/// `name`
pub name: ByteString,
/// `action`
pub action: i8,
/// `displayText`
pub display_text: Option<ByteString>,
/// `type`
pub r#type: Option<ByteString>,
}
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 v830 = r.read_string()?;
let v831 = r.read_i8()?;
let v832 = if (v831 == 0) || (v831 == 2) {
Some(r.read_string()?)
} else {
None
};
let v833 = if (v831 == 0) || (v831 == 2) {
Some(r.read_string()?)
} else {
None
};
ScoreboardObjective {
name: v830,
action: v831,
display_text: v832,
r#type: v833,
}
})
}
}
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(v834), true) => {
w.put_string(&(*v834))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.displayText",
));
}
}
match (
&(*self).r#type,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v835), true) => {
w.put_string(&(*v835))?;
}
(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 v836 = g.string();
let v837 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
let v838 = if (v837 == 0) || (v837 == 2) {
Some(g.string())
} else {
None
};
let v839 = if (v837 == 0) || (v837 == 2) {
Some(g.string())
} else {
None
};
ScoreboardObjective {
name: v836,
action: v837,
display_text: v838,
r#type: v839,
}
}
}
}
impl From<ScoreboardObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardObjective) -> Self {
Self::ScoreboardObjective(p)
}
}
/// `set_passengers` (clientbound play, id 0x43).
#[derive(Debug, Clone, PartialEq)]
pub struct SetPassengers {
/// `entityId`
pub entity_id: i32,
/// `passengers`
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 v840 = r.read_varint()?;
let v841 = {
let v842 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v843 = Vec::with_capacity(v842.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v842 {
v843.push(r.read_varint()?);
}
v843
};
SetPassengers {
entity_id: v840,
passengers: v841,
}
})
}
}
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 v844 in (*self).passengers.iter() {
w.put_varint((*v844));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetPassengers {
fn generate(g: &mut Gen) -> Self {
{
let v845 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v846 = {
let v847 = g.count();
let mut v848 = Vec::with_capacity(v847.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v847 {
v848.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v848
};
SetPassengers {
entity_id: v845,
passengers: v846,
}
}
}
}
impl From<SetPassengers> for ClientboundPlayPacket {
fn from(p: SetPassengers) -> Self {
Self::SetPassengers(p)
}
}
/// `teams` (clientbound play, id 0x44).
#[derive(Debug, Clone, PartialEq)]
pub struct Teams {
/// `team`
pub team: ByteString,
/// `mode`
pub mode: i8,
/// `name`
pub name: Option<ByteString>,
/// `prefix`
pub prefix: Option<ByteString>,
/// `suffix`
pub suffix: Option<ByteString>,
/// `friendlyFire`
pub friendly_fire: Option<i8>,
/// `nameTagVisibility`
pub name_tag_visibility: Option<ByteString>,
/// `collisionRule`
pub collision_rule: Option<ByteString>,
/// `color`
pub color: Option<i8>,
/// `players`
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 v849 = r.read_string()?;
let v850 = r.read_i8()?;
let v851 = if (v850 == 0) || (v850 == 2) {
Some(r.read_string()?)
} else {
None
};
let v852 = if (v850 == 0) || (v850 == 2) {
Some(r.read_string()?)
} else {
None
};
let v853 = if (v850 == 0) || (v850 == 2) {
Some(r.read_string()?)
} else {
None
};
let v854 = if (v850 == 0) || (v850 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v855 = if (v850 == 0) || (v850 == 2) {
Some(r.read_string()?)
} else {
None
};
let v856 = if (v850 == 0) || (v850 == 2) {
Some(r.read_string()?)
} else {
None
};
let v857 = if (v850 == 0) || (v850 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v858 = if (v850 == 0) || (v850 == 3) || (v850 == 4) {
Some({
let v859 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v860 = Vec::with_capacity(v859.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v859 {
v860.push(r.read_string()?);
}
v860
})
} else {
None
};
Teams {
team: v849,
mode: v850,
name: v851,
prefix: v852,
suffix: v853,
friendly_fire: v854,
name_tag_visibility: v855,
collision_rule: v856,
color: v857,
players: v858,
}
})
}
}
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(v861), true) => {
w.put_string(&(*v861))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.name")),
}
match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v862), true) => {
w.put_string(&(*v862))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.prefix")),
}
match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v863), true) => {
w.put_string(&(*v863))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.suffix")),
}
match (
&(*self).friendly_fire,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v864), true) => {
w.put_i8((*v864));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.friendlyFire",
));
}
}
match (
&(*self).name_tag_visibility,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v865), true) => {
w.put_string(&(*v865))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.nameTagVisibility",
));
}
}
match (
&(*self).collision_rule,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v866), true) => {
w.put_string(&(*v866))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.teams.collisionRule",
));
}
}
match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v867), true) => {
w.put_i8((*v867));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.teams.color")),
}
match (
&(*self).players,
((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
) {
(Some(v868), true) => {
w.put_len_varint((*v868).len())?;
for v869 in (*v868).iter() {
w.put_string(&(*v869))?;
}
}
(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 v870 = g.string();
let v871 = (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 v872 = if (v871 == 0) || (v871 == 2) {
Some(g.string())
} else {
None
};
let v873 = if (v871 == 0) || (v871 == 2) {
Some(g.string())
} else {
None
};
let v874 = if (v871 == 0) || (v871 == 2) {
Some(g.string())
} else {
None
};
let v875 = if (v871 == 0) || (v871 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v876 = if (v871 == 0) || (v871 == 2) {
Some(g.string())
} else {
None
};
let v877 = if (v871 == 0) || (v871 == 2) {
Some(g.string())
} else {
None
};
let v878 = if (v871 == 0) || (v871 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v879 = if (v871 == 0) || (v871 == 3) || (v871 == 4) {
Some({
let v880 = g.count();
let mut v881 = Vec::with_capacity(v880.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v880 {
v881.push(g.string());
}
v881
})
} else {
None
};
Teams {
team: v870,
mode: v871,
name: v872,
prefix: v873,
suffix: v874,
friendly_fire: v875,
name_tag_visibility: v876,
collision_rule: v877,
color: v878,
players: v879,
}
}
}
}
impl From<Teams> for ClientboundPlayPacket {
fn from(p: Teams) -> Self {
Self::Teams(p)
}
}
/// `scoreboard_score` (clientbound play, id 0x45).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardScore {
/// `itemName`
pub item_name: ByteString,
/// `action`
pub action: i32,
/// `scoreName`
pub score_name: ByteString,
/// `value`
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 v882 = r.read_string()?;
let v883 = r.read_varint()?;
let v884 = r.read_string()?;
let v885 = if !(v883 == 1) {
Some(r.read_varint()?)
} else {
None
};
ScoreboardScore {
item_name: v882,
action: v883,
score_name: v884,
value: v885,
}
})
}
}
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(v886), true) => {
w.put_varint((*v886));
}
(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 v887 = g.string();
let v888 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
let v889 = g.string();
let v890 = if !(v888 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
ScoreboardScore {
item_name: v887,
action: v888,
score_name: v889,
value: v890,
}
}
}
}
impl From<ScoreboardScore> for ClientboundPlayPacket {
fn from(p: ScoreboardScore) -> Self {
Self::ScoreboardScore(p)
}
}
/// `spawn_position` (clientbound play, id 0x46).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnPosition {
/// `location`
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 v891 = BlockPos::read(r, PositionLayout::Xyz)?;
SpawnPosition { location: v891 }
})
}
}
impl Encode for SpawnPosition {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnPosition {
fn generate(g: &mut Gen) -> Self {
{
let v892 = g.position();
SpawnPosition { location: v892 }
}
}
}
impl From<SpawnPosition> for ClientboundPlayPacket {
fn from(p: SpawnPosition) -> Self {
Self::SpawnPosition(p)
}
}
/// `update_time` (clientbound play, id 0x47).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateTime {
/// `age`
pub age: i64,
/// `time`
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 v893 = r.read_i64()?;
let v894 = r.read_i64()?;
UpdateTime {
age: v893,
time: v894,
}
})
}
}
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 v895 = g.i64();
let v896 = g.i64();
UpdateTime {
age: v895,
time: v896,
}
}
}
}
impl From<UpdateTime> for ClientboundPlayPacket {
fn from(p: UpdateTime) -> Self {
Self::UpdateTime(p)
}
}
/// `title` (clientbound play, id 0x48).
#[derive(Debug, Clone, PartialEq)]
pub struct Title {
/// `action`
pub action: i32,
/// `text`
pub text: Option<ByteString>,
/// `fadeIn`
pub fade_in: Option<i32>,
/// `stay`
pub stay: Option<i32>,
/// `fadeOut`
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 v897 = r.read_varint()?;
let v898 = if (v897 == 0) || (v897 == 1) || (v897 == 2) {
Some(r.read_string()?)
} else {
None
};
let v899 = if (v897 == 3) {
Some(r.read_i32()?)
} else {
None
};
let v900 = if (v897 == 3) {
Some(r.read_i32()?)
} else {
None
};
let v901 = if (v897 == 3) {
Some(r.read_i32()?)
} else {
None
};
Title {
action: v897,
text: v898,
fade_in: v899,
stay: v900,
fade_out: v901,
}
})
}
}
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(v902), true) => {
w.put_string(&(*v902))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
}
match (&(*self).fade_in, ((*self).action == 3)) {
(Some(v903), true) => {
w.put_i32((*v903));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
}
match (&(*self).stay, ((*self).action == 3)) {
(Some(v904), true) => {
w.put_i32((*v904));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
}
match (&(*self).fade_out, ((*self).action == 3)) {
(Some(v905), true) => {
w.put_i32((*v905));
}
(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 v906 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 3, 3]) as i32);
let v907 = if (v906 == 0) || (v906 == 1) || (v906 == 2) {
Some(g.string())
} else {
None
};
let v908 = if (v906 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v909 = if (v906 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v910 = if (v906 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Title {
action: v906,
text: v907,
fade_in: v908,
stay: v909,
fade_out: v910,
}
}
}
}
impl From<Title> for ClientboundPlayPacket {
fn from(p: Title) -> Self {
Self::Title(p)
}
}
/// `sound_effect` (clientbound play, id 0x49).
#[derive(Debug, Clone, PartialEq)]
pub struct SoundEffect {
/// `soundId`
pub sound_id: i32,
/// `soundCategory`
pub sound_category: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
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 v911 = r.read_varint()?;
let v912 = r.read_varint()?;
let v913 = r.read_i32()?;
let v914 = r.read_i32()?;
let v915 = r.read_i32()?;
let v916 = r.read_f32()?;
let v917 = r.read_f32()?;
SoundEffect {
sound_id: v911,
sound_category: v912,
x: v913,
y: v914,
z: v915,
volume: v916,
pitch: v917,
}
})
}
}
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 v918 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v919 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v920 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v921 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v922 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v923 = g.f32();
let v924 = g.f32();
SoundEffect {
sound_id: v918,
sound_category: v919,
x: v920,
y: v921,
z: v922,
volume: v923,
pitch: v924,
}
}
}
}
impl From<SoundEffect> for ClientboundPlayPacket {
fn from(p: SoundEffect) -> Self {
Self::SoundEffect(p)
}
}
/// `playerlist_header` (clientbound play, id 0x4a).
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerlistHeader {
/// `header`
pub header: ByteString,
/// `footer`
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 v925 = r.read_string()?;
let v926 = r.read_string()?;
PlayerlistHeader {
header: v925,
footer: v926,
}
})
}
}
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 v927 = g.string();
let v928 = g.string();
PlayerlistHeader {
header: v927,
footer: v928,
}
}
}
}
impl From<PlayerlistHeader> for ClientboundPlayPacket {
fn from(p: PlayerlistHeader) -> Self {
Self::PlayerlistHeader(p)
}
}
/// `collect` (clientbound play, id 0x4b).
#[derive(Debug, Clone, PartialEq)]
pub struct Collect {
/// `collectedEntityId`
pub collected_entity_id: i32,
/// `collectorEntityId`
pub collector_entity_id: i32,
/// `pickupItemCount`
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 v929 = r.read_varint()?;
let v930 = r.read_varint()?;
let v931 = r.read_varint()?;
Collect {
collected_entity_id: v929,
collector_entity_id: v930,
pickup_item_count: v931,
}
})
}
}
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 v932 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v933 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v934 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Collect {
collected_entity_id: v932,
collector_entity_id: v933,
pickup_item_count: v934,
}
}
}
}
impl From<Collect> for ClientboundPlayPacket {
fn from(p: Collect) -> Self {
Self::Collect(p)
}
}
/// `entity_teleport` (clientbound play, id 0x4c).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityTeleport {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: f64,
/// `y`
pub y: f64,
/// `z`
pub z: f64,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `onGround`
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 v935 = r.read_varint()?;
let v936 = r.read_f64()?;
let v937 = r.read_f64()?;
let v938 = r.read_f64()?;
let v939 = r.read_i8()?;
let v940 = r.read_i8()?;
let v941 = r.read_bool()?;
EntityTeleport {
entity_id: v935,
x: v936,
y: v937,
z: v938,
yaw: v939,
pitch: v940,
on_ground: v941,
}
})
}
}
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 v942 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v943 = g.f64();
let v944 = g.f64();
let v945 = g.f64();
let v946 = (g.int_in(-128, 127, &[]) as i8);
let v947 = (g.int_in(-128, 127, &[]) as i8);
let v948 = g.bool();
EntityTeleport {
entity_id: v942,
x: v943,
y: v944,
z: v945,
yaw: v946,
pitch: v947,
on_ground: v948,
}
}
}
}
impl From<EntityTeleport> for ClientboundPlayPacket {
fn from(p: EntityTeleport) -> Self {
Self::EntityTeleport(p)
}
}
/// `advancements` (clientbound play, id 0x4d).
#[derive(Debug, Clone, PartialEq)]
pub struct Advancements {
/// `reset`
pub reset: bool,
/// `advancementMapping`
pub advancement_mapping: Vec<AdvancementsAdvancementMapping>,
/// `identifiers`
pub identifiers: Vec<ByteString>,
/// `progressMapping`
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 v949 = r.read_bool()?;
let v950 = {
let v951 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 5)?
};
let mut v952 = Vec::with_capacity(v951.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v951 {
v952.push({
let v953 = r.read_string()?;
let v954 = {
let v955 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
let v956 = if r.read_bool()? {
Some({
let v957 = r.read_string()?;
let v958 = r.read_string()?;
let v959 = <types::Slot as Decode>::decode(r)?;
let v960 = r.read_varint()?;
let v961 = {
let v962 = u64::from(r.read_i32()? as u32);
AdvancementsAdvancementMappingValueDisplayDataFlags {
_unused: (((v962 >> 3) & 0x1fffffff) as u32),
hidden: (((v962 >> 2) & 0x1) as u8),
show_toast: (((v962 >> 1) & 0x1) as u8),
has_background_texture: (((v962 >> 0) & 0x1) as u8),
}
};
let v963 = if (v961.has_background_texture == 1) {
Some(r.read_string()?)
} else {
None
};
let v964 = r.read_f32()?;
let v965 = r.read_f32()?;
AdvancementsAdvancementMappingValueDisplayData {
title: v957,
description: v958,
icon: v959,
frame_type: v960,
flags: v961,
background_texture: v963,
x_cord: v964,
y_cord: v965,
}
})
} else {
None
};
let v966 = {
let v967 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v968 =
Vec::with_capacity(v967.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v967 {
v968.push({
let v969 = r.read_string()?;
AdvancementsAdvancementMappingValueCriteria { key: v969 }
});
}
v968
};
let v971 = {
let v972 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v973 =
Vec::with_capacity(v972.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v972 {
v973.push({
let v974 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v975 = Vec::with_capacity(
v974.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v974 {
v975.push(r.read_string()?);
}
v975
});
}
v973
};
AdvancementsAdvancementMappingValue {
parent_id: v955,
display_data: v956,
criteria: v966,
requirements: v971,
}
};
AdvancementsAdvancementMapping {
key: v953,
value: v954,
}
});
}
v952
};
let v976 = {
let v977 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v978 = Vec::with_capacity(v977.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v977 {
v978.push(r.read_string()?);
}
v978
};
let v979 = {
let v980 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v981 = Vec::with_capacity(v980.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v980 {
v981.push({
let v982 = r.read_string()?;
let v983 = {
let v984 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v985 =
Vec::with_capacity(v984.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v984 {
v985.push({
let v986 = r.read_string()?;
let v987 = if r.read_bool()? {
Some(r.read_i64()?)
} else {
None
};
AdvancementsProgressMappingValue {
criterion_identifier: v986,
criterion_progress: v987,
}
});
}
v985
};
AdvancementsProgressMapping {
key: v982,
value: v983,
}
});
}
v981
};
Advancements {
reset: v949,
advancement_mapping: v950,
identifiers: v976,
progress_mapping: v979,
}
})
}
}
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 v988 in (*self).advancement_mapping.iter() {
w.put_string(&(*v988).key)?;
match &(*v988).value.parent_id {
Some(v989) => {
w.put_u8(1);
w.put_string(&(*v989))?;
}
None => w.put_u8(0),
}
match &(*v988).value.display_data {
Some(v990) => {
w.put_u8(1);
w.put_string(&(*v990).title)?;
w.put_string(&(*v990).description)?;
(*v990).icon.encode(w)?;
w.put_varint((*v990).frame_type);
{
let mut bits: u64 = 0;
{
let x = i128::from((*v990).flags._unused);
if x < 0 || x > 536870911 {
return Err(EncodeError::OutOfRange("_unused"));
}
bits = (bits << 29) | ((x as u64) & 0x1fffffff);
}
{
let x = i128::from((*v990).flags.hidden);
if x < 0 || x > 1 {
return Err(EncodeError::OutOfRange("hidden"));
}
bits = (bits << 1) | ((x as u64) & 0x1);
}
{
let x = i128::from((*v990).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((*v990).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 (
&(*v990).background_texture,
((*v990).flags.has_background_texture == 1),
) {
(Some(v991), true) => {
w.put_string(&(*v991))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.advancements.advancementMapping.value.displayData.backgroundTexture",
));
}
}
w.put_f32((*v990).x_cord);
w.put_f32((*v990).y_cord);
}
None => w.put_u8(0),
}
w.put_len_varint((*v988).value.criteria.len())?;
for v992 in (*v988).value.criteria.iter() {
w.put_string(&(*v992).key)?;
}
w.put_len_varint((*v988).value.requirements.len())?;
for v993 in (*v988).value.requirements.iter() {
w.put_len_varint((*v993).len())?;
for v994 in (*v993).iter() {
w.put_string(&(*v994))?;
}
}
}
w.put_len_varint((*self).identifiers.len())?;
for v995 in (*self).identifiers.iter() {
w.put_string(&(*v995))?;
}
w.put_len_varint((*self).progress_mapping.len())?;
for v996 in (*self).progress_mapping.iter() {
w.put_string(&(*v996).key)?;
w.put_len_varint((*v996).value.len())?;
for v997 in (*v996).value.iter() {
w.put_string(&(*v997).criterion_identifier)?;
match &(*v997).criterion_progress {
Some(v998) => {
w.put_u8(1);
w.put_i64((*v998));
}
None => w.put_u8(0),
}
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Advancements {
fn generate(g: &mut Gen) -> Self {
{
let v999 = g.bool();
let v1000 = {
let v1001 = g.count();
let mut v1002 = Vec::with_capacity(v1001.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1001 {
v1002.push({
let v1003 = g.string();
let v1004 = {
let v1005 = if g.bool() { Some(g.string()) } else { None };
let v1006 = if g.bool() {
Some({
let v1007 = g.string();
let v1008 = g.string();
let v1009 = <types::Slot as Generate>::generate(g);
let v1010 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1011 = {
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 v1013 = if (v1011.has_background_texture == 1) {
Some(g.string())
} else {
None
};
let v1014 = g.f32();
let v1015 = g.f32();
AdvancementsAdvancementMappingValueDisplayData {
title: v1007,
description: v1008,
icon: v1009,
frame_type: v1010,
flags: v1011,
background_texture: v1013,
x_cord: v1014,
y_cord: v1015,
}
})
} else {
None
};
let v1016 = {
let v1017 = g.count();
let mut v1018 =
Vec::with_capacity(v1017.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1017 {
v1018.push({
let v1019 = g.string();
AdvancementsAdvancementMappingValueCriteria { key: v1019 }
});
}
v1018
};
let v1021 = {
let v1022 = g.count();
let mut v1023 =
Vec::with_capacity(v1022.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1022 {
v1023.push({
let v1024 = g.count();
let mut v1025 = Vec::with_capacity(
v1024.min(crate::codec::PREALLOC_LIMIT),
);
for _ in 0..v1024 {
v1025.push(g.string());
}
v1025
});
}
v1023
};
AdvancementsAdvancementMappingValue {
parent_id: v1005,
display_data: v1006,
criteria: v1016,
requirements: v1021,
}
};
AdvancementsAdvancementMapping {
key: v1003,
value: v1004,
}
});
}
v1002
};
let v1026 = {
let v1027 = g.count();
let mut v1028 = Vec::with_capacity(v1027.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1027 {
v1028.push(g.string());
}
v1028
};
let v1029 = {
let v1030 = g.count();
let mut v1031 = Vec::with_capacity(v1030.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1030 {
v1031.push({
let v1032 = g.string();
let v1033 = {
let v1034 = g.count();
let mut v1035 =
Vec::with_capacity(v1034.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1034 {
v1035.push({
let v1036 = g.string();
let v1037 = if g.bool() { Some(g.i64()) } else { None };
AdvancementsProgressMappingValue {
criterion_identifier: v1036,
criterion_progress: v1037,
}
});
}
v1035
};
AdvancementsProgressMapping {
key: v1032,
value: v1033,
}
});
}
v1031
};
Advancements {
reset: v999,
advancement_mapping: v1000,
identifiers: v1026,
progress_mapping: v1029,
}
}
}
}
impl From<Advancements> for ClientboundPlayPacket {
fn from(p: Advancements) -> Self {
Self::Advancements(p)
}
}
/// `entity_update_attributes` (clientbound play, id 0x4e).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityUpdateAttributes {
/// `entityId`
pub entity_id: i32,
/// `properties`
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 v1038 = r.read_varint()?;
let v1039 = {
let v1040 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 10)?
};
let mut v1041 = Vec::with_capacity(v1040.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1040 {
v1041.push({
let v1042 = r.read_string()?;
let v1043 = r.read_f64()?;
let v1044 = {
let v1045 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 25)?
};
let mut v1046 =
Vec::with_capacity(v1045.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1045 {
v1046.push({
let v1047 = r.read_uuid()?;
let v1048 = r.read_f64()?;
let v1049 = r.read_i8()?;
EntityUpdateAttributesPropertiesModifiers {
uuid: v1047,
amount: v1048,
operation: v1049,
}
});
}
v1046
};
EntityUpdateAttributesProperties {
key: v1042,
value: v1043,
modifiers: v1044,
}
});
}
v1041
};
EntityUpdateAttributes {
entity_id: v1038,
properties: v1039,
}
})
}
}
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 v1050 in (*self).properties.iter() {
w.put_string(&(*v1050).key)?;
w.put_f64((*v1050).value);
w.put_len_varint((*v1050).modifiers.len())?;
for v1051 in (*v1050).modifiers.iter() {
w.put_uuid(&(*v1051).uuid);
w.put_f64((*v1051).amount);
w.put_i8((*v1051).operation);
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityUpdateAttributes {
fn generate(g: &mut Gen) -> Self {
{
let v1052 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1053 = {
let v1054 = g.count();
let mut v1055 = Vec::with_capacity(v1054.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1054 {
v1055.push({
let v1056 = g.string();
let v1057 = g.f64();
let v1058 = {
let v1059 = g.count();
let mut v1060 =
Vec::with_capacity(v1059.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v1059 {
v1060.push({
let v1061 = g.uuid();
let v1062 = g.f64();
let v1063 = (g.int_in(-128, 127, &[]) as i8);
EntityUpdateAttributesPropertiesModifiers {
uuid: v1061,
amount: v1062,
operation: v1063,
}
});
}
v1060
};
EntityUpdateAttributesProperties {
key: v1056,
value: v1057,
modifiers: v1058,
}
});
}
v1055
};
EntityUpdateAttributes {
entity_id: v1052,
properties: v1053,
}
}
}
}
impl From<EntityUpdateAttributes> for ClientboundPlayPacket {
fn from(p: EntityUpdateAttributes) -> Self {
Self::EntityUpdateAttributes(p)
}
}
/// `entity_effect` (clientbound play, id 0x4f).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEffect {
/// `entityId`
pub entity_id: i32,
/// `effectId`
pub effect_id: i8,
/// `amplifier`
pub amplifier: i8,
/// `duration`
pub duration: i32,
/// `hideParticles`
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 v1064 = r.read_varint()?;
let v1065 = r.read_i8()?;
let v1066 = r.read_i8()?;
let v1067 = r.read_varint()?;
let v1068 = r.read_i8()?;
EntityEffect {
entity_id: v1064,
effect_id: v1065,
amplifier: v1066,
duration: v1067,
hide_particles: v1068,
}
})
}
}
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 v1069 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1070 = (g.int_in(-128, 127, &[]) as i8);
let v1071 = (g.int_in(-128, 127, &[]) as i8);
let v1072 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v1073 = (g.int_in(-128, 127, &[]) as i8);
EntityEffect {
entity_id: v1069,
effect_id: v1070,
amplifier: v1071,
duration: v1072,
hide_particles: v1073,
}
}
}
}
impl From<EntityEffect> for ClientboundPlayPacket {
fn from(p: EntityEffect) -> Self {
Self::EntityEffect(p)
}
}
/// Every Clientbound packet of the Play state.
#[derive(Debug, Clone, PartialEq)]
pub enum ClientboundPlayPacket {
/// `spawn_entity`
SpawnEntity(SpawnEntity),
/// `spawn_entity_experience_orb`
SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
/// `spawn_entity_weather`
SpawnEntityWeather(SpawnEntityWeather),
/// `spawn_entity_living`
SpawnEntityLiving(SpawnEntityLiving),
/// `spawn_entity_painting`
SpawnEntityPainting(SpawnEntityPainting),
/// `named_entity_spawn`
NamedEntitySpawn(NamedEntitySpawn),
/// `animation`
Animation(Animation),
/// `statistics`
Statistics(Statistics),
/// `block_break_animation`
BlockBreakAnimation(BlockBreakAnimation),
/// `tile_entity_data`
TileEntityData(TileEntityData),
/// `block_action`
BlockAction(BlockAction),
/// `block_change`
BlockChange(BlockChange),
/// `boss_bar`
BossBar(BossBar),
/// `difficulty`
Difficulty(Difficulty),
/// `tab_complete`
TabComplete(TabComplete),
/// `chat`
Chat(Chat),
/// `multi_block_change`
MultiBlockChange(MultiBlockChange),
/// `transaction`
Transaction(Transaction),
/// `close_window`
CloseWindow(CloseWindow),
/// `open_window`
OpenWindow(OpenWindow),
/// `window_items`
WindowItems(WindowItems),
/// `craft_progress_bar`
CraftProgressBar(CraftProgressBar),
/// `set_slot`
SetSlot(SetSlot),
/// `set_cooldown`
SetCooldown(SetCooldown),
/// `custom_payload`
CustomPayload(CustomPayload),
/// `named_sound_effect`
NamedSoundEffect(NamedSoundEffect),
/// `kick_disconnect`
KickDisconnect(KickDisconnect),
/// `entity_status`
EntityStatus(EntityStatus),
/// `explosion`
Explosion(Explosion),
/// `unload_chunk`
UnloadChunk(UnloadChunk),
/// `game_state_change`
GameStateChange(GameStateChange),
/// `keep_alive`
KeepAlive(KeepAlive),
/// `map_chunk`
MapChunk(MapChunk),
/// `world_event`
WorldEvent(WorldEvent),
/// `world_particles`
WorldParticles(WorldParticles),
/// `login`
Login(Login),
/// `map`
Map(Map),
/// `entity`
Entity(Entity),
/// `rel_entity_move`
RelEntityMove(RelEntityMove),
/// `entity_move_look`
EntityMoveLook(EntityMoveLook),
/// `entity_look`
EntityLook(EntityLook),
/// `vehicle_move`
VehicleMove(VehicleMove),
/// `open_sign_entity`
OpenSignEntity(OpenSignEntity),
/// `craft_recipe_response`
CraftRecipeResponse(CraftRecipeResponse),
/// `abilities`
Abilities(Abilities),
/// `combat_event`
CombatEvent(CombatEvent),
/// `player_info`
PlayerInfo(PlayerInfo),
/// `position`
Position(Position),
/// `bed`
Bed(Bed),
/// `unlock_recipes`
UnlockRecipes(UnlockRecipes),
/// `entity_destroy`
EntityDestroy(EntityDestroy),
/// `remove_entity_effect`
RemoveEntityEffect(RemoveEntityEffect),
/// `resource_pack_send`
ResourcePackSend(ResourcePackSend),
/// `respawn`
Respawn(Respawn),
/// `entity_head_rotation`
EntityHeadRotation(EntityHeadRotation),
/// `select_advancement_tab`
SelectAdvancementTab(SelectAdvancementTab),
/// `world_border`
WorldBorder(WorldBorder),
/// `camera`
Camera(Camera),
/// `held_item_slot`
HeldItemSlot(HeldItemSlot),
/// `scoreboard_display_objective`
ScoreboardDisplayObjective(ScoreboardDisplayObjective),
/// `entity_metadata`
EntityMetadata(EntityMetadata),
/// `attach_entity`
AttachEntity(AttachEntity),
/// `entity_velocity`
EntityVelocity(EntityVelocity),
/// `entity_equipment`
EntityEquipment(EntityEquipment),
/// `experience`
Experience(Experience),
/// `update_health`
UpdateHealth(UpdateHealth),
/// `scoreboard_objective`
ScoreboardObjective(ScoreboardObjective),
/// `set_passengers`
SetPassengers(SetPassengers),
/// `teams`
Teams(Teams),
/// `scoreboard_score`
ScoreboardScore(ScoreboardScore),
/// `spawn_position`
SpawnPosition(SpawnPosition),
/// `update_time`
UpdateTime(UpdateTime),
/// `title`
Title(Title),
/// `sound_effect`
SoundEffect(SoundEffect),
/// `playerlist_header`
PlayerlistHeader(PlayerlistHeader),
/// `collect`
Collect(Collect),
/// `entity_teleport`
EntityTeleport(EntityTeleport),
/// `advancements`
Advancements(Advancements),
/// `entity_update_attributes`
EntityUpdateAttributes(EntityUpdateAttributes),
/// `entity_effect`
EntityEffect(EntityEffect),
}
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_WEATHER => decode_exact(&raw.body).map(Self::SpawnEntityWeather),
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::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::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
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::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::LOGIN => decode_exact(&raw.body).map(Self::Login),
id::MAP => decode_exact(&raw.body).map(Self::Map),
id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
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::VEHICLE_MOVE => decode_exact(&raw.body).map(Self::VehicleMove),
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::POSITION => decode_exact(&raw.body).map(Self::Position),
id::BED => decode_exact(&raw.body).map(Self::Bed),
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::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::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::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
id::TITLE => decode_exact(&raw.body).map(Self::Title),
id::SOUND_EFFECT => decode_exact(&raw.body).map(Self::SoundEffect),
id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
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),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::SpawnEntity(_) => id::SPAWN_ENTITY,
Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
Self::SpawnEntityWeather(_) => id::SPAWN_ENTITY_WEATHER,
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::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::TabComplete(_) => id::TAB_COMPLETE,
Self::Chat(_) => id::CHAT,
Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
Self::Transaction(_) => id::TRANSACTION,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::OpenWindow(_) => id::OPEN_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::KeepAlive(_) => id::KEEP_ALIVE,
Self::MapChunk(_) => id::MAP_CHUNK,
Self::WorldEvent(_) => id::WORLD_EVENT,
Self::WorldParticles(_) => id::WORLD_PARTICLES,
Self::Login(_) => id::LOGIN,
Self::Map(_) => id::MAP,
Self::Entity(_) => id::ENTITY,
Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
Self::EntityLook(_) => id::ENTITY_LOOK,
Self::VehicleMove(_) => id::VEHICLE_MOVE,
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::Position(_) => id::POSITION,
Self::Bed(_) => id::BED,
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::SelectAdvancementTab(_) => id::SELECT_ADVANCEMENT_TAB,
Self::WorldBorder(_) => id::WORLD_BORDER,
Self::Camera(_) => id::CAMERA,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
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::SpawnPosition(_) => id::SPAWN_POSITION,
Self::UpdateTime(_) => id::UPDATE_TIME,
Self::Title(_) => id::TITLE,
Self::SoundEffect(_) => id::SOUND_EFFECT,
Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
Self::Collect(_) => id::COLLECT,
Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
Self::Advancements(_) => id::ADVANCEMENTS,
Self::EntityUpdateAttributes(_) => id::ENTITY_UPDATE_ATTRIBUTES,
Self::EntityEffect(_) => id::ENTITY_EFFECT,
}
}
fn name(&self) -> &'static str {
match *self {
Self::SpawnEntity(_) => "spawn_entity",
Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
Self::SpawnEntityWeather(_) => "spawn_entity_weather",
Self::SpawnEntityLiving(_) => "spawn_entity_living",
Self::SpawnEntityPainting(_) => "spawn_entity_painting",
Self::NamedEntitySpawn(_) => "named_entity_spawn",
Self::Animation(_) => "animation",
Self::Statistics(_) => "statistics",
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::TabComplete(_) => "tab_complete",
Self::Chat(_) => "chat",
Self::MultiBlockChange(_) => "multi_block_change",
Self::Transaction(_) => "transaction",
Self::CloseWindow(_) => "close_window",
Self::OpenWindow(_) => "open_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::KeepAlive(_) => "keep_alive",
Self::MapChunk(_) => "map_chunk",
Self::WorldEvent(_) => "world_event",
Self::WorldParticles(_) => "world_particles",
Self::Login(_) => "login",
Self::Map(_) => "map",
Self::Entity(_) => "entity",
Self::RelEntityMove(_) => "rel_entity_move",
Self::EntityMoveLook(_) => "entity_move_look",
Self::EntityLook(_) => "entity_look",
Self::VehicleMove(_) => "vehicle_move",
Self::OpenSignEntity(_) => "open_sign_entity",
Self::CraftRecipeResponse(_) => "craft_recipe_response",
Self::Abilities(_) => "abilities",
Self::CombatEvent(_) => "combat_event",
Self::PlayerInfo(_) => "player_info",
Self::Position(_) => "position",
Self::Bed(_) => "bed",
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::SelectAdvancementTab(_) => "select_advancement_tab",
Self::WorldBorder(_) => "world_border",
Self::Camera(_) => "camera",
Self::HeldItemSlot(_) => "held_item_slot",
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::SpawnPosition(_) => "spawn_position",
Self::UpdateTime(_) => "update_time",
Self::Title(_) => "title",
Self::SoundEffect(_) => "sound_effect",
Self::PlayerlistHeader(_) => "playerlist_header",
Self::Collect(_) => "collect",
Self::EntityTeleport(_) => "entity_teleport",
Self::Advancements(_) => "advancements",
Self::EntityUpdateAttributes(_) => "entity_update_attributes",
Self::EntityEffect(_) => "entity_effect",
}
}
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::SpawnEntityWeather(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::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::TabComplete(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::MultiBlockChange(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::OpenWindow(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::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::Login(ref p) => p.encode(w),
Self::Map(ref p) => p.encode(w),
Self::Entity(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::VehicleMove(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::Position(ref p) => p.encode(w),
Self::Bed(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::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::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::SpawnPosition(ref p) => p.encode(w),
Self::UpdateTime(ref p) => p.encode(w),
Self::Title(ref p) => p.encode(w),
Self::SoundEffect(ref p) => p.encode(w),
Self::PlayerlistHeader(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),
}
}
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_WEATHER => Some("spawn_entity_weather"),
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::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::TAB_COMPLETE => Some("tab_complete"),
id::CHAT => Some("chat"),
id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
id::TRANSACTION => Some("transaction"),
id::CLOSE_WINDOW => Some("close_window"),
id::OPEN_WINDOW => Some("open_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::KEEP_ALIVE => Some("keep_alive"),
id::MAP_CHUNK => Some("map_chunk"),
id::WORLD_EVENT => Some("world_event"),
id::WORLD_PARTICLES => Some("world_particles"),
id::LOGIN => Some("login"),
id::MAP => Some("map"),
id::ENTITY => Some("entity"),
id::REL_ENTITY_MOVE => Some("rel_entity_move"),
id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
id::ENTITY_LOOK => Some("entity_look"),
id::VEHICLE_MOVE => Some("vehicle_move"),
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::POSITION => Some("position"),
id::BED => Some("bed"),
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::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::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::SPAWN_POSITION => Some("spawn_position"),
id::UPDATE_TIME => Some("update_time"),
id::TITLE => Some("title"),
id::SOUND_EFFECT => Some("sound_effect"),
id::PLAYERLIST_HEADER => Some("playerlist_header"),
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"),
_ => None,
}
}
}
impl ClientboundPlayPacket {
/// All packet ids of this set, ascending.
pub const IDS: &'static [i32] = &[
id::SPAWN_ENTITY,
id::SPAWN_ENTITY_EXPERIENCE_ORB,
id::SPAWN_ENTITY_WEATHER,
id::SPAWN_ENTITY_LIVING,
id::SPAWN_ENTITY_PAINTING,
id::NAMED_ENTITY_SPAWN,
id::ANIMATION,
id::STATISTICS,
id::BLOCK_BREAK_ANIMATION,
id::TILE_ENTITY_DATA,
id::BLOCK_ACTION,
id::BLOCK_CHANGE,
id::BOSS_BAR,
id::DIFFICULTY,
id::TAB_COMPLETE,
id::CHAT,
id::MULTI_BLOCK_CHANGE,
id::TRANSACTION,
id::CLOSE_WINDOW,
id::OPEN_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::KEEP_ALIVE,
id::MAP_CHUNK,
id::WORLD_EVENT,
id::WORLD_PARTICLES,
id::LOGIN,
id::MAP,
id::ENTITY,
id::REL_ENTITY_MOVE,
id::ENTITY_MOVE_LOOK,
id::ENTITY_LOOK,
id::VEHICLE_MOVE,
id::OPEN_SIGN_ENTITY,
id::CRAFT_RECIPE_RESPONSE,
id::ABILITIES,
id::COMBAT_EVENT,
id::PLAYER_INFO,
id::POSITION,
id::BED,
id::UNLOCK_RECIPES,
id::ENTITY_DESTROY,
id::REMOVE_ENTITY_EFFECT,
id::RESOURCE_PACK_SEND,
id::RESPAWN,
id::ENTITY_HEAD_ROTATION,
id::SELECT_ADVANCEMENT_TAB,
id::WORLD_BORDER,
id::CAMERA,
id::HELD_ITEM_SLOT,
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::SPAWN_POSITION,
id::UPDATE_TIME,
id::TITLE,
id::SOUND_EFFECT,
id::PLAYERLIST_HEADER,
id::COLLECT,
id::ENTITY_TELEPORT,
id::ADVANCEMENTS,
id::ENTITY_UPDATE_ATTRIBUTES,
id::ENTITY_EFFECT,
];
/// Generates a random packet with the given id (test support).
#[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_WEATHER => Some(Self::SpawnEntityWeather(
<SpawnEntityWeather 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::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::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
<MultiBlockChange 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::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow 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::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::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
id::ENTITY => Some(Self::Entity(<Entity 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::VEHICLE_MOVE => Some(Self::VehicleMove(<VehicleMove 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::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
id::BED => Some(Self::Bed(<Bed 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::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::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::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition 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::SOUND_EFFECT => Some(Self::SoundEffect(<SoundEffect as Generate>::generate(g))),
id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
<PlayerlistHeader 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))),
_ => None,
}
}
}