// @generated by ghast-codegen-protocol from PrismarineJS minecraft-data 3.119.0
// (data/pc/1.8/protocol.json, Minecraft 1.8.9). 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_8::types;
use bytes::{BufMut, Bytes, BytesMut};
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateAttributesPropertiesModifiers {
/// `uuid`
pub uuid: Uuid,
/// `amount`
pub amount: f64,
/// `operation`
pub operation: i8,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateAttributesProperties {
/// `key`
pub key: ByteString,
/// `value`
pub value: f64,
/// `modifiers`
pub modifiers: Vec<UpdateAttributesPropertiesModifiers>,
}
/// 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 MapChunkBulkMeta {
/// `x`
pub x: i32,
/// `z`
pub z: i32,
/// `bitMap`
pub bit_map: u16,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct ExplosionAffectedBlockOffsets {
/// `x`
pub x: i8,
/// `y`
pub y: i8,
/// `z`
pub z: i8,
}
/// 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,
}
/// 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),
}
}
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct MapIcons {
/// `directionAndType`
pub direction_and_type: i8,
/// `x`
pub x: i8,
/// `z`
pub z: i8,
}
/// Nested container.
#[derive(Debug, Clone, PartialEq)]
pub struct StatisticsEntries {
/// `name`
pub name: ByteString,
/// `value`
pub value: i32,
}
/// 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,
}
/// 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),
}
}
}
/// Packet ids.
pub mod id {
/// `keep_alive`
pub const KEEP_ALIVE: i32 = 0x00;
/// `login`
pub const LOGIN: i32 = 0x01;
/// `chat`
pub const CHAT: i32 = 0x02;
/// `update_time`
pub const UPDATE_TIME: i32 = 0x03;
/// `entity_equipment`
pub const ENTITY_EQUIPMENT: i32 = 0x04;
/// `spawn_position`
pub const SPAWN_POSITION: i32 = 0x05;
/// `update_health`
pub const UPDATE_HEALTH: i32 = 0x06;
/// `respawn`
pub const RESPAWN: i32 = 0x07;
/// `position`
pub const POSITION: i32 = 0x08;
/// `held_item_slot`
pub const HELD_ITEM_SLOT: i32 = 0x09;
/// `bed`
pub const BED: i32 = 0x0a;
/// `animation`
pub const ANIMATION: i32 = 0x0b;
/// `named_entity_spawn`
pub const NAMED_ENTITY_SPAWN: i32 = 0x0c;
/// `collect`
pub const COLLECT: i32 = 0x0d;
/// `spawn_entity`
pub const SPAWN_ENTITY: i32 = 0x0e;
/// `spawn_entity_living`
pub const SPAWN_ENTITY_LIVING: i32 = 0x0f;
/// `spawn_entity_painting`
pub const SPAWN_ENTITY_PAINTING: i32 = 0x10;
/// `spawn_entity_experience_orb`
pub const SPAWN_ENTITY_EXPERIENCE_ORB: i32 = 0x11;
/// `entity_velocity`
pub const ENTITY_VELOCITY: i32 = 0x12;
/// `entity_destroy`
pub const ENTITY_DESTROY: i32 = 0x13;
/// `entity`
pub const ENTITY: i32 = 0x14;
/// `rel_entity_move`
pub const REL_ENTITY_MOVE: i32 = 0x15;
/// `entity_look`
pub const ENTITY_LOOK: i32 = 0x16;
/// `entity_move_look`
pub const ENTITY_MOVE_LOOK: i32 = 0x17;
/// `entity_teleport`
pub const ENTITY_TELEPORT: i32 = 0x18;
/// `entity_head_rotation`
pub const ENTITY_HEAD_ROTATION: i32 = 0x19;
/// `entity_status`
pub const ENTITY_STATUS: i32 = 0x1a;
/// `attach_entity`
pub const ATTACH_ENTITY: i32 = 0x1b;
/// `entity_metadata`
pub const ENTITY_METADATA: i32 = 0x1c;
/// `entity_effect`
pub const ENTITY_EFFECT: i32 = 0x1d;
/// `remove_entity_effect`
pub const REMOVE_ENTITY_EFFECT: i32 = 0x1e;
/// `experience`
pub const EXPERIENCE: i32 = 0x1f;
/// `update_attributes`
pub const UPDATE_ATTRIBUTES: i32 = 0x20;
/// `map_chunk`
pub const MAP_CHUNK: i32 = 0x21;
/// `multi_block_change`
pub const MULTI_BLOCK_CHANGE: i32 = 0x22;
/// `block_change`
pub const BLOCK_CHANGE: i32 = 0x23;
/// `block_action`
pub const BLOCK_ACTION: i32 = 0x24;
/// `block_break_animation`
pub const BLOCK_BREAK_ANIMATION: i32 = 0x25;
/// `map_chunk_bulk`
pub const MAP_CHUNK_BULK: i32 = 0x26;
/// `explosion`
pub const EXPLOSION: i32 = 0x27;
/// `world_event`
pub const WORLD_EVENT: i32 = 0x28;
/// `named_sound_effect`
pub const NAMED_SOUND_EFFECT: i32 = 0x29;
/// `world_particles`
pub const WORLD_PARTICLES: i32 = 0x2a;
/// `game_state_change`
pub const GAME_STATE_CHANGE: i32 = 0x2b;
/// `spawn_entity_weather`
pub const SPAWN_ENTITY_WEATHER: i32 = 0x2c;
/// `open_window`
pub const OPEN_WINDOW: i32 = 0x2d;
/// `close_window`
pub const CLOSE_WINDOW: i32 = 0x2e;
/// `set_slot`
pub const SET_SLOT: i32 = 0x2f;
/// `window_items`
pub const WINDOW_ITEMS: i32 = 0x30;
/// `craft_progress_bar`
pub const CRAFT_PROGRESS_BAR: i32 = 0x31;
/// `transaction`
pub const TRANSACTION: i32 = 0x32;
/// `update_sign`
pub const UPDATE_SIGN: i32 = 0x33;
/// `map`
pub const MAP: i32 = 0x34;
/// `tile_entity_data`
pub const TILE_ENTITY_DATA: i32 = 0x35;
/// `open_sign_entity`
pub const OPEN_SIGN_ENTITY: i32 = 0x36;
/// `statistics`
pub const STATISTICS: i32 = 0x37;
/// `player_info`
pub const PLAYER_INFO: i32 = 0x38;
/// `abilities`
pub const ABILITIES: i32 = 0x39;
/// `tab_complete`
pub const TAB_COMPLETE: i32 = 0x3a;
/// `scoreboard_objective`
pub const SCOREBOARD_OBJECTIVE: i32 = 0x3b;
/// `scoreboard_score`
pub const SCOREBOARD_SCORE: i32 = 0x3c;
/// `scoreboard_display_objective`
pub const SCOREBOARD_DISPLAY_OBJECTIVE: i32 = 0x3d;
/// `scoreboard_team`
pub const SCOREBOARD_TEAM: i32 = 0x3e;
/// `custom_payload`
pub const CUSTOM_PAYLOAD: i32 = 0x3f;
/// `kick_disconnect`
pub const KICK_DISCONNECT: i32 = 0x40;
/// `difficulty`
pub const DIFFICULTY: i32 = 0x41;
/// `combat_event`
pub const COMBAT_EVENT: i32 = 0x42;
/// `camera`
pub const CAMERA: i32 = 0x43;
/// `world_border`
pub const WORLD_BORDER: i32 = 0x44;
/// `title`
pub const TITLE: i32 = 0x45;
/// `set_compression`
pub const SET_COMPRESSION: i32 = 0x46;
/// `playerlist_header`
pub const PLAYERLIST_HEADER: i32 = 0x47;
/// `resource_pack_send`
pub const RESOURCE_PACK_SEND: i32 = 0x48;
/// `update_entity_nbt`
pub const UPDATE_ENTITY_NBT: i32 = 0x49;
}
/// `keep_alive` (clientbound play, id 0x00).
#[derive(Debug, Clone, PartialEq)]
pub struct KeepAlive {
/// `keepAliveId`
pub keep_alive_id: i32,
}
impl crate::packet::Packet for KeepAlive {
const ID: i32 = id::KEEP_ALIVE;
const NAME: &'static str = "keep_alive";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for KeepAlive {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v37 = r.read_varint()?;
KeepAlive { keep_alive_id: v37 }
})
}
}
impl Encode for KeepAlive {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).keep_alive_id);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for KeepAlive {
fn generate(g: &mut Gen) -> Self {
{
let v38 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
KeepAlive { keep_alive_id: v38 }
}
}
}
impl From<KeepAlive> for ClientboundPlayPacket {
fn from(p: KeepAlive) -> Self {
Self::KeepAlive(p)
}
}
/// `login` (clientbound play, id 0x01).
#[derive(Debug, Clone, PartialEq)]
pub struct Login {
/// `entityId`
pub entity_id: i32,
/// `gameMode`
pub game_mode: u8,
/// `dimension`
pub dimension: i8,
/// `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 v39 = r.read_i32()?;
let v40 = r.read_u8()?;
let v41 = r.read_i8()?;
let v42 = r.read_u8()?;
let v43 = r.read_u8()?;
let v44 = r.read_string()?;
let v45 = r.read_bool()?;
Login {
entity_id: v39,
game_mode: v40,
dimension: v41,
difficulty: v42,
max_players: v43,
level_type: v44,
reduced_debug_info: v45,
}
})
}
}
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_i8((*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 v46 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v47 = (g.int_in(0, 255, &[]) as u8);
let v48 = (g.int_in(-128, 127, &[]) as i8);
let v49 = (g.int_in(0, 255, &[]) as u8);
let v50 = (g.int_in(0, 255, &[]) as u8);
let v51 = g.string();
let v52 = g.bool();
Login {
entity_id: v46,
game_mode: v47,
dimension: v48,
difficulty: v49,
max_players: v50,
level_type: v51,
reduced_debug_info: v52,
}
}
}
}
impl From<Login> for ClientboundPlayPacket {
fn from(p: Login) -> Self {
Self::Login(p)
}
}
/// `chat` (clientbound play, id 0x02).
#[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 v53 = r.read_string()?;
let v54 = r.read_i8()?;
Chat {
message: v53,
position: v54,
}
})
}
}
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 v55 = g.string();
let v56 = (g.int_in(-128, 127, &[]) as i8);
Chat {
message: v55,
position: v56,
}
}
}
}
impl From<Chat> for ClientboundPlayPacket {
fn from(p: Chat) -> Self {
Self::Chat(p)
}
}
/// `update_time` (clientbound play, id 0x03).
#[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 v57 = r.read_i64()?;
let v58 = r.read_i64()?;
UpdateTime {
age: v57,
time: v58,
}
})
}
}
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 v59 = g.i64();
let v60 = g.i64();
UpdateTime {
age: v59,
time: v60,
}
}
}
}
impl From<UpdateTime> for ClientboundPlayPacket {
fn from(p: UpdateTime) -> Self {
Self::UpdateTime(p)
}
}
/// `entity_equipment` (clientbound play, id 0x04).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityEquipment {
/// `entityId`
pub entity_id: i32,
/// `slot`
pub slot: i16,
/// `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 v61 = r.read_varint()?;
let v62 = r.read_i16()?;
let v63 = <types::Slot as Decode>::decode(r)?;
EntityEquipment {
entity_id: v61,
slot: v62,
item: v63,
}
})
}
}
impl Encode for EntityEquipment {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i16((*self).slot);
(*self).item.encode(w)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityEquipment {
fn generate(g: &mut Gen) -> Self {
{
let v64 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v65 = (g.int_in(-32768, 32767, &[]) as i16);
let v66 = <types::Slot as Generate>::generate(g);
EntityEquipment {
entity_id: v64,
slot: v65,
item: v66,
}
}
}
}
impl From<EntityEquipment> for ClientboundPlayPacket {
fn from(p: EntityEquipment) -> Self {
Self::EntityEquipment(p)
}
}
/// `spawn_position` (clientbound play, id 0x05).
#[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 v67 = BlockPos::read(r, PositionLayout::Xyz)?;
SpawnPosition { location: v67 }
})
}
}
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 v68 = g.position();
SpawnPosition { location: v68 }
}
}
}
impl From<SpawnPosition> for ClientboundPlayPacket {
fn from(p: SpawnPosition) -> Self {
Self::SpawnPosition(p)
}
}
/// `update_health` (clientbound play, id 0x06).
#[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 v69 = r.read_f32()?;
let v70 = r.read_varint()?;
let v71 = r.read_f32()?;
UpdateHealth {
health: v69,
food: v70,
food_saturation: v71,
}
})
}
}
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 v72 = g.f32();
let v73 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v74 = g.f32();
UpdateHealth {
health: v72,
food: v73,
food_saturation: v74,
}
}
}
}
impl From<UpdateHealth> for ClientboundPlayPacket {
fn from(p: UpdateHealth) -> Self {
Self::UpdateHealth(p)
}
}
/// `respawn` (clientbound play, id 0x07).
#[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 v75 = r.read_i32()?;
let v76 = r.read_u8()?;
let v77 = r.read_u8()?;
let v78 = r.read_string()?;
Respawn {
dimension: v75,
difficulty: v76,
gamemode: v77,
level_type: v78,
}
})
}
}
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 v79 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v80 = (g.int_in(0, 255, &[]) as u8);
let v81 = (g.int_in(0, 255, &[]) as u8);
let v82 = g.string();
Respawn {
dimension: v79,
difficulty: v80,
gamemode: v81,
level_type: v82,
}
}
}
}
impl From<Respawn> for ClientboundPlayPacket {
fn from(p: Respawn) -> Self {
Self::Respawn(p)
}
}
/// `position` (clientbound play, id 0x08).
#[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,
}
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 v83 = r.read_f64()?;
let v84 = r.read_f64()?;
let v85 = r.read_f64()?;
let v86 = r.read_f32()?;
let v87 = r.read_f32()?;
let v88 = r.read_i8()?;
Position {
x: v83,
y: v84,
z: v85,
yaw: v86,
pitch: v87,
flags: v88,
}
})
}
}
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);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Position {
fn generate(g: &mut Gen) -> Self {
{
let v89 = g.f64();
let v90 = g.f64();
let v91 = g.f64();
let v92 = g.f32();
let v93 = g.f32();
let v94 = (g.int_in(-128, 127, &[]) as i8);
Position {
x: v89,
y: v90,
z: v91,
yaw: v92,
pitch: v93,
flags: v94,
}
}
}
}
impl From<Position> for ClientboundPlayPacket {
fn from(p: Position) -> Self {
Self::Position(p)
}
}
/// `held_item_slot` (clientbound play, id 0x09).
#[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 v95 = r.read_i8()?;
HeldItemSlot { slot: v95 }
})
}
}
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 v96 = (g.int_in(-128, 127, &[]) as i8);
HeldItemSlot { slot: v96 }
}
}
}
impl From<HeldItemSlot> for ClientboundPlayPacket {
fn from(p: HeldItemSlot) -> Self {
Self::HeldItemSlot(p)
}
}
/// `bed` (clientbound play, id 0x0a).
#[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 v97 = r.read_varint()?;
let v98 = BlockPos::read(r, PositionLayout::Xyz)?;
Bed {
entity_id: v97,
location: v98,
}
})
}
}
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 v99 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v100 = g.position();
Bed {
entity_id: v99,
location: v100,
}
}
}
}
impl From<Bed> for ClientboundPlayPacket {
fn from(p: Bed) -> Self {
Self::Bed(p)
}
}
/// `animation` (clientbound play, id 0x0b).
#[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 v101 = r.read_varint()?;
let v102 = r.read_u8()?;
Animation {
entity_id: v101,
animation: v102,
}
})
}
}
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 v103 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v104 = (g.int_in(0, 255, &[]) as u8);
Animation {
entity_id: v103,
animation: v104,
}
}
}
}
impl From<Animation> for ClientboundPlayPacket {
fn from(p: Animation) -> Self {
Self::Animation(p)
}
}
/// `named_entity_spawn` (clientbound play, id 0x0c).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedEntitySpawn {
/// `entityId`
pub entity_id: i32,
/// `playerUUID`
pub player_uuid: Uuid,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `yaw`
pub yaw: i8,
/// `pitch`
pub pitch: i8,
/// `currentItem`
pub current_item: i16,
/// `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 v105 = r.read_varint()?;
let v106 = r.read_uuid()?;
let v107 = r.read_i32()?;
let v108 = r.read_i32()?;
let v109 = r.read_i32()?;
let v110 = r.read_i8()?;
let v111 = r.read_i8()?;
let v112 = r.read_i16()?;
let v113 = {
let mut v114 = Vec::new();
loop {
if r.peek_u8()? == 127 {
r.skip(1)?;
break;
}
v114.push({
let v115 = u64::from(r.read_u8()?);
let v116 = (((v115 >> 5) & 0x7) as u8);
let v117 = (((v115 >> 0) & 0x1f) as u8);
let v118 = (if (v116 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v116 == 1) {
types::EntityMetadataValue::Short(r.read_i16()?)
} else if (v116 == 2) {
types::EntityMetadataValue::Int(r.read_i32()?)
} else if (v116 == 3) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v116 == 4) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v116 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v116 == 6) {
types::EntityMetadataValue::BlockPos({
let v119 = r.read_i32()?;
let v120 = r.read_i32()?;
let v121 = r.read_i32()?;
types::EntityMetadataValueBlockPos {
x: v119,
y: v120,
z: v121,
}
})
} else if (v116 == 7) {
types::EntityMetadataValue::Rotation({
let v122 = r.read_f32()?;
let v123 = r.read_f32()?;
let v124 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v122,
yaw: v123,
roll: v124,
}
})
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
r#type: v116,
key: v117,
value: v118,
}
});
}
v114
};
NamedEntitySpawn {
entity_id: v105,
player_uuid: v106,
x: v107,
y: v108,
z: v109,
yaw: v110,
pitch: v111,
current_item: v112,
metadata: v113,
}
})
}
}
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_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_i16((*self).current_item);
for v125 in (*self).metadata.iter() {
let v126 = w.len();
{
let mut bits: u64 = 0;
{
let x = i128::from((*v125).r#type);
if x < 0 || x > 7 {
return Err(EncodeError::OutOfRange("type"));
}
bits = (bits << 3) | ((x as u64) & 0x7);
}
{
let x = i128::from((*v125).key);
if x < 0 || x > 31 {
return Err(EncodeError::OutOfRange("key"));
}
bits = (bits << 5) | ((x as u64) & 0x1f);
}
w.put_u8(bits as u8);
}
match &(*v125).value {
types::EntityMetadataValue::Byte(v127) => {
if !((*v125).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i8((*v127));
}
types::EntityMetadataValue::Short(v128) => {
if !((*v125).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i16((*v128));
}
types::EntityMetadataValue::Int(v129) => {
if !((*v125).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i32((*v129));
}
types::EntityMetadataValue::Float(v130) => {
if !((*v125).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v130));
}
types::EntityMetadataValue::String(v131) => {
if !((*v125).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_string(&(*v131))?;
}
types::EntityMetadataValue::Slot(v132) => {
if !((*v125).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
(*v132).encode(w)?;
}
types::EntityMetadataValue::BlockPos(v133) => {
if !((*v125).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_i32((*v133).x);
w.put_i32((*v133).y);
w.put_i32((*v133).z);
}
types::EntityMetadataValue::Rotation(v134) => {
if !((*v125).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
w.put_f32((*v134).pitch);
w.put_f32((*v134).yaw);
w.put_f32((*v134).roll);
}
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)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.named_entity_spawn.metadata.value",
));
}
}
}
if w.get(v126) == Some(&127) {
return Err(EncodeError::OutOfRange(
"play.clientbound.named_entity_spawn.metadata",
));
}
}
w.put_u8(127);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NamedEntitySpawn {
fn generate(g: &mut Gen) -> Self {
{
let v135 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v136 = g.uuid();
let v137 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v138 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v139 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v140 = (g.int_in(-128, 127, &[]) as i8);
let v141 = (g.int_in(-128, 127, &[]) as i8);
let v142 = (g.int_in(-32768, 32767, &[]) as i16);
let v143 = {
let n = g.count();
let mut v144 = Vec::with_capacity(n);
for _ in 0..n {
v144.push(loop { let v145 = { let v147 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v148 = (g.int_in(0, 31, &[]) as u8);let v149 = (if (v147 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v147 == 1) { types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v147 == 2) { types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v147 == 3) { types::EntityMetadataValue::Float(g.f32()) } else if (v147 == 4) { types::EntityMetadataValue::String(g.string()) } else if (v147 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v147 == 6) { types::EntityMetadataValue::BlockPos({ let v150 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v151 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v152 = (g.int_in(-2147483648, 2147483647, &[]) as i32); types::EntityMetadataValueBlockPos { x: v150, y: v151, z: v152 } }) } else if (v147 == 7) { types::EntityMetadataValue::Rotation({ let v153 = g.f32();let v154 = g.f32();let v155 = g.f32(); types::EntityMetadataValueRotation { pitch: v153, yaw: v154, roll: v155 } }) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { r#type: v147, key: v148, value: v149 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v145.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v145.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v145.value { types::EntityMetadataValue::Byte(v156) => { if !((v145.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i8((*v156)); }types::EntityMetadataValue::Short(v157) => { if !((v145.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i16((*v157)); }types::EntityMetadataValue::Int(v158) => { if !((v145.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v158)); }types::EntityMetadataValue::Float(v159) => { if !((v145.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v159)); }types::EntityMetadataValue::String(v160) => { if !((v145.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_string(&(*v160))?; }types::EntityMetadataValue::Slot(v161) => { if !((v145.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } (*v161).encode(w)?; }types::EntityMetadataValue::BlockPos(v162) => { if !((v145.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_i32((*v162).x);w.put_i32((*v162).y);w.put_i32((*v162).z); }types::EntityMetadataValue::Rotation(v163) => { if !((v145.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } w.put_f32((*v163).pitch);w.put_f32((*v163).yaw);w.put_f32((*v163).roll); }types::EntityMetadataValue::Other => { if !(!((v145.r#type == 0) || (v145.r#type == 1) || (v145.r#type == 2) || (v145.r#type == 3) || (v145.r#type == 4) || (v145.r#type == 5) || (v145.r#type == 6) || (v145.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.named_entity_spawn.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v145; } });
}
v144
};
NamedEntitySpawn {
entity_id: v135,
player_uuid: v136,
x: v137,
y: v138,
z: v139,
yaw: v140,
pitch: v141,
current_item: v142,
metadata: v143,
}
}
}
}
impl From<NamedEntitySpawn> for ClientboundPlayPacket {
fn from(p: NamedEntitySpawn) -> Self {
Self::NamedEntitySpawn(p)
}
}
/// `collect` (clientbound play, id 0x0d).
#[derive(Debug, Clone, PartialEq)]
pub struct Collect {
/// `collectedEntityId`
pub collected_entity_id: i32,
/// `collectorEntityId`
pub collector_entity_id: 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 v164 = r.read_varint()?;
let v165 = r.read_varint()?;
Collect {
collected_entity_id: v164,
collector_entity_id: v165,
}
})
}
}
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);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Collect {
fn generate(g: &mut Gen) -> Self {
{
let v166 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v167 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Collect {
collected_entity_id: v166,
collector_entity_id: v167,
}
}
}
}
impl From<Collect> for ClientboundPlayPacket {
fn from(p: Collect) -> Self {
Self::Collect(p)
}
}
/// `spawn_entity` (clientbound play, id 0x0e).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntity {
/// `entityId`
pub entity_id: i32,
/// `type`
pub r#type: i8,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `pitch`
pub pitch: i8,
/// `yaw`
pub yaw: i8,
/// `objectData`
pub object_data: i32,
/// `velocity` — present iff `objectData > 0`, as vanilla 1.8.9 reads it (minecraft-data says `!= 0`)
pub velocity: Option<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 v168 = r.read_varint()?;
let v169 = r.read_i8()?;
let v170 = r.read_i32()?;
let v171 = r.read_i32()?;
let v172 = r.read_i32()?;
let v173 = r.read_i8()?;
let v174 = r.read_i8()?;
let v175 = r.read_i32()?;
let v176 = if (v175 > 0) {
Some(<types::Vec3i16 as Decode>::decode(r)?)
} else {
None
};
SpawnEntity {
entity_id: v168,
r#type: v169,
x: v170,
y: v171,
z: v172,
pitch: v173,
yaw: v174,
object_data: v175,
velocity: v176,
}
})
}
}
impl Encode for SpawnEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).r#type);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_i8((*self).pitch);
w.put_i8((*self).yaw);
w.put_i32((*self).object_data);
match (&(*self).velocity, ((*self).object_data > 0)) {
(Some(v177), true) => {
(*v177).encode(w)?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity.velocity",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntity {
fn generate(g: &mut Gen) -> Self {
{
let v178 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v179 = (g.int_in(-128, 127, &[]) as i8);
let v180 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v181 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v182 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v183 = (g.int_in(-128, 127, &[]) as i8);
let v184 = (g.int_in(-128, 127, &[]) as i8);
let v185 = (g.int_in(-2147483648, 2147483647, &[0, 1, -1, 5, -2147483648]) as i32);
let v186 = if (v185 > 0) {
Some(<types::Vec3i16 as Generate>::generate(g))
} else {
None
};
SpawnEntity {
entity_id: v178,
r#type: v179,
x: v180,
y: v181,
z: v182,
pitch: v183,
yaw: v184,
object_data: v185,
velocity: v186,
}
}
}
}
impl From<SpawnEntity> for ClientboundPlayPacket {
fn from(p: SpawnEntity) -> Self {
Self::SpawnEntity(p)
}
}
/// `spawn_entity_living` (clientbound play, id 0x0f).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityLiving {
/// `entityId`
pub entity_id: i32,
/// `type`
pub r#type: u8,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `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 v187 = r.read_varint()?;
let v188 = r.read_u8()?;
let v189 = r.read_i32()?;
let v190 = r.read_i32()?;
let v191 = r.read_i32()?;
let v192 = r.read_i8()?;
let v193 = r.read_i8()?;
let v194 = r.read_i8()?;
let v195 = <types::Vec3i16 as Decode>::decode(r)?;
let v196 = {
let mut v197 = Vec::new();
loop {
if r.peek_u8()? == 127 {
r.skip(1)?;
break;
}
v197.push({
let v198 = u64::from(r.read_u8()?);
let v199 = (((v198 >> 5) & 0x7) as u8);
let v200 = (((v198 >> 0) & 0x1f) as u8);
let v201 = (if (v199 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v199 == 1) {
types::EntityMetadataValue::Short(r.read_i16()?)
} else if (v199 == 2) {
types::EntityMetadataValue::Int(r.read_i32()?)
} else if (v199 == 3) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v199 == 4) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v199 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v199 == 6) {
types::EntityMetadataValue::BlockPos({
let v202 = r.read_i32()?;
let v203 = r.read_i32()?;
let v204 = r.read_i32()?;
types::EntityMetadataValueBlockPos {
x: v202,
y: v203,
z: v204,
}
})
} else if (v199 == 7) {
types::EntityMetadataValue::Rotation({
let v205 = r.read_f32()?;
let v206 = r.read_f32()?;
let v207 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v205,
yaw: v206,
roll: v207,
}
})
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
r#type: v199,
key: v200,
value: v201,
}
});
}
v197
};
SpawnEntityLiving {
entity_id: v187,
r#type: v188,
x: v189,
y: v190,
z: v191,
yaw: v192,
pitch: v193,
head_pitch: v194,
velocity: v195,
metadata: v196,
}
})
}
}
impl Encode for SpawnEntityLiving {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_u8((*self).r#type);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_i8((*self).yaw);
w.put_i8((*self).pitch);
w.put_i8((*self).head_pitch);
(*self).velocity.encode(w)?;
for v208 in (*self).metadata.iter() {
let v209 = w.len();
{
let mut bits: u64 = 0;
{
let x = i128::from((*v208).r#type);
if x < 0 || x > 7 {
return Err(EncodeError::OutOfRange("type"));
}
bits = (bits << 3) | ((x as u64) & 0x7);
}
{
let x = i128::from((*v208).key);
if x < 0 || x > 31 {
return Err(EncodeError::OutOfRange("key"));
}
bits = (bits << 5) | ((x as u64) & 0x1f);
}
w.put_u8(bits as u8);
}
match &(*v208).value {
types::EntityMetadataValue::Byte(v210) => {
if !((*v208).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i8((*v210));
}
types::EntityMetadataValue::Short(v211) => {
if !((*v208).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i16((*v211));
}
types::EntityMetadataValue::Int(v212) => {
if !((*v208).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i32((*v212));
}
types::EntityMetadataValue::Float(v213) => {
if !((*v208).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v213));
}
types::EntityMetadataValue::String(v214) => {
if !((*v208).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_string(&(*v214))?;
}
types::EntityMetadataValue::Slot(v215) => {
if !((*v208).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
(*v215).encode(w)?;
}
types::EntityMetadataValue::BlockPos(v216) => {
if !((*v208).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_i32((*v216).x);
w.put_i32((*v216).y);
w.put_i32((*v216).z);
}
types::EntityMetadataValue::Rotation(v217) => {
if !((*v208).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
w.put_f32((*v217).pitch);
w.put_f32((*v217).yaw);
w.put_f32((*v217).roll);
}
types::EntityMetadataValue::Other => {
if !(!(((*v208).r#type == 0)
|| ((*v208).r#type == 1)
|| ((*v208).r#type == 2)
|| ((*v208).r#type == 3)
|| ((*v208).r#type == 4)
|| ((*v208).r#type == 5)
|| ((*v208).r#type == 6)
|| ((*v208).r#type == 7)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.spawn_entity_living.metadata.value",
));
}
}
}
if w.get(v209) == Some(&127) {
return Err(EncodeError::OutOfRange(
"play.clientbound.spawn_entity_living.metadata",
));
}
}
w.put_u8(127);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityLiving {
fn generate(g: &mut Gen) -> Self {
{
let v218 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v219 = (g.int_in(0, 255, &[]) as u8);
let v220 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v221 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v222 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v223 = (g.int_in(-128, 127, &[]) as i8);
let v224 = (g.int_in(-128, 127, &[]) as i8);
let v225 = (g.int_in(-128, 127, &[]) as i8);
let v226 = <types::Vec3i16 as Generate>::generate(g);
let v227 = {
let n = g.count();
let mut v228 = Vec::with_capacity(n);
for _ in 0..n {
v228.push(loop { let v229 = { let v231 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);let v232 = (g.int_in(0, 31, &[]) as u8);let v233 = (if (v231 == 0) { types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8)) } else if (v231 == 1) { types::EntityMetadataValue::Short((g.int_in(-32768, 32767, &[]) as i16)) } else if (v231 == 2) { types::EntityMetadataValue::Int((g.int_in(-2147483648, 2147483647, &[]) as i32)) } else if (v231 == 3) { types::EntityMetadataValue::Float(g.f32()) } else if (v231 == 4) { types::EntityMetadataValue::String(g.string()) } else if (v231 == 5) { types::EntityMetadataValue::Slot(<types::Slot as Generate>::generate(g)) } else if (v231 == 6) { types::EntityMetadataValue::BlockPos({ let v234 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v235 = (g.int_in(-2147483648, 2147483647, &[]) as i32);let v236 = (g.int_in(-2147483648, 2147483647, &[]) as i32); types::EntityMetadataValueBlockPos { x: v234, y: v235, z: v236 } }) } else if (v231 == 7) { types::EntityMetadataValue::Rotation({ let v237 = g.f32();let v238 = g.f32();let v239 = g.f32(); types::EntityMetadataValueRotation { pitch: v237, yaw: v238, roll: v239 } }) } else { types::EntityMetadataValue::Other }); types::EntityMetadataEntry { r#type: v231, key: v232, value: v233 } }; if crate::testgen::first_byte_ok(|w: &mut BytesMut| -> EncodeResult { { let mut bits: u64 = 0;{ let x = i128::from(v229.r#type); if x < 0 || x > 7 { return Err(EncodeError::OutOfRange("type")); } bits = (bits << 3) | ((x as u64) & 0x7); }{ let x = i128::from(v229.key); if x < 0 || x > 31 { return Err(EncodeError::OutOfRange("key")); } bits = (bits << 5) | ((x as u64) & 0x1f); }w.put_u8(bits as u8); }match &v229.value { types::EntityMetadataValue::Byte(v240) => { if !((v229.r#type == 0)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i8((*v240)); }types::EntityMetadataValue::Short(v241) => { if !((v229.r#type == 1)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i16((*v241)); }types::EntityMetadataValue::Int(v242) => { if !((v229.r#type == 2)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v242)); }types::EntityMetadataValue::Float(v243) => { if !((v229.r#type == 3)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v243)); }types::EntityMetadataValue::String(v244) => { if !((v229.r#type == 4)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_string(&(*v244))?; }types::EntityMetadataValue::Slot(v245) => { if !((v229.r#type == 5)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } (*v245).encode(w)?; }types::EntityMetadataValue::BlockPos(v246) => { if !((v229.r#type == 6)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_i32((*v246).x);w.put_i32((*v246).y);w.put_i32((*v246).z); }types::EntityMetadataValue::Rotation(v247) => { if !((v229.r#type == 7)) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } w.put_f32((*v247).pitch);w.put_f32((*v247).yaw);w.put_f32((*v247).roll); }types::EntityMetadataValue::Other => { if !(!((v229.r#type == 0) || (v229.r#type == 1) || (v229.r#type == 2) || (v229.r#type == 3) || (v229.r#type == 4) || (v229.r#type == 5) || (v229.r#type == 6) || (v229.r#type == 7))) { return Err(EncodeError::SwitchMismatch("play.clientbound.spawn_entity_living.metadata.value")); } } } Ok(()) }, |b| b != 127) { break v229; } });
}
v228
};
SpawnEntityLiving {
entity_id: v218,
r#type: v219,
x: v220,
y: v221,
z: v222,
yaw: v223,
pitch: v224,
head_pitch: v225,
velocity: v226,
metadata: v227,
}
}
}
}
impl From<SpawnEntityLiving> for ClientboundPlayPacket {
fn from(p: SpawnEntityLiving) -> Self {
Self::SpawnEntityLiving(p)
}
}
/// `spawn_entity_painting` (clientbound play, id 0x10).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityPainting {
/// `entityId`
pub entity_id: i32,
/// `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 v248 = r.read_varint()?;
let v249 = r.read_string()?;
let v250 = BlockPos::read(r, PositionLayout::Xyz)?;
let v251 = r.read_u8()?;
SpawnEntityPainting {
entity_id: v248,
title: v249,
location: v250,
direction: v251,
}
})
}
}
impl Encode for SpawnEntityPainting {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
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 v252 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v253 = g.string();
let v254 = g.position();
let v255 = (g.int_in(0, 255, &[]) as u8);
SpawnEntityPainting {
entity_id: v252,
title: v253,
location: v254,
direction: v255,
}
}
}
}
impl From<SpawnEntityPainting> for ClientboundPlayPacket {
fn from(p: SpawnEntityPainting) -> Self {
Self::SpawnEntityPainting(p)
}
}
/// `spawn_entity_experience_orb` (clientbound play, id 0x11).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityExperienceOrb {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `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 v256 = r.read_varint()?;
let v257 = r.read_i32()?;
let v258 = r.read_i32()?;
let v259 = r.read_i32()?;
let v260 = r.read_i16()?;
SpawnEntityExperienceOrb {
entity_id: v256,
x: v257,
y: v258,
z: v259,
count: v260,
}
})
}
}
impl Encode for SpawnEntityExperienceOrb {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_i16((*self).count);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityExperienceOrb {
fn generate(g: &mut Gen) -> Self {
{
let v261 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v262 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v263 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v264 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v265 = (g.int_in(-32768, 32767, &[]) as i16);
SpawnEntityExperienceOrb {
entity_id: v261,
x: v262,
y: v263,
z: v264,
count: v265,
}
}
}
}
impl From<SpawnEntityExperienceOrb> for ClientboundPlayPacket {
fn from(p: SpawnEntityExperienceOrb) -> Self {
Self::SpawnEntityExperienceOrb(p)
}
}
/// `entity_velocity` (clientbound play, id 0x12).
#[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 v266 = r.read_varint()?;
let v267 = <types::Vec3i16 as Decode>::decode(r)?;
EntityVelocity {
entity_id: v266,
velocity: v267,
}
})
}
}
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 v268 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v269 = <types::Vec3i16 as Generate>::generate(g);
EntityVelocity {
entity_id: v268,
velocity: v269,
}
}
}
}
impl From<EntityVelocity> for ClientboundPlayPacket {
fn from(p: EntityVelocity) -> Self {
Self::EntityVelocity(p)
}
}
/// `entity_destroy` (clientbound play, id 0x13).
#[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 v270 = {
let v271 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v272 = Vec::with_capacity(v271.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v271 {
v272.push(r.read_varint()?);
}
v272
};
EntityDestroy { entity_ids: v270 }
})
}
}
impl Encode for EntityDestroy {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entity_ids.len())?;
for v273 in (*self).entity_ids.iter() {
w.put_varint((*v273));
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityDestroy {
fn generate(g: &mut Gen) -> Self {
{
let v274 = {
let v275 = g.count();
let mut v276 = Vec::with_capacity(v275.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v275 {
v276.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v276
};
EntityDestroy { entity_ids: v274 }
}
}
}
impl From<EntityDestroy> for ClientboundPlayPacket {
fn from(p: EntityDestroy) -> Self {
Self::EntityDestroy(p)
}
}
/// `entity` (clientbound play, id 0x14).
#[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 v277 = r.read_varint()?;
Entity { entity_id: v277 }
})
}
}
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 v278 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Entity { entity_id: v278 }
}
}
}
impl From<Entity> for ClientboundPlayPacket {
fn from(p: Entity) -> Self {
Self::Entity(p)
}
}
/// `rel_entity_move` (clientbound play, id 0x15).
#[derive(Debug, Clone, PartialEq)]
pub struct RelEntityMove {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i8,
/// `dY`
pub d_y: i8,
/// `dZ`
pub d_z: i8,
/// `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 v279 = r.read_varint()?;
let v280 = r.read_i8()?;
let v281 = r.read_i8()?;
let v282 = r.read_i8()?;
let v283 = r.read_bool()?;
RelEntityMove {
entity_id: v279,
d_x: v280,
d_y: v281,
d_z: v282,
on_ground: v283,
}
})
}
}
impl Encode for RelEntityMove {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).d_x);
w.put_i8((*self).d_y);
w.put_i8((*self).d_z);
w.put_bool((*self).on_ground);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for RelEntityMove {
fn generate(g: &mut Gen) -> Self {
{
let v284 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v285 = (g.int_in(-128, 127, &[]) as i8);
let v286 = (g.int_in(-128, 127, &[]) as i8);
let v287 = (g.int_in(-128, 127, &[]) as i8);
let v288 = g.bool();
RelEntityMove {
entity_id: v284,
d_x: v285,
d_y: v286,
d_z: v287,
on_ground: v288,
}
}
}
}
impl From<RelEntityMove> for ClientboundPlayPacket {
fn from(p: RelEntityMove) -> Self {
Self::RelEntityMove(p)
}
}
/// `entity_look` (clientbound play, id 0x16).
#[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 v289 = r.read_varint()?;
let v290 = r.read_i8()?;
let v291 = r.read_i8()?;
let v292 = r.read_bool()?;
EntityLook {
entity_id: v289,
yaw: v290,
pitch: v291,
on_ground: v292,
}
})
}
}
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 v293 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v294 = (g.int_in(-128, 127, &[]) as i8);
let v295 = (g.int_in(-128, 127, &[]) as i8);
let v296 = g.bool();
EntityLook {
entity_id: v293,
yaw: v294,
pitch: v295,
on_ground: v296,
}
}
}
}
impl From<EntityLook> for ClientboundPlayPacket {
fn from(p: EntityLook) -> Self {
Self::EntityLook(p)
}
}
/// `entity_move_look` (clientbound play, id 0x17).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityMoveLook {
/// `entityId`
pub entity_id: i32,
/// `dX`
pub d_x: i8,
/// `dY`
pub d_y: i8,
/// `dZ`
pub d_z: i8,
/// `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 v297 = r.read_varint()?;
let v298 = r.read_i8()?;
let v299 = r.read_i8()?;
let v300 = r.read_i8()?;
let v301 = r.read_i8()?;
let v302 = r.read_i8()?;
let v303 = r.read_bool()?;
EntityMoveLook {
entity_id: v297,
d_x: v298,
d_y: v299,
d_z: v300,
yaw: v301,
pitch: v302,
on_ground: v303,
}
})
}
}
impl Encode for EntityMoveLook {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i8((*self).d_x);
w.put_i8((*self).d_y);
w.put_i8((*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 v304 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v305 = (g.int_in(-128, 127, &[]) as i8);
let v306 = (g.int_in(-128, 127, &[]) as i8);
let v307 = (g.int_in(-128, 127, &[]) as i8);
let v308 = (g.int_in(-128, 127, &[]) as i8);
let v309 = (g.int_in(-128, 127, &[]) as i8);
let v310 = g.bool();
EntityMoveLook {
entity_id: v304,
d_x: v305,
d_y: v306,
d_z: v307,
yaw: v308,
pitch: v309,
on_ground: v310,
}
}
}
}
impl From<EntityMoveLook> for ClientboundPlayPacket {
fn from(p: EntityMoveLook) -> Self {
Self::EntityMoveLook(p)
}
}
/// `entity_teleport` (clientbound play, id 0x18).
#[derive(Debug, Clone, PartialEq)]
pub struct EntityTeleport {
/// `entityId`
pub entity_id: i32,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `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 v311 = r.read_varint()?;
let v312 = r.read_i32()?;
let v313 = r.read_i32()?;
let v314 = r.read_i32()?;
let v315 = r.read_i8()?;
let v316 = r.read_i8()?;
let v317 = r.read_bool()?;
EntityTeleport {
entity_id: v311,
x: v312,
y: v313,
z: v314,
yaw: v315,
pitch: v316,
on_ground: v317,
}
})
}
}
impl Encode for EntityTeleport {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*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 v318 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v319 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v320 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v321 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v322 = (g.int_in(-128, 127, &[]) as i8);
let v323 = (g.int_in(-128, 127, &[]) as i8);
let v324 = g.bool();
EntityTeleport {
entity_id: v318,
x: v319,
y: v320,
z: v321,
yaw: v322,
pitch: v323,
on_ground: v324,
}
}
}
}
impl From<EntityTeleport> for ClientboundPlayPacket {
fn from(p: EntityTeleport) -> Self {
Self::EntityTeleport(p)
}
}
/// `entity_head_rotation` (clientbound play, id 0x19).
#[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 v325 = r.read_varint()?;
let v326 = r.read_i8()?;
EntityHeadRotation {
entity_id: v325,
head_yaw: v326,
}
})
}
}
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 v327 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v328 = (g.int_in(-128, 127, &[]) as i8);
EntityHeadRotation {
entity_id: v327,
head_yaw: v328,
}
}
}
}
impl From<EntityHeadRotation> for ClientboundPlayPacket {
fn from(p: EntityHeadRotation) -> Self {
Self::EntityHeadRotation(p)
}
}
/// `entity_status` (clientbound play, id 0x1a).
#[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 v329 = r.read_i32()?;
let v330 = r.read_i8()?;
EntityStatus {
entity_id: v329,
entity_status: v330,
}
})
}
}
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 v331 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v332 = (g.int_in(-128, 127, &[]) as i8);
EntityStatus {
entity_id: v331,
entity_status: v332,
}
}
}
}
impl From<EntityStatus> for ClientboundPlayPacket {
fn from(p: EntityStatus) -> Self {
Self::EntityStatus(p)
}
}
/// `attach_entity` (clientbound play, id 0x1b).
#[derive(Debug, Clone, PartialEq)]
pub struct AttachEntity {
/// `entityId`
pub entity_id: i32,
/// `vehicleId`
pub vehicle_id: i32,
/// `leash`
pub leash: bool,
}
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 v333 = r.read_i32()?;
let v334 = r.read_i32()?;
let v335 = r.read_bool()?;
AttachEntity {
entity_id: v333,
vehicle_id: v334,
leash: v335,
}
})
}
}
impl Encode for AttachEntity {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_i32((*self).entity_id);
w.put_i32((*self).vehicle_id);
w.put_bool((*self).leash);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for AttachEntity {
fn generate(g: &mut Gen) -> Self {
{
let v336 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v337 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v338 = g.bool();
AttachEntity {
entity_id: v336,
vehicle_id: v337,
leash: v338,
}
}
}
}
impl From<AttachEntity> for ClientboundPlayPacket {
fn from(p: AttachEntity) -> Self {
Self::AttachEntity(p)
}
}
/// `entity_metadata` (clientbound play, id 0x1c).
#[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 v339 = r.read_varint()?;
let v340 = {
let mut v341 = Vec::new();
loop {
if r.peek_u8()? == 127 {
r.skip(1)?;
break;
}
v341.push({
let v342 = u64::from(r.read_u8()?);
let v343 = (((v342 >> 5) & 0x7) as u8);
let v344 = (((v342 >> 0) & 0x1f) as u8);
let v345 = (if (v343 == 0) {
types::EntityMetadataValue::Byte(r.read_i8()?)
} else if (v343 == 1) {
types::EntityMetadataValue::Short(r.read_i16()?)
} else if (v343 == 2) {
types::EntityMetadataValue::Int(r.read_i32()?)
} else if (v343 == 3) {
types::EntityMetadataValue::Float(r.read_f32()?)
} else if (v343 == 4) {
types::EntityMetadataValue::String(r.read_string()?)
} else if (v343 == 5) {
types::EntityMetadataValue::Slot(<types::Slot as Decode>::decode(r)?)
} else if (v343 == 6) {
types::EntityMetadataValue::BlockPos({
let v346 = r.read_i32()?;
let v347 = r.read_i32()?;
let v348 = r.read_i32()?;
types::EntityMetadataValueBlockPos {
x: v346,
y: v347,
z: v348,
}
})
} else if (v343 == 7) {
types::EntityMetadataValue::Rotation({
let v349 = r.read_f32()?;
let v350 = r.read_f32()?;
let v351 = r.read_f32()?;
types::EntityMetadataValueRotation {
pitch: v349,
yaw: v350,
roll: v351,
}
})
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
r#type: v343,
key: v344,
value: v345,
}
});
}
v341
};
EntityMetadata {
entity_id: v339,
metadata: v340,
}
})
}
}
impl Encode for EntityMetadata {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
for v352 in (*self).metadata.iter() {
let v353 = w.len();
{
let mut bits: u64 = 0;
{
let x = i128::from((*v352).r#type);
if x < 0 || x > 7 {
return Err(EncodeError::OutOfRange("type"));
}
bits = (bits << 3) | ((x as u64) & 0x7);
}
{
let x = i128::from((*v352).key);
if x < 0 || x > 31 {
return Err(EncodeError::OutOfRange("key"));
}
bits = (bits << 5) | ((x as u64) & 0x1f);
}
w.put_u8(bits as u8);
}
match &(*v352).value {
types::EntityMetadataValue::Byte(v354) => {
if !((*v352).r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v354));
}
types::EntityMetadataValue::Short(v355) => {
if !((*v352).r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i16((*v355));
}
types::EntityMetadataValue::Int(v356) => {
if !((*v352).r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i32((*v356));
}
types::EntityMetadataValue::Float(v357) => {
if !((*v352).r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v357));
}
types::EntityMetadataValue::String(v358) => {
if !((*v352).r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v358))?;
}
types::EntityMetadataValue::Slot(v359) => {
if !((*v352).r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v359).encode(w)?;
}
types::EntityMetadataValue::BlockPos(v360) => {
if !((*v352).r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i32((*v360).x);
w.put_i32((*v360).y);
w.put_i32((*v360).z);
}
types::EntityMetadataValue::Rotation(v361) => {
if !((*v352).r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v361).pitch);
w.put_f32((*v361).yaw);
w.put_f32((*v361).roll);
}
types::EntityMetadataValue::Other => {
if !(!(((*v352).r#type == 0)
|| ((*v352).r#type == 1)
|| ((*v352).r#type == 2)
|| ((*v352).r#type == 3)
|| ((*v352).r#type == 4)
|| ((*v352).r#type == 5)
|| ((*v352).r#type == 6)
|| ((*v352).r#type == 7)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
if w.get(v353) == Some(&127) {
return Err(EncodeError::OutOfRange(
"play.clientbound.entity_metadata.metadata",
));
}
}
w.put_u8(127);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityMetadata {
fn generate(g: &mut Gen) -> Self {
{
let v362 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v363 = {
let n = g.count();
let mut v364 = Vec::with_capacity(n);
for _ in 0..n {
v364.push(loop {
let v365 = {
let v367 = (g.int_in(0, 7, &[0, 1, 2, 3, 4, 5, 6, 7]) as u8);
let v368 = (g.int_in(0, 31, &[]) as u8);
let v369 = (if (v367 == 0) {
types::EntityMetadataValue::Byte((g.int_in(-128, 127, &[]) as i8))
} else if (v367 == 1) {
types::EntityMetadataValue::Short(
(g.int_in(-32768, 32767, &[]) as i16),
)
} else if (v367 == 2) {
types::EntityMetadataValue::Int(
(g.int_in(-2147483648, 2147483647, &[]) as i32),
)
} else if (v367 == 3) {
types::EntityMetadataValue::Float(g.f32())
} else if (v367 == 4) {
types::EntityMetadataValue::String(g.string())
} else if (v367 == 5) {
types::EntityMetadataValue::Slot(
<types::Slot as Generate>::generate(g),
)
} else if (v367 == 6) {
types::EntityMetadataValue::BlockPos({
let v370 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v371 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v372 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
types::EntityMetadataValueBlockPos {
x: v370,
y: v371,
z: v372,
}
})
} else if (v367 == 7) {
types::EntityMetadataValue::Rotation({
let v373 = g.f32();
let v374 = g.f32();
let v375 = g.f32();
types::EntityMetadataValueRotation {
pitch: v373,
yaw: v374,
roll: v375,
}
})
} else {
types::EntityMetadataValue::Other
});
types::EntityMetadataEntry {
r#type: v367,
key: v368,
value: v369,
}
};
if crate::testgen::first_byte_ok(
|w: &mut BytesMut| -> EncodeResult {
{
let mut bits: u64 = 0;
{
let x = i128::from(v365.r#type);
if x < 0 || x > 7 {
return Err(EncodeError::OutOfRange("type"));
}
bits = (bits << 3) | ((x as u64) & 0x7);
}
{
let x = i128::from(v365.key);
if x < 0 || x > 31 {
return Err(EncodeError::OutOfRange("key"));
}
bits = (bits << 5) | ((x as u64) & 0x1f);
}
w.put_u8(bits as u8);
}
match &v365.value {
types::EntityMetadataValue::Byte(v376) => {
if !(v365.r#type == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i8((*v376));
}
types::EntityMetadataValue::Short(v377) => {
if !(v365.r#type == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i16((*v377));
}
types::EntityMetadataValue::Int(v378) => {
if !(v365.r#type == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i32((*v378));
}
types::EntityMetadataValue::Float(v379) => {
if !(v365.r#type == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v379));
}
types::EntityMetadataValue::String(v380) => {
if !(v365.r#type == 4) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_string(&(*v380))?;
}
types::EntityMetadataValue::Slot(v381) => {
if !(v365.r#type == 5) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
(*v381).encode(w)?;
}
types::EntityMetadataValue::BlockPos(v382) => {
if !(v365.r#type == 6) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_i32((*v382).x);
w.put_i32((*v382).y);
w.put_i32((*v382).z);
}
types::EntityMetadataValue::Rotation(v383) => {
if !(v365.r#type == 7) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
w.put_f32((*v383).pitch);
w.put_f32((*v383).yaw);
w.put_f32((*v383).roll);
}
types::EntityMetadataValue::Other => {
if !(!((v365.r#type == 0)
|| (v365.r#type == 1)
|| (v365.r#type == 2)
|| (v365.r#type == 3)
|| (v365.r#type == 4)
|| (v365.r#type == 5)
|| (v365.r#type == 6)
|| (v365.r#type == 7)))
{
return Err(EncodeError::SwitchMismatch(
"play.clientbound.entity_metadata.metadata.value",
));
}
}
}
Ok(())
},
|b| b != 127,
) {
break v365;
}
});
}
v364
};
EntityMetadata {
entity_id: v362,
metadata: v363,
}
}
}
}
impl From<EntityMetadata> for ClientboundPlayPacket {
fn from(p: EntityMetadata) -> Self {
Self::EntityMetadata(p)
}
}
/// `entity_effect` (clientbound play, id 0x1d).
#[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: bool,
}
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 v384 = r.read_varint()?;
let v385 = r.read_i8()?;
let v386 = r.read_i8()?;
let v387 = r.read_varint()?;
let v388 = r.read_bool()?;
EntityEffect {
entity_id: v384,
effect_id: v385,
amplifier: v386,
duration: v387,
hide_particles: v388,
}
})
}
}
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_bool((*self).hide_particles);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for EntityEffect {
fn generate(g: &mut Gen) -> Self {
{
let v389 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v390 = (g.int_in(-128, 127, &[]) as i8);
let v391 = (g.int_in(-128, 127, &[]) as i8);
let v392 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v393 = g.bool();
EntityEffect {
entity_id: v389,
effect_id: v390,
amplifier: v391,
duration: v392,
hide_particles: v393,
}
}
}
}
impl From<EntityEffect> for ClientboundPlayPacket {
fn from(p: EntityEffect) -> Self {
Self::EntityEffect(p)
}
}
/// `remove_entity_effect` (clientbound play, id 0x1e).
#[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 v394 = r.read_varint()?;
let v395 = r.read_i8()?;
RemoveEntityEffect {
entity_id: v394,
effect_id: v395,
}
})
}
}
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 v396 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v397 = (g.int_in(-128, 127, &[]) as i8);
RemoveEntityEffect {
entity_id: v396,
effect_id: v397,
}
}
}
}
impl From<RemoveEntityEffect> for ClientboundPlayPacket {
fn from(p: RemoveEntityEffect) -> Self {
Self::RemoveEntityEffect(p)
}
}
/// `experience` (clientbound play, id 0x1f).
#[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 v398 = r.read_f32()?;
let v399 = r.read_varint()?;
let v400 = r.read_varint()?;
Experience {
experience_bar: v398,
level: v399,
total_experience: v400,
}
})
}
}
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 v401 = g.f32();
let v402 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v403 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Experience {
experience_bar: v401,
level: v402,
total_experience: v403,
}
}
}
}
impl From<Experience> for ClientboundPlayPacket {
fn from(p: Experience) -> Self {
Self::Experience(p)
}
}
/// `update_attributes` (clientbound play, id 0x20).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateAttributes {
/// `entityId`
pub entity_id: i32,
/// `properties`
pub properties: Vec<UpdateAttributesProperties>,
}
impl crate::packet::Packet for UpdateAttributes {
const ID: i32 = id::UPDATE_ATTRIBUTES;
const NAME: &'static str = "update_attributes";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateAttributes {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v404 = r.read_varint()?;
let v405 = {
let v406 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 10)?
};
let mut v407 = Vec::with_capacity(v406.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v406 {
v407.push({
let v408 = r.read_string()?;
let v409 = r.read_f64()?;
let v410 = {
let v411 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 25)?
};
let mut v412 =
Vec::with_capacity(v411.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v411 {
v412.push({
let v413 = r.read_uuid()?;
let v414 = r.read_f64()?;
let v415 = r.read_i8()?;
UpdateAttributesPropertiesModifiers {
uuid: v413,
amount: v414,
operation: v415,
}
});
}
v412
};
UpdateAttributesProperties {
key: v408,
value: v409,
modifiers: v410,
}
});
}
v407
};
UpdateAttributes {
entity_id: v404,
properties: v405,
}
})
}
}
impl Encode for UpdateAttributes {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
w.put_i32(crate::codec::count_i32((*self).properties.len())?);
for v416 in (*self).properties.iter() {
w.put_string(&(*v416).key)?;
w.put_f64((*v416).value);
w.put_len_varint((*v416).modifiers.len())?;
for v417 in (*v416).modifiers.iter() {
w.put_uuid(&(*v417).uuid);
w.put_f64((*v417).amount);
w.put_i8((*v417).operation);
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateAttributes {
fn generate(g: &mut Gen) -> Self {
{
let v418 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v419 = {
let v420 = g.count();
let mut v421 = Vec::with_capacity(v420.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v420 {
v421.push({
let v422 = g.string();
let v423 = g.f64();
let v424 = {
let v425 = g.count();
let mut v426 =
Vec::with_capacity(v425.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v425 {
v426.push({
let v427 = g.uuid();
let v428 = g.f64();
let v429 = (g.int_in(-128, 127, &[]) as i8);
UpdateAttributesPropertiesModifiers {
uuid: v427,
amount: v428,
operation: v429,
}
});
}
v426
};
UpdateAttributesProperties {
key: v422,
value: v423,
modifiers: v424,
}
});
}
v421
};
UpdateAttributes {
entity_id: v418,
properties: v419,
}
}
}
}
impl From<UpdateAttributes> for ClientboundPlayPacket {
fn from(p: UpdateAttributes) -> Self {
Self::UpdateAttributes(p)
}
}
/// `map_chunk` (clientbound play, id 0x21).
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunk {
/// `x`
pub x: i32,
/// `z`
pub z: i32,
/// `groundUp`
pub ground_up: bool,
/// `bitMap`
pub bit_map: u16,
/// `chunkData`
pub chunk_data: Bytes,
}
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 v430 = r.read_i32()?;
let v431 = r.read_i32()?;
let v432 = r.read_bool()?;
let v433 = r.read_u16()?;
let v434 = r.read_byte_array()?;
MapChunk {
x: v430,
z: v431,
ground_up: v432,
bit_map: v433,
chunk_data: v434,
}
})
}
}
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_u16((*self).bit_map);
w.put_byte_array(&(*self).chunk_data)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MapChunk {
fn generate(g: &mut Gen) -> Self {
{
let v435 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v436 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v437 = g.bool();
let v438 = (g.int_in(0, 65535, &[]) as u16);
let v439 = g.bytes();
MapChunk {
x: v435,
z: v436,
ground_up: v437,
bit_map: v438,
chunk_data: v439,
}
}
}
}
impl From<MapChunk> for ClientboundPlayPacket {
fn from(p: MapChunk) -> Self {
Self::MapChunk(p)
}
}
/// `multi_block_change` (clientbound play, id 0x22).
#[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 v440 = r.read_i32()?;
let v441 = r.read_i32()?;
let v442 = {
let v443 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v444 = Vec::with_capacity(v443.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v443 {
v444.push({
let v445 = r.read_u8()?;
let v446 = r.read_u8()?;
let v447 = r.read_varint()?;
MultiBlockChangeRecords {
horizontal_pos: v445,
y: v446,
block_id: v447,
}
});
}
v444
};
MultiBlockChange {
chunk_x: v440,
chunk_z: v441,
records: v442,
}
})
}
}
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 v448 in (*self).records.iter() {
w.put_u8((*v448).horizontal_pos);
w.put_u8((*v448).y);
w.put_varint((*v448).block_id);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MultiBlockChange {
fn generate(g: &mut Gen) -> Self {
{
let v449 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v450 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v451 = {
let v452 = g.count();
let mut v453 = Vec::with_capacity(v452.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v452 {
v453.push({
let v454 = (g.int_in(0, 255, &[]) as u8);
let v455 = (g.int_in(0, 255, &[]) as u8);
let v456 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
MultiBlockChangeRecords {
horizontal_pos: v454,
y: v455,
block_id: v456,
}
});
}
v453
};
MultiBlockChange {
chunk_x: v449,
chunk_z: v450,
records: v451,
}
}
}
}
impl From<MultiBlockChange> for ClientboundPlayPacket {
fn from(p: MultiBlockChange) -> Self {
Self::MultiBlockChange(p)
}
}
/// `block_change` (clientbound play, id 0x23).
#[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 v457 = BlockPos::read(r, PositionLayout::Xyz)?;
let v458 = r.read_varint()?;
BlockChange {
location: v457,
r#type: v458,
}
})
}
}
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 v459 = g.position();
let v460 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockChange {
location: v459,
r#type: v460,
}
}
}
}
impl From<BlockChange> for ClientboundPlayPacket {
fn from(p: BlockChange) -> Self {
Self::BlockChange(p)
}
}
/// `block_action` (clientbound play, id 0x24).
#[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 v461 = BlockPos::read(r, PositionLayout::Xyz)?;
let v462 = r.read_u8()?;
let v463 = r.read_u8()?;
let v464 = r.read_varint()?;
BlockAction {
location: v461,
byte1: v462,
byte2: v463,
block_id: v464,
}
})
}
}
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 v465 = g.position();
let v466 = (g.int_in(0, 255, &[]) as u8);
let v467 = (g.int_in(0, 255, &[]) as u8);
let v468 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
BlockAction {
location: v465,
byte1: v466,
byte2: v467,
block_id: v468,
}
}
}
}
impl From<BlockAction> for ClientboundPlayPacket {
fn from(p: BlockAction) -> Self {
Self::BlockAction(p)
}
}
/// `block_break_animation` (clientbound play, id 0x25).
#[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 v469 = r.read_varint()?;
let v470 = BlockPos::read(r, PositionLayout::Xyz)?;
let v471 = r.read_i8()?;
BlockBreakAnimation {
entity_id: v469,
location: v470,
destroy_stage: v471,
}
})
}
}
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 v472 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v473 = g.position();
let v474 = (g.int_in(-128, 127, &[]) as i8);
BlockBreakAnimation {
entity_id: v472,
location: v473,
destroy_stage: v474,
}
}
}
}
impl From<BlockBreakAnimation> for ClientboundPlayPacket {
fn from(p: BlockBreakAnimation) -> Self {
Self::BlockBreakAnimation(p)
}
}
/// `map_chunk_bulk` (clientbound play, id 0x26).
#[derive(Debug, Clone, PartialEq)]
pub struct MapChunkBulk {
/// `skyLightSent`
pub sky_light_sent: bool,
/// `meta`
pub meta: Vec<MapChunkBulkMeta>,
/// `data`
pub data: Bytes,
}
impl crate::packet::Packet for MapChunkBulk {
const ID: i32 = id::MAP_CHUNK_BULK;
const NAME: &'static str = "map_chunk_bulk";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for MapChunkBulk {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v475 = r.read_bool()?;
let v476 = {
let v477 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 10)?
};
let mut v478 = Vec::with_capacity(v477.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v477 {
v478.push({
let v479 = r.read_i32()?;
let v480 = r.read_i32()?;
let v481 = r.read_u16()?;
MapChunkBulkMeta {
x: v479,
z: v480,
bit_map: v481,
}
});
}
v478
};
let v482 = r.read_rest();
MapChunkBulk {
sky_light_sent: v475,
meta: v476,
data: v482,
}
})
}
}
impl Encode for MapChunkBulk {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_bool((*self).sky_light_sent);
w.put_len_varint((*self).meta.len())?;
for v483 in (*self).meta.iter() {
w.put_i32((*v483).x);
w.put_i32((*v483).z);
w.put_u16((*v483).bit_map);
}
w.put_slice(&(*self).data);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for MapChunkBulk {
fn generate(g: &mut Gen) -> Self {
{
let v484 = g.bool();
let v485 = {
let v486 = g.count();
let mut v487 = Vec::with_capacity(v486.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v486 {
v487.push({
let v488 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v489 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v490 = (g.int_in(0, 65535, &[]) as u16);
MapChunkBulkMeta {
x: v488,
z: v489,
bit_map: v490,
}
});
}
v487
};
let v491 = g.bytes();
MapChunkBulk {
sky_light_sent: v484,
meta: v485,
data: v491,
}
}
}
}
impl From<MapChunkBulk> for ClientboundPlayPacket {
fn from(p: MapChunkBulk) -> Self {
Self::MapChunkBulk(p)
}
}
/// `explosion` (clientbound play, id 0x27).
#[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 v492 = r.read_f32()?;
let v493 = r.read_f32()?;
let v494 = r.read_f32()?;
let v495 = r.read_f32()?;
let v496 = {
let v497 = {
let c = r.read_i32()?;
r.check_count(i64::from(c), 3)?
};
let mut v498 = Vec::with_capacity(v497.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v497 {
v498.push({
let v499 = r.read_i8()?;
let v500 = r.read_i8()?;
let v501 = r.read_i8()?;
ExplosionAffectedBlockOffsets {
x: v499,
y: v500,
z: v501,
}
});
}
v498
};
let v502 = r.read_f32()?;
let v503 = r.read_f32()?;
let v504 = r.read_f32()?;
Explosion {
x: v492,
y: v493,
z: v494,
radius: v495,
affected_block_offsets: v496,
player_motion_x: v502,
player_motion_y: v503,
player_motion_z: v504,
}
})
}
}
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 v505 in (*self).affected_block_offsets.iter() {
w.put_i8((*v505).x);
w.put_i8((*v505).y);
w.put_i8((*v505).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 v506 = g.f32();
let v507 = g.f32();
let v508 = g.f32();
let v509 = g.f32();
let v510 = {
let v511 = g.count();
let mut v512 = Vec::with_capacity(v511.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v511 {
v512.push({
let v513 = (g.int_in(-128, 127, &[]) as i8);
let v514 = (g.int_in(-128, 127, &[]) as i8);
let v515 = (g.int_in(-128, 127, &[]) as i8);
ExplosionAffectedBlockOffsets {
x: v513,
y: v514,
z: v515,
}
});
}
v512
};
let v516 = g.f32();
let v517 = g.f32();
let v518 = g.f32();
Explosion {
x: v506,
y: v507,
z: v508,
radius: v509,
affected_block_offsets: v510,
player_motion_x: v516,
player_motion_y: v517,
player_motion_z: v518,
}
}
}
}
impl From<Explosion> for ClientboundPlayPacket {
fn from(p: Explosion) -> Self {
Self::Explosion(p)
}
}
/// `world_event` (clientbound play, id 0x28).
#[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 v519 = r.read_i32()?;
let v520 = BlockPos::read(r, PositionLayout::Xyz)?;
let v521 = r.read_i32()?;
let v522 = r.read_bool()?;
WorldEvent {
effect_id: v519,
location: v520,
data: v521,
global: v522,
}
})
}
}
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 v523 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v524 = g.position();
let v525 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v526 = g.bool();
WorldEvent {
effect_id: v523,
location: v524,
data: v525,
global: v526,
}
}
}
}
impl From<WorldEvent> for ClientboundPlayPacket {
fn from(p: WorldEvent) -> Self {
Self::WorldEvent(p)
}
}
/// `named_sound_effect` (clientbound play, id 0x29).
#[derive(Debug, Clone, PartialEq)]
pub struct NamedSoundEffect {
/// `soundName`
pub sound_name: ByteString,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
/// `volume`
pub volume: f32,
/// `pitch`
pub pitch: u8,
}
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 v527 = r.read_string()?;
let v528 = r.read_i32()?;
let v529 = r.read_i32()?;
let v530 = r.read_i32()?;
let v531 = r.read_f32()?;
let v532 = r.read_u8()?;
NamedSoundEffect {
sound_name: v527,
x: v528,
y: v529,
z: v530,
volume: v531,
pitch: v532,
}
})
}
}
impl Encode for NamedSoundEffect {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_string(&(*self).sound_name)?;
w.put_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
w.put_f32((*self).volume);
w.put_u8((*self).pitch);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for NamedSoundEffect {
fn generate(g: &mut Gen) -> Self {
{
let v533 = g.string();
let v534 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v535 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v536 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v537 = g.f32();
let v538 = (g.int_in(0, 255, &[]) as u8);
NamedSoundEffect {
sound_name: v533,
x: v534,
y: v535,
z: v536,
volume: v537,
pitch: v538,
}
}
}
}
impl From<NamedSoundEffect> for ClientboundPlayPacket {
fn from(p: NamedSoundEffect) -> Self {
Self::NamedSoundEffect(p)
}
}
/// `world_particles` (clientbound play, id 0x2a).
#[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 v539 = r.read_i32()?;
let v540 = r.read_bool()?;
let v541 = r.read_f32()?;
let v542 = r.read_f32()?;
let v543 = r.read_f32()?;
let v544 = r.read_f32()?;
let v545 = r.read_f32()?;
let v546 = r.read_f32()?;
let v547 = r.read_f32()?;
let v548 = r.read_i32()?;
let v549 = (if (v539 == 36) {
WorldParticlesData::Case36({
let v550 = 2;
let mut v551 = Vec::with_capacity(v550.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v550 {
v551.push(r.read_varint()?);
}
v551
})
} else if (v539 == 37) {
WorldParticlesData::Case37({
let v552 = 1;
let mut v553 = Vec::with_capacity(v552.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v552 {
v553.push(r.read_varint()?);
}
v553
})
} else if (v539 == 38) {
WorldParticlesData::Case38({
let v554 = 1;
let mut v555 = Vec::with_capacity(v554.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v554 {
v555.push(r.read_varint()?);
}
v555
})
} else {
WorldParticlesData::Other
});
WorldParticles {
particle_id: v539,
long_distance: v540,
x: v541,
y: v542,
z: v543,
offset_x: v544,
offset_y: v545,
offset_z: v546,
particle_data: v547,
particles: v548,
data: v549,
}
})
}
}
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(v556) => {
if !((*self).particle_id == 36) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v556).len() != 2 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 2,
actual: (*v556).len(),
});
}
for v557 in (*v556).iter() {
w.put_varint((*v557));
}
}
WorldParticlesData::Case37(v558) => {
if !((*self).particle_id == 37) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v558).len() != 1 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 1,
actual: (*v558).len(),
});
}
for v559 in (*v558).iter() {
w.put_varint((*v559));
}
}
WorldParticlesData::Case38(v560) => {
if !((*self).particle_id == 38) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_particles.data",
));
}
if (*v560).len() != 1 {
return Err(EncodeError::CountMismatch {
field: "play.clientbound.world_particles.data",
expected: 1,
actual: (*v560).len(),
});
}
for v561 in (*v560).iter() {
w.put_varint((*v561));
}
}
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 v562 = (g.int_in(-2147483648, 2147483647, &[36, 37, 38]) as i32);
let v563 = g.bool();
let v564 = g.f32();
let v565 = g.f32();
let v566 = g.f32();
let v567 = g.f32();
let v568 = g.f32();
let v569 = g.f32();
let v570 = g.f32();
let v571 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v572 = (if (v562 == 36) {
WorldParticlesData::Case36({
let v573 = 2;
let mut v574 = Vec::with_capacity(v573.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v573 {
v574.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v574
})
} else if (v562 == 37) {
WorldParticlesData::Case37({
let v575 = 1;
let mut v576 = Vec::with_capacity(v575.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v575 {
v576.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v576
})
} else if (v562 == 38) {
WorldParticlesData::Case38({
let v577 = 1;
let mut v578 = Vec::with_capacity(v577.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v577 {
v578.push((g.int_in(-2147483648, 2147483647, &[]) as i32));
}
v578
})
} else {
WorldParticlesData::Other
});
WorldParticles {
particle_id: v562,
long_distance: v563,
x: v564,
y: v565,
z: v566,
offset_x: v567,
offset_y: v568,
offset_z: v569,
particle_data: v570,
particles: v571,
data: v572,
}
}
}
}
impl From<WorldParticles> for ClientboundPlayPacket {
fn from(p: WorldParticles) -> Self {
Self::WorldParticles(p)
}
}
/// `game_state_change` (clientbound play, id 0x2b).
#[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 v579 = GameStateChangeReason(r.read_u8()?);
let v580 = r.read_f32()?;
GameStateChange {
reason: v579,
game_mode: v580,
}
})
}
}
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 v581 =
GameStateChangeReason(g.int_in(0, 255, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) as u8);
let v582 = g.f32();
GameStateChange {
reason: v581,
game_mode: v582,
}
}
}
}
impl From<GameStateChange> for ClientboundPlayPacket {
fn from(p: GameStateChange) -> Self {
Self::GameStateChange(p)
}
}
/// `spawn_entity_weather` (clientbound play, id 0x2c).
#[derive(Debug, Clone, PartialEq)]
pub struct SpawnEntityWeather {
/// `entityId`
pub entity_id: i32,
/// `type`
pub r#type: i8,
/// `x`
pub x: i32,
/// `y`
pub y: i32,
/// `z`
pub z: i32,
}
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 v583 = r.read_varint()?;
let v584 = r.read_i8()?;
let v585 = r.read_i32()?;
let v586 = r.read_i32()?;
let v587 = r.read_i32()?;
SpawnEntityWeather {
entity_id: v583,
r#type: v584,
x: v585,
y: v586,
z: v587,
}
})
}
}
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_i32((*self).x);
w.put_i32((*self).y);
w.put_i32((*self).z);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SpawnEntityWeather {
fn generate(g: &mut Gen) -> Self {
{
let v588 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v589 = (g.int_in(-128, 127, &[]) as i8);
let v590 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v591 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v592 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
SpawnEntityWeather {
entity_id: v588,
r#type: v589,
x: v590,
y: v591,
z: v592,
}
}
}
}
impl From<SpawnEntityWeather> for ClientboundPlayPacket {
fn from(p: SpawnEntityWeather) -> Self {
Self::SpawnEntityWeather(p)
}
}
/// `open_window` (clientbound play, id 0x2d).
#[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 v593 = r.read_u8()?;
let v594 = r.read_string()?;
let v595 = r.read_string()?;
let v596 = r.read_u8()?;
let v597 = if (&*v594 == "EntityHorse") {
Some(r.read_i32()?)
} else {
None
};
OpenWindow {
window_id: v593,
inventory_type: v594,
window_title: v595,
slot_count: v596,
entity_id: v597,
}
})
}
}
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(v598), true) => {
w.put_i32((*v598));
}
(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 v599 = (g.int_in(0, 255, &[]) as u8);
let v600 = g.string_in(&["EntityHorse"]);
let v601 = g.string();
let v602 = (g.int_in(0, 255, &[]) as u8);
let v603 = if (&*v600 == "EntityHorse") {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
OpenWindow {
window_id: v599,
inventory_type: v600,
window_title: v601,
slot_count: v602,
entity_id: v603,
}
}
}
}
impl From<OpenWindow> for ClientboundPlayPacket {
fn from(p: OpenWindow) -> Self {
Self::OpenWindow(p)
}
}
/// `close_window` (clientbound play, id 0x2e).
#[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 v604 = r.read_u8()?;
CloseWindow { window_id: v604 }
})
}
}
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 v605 = (g.int_in(0, 255, &[]) as u8);
CloseWindow { window_id: v605 }
}
}
}
impl From<CloseWindow> for ClientboundPlayPacket {
fn from(p: CloseWindow) -> Self {
Self::CloseWindow(p)
}
}
/// `set_slot` (clientbound play, id 0x2f).
#[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 v606 = r.read_i8()?;
let v607 = r.read_i16()?;
let v608 = <types::Slot as Decode>::decode(r)?;
SetSlot {
window_id: v606,
slot: v607,
item: v608,
}
})
}
}
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 v609 = (g.int_in(-128, 127, &[]) as i8);
let v610 = (g.int_in(-32768, 32767, &[]) as i16);
let v611 = <types::Slot as Generate>::generate(g);
SetSlot {
window_id: v609,
slot: v610,
item: v611,
}
}
}
}
impl From<SetSlot> for ClientboundPlayPacket {
fn from(p: SetSlot) -> Self {
Self::SetSlot(p)
}
}
/// `window_items` (clientbound play, id 0x30).
#[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 v612 = r.read_u8()?;
let v613 = {
let v614 = {
let c = r.read_i16()?;
r.check_count(i64::from(c), 1)?
};
let mut v615 = Vec::with_capacity(v614.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v614 {
v615.push(<types::Slot as Decode>::decode(r)?);
}
v615
};
WindowItems {
window_id: v612,
items: v613,
}
})
}
}
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 v616 in (*self).items.iter() {
(*v616).encode(w)?;
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for WindowItems {
fn generate(g: &mut Gen) -> Self {
{
let v617 = (g.int_in(0, 255, &[]) as u8);
let v618 = {
let v619 = g.count();
let mut v620 = Vec::with_capacity(v619.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v619 {
v620.push(<types::Slot as Generate>::generate(g));
}
v620
};
WindowItems {
window_id: v617,
items: v618,
}
}
}
}
impl From<WindowItems> for ClientboundPlayPacket {
fn from(p: WindowItems) -> Self {
Self::WindowItems(p)
}
}
/// `craft_progress_bar` (clientbound play, id 0x31).
#[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 v621 = r.read_u8()?;
let v622 = r.read_i16()?;
let v623 = r.read_i16()?;
CraftProgressBar {
window_id: v621,
property: v622,
value: v623,
}
})
}
}
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 v624 = (g.int_in(0, 255, &[]) as u8);
let v625 = (g.int_in(-32768, 32767, &[]) as i16);
let v626 = (g.int_in(-32768, 32767, &[]) as i16);
CraftProgressBar {
window_id: v624,
property: v625,
value: v626,
}
}
}
}
impl From<CraftProgressBar> for ClientboundPlayPacket {
fn from(p: CraftProgressBar) -> Self {
Self::CraftProgressBar(p)
}
}
/// `transaction` (clientbound play, id 0x32).
#[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 v627 = r.read_i8()?;
let v628 = r.read_i16()?;
let v629 = r.read_bool()?;
Transaction {
window_id: v627,
action: v628,
accepted: v629,
}
})
}
}
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 v630 = (g.int_in(-128, 127, &[]) as i8);
let v631 = (g.int_in(-32768, 32767, &[]) as i16);
let v632 = g.bool();
Transaction {
window_id: v630,
action: v631,
accepted: v632,
}
}
}
}
impl From<Transaction> for ClientboundPlayPacket {
fn from(p: Transaction) -> Self {
Self::Transaction(p)
}
}
/// `update_sign` (clientbound play, id 0x33).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateSign {
/// `location`
pub location: BlockPos,
/// `text1`
pub text1: ByteString,
/// `text2`
pub text2: ByteString,
/// `text3`
pub text3: ByteString,
/// `text4`
pub text4: ByteString,
}
impl crate::packet::Packet for UpdateSign {
const ID: i32 = id::UPDATE_SIGN;
const NAME: &'static str = "update_sign";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateSign {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v633 = BlockPos::read(r, PositionLayout::Xyz)?;
let v634 = r.read_string()?;
let v635 = r.read_string()?;
let v636 = r.read_string()?;
let v637 = r.read_string()?;
UpdateSign {
location: v633,
text1: v634,
text2: v635,
text3: v636,
text4: v637,
}
})
}
}
impl Encode for UpdateSign {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
(*self).location.write(w, PositionLayout::Xyz)?;
w.put_string(&(*self).text1)?;
w.put_string(&(*self).text2)?;
w.put_string(&(*self).text3)?;
w.put_string(&(*self).text4)?;
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateSign {
fn generate(g: &mut Gen) -> Self {
{
let v638 = g.position();
let v639 = g.string();
let v640 = g.string();
let v641 = g.string();
let v642 = g.string();
UpdateSign {
location: v638,
text1: v639,
text2: v640,
text3: v641,
text4: v642,
}
}
}
}
impl From<UpdateSign> for ClientboundPlayPacket {
fn from(p: UpdateSign) -> Self {
Self::UpdateSign(p)
}
}
/// `map` (clientbound play, id 0x34).
#[derive(Debug, Clone, PartialEq)]
pub struct Map {
/// `itemDamage`
pub item_damage: i32,
/// `scale`
pub scale: i8,
/// `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 v643 = r.read_varint()?;
let v644 = r.read_i8()?;
let v645 = {
let v646 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v647 = Vec::with_capacity(v646.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v646 {
v647.push({
let v648 = r.read_i8()?;
let v649 = r.read_i8()?;
let v650 = r.read_i8()?;
MapIcons {
direction_and_type: v648,
x: v649,
z: v650,
}
});
}
v647
};
let v651 = r.read_i8()?;
let v652 = if !(v651 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v653 = if !(v651 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v654 = if !(v651 == 0) {
Some(r.read_i8()?)
} else {
None
};
let v655 = if !(v651 == 0) {
Some(r.read_byte_array()?)
} else {
None
};
Map {
item_damage: v643,
scale: v644,
icons: v645,
columns: v651,
rows: v652,
x: v653,
y: v654,
data: v655,
}
})
}
}
impl Encode for Map {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).item_damage);
w.put_i8((*self).scale);
w.put_len_varint((*self).icons.len())?;
for v656 in (*self).icons.iter() {
w.put_i8((*v656).direction_and_type);
w.put_i8((*v656).x);
w.put_i8((*v656).z);
}
w.put_i8((*self).columns);
match (&(*self).rows, !((*self).columns == 0)) {
(Some(v657), true) => {
w.put_i8((*v657));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.rows")),
}
match (&(*self).x, !((*self).columns == 0)) {
(Some(v658), true) => {
w.put_i8((*v658));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.x")),
}
match (&(*self).y, !((*self).columns == 0)) {
(Some(v659), true) => {
w.put_i8((*v659));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.map.y")),
}
match (&(*self).data, !((*self).columns == 0)) {
(Some(v660), true) => {
w.put_byte_array(&(*v660))?;
}
(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 v661 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v662 = (g.int_in(-128, 127, &[]) as i8);
let v663 = {
let v664 = g.count();
let mut v665 = Vec::with_capacity(v664.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v664 {
v665.push({
let v666 = (g.int_in(-128, 127, &[]) as i8);
let v667 = (g.int_in(-128, 127, &[]) as i8);
let v668 = (g.int_in(-128, 127, &[]) as i8);
MapIcons {
direction_and_type: v666,
x: v667,
z: v668,
}
});
}
v665
};
let v669 = (g.int_in(-128, 127, &[0, 0, 0, 0]) as i8);
let v670 = if !(v669 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v671 = if !(v669 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v672 = if !(v669 == 0) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v673 = if !(v669 == 0) { Some(g.bytes()) } else { None };
Map {
item_damage: v661,
scale: v662,
icons: v663,
columns: v669,
rows: v670,
x: v671,
y: v672,
data: v673,
}
}
}
}
impl From<Map> for ClientboundPlayPacket {
fn from(p: Map) -> Self {
Self::Map(p)
}
}
/// `tile_entity_data` (clientbound play, id 0x35).
#[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 v674 = BlockPos::read(r, PositionLayout::Xyz)?;
let v675 = r.read_u8()?;
let v676 = RawNbt::read_optional(r)?;
TileEntityData {
location: v674,
action: v675,
nbt_data: v676,
}
})
}
}
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 v677 = g.position();
let v678 = (g.int_in(0, 255, &[]) as u8);
let v679 = g.opt_nbt();
TileEntityData {
location: v677,
action: v678,
nbt_data: v679,
}
}
}
}
impl From<TileEntityData> for ClientboundPlayPacket {
fn from(p: TileEntityData) -> Self {
Self::TileEntityData(p)
}
}
/// `open_sign_entity` (clientbound play, id 0x36).
#[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 v680 = BlockPos::read(r, PositionLayout::Xyz)?;
OpenSignEntity { location: v680 }
})
}
}
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 v681 = g.position();
OpenSignEntity { location: v681 }
}
}
}
impl From<OpenSignEntity> for ClientboundPlayPacket {
fn from(p: OpenSignEntity) -> Self {
Self::OpenSignEntity(p)
}
}
/// `statistics` (clientbound play, id 0x37).
#[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 v682 = {
let v683 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 2)?
};
let mut v684 = Vec::with_capacity(v683.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v683 {
v684.push({
let v685 = r.read_string()?;
let v686 = r.read_varint()?;
StatisticsEntries {
name: v685,
value: v686,
}
});
}
v684
};
Statistics { entries: v682 }
})
}
}
impl Encode for Statistics {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).entries.len())?;
for v687 in (*self).entries.iter() {
w.put_string(&(*v687).name)?;
w.put_varint((*v687).value);
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for Statistics {
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({
let v691 = g.string();
let v692 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
StatisticsEntries {
name: v691,
value: v692,
}
});
}
v690
};
Statistics { entries: v688 }
}
}
}
impl From<Statistics> for ClientboundPlayPacket {
fn from(p: Statistics) -> Self {
Self::Statistics(p)
}
}
/// `player_info` (clientbound play, id 0x38).
#[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 v693 = PlayerInfoAction(r.read_varint()?);
let v694 = {
let v695 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 16)?
};
let mut v696 = Vec::with_capacity(v695.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v695 {
v696.push({
let v697 = r.read_uuid()?;
let v698 = (if (v693.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v699 = r.read_string()?;
let v700 = {
let v701 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 3)?
};
let mut v702 =
Vec::with_capacity(v701.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v701 {
v702.push({
let v703 = r.read_string()?;
let v704 = r.read_string()?;
let v705 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayerProperties {
name: v703,
value: v704,
signature: v705,
}
});
}
v702
};
let v706 = r.read_varint()?;
let v707 = r.read_varint()?;
let v708 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyAddPlayer {
name: v699,
properties: v700,
gamemode: v706,
ping: v707,
display_name: v708,
}
})
} else if (v693.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v709 = r.read_varint()?;
PlayerInfoDataBodyUpdateGameMode { gamemode: v709 }
})
} else if (v693.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v710 = r.read_varint()?;
PlayerInfoDataBodyUpdateLatency { ping: v710 }
})
} else if (v693.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v711 = if r.read_bool()? {
Some(r.read_string()?)
} else {
None
};
PlayerInfoDataBodyUpdateDisplayName { display_name: v711 }
})
} else if (v693.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v697,
body: v698,
}
});
}
v696
};
PlayerInfo {
action: v693,
data: v694,
}
})
}
}
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 v712 in (*self).data.iter() {
w.put_uuid(&(*v712).uuid);
match &(*v712).body {
PlayerInfoDataBody::AddPlayer(v713) => {
if !((*self).action.0 == 0) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_string(&(*v713).name)?;
w.put_len_varint((*v713).properties.len())?;
for v714 in (*v713).properties.iter() {
w.put_string(&(*v714).name)?;
w.put_string(&(*v714).value)?;
match &(*v714).signature {
Some(v715) => {
w.put_u8(1);
w.put_string(&(*v715))?;
}
None => w.put_u8(0),
}
}
w.put_varint((*v713).gamemode);
w.put_varint((*v713).ping);
match &(*v713).display_name {
Some(v716) => {
w.put_u8(1);
w.put_string(&(*v716))?;
}
None => w.put_u8(0),
}
}
PlayerInfoDataBody::UpdateGameMode(v717) => {
if !((*self).action.0 == 1) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v717).gamemode);
}
PlayerInfoDataBody::UpdateLatency(v718) => {
if !((*self).action.0 == 2) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
w.put_varint((*v718).ping);
}
PlayerInfoDataBody::UpdateDisplayName(v719) => {
if !((*self).action.0 == 3) {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.player_info.data.body",
));
}
match &(*v719).display_name {
Some(v720) => {
w.put_u8(1);
w.put_string(&(*v720))?;
}
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 v721 = PlayerInfoAction(g.int_in(-2147483648, 2147483647, &[0, 1, 2, 3, 4]) as i32);
let v722 = {
let v723 = g.count();
let mut v724 = Vec::with_capacity(v723.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v723 {
v724.push({
let v725 = g.uuid();
let v726 = (if (v721.0 == 0) {
PlayerInfoDataBody::AddPlayer({
let v727 = g.string();
let v728 = {
let v729 = g.count();
let mut v730 =
Vec::with_capacity(v729.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v729 {
v730.push({
let v731 = g.string();
let v732 = g.string();
let v733 =
if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayerProperties {
name: v731,
value: v732,
signature: v733,
}
});
}
v730
};
let v734 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v735 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v736 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyAddPlayer {
name: v727,
properties: v728,
gamemode: v734,
ping: v735,
display_name: v736,
}
})
} else if (v721.0 == 1) {
PlayerInfoDataBody::UpdateGameMode({
let v737 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateGameMode { gamemode: v737 }
})
} else if (v721.0 == 2) {
PlayerInfoDataBody::UpdateLatency({
let v738 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
PlayerInfoDataBodyUpdateLatency { ping: v738 }
})
} else if (v721.0 == 3) {
PlayerInfoDataBody::UpdateDisplayName({
let v739 = if g.bool() { Some(g.string()) } else { None };
PlayerInfoDataBodyUpdateDisplayName { display_name: v739 }
})
} else if (v721.0 == 4) {
PlayerInfoDataBody::RemovePlayer
} else {
PlayerInfoDataBody::Other
});
PlayerInfoData {
uuid: v725,
body: v726,
}
});
}
v724
};
PlayerInfo {
action: v721,
data: v722,
}
}
}
}
impl From<PlayerInfo> for ClientboundPlayPacket {
fn from(p: PlayerInfo) -> Self {
Self::PlayerInfo(p)
}
}
/// `abilities` (clientbound play, id 0x39).
#[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 v740 = r.read_i8()?;
let v741 = r.read_f32()?;
let v742 = r.read_f32()?;
Abilities {
flags: v740,
flying_speed: v741,
walking_speed: v742,
}
})
}
}
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 v743 = (g.int_in(-128, 127, &[]) as i8);
let v744 = g.f32();
let v745 = g.f32();
Abilities {
flags: v743,
flying_speed: v744,
walking_speed: v745,
}
}
}
}
impl From<Abilities> for ClientboundPlayPacket {
fn from(p: Abilities) -> Self {
Self::Abilities(p)
}
}
/// `tab_complete` (clientbound play, id 0x3a).
#[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 v746 = {
let v747 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v748 = Vec::with_capacity(v747.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v747 {
v748.push(r.read_string()?);
}
v748
};
TabComplete { matches: v746 }
})
}
}
impl Encode for TabComplete {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_len_varint((*self).matches.len())?;
for v749 in (*self).matches.iter() {
w.put_string(&(*v749))?;
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for TabComplete {
fn generate(g: &mut Gen) -> Self {
{
let v750 = {
let v751 = g.count();
let mut v752 = Vec::with_capacity(v751.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v751 {
v752.push(g.string());
}
v752
};
TabComplete { matches: v750 }
}
}
}
impl From<TabComplete> for ClientboundPlayPacket {
fn from(p: TabComplete) -> Self {
Self::TabComplete(p)
}
}
/// `scoreboard_objective` (clientbound play, id 0x3b).
#[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 v753 = r.read_string()?;
let v754 = r.read_i8()?;
let v755 = if (v754 == 0) || (v754 == 2) {
Some(r.read_string()?)
} else {
None
};
let v756 = if (v754 == 0) || (v754 == 2) {
Some(r.read_string()?)
} else {
None
};
ScoreboardObjective {
name: v753,
action: v754,
display_text: v755,
r#type: v756,
}
})
}
}
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(v757), true) => {
w.put_string(&(*v757))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_objective.displayText",
));
}
}
match (
&(*self).r#type,
((*self).action == 0) || ((*self).action == 2),
) {
(Some(v758), true) => {
w.put_string(&(*v758))?;
}
(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 v759 = g.string();
let v760 = (g.int_in(-128, 127, &[0, 2, 0, 2]) as i8);
let v761 = if (v760 == 0) || (v760 == 2) {
Some(g.string())
} else {
None
};
let v762 = if (v760 == 0) || (v760 == 2) {
Some(g.string())
} else {
None
};
ScoreboardObjective {
name: v759,
action: v760,
display_text: v761,
r#type: v762,
}
}
}
}
impl From<ScoreboardObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardObjective) -> Self {
Self::ScoreboardObjective(p)
}
}
/// `scoreboard_score` (clientbound play, id 0x3c).
#[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 v763 = r.read_string()?;
let v764 = r.read_varint()?;
let v765 = r.read_string()?;
let v766 = if !(v764 == 1) {
Some(r.read_varint()?)
} else {
None
};
ScoreboardScore {
item_name: v763,
action: v764,
score_name: v765,
value: v766,
}
})
}
}
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(v767), true) => {
w.put_varint((*v767));
}
(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 v768 = g.string();
let v769 = (g.int_in(-2147483648, 2147483647, &[1]) as i32);
let v770 = g.string();
let v771 = if !(v769 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
ScoreboardScore {
item_name: v768,
action: v769,
score_name: v770,
value: v771,
}
}
}
}
impl From<ScoreboardScore> for ClientboundPlayPacket {
fn from(p: ScoreboardScore) -> Self {
Self::ScoreboardScore(p)
}
}
/// `scoreboard_display_objective` (clientbound play, id 0x3d).
#[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 v772 = r.read_i8()?;
let v773 = r.read_string()?;
ScoreboardDisplayObjective {
position: v772,
name: v773,
}
})
}
}
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 v774 = (g.int_in(-128, 127, &[]) as i8);
let v775 = g.string();
ScoreboardDisplayObjective {
position: v774,
name: v775,
}
}
}
}
impl From<ScoreboardDisplayObjective> for ClientboundPlayPacket {
fn from(p: ScoreboardDisplayObjective) -> Self {
Self::ScoreboardDisplayObjective(p)
}
}
/// `scoreboard_team` (clientbound play, id 0x3e).
#[derive(Debug, Clone, PartialEq)]
pub struct ScoreboardTeam {
/// `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>,
/// `color`
pub color: Option<i8>,
/// `players`
pub players: Option<Vec<ByteString>>,
}
impl crate::packet::Packet for ScoreboardTeam {
const ID: i32 = id::SCOREBOARD_TEAM;
const NAME: &'static str = "scoreboard_team";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for ScoreboardTeam {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v776 = r.read_string()?;
let v777 = r.read_i8()?;
let v778 = if (v777 == 0) || (v777 == 2) {
Some(r.read_string()?)
} else {
None
};
let v779 = if (v777 == 0) || (v777 == 2) {
Some(r.read_string()?)
} else {
None
};
let v780 = if (v777 == 0) || (v777 == 2) {
Some(r.read_string()?)
} else {
None
};
let v781 = if (v777 == 0) || (v777 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v782 = if (v777 == 0) || (v777 == 2) {
Some(r.read_string()?)
} else {
None
};
let v783 = if (v777 == 0) || (v777 == 2) {
Some(r.read_i8()?)
} else {
None
};
let v784 = if (v777 == 0) || (v777 == 3) || (v777 == 4) {
Some({
let v785 = {
let c = r.read_varint()?;
r.check_count(i64::from(c), 1)?
};
let mut v786 = Vec::with_capacity(v785.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v785 {
v786.push(r.read_string()?);
}
v786
})
} else {
None
};
ScoreboardTeam {
team: v776,
mode: v777,
name: v778,
prefix: v779,
suffix: v780,
friendly_fire: v781,
name_tag_visibility: v782,
color: v783,
players: v784,
}
})
}
}
impl Encode for ScoreboardTeam {
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(v787), true) => {
w.put_string(&(*v787))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.name",
));
}
}
match (&(*self).prefix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v788), true) => {
w.put_string(&(*v788))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.prefix",
));
}
}
match (&(*self).suffix, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v789), true) => {
w.put_string(&(*v789))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.suffix",
));
}
}
match (
&(*self).friendly_fire,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v790), true) => {
w.put_i8((*v790));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.friendlyFire",
));
}
}
match (
&(*self).name_tag_visibility,
((*self).mode == 0) || ((*self).mode == 2),
) {
(Some(v791), true) => {
w.put_string(&(*v791))?;
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.nameTagVisibility",
));
}
}
match (&(*self).color, ((*self).mode == 0) || ((*self).mode == 2)) {
(Some(v792), true) => {
w.put_i8((*v792));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.color",
));
}
}
match (
&(*self).players,
((*self).mode == 0) || ((*self).mode == 3) || ((*self).mode == 4),
) {
(Some(v793), true) => {
w.put_len_varint((*v793).len())?;
for v794 in (*v793).iter() {
w.put_string(&(*v794))?;
}
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.scoreboard_team.players",
));
}
}
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for ScoreboardTeam {
fn generate(g: &mut Gen) -> Self {
{
let v795 = g.string();
let v796 = (g.int_in(-128, 127, &[0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3, 4]) as i8);
let v797 = if (v796 == 0) || (v796 == 2) {
Some(g.string())
} else {
None
};
let v798 = if (v796 == 0) || (v796 == 2) {
Some(g.string())
} else {
None
};
let v799 = if (v796 == 0) || (v796 == 2) {
Some(g.string())
} else {
None
};
let v800 = if (v796 == 0) || (v796 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v801 = if (v796 == 0) || (v796 == 2) {
Some(g.string())
} else {
None
};
let v802 = if (v796 == 0) || (v796 == 2) {
Some((g.int_in(-128, 127, &[]) as i8))
} else {
None
};
let v803 = if (v796 == 0) || (v796 == 3) || (v796 == 4) {
Some({
let v804 = g.count();
let mut v805 = Vec::with_capacity(v804.min(crate::codec::PREALLOC_LIMIT));
for _ in 0..v804 {
v805.push(g.string());
}
v805
})
} else {
None
};
ScoreboardTeam {
team: v795,
mode: v796,
name: v797,
prefix: v798,
suffix: v799,
friendly_fire: v800,
name_tag_visibility: v801,
color: v802,
players: v803,
}
}
}
}
impl From<ScoreboardTeam> for ClientboundPlayPacket {
fn from(p: ScoreboardTeam) -> Self {
Self::ScoreboardTeam(p)
}
}
/// `custom_payload` (clientbound play, id 0x3f).
#[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 v806 = r.read_string()?;
let v807 = r.read_rest();
CustomPayload {
channel: v806,
data: v807,
}
})
}
}
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 v808 = g.string();
let v809 = g.bytes();
CustomPayload {
channel: v808,
data: v809,
}
}
}
}
impl From<CustomPayload> for ClientboundPlayPacket {
fn from(p: CustomPayload) -> Self {
Self::CustomPayload(p)
}
}
/// `kick_disconnect` (clientbound play, id 0x40).
#[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 v810 = r.read_string()?;
KickDisconnect { reason: v810 }
})
}
}
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 v811 = g.string();
KickDisconnect { reason: v811 }
}
}
}
impl From<KickDisconnect> for ClientboundPlayPacket {
fn from(p: KickDisconnect) -> Self {
Self::KickDisconnect(p)
}
}
/// `difficulty` (clientbound play, id 0x41).
#[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 v812 = DifficultyDifficulty(r.read_u8()?);
Difficulty { difficulty: v812 }
})
}
}
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 v813 = DifficultyDifficulty(g.int_in(0, 255, &[0, 1, 2, 3]) as u8);
Difficulty { difficulty: v813 }
}
}
}
impl From<Difficulty> for ClientboundPlayPacket {
fn from(p: Difficulty) -> Self {
Self::Difficulty(p)
}
}
/// `combat_event` (clientbound play, id 0x42).
#[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 v814 = r.read_varint()?;
let v815 = if (v814 == 1) {
Some(r.read_varint()?)
} else {
None
};
let v816 = if (v814 == 2) {
Some(r.read_varint()?)
} else {
None
};
let v817 = if (v814 == 1) || (v814 == 2) {
Some(r.read_i32()?)
} else {
None
};
let v818 = if (v814 == 2) {
Some(r.read_string()?)
} else {
None
};
CombatEvent {
event: v814,
duration: v815,
player_id: v816,
entity_id: v817,
message: v818,
}
})
}
}
impl Encode for CombatEvent {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).event);
match (&(*self).duration, ((*self).event == 1)) {
(Some(v819), true) => {
w.put_varint((*v819));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.duration",
));
}
}
match (&(*self).player_id, ((*self).event == 2)) {
(Some(v820), true) => {
w.put_varint((*v820));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.playerId",
));
}
}
match (
&(*self).entity_id,
((*self).event == 1) || ((*self).event == 2),
) {
(Some(v821), true) => {
w.put_i32((*v821));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.combat_event.entityId",
));
}
}
match (&(*self).message, ((*self).event == 2)) {
(Some(v822), true) => {
w.put_string(&(*v822))?;
}
(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 v823 = (g.int_in(-2147483648, 2147483647, &[1, 2, 1, 2, 2]) as i32);
let v824 = if (v823 == 1) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v825 = if (v823 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v826 = if (v823 == 1) || (v823 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v827 = if (v823 == 2) { Some(g.string()) } else { None };
CombatEvent {
event: v823,
duration: v824,
player_id: v825,
entity_id: v826,
message: v827,
}
}
}
}
impl From<CombatEvent> for ClientboundPlayPacket {
fn from(p: CombatEvent) -> Self {
Self::CombatEvent(p)
}
}
/// `camera` (clientbound play, id 0x43).
#[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 v828 = r.read_varint()?;
Camera { camera_id: v828 }
})
}
}
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 v829 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
Camera { camera_id: v829 }
}
}
}
impl From<Camera> for ClientboundPlayPacket {
fn from(p: Camera) -> Self {
Self::Camera(p)
}
}
/// `world_border` (clientbound play, id 0x44).
#[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 v830 = r.read_varint()?;
let v831 = if (v830 == 0) {
Some(r.read_f64()?)
} else {
None
};
let v832 = if (v830 == 2) || (v830 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v833 = if (v830 == 2) || (v830 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v834 = if (v830 == 1) || (v830 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v835 = if (v830 == 1) || (v830 == 3) {
Some(r.read_f64()?)
} else {
None
};
let v836 = if (v830 == 1) || (v830 == 3) {
Some(r.read_varlong()?)
} else {
None
};
let v837 = if (v830 == 3) {
Some(r.read_varint()?)
} else {
None
};
let v838 = if (v830 == 3) || (v830 == 4) {
Some(r.read_varint()?)
} else {
None
};
let v839 = if (v830 == 3) || (v830 == 5) {
Some(r.read_varint()?)
} else {
None
};
WorldBorder {
action: v830,
radius: v831,
x: v832,
z: v833,
old_radius: v834,
new_radius: v835,
speed: v836,
portal_boundary: v837,
warning_time: v838,
warning_blocks: v839,
}
})
}
}
impl Encode for WorldBorder {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).action);
match (&(*self).radius, ((*self).action == 0)) {
(Some(v840), true) => {
w.put_f64((*v840));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.radius",
));
}
}
match (&(*self).x, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v841), true) => {
w.put_f64((*v841));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.x",
));
}
}
match (&(*self).z, ((*self).action == 2) || ((*self).action == 3)) {
(Some(v842), true) => {
w.put_f64((*v842));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.z",
));
}
}
match (
&(*self).old_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v843), true) => {
w.put_f64((*v843));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.old_radius",
));
}
}
match (
&(*self).new_radius,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v844), true) => {
w.put_f64((*v844));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.new_radius",
));
}
}
match (
&(*self).speed,
((*self).action == 1) || ((*self).action == 3),
) {
(Some(v845), true) => {
w.put_varlong((*v845));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.speed",
));
}
}
match (&(*self).portal_boundary, ((*self).action == 3)) {
(Some(v846), true) => {
w.put_varint((*v846));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.portalBoundary",
));
}
}
match (
&(*self).warning_time,
((*self).action == 3) || ((*self).action == 4),
) {
(Some(v847), true) => {
w.put_varint((*v847));
}
(None, false) => {}
_ => {
return Err(EncodeError::SwitchMismatch(
"play.clientbound.world_border.warning_time",
));
}
}
match (
&(*self).warning_blocks,
((*self).action == 3) || ((*self).action == 5),
) {
(Some(v848), true) => {
w.put_varint((*v848));
}
(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 v849 = (g.int_in(
-2147483648,
2147483647,
&[0, 2, 3, 2, 3, 1, 3, 1, 3, 1, 3, 3, 3, 4, 3, 5],
) as i32);
let v850 = if (v849 == 0) { Some(g.f64()) } else { None };
let v851 = if (v849 == 2) || (v849 == 3) {
Some(g.f64())
} else {
None
};
let v852 = if (v849 == 2) || (v849 == 3) {
Some(g.f64())
} else {
None
};
let v853 = if (v849 == 1) || (v849 == 3) {
Some(g.f64())
} else {
None
};
let v854 = if (v849 == 1) || (v849 == 3) {
Some(g.f64())
} else {
None
};
let v855 = if (v849 == 1) || (v849 == 3) {
Some(g.varlong())
} else {
None
};
let v856 = if (v849 == 3) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v857 = if (v849 == 3) || (v849 == 4) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v858 = if (v849 == 3) || (v849 == 5) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
WorldBorder {
action: v849,
radius: v850,
x: v851,
z: v852,
old_radius: v853,
new_radius: v854,
speed: v855,
portal_boundary: v856,
warning_time: v857,
warning_blocks: v858,
}
}
}
}
impl From<WorldBorder> for ClientboundPlayPacket {
fn from(p: WorldBorder) -> Self {
Self::WorldBorder(p)
}
}
/// `title` (clientbound play, id 0x45).
#[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 v859 = r.read_varint()?;
let v860 = if (v859 == 0) || (v859 == 1) {
Some(r.read_string()?)
} else {
None
};
let v861 = if (v859 == 2) {
Some(r.read_i32()?)
} else {
None
};
let v862 = if (v859 == 2) {
Some(r.read_i32()?)
} else {
None
};
let v863 = if (v859 == 2) {
Some(r.read_i32()?)
} else {
None
};
Title {
action: v859,
text: v860,
fade_in: v861,
stay: v862,
fade_out: v863,
}
})
}
}
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),
) {
(Some(v864), true) => {
w.put_string(&(*v864))?;
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.text")),
}
match (&(*self).fade_in, ((*self).action == 2)) {
(Some(v865), true) => {
w.put_i32((*v865));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.fadeIn")),
}
match (&(*self).stay, ((*self).action == 2)) {
(Some(v866), true) => {
w.put_i32((*v866));
}
(None, false) => {}
_ => return Err(EncodeError::SwitchMismatch("play.clientbound.title.stay")),
}
match (&(*self).fade_out, ((*self).action == 2)) {
(Some(v867), true) => {
w.put_i32((*v867));
}
(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 v868 = (g.int_in(-2147483648, 2147483647, &[0, 1, 2, 2, 2]) as i32);
let v869 = if (v868 == 0) || (v868 == 1) {
Some(g.string())
} else {
None
};
let v870 = if (v868 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v871 = if (v868 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
let v872 = if (v868 == 2) {
Some((g.int_in(-2147483648, 2147483647, &[]) as i32))
} else {
None
};
Title {
action: v868,
text: v869,
fade_in: v870,
stay: v871,
fade_out: v872,
}
}
}
}
impl From<Title> for ClientboundPlayPacket {
fn from(p: Title) -> Self {
Self::Title(p)
}
}
/// `set_compression` (clientbound play, id 0x46).
#[derive(Debug, Clone, PartialEq)]
pub struct SetCompression {
/// `threshold`
pub threshold: i32,
}
impl crate::packet::Packet for SetCompression {
const ID: i32 = id::SET_COMPRESSION;
const NAME: &'static str = "set_compression";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for SetCompression {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v873 = r.read_varint()?;
SetCompression { threshold: v873 }
})
}
}
impl Encode for SetCompression {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).threshold);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for SetCompression {
fn generate(g: &mut Gen) -> Self {
{
let v874 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
SetCompression { threshold: v874 }
}
}
}
impl From<SetCompression> for ClientboundPlayPacket {
fn from(p: SetCompression) -> Self {
Self::SetCompression(p)
}
}
/// `playerlist_header` (clientbound play, id 0x47).
#[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 v875 = r.read_string()?;
let v876 = r.read_string()?;
PlayerlistHeader {
header: v875,
footer: v876,
}
})
}
}
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 v877 = g.string();
let v878 = g.string();
PlayerlistHeader {
header: v877,
footer: v878,
}
}
}
}
impl From<PlayerlistHeader> for ClientboundPlayPacket {
fn from(p: PlayerlistHeader) -> Self {
Self::PlayerlistHeader(p)
}
}
/// `resource_pack_send` (clientbound play, id 0x48).
#[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 v879 = r.read_string()?;
let v880 = r.read_string()?;
ResourcePackSend {
url: v879,
hash: v880,
}
})
}
}
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 v881 = g.string();
let v882 = g.string();
ResourcePackSend {
url: v881,
hash: v882,
}
}
}
}
impl From<ResourcePackSend> for ClientboundPlayPacket {
fn from(p: ResourcePackSend) -> Self {
Self::ResourcePackSend(p)
}
}
/// `update_entity_nbt` (clientbound play, id 0x49).
#[derive(Debug, Clone, PartialEq)]
pub struct UpdateEntityNbt {
/// `entityId`
pub entity_id: i32,
/// `tag`
pub tag: RawNbt,
}
impl crate::packet::Packet for UpdateEntityNbt {
const ID: i32 = id::UPDATE_ENTITY_NBT;
const NAME: &'static str = "update_entity_nbt";
const STATE: State = State::Play;
const DIRECTION: Direction = Direction::Clientbound;
}
impl Decode for UpdateEntityNbt {
fn decode(r: &mut Reader<'_>) -> DecodeResult<Self> {
Ok({
let v883 = r.read_varint()?;
let v884 = RawNbt::read(r)?;
UpdateEntityNbt {
entity_id: v883,
tag: v884,
}
})
}
}
impl Encode for UpdateEntityNbt {
fn encode(&self, w: &mut BytesMut) -> EncodeResult {
w.put_varint((*self).entity_id);
(*self).tag.write(w);
Ok(())
}
}
#[cfg(feature = "testgen")]
impl Generate for UpdateEntityNbt {
fn generate(g: &mut Gen) -> Self {
{
let v885 = (g.int_in(-2147483648, 2147483647, &[]) as i32);
let v886 = g.nbt();
UpdateEntityNbt {
entity_id: v885,
tag: v886,
}
}
}
}
impl From<UpdateEntityNbt> for ClientboundPlayPacket {
fn from(p: UpdateEntityNbt) -> Self {
Self::UpdateEntityNbt(p)
}
}
/// Every Clientbound packet of the Play state.
#[derive(Debug, Clone, PartialEq)]
pub enum ClientboundPlayPacket {
/// `keep_alive`
KeepAlive(KeepAlive),
/// `login`
Login(Login),
/// `chat`
Chat(Chat),
/// `update_time`
UpdateTime(UpdateTime),
/// `entity_equipment`
EntityEquipment(EntityEquipment),
/// `spawn_position`
SpawnPosition(SpawnPosition),
/// `update_health`
UpdateHealth(UpdateHealth),
/// `respawn`
Respawn(Respawn),
/// `position`
Position(Position),
/// `held_item_slot`
HeldItemSlot(HeldItemSlot),
/// `bed`
Bed(Bed),
/// `animation`
Animation(Animation),
/// `named_entity_spawn`
NamedEntitySpawn(NamedEntitySpawn),
/// `collect`
Collect(Collect),
/// `spawn_entity`
SpawnEntity(SpawnEntity),
/// `spawn_entity_living`
SpawnEntityLiving(SpawnEntityLiving),
/// `spawn_entity_painting`
SpawnEntityPainting(SpawnEntityPainting),
/// `spawn_entity_experience_orb`
SpawnEntityExperienceOrb(SpawnEntityExperienceOrb),
/// `entity_velocity`
EntityVelocity(EntityVelocity),
/// `entity_destroy`
EntityDestroy(EntityDestroy),
/// `entity`
Entity(Entity),
/// `rel_entity_move`
RelEntityMove(RelEntityMove),
/// `entity_look`
EntityLook(EntityLook),
/// `entity_move_look`
EntityMoveLook(EntityMoveLook),
/// `entity_teleport`
EntityTeleport(EntityTeleport),
/// `entity_head_rotation`
EntityHeadRotation(EntityHeadRotation),
/// `entity_status`
EntityStatus(EntityStatus),
/// `attach_entity`
AttachEntity(AttachEntity),
/// `entity_metadata`
EntityMetadata(EntityMetadata),
/// `entity_effect`
EntityEffect(EntityEffect),
/// `remove_entity_effect`
RemoveEntityEffect(RemoveEntityEffect),
/// `experience`
Experience(Experience),
/// `update_attributes`
UpdateAttributes(UpdateAttributes),
/// `map_chunk`
MapChunk(MapChunk),
/// `multi_block_change`
MultiBlockChange(MultiBlockChange),
/// `block_change`
BlockChange(BlockChange),
/// `block_action`
BlockAction(BlockAction),
/// `block_break_animation`
BlockBreakAnimation(BlockBreakAnimation),
/// `map_chunk_bulk`
MapChunkBulk(MapChunkBulk),
/// `explosion`
Explosion(Explosion),
/// `world_event`
WorldEvent(WorldEvent),
/// `named_sound_effect`
NamedSoundEffect(NamedSoundEffect),
/// `world_particles`
WorldParticles(WorldParticles),
/// `game_state_change`
GameStateChange(GameStateChange),
/// `spawn_entity_weather`
SpawnEntityWeather(SpawnEntityWeather),
/// `open_window`
OpenWindow(OpenWindow),
/// `close_window`
CloseWindow(CloseWindow),
/// `set_slot`
SetSlot(SetSlot),
/// `window_items`
WindowItems(WindowItems),
/// `craft_progress_bar`
CraftProgressBar(CraftProgressBar),
/// `transaction`
Transaction(Transaction),
/// `update_sign`
UpdateSign(UpdateSign),
/// `map`
Map(Map),
/// `tile_entity_data`
TileEntityData(TileEntityData),
/// `open_sign_entity`
OpenSignEntity(OpenSignEntity),
/// `statistics`
Statistics(Statistics),
/// `player_info`
PlayerInfo(PlayerInfo),
/// `abilities`
Abilities(Abilities),
/// `tab_complete`
TabComplete(TabComplete),
/// `scoreboard_objective`
ScoreboardObjective(ScoreboardObjective),
/// `scoreboard_score`
ScoreboardScore(ScoreboardScore),
/// `scoreboard_display_objective`
ScoreboardDisplayObjective(ScoreboardDisplayObjective),
/// `scoreboard_team`
ScoreboardTeam(ScoreboardTeam),
/// `custom_payload`
CustomPayload(CustomPayload),
/// `kick_disconnect`
KickDisconnect(KickDisconnect),
/// `difficulty`
Difficulty(Difficulty),
/// `combat_event`
CombatEvent(CombatEvent),
/// `camera`
Camera(Camera),
/// `world_border`
WorldBorder(WorldBorder),
/// `title`
Title(Title),
/// `set_compression`
SetCompression(SetCompression),
/// `playerlist_header`
PlayerlistHeader(PlayerlistHeader),
/// `resource_pack_send`
ResourcePackSend(ResourcePackSend),
/// `update_entity_nbt`
UpdateEntityNbt(UpdateEntityNbt),
}
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::KEEP_ALIVE => decode_exact(&raw.body).map(Self::KeepAlive),
id::LOGIN => decode_exact(&raw.body).map(Self::Login),
id::CHAT => decode_exact(&raw.body).map(Self::Chat),
id::UPDATE_TIME => decode_exact(&raw.body).map(Self::UpdateTime),
id::ENTITY_EQUIPMENT => decode_exact(&raw.body).map(Self::EntityEquipment),
id::SPAWN_POSITION => decode_exact(&raw.body).map(Self::SpawnPosition),
id::UPDATE_HEALTH => decode_exact(&raw.body).map(Self::UpdateHealth),
id::RESPAWN => decode_exact(&raw.body).map(Self::Respawn),
id::POSITION => decode_exact(&raw.body).map(Self::Position),
id::HELD_ITEM_SLOT => decode_exact(&raw.body).map(Self::HeldItemSlot),
id::BED => decode_exact(&raw.body).map(Self::Bed),
id::ANIMATION => decode_exact(&raw.body).map(Self::Animation),
id::NAMED_ENTITY_SPAWN => decode_exact(&raw.body).map(Self::NamedEntitySpawn),
id::COLLECT => decode_exact(&raw.body).map(Self::Collect),
id::SPAWN_ENTITY => decode_exact(&raw.body).map(Self::SpawnEntity),
id::SPAWN_ENTITY_LIVING => decode_exact(&raw.body).map(Self::SpawnEntityLiving),
id::SPAWN_ENTITY_PAINTING => decode_exact(&raw.body).map(Self::SpawnEntityPainting),
id::SPAWN_ENTITY_EXPERIENCE_ORB => {
decode_exact(&raw.body).map(Self::SpawnEntityExperienceOrb)
}
id::ENTITY_VELOCITY => decode_exact(&raw.body).map(Self::EntityVelocity),
id::ENTITY_DESTROY => decode_exact(&raw.body).map(Self::EntityDestroy),
id::ENTITY => decode_exact(&raw.body).map(Self::Entity),
id::REL_ENTITY_MOVE => decode_exact(&raw.body).map(Self::RelEntityMove),
id::ENTITY_LOOK => decode_exact(&raw.body).map(Self::EntityLook),
id::ENTITY_MOVE_LOOK => decode_exact(&raw.body).map(Self::EntityMoveLook),
id::ENTITY_TELEPORT => decode_exact(&raw.body).map(Self::EntityTeleport),
id::ENTITY_HEAD_ROTATION => decode_exact(&raw.body).map(Self::EntityHeadRotation),
id::ENTITY_STATUS => decode_exact(&raw.body).map(Self::EntityStatus),
id::ATTACH_ENTITY => decode_exact(&raw.body).map(Self::AttachEntity),
id::ENTITY_METADATA => decode_exact(&raw.body).map(Self::EntityMetadata),
id::ENTITY_EFFECT => decode_exact(&raw.body).map(Self::EntityEffect),
id::REMOVE_ENTITY_EFFECT => decode_exact(&raw.body).map(Self::RemoveEntityEffect),
id::EXPERIENCE => decode_exact(&raw.body).map(Self::Experience),
id::UPDATE_ATTRIBUTES => decode_exact(&raw.body).map(Self::UpdateAttributes),
id::MAP_CHUNK => decode_exact(&raw.body).map(Self::MapChunk),
id::MULTI_BLOCK_CHANGE => decode_exact(&raw.body).map(Self::MultiBlockChange),
id::BLOCK_CHANGE => decode_exact(&raw.body).map(Self::BlockChange),
id::BLOCK_ACTION => decode_exact(&raw.body).map(Self::BlockAction),
id::BLOCK_BREAK_ANIMATION => decode_exact(&raw.body).map(Self::BlockBreakAnimation),
id::MAP_CHUNK_BULK => decode_exact(&raw.body).map(Self::MapChunkBulk),
id::EXPLOSION => decode_exact(&raw.body).map(Self::Explosion),
id::WORLD_EVENT => decode_exact(&raw.body).map(Self::WorldEvent),
id::NAMED_SOUND_EFFECT => decode_exact(&raw.body).map(Self::NamedSoundEffect),
id::WORLD_PARTICLES => decode_exact(&raw.body).map(Self::WorldParticles),
id::GAME_STATE_CHANGE => decode_exact(&raw.body).map(Self::GameStateChange),
id::SPAWN_ENTITY_WEATHER => decode_exact(&raw.body).map(Self::SpawnEntityWeather),
id::OPEN_WINDOW => decode_exact(&raw.body).map(Self::OpenWindow),
id::CLOSE_WINDOW => decode_exact(&raw.body).map(Self::CloseWindow),
id::SET_SLOT => decode_exact(&raw.body).map(Self::SetSlot),
id::WINDOW_ITEMS => decode_exact(&raw.body).map(Self::WindowItems),
id::CRAFT_PROGRESS_BAR => decode_exact(&raw.body).map(Self::CraftProgressBar),
id::TRANSACTION => decode_exact(&raw.body).map(Self::Transaction),
id::UPDATE_SIGN => decode_exact(&raw.body).map(Self::UpdateSign),
id::MAP => decode_exact(&raw.body).map(Self::Map),
id::TILE_ENTITY_DATA => decode_exact(&raw.body).map(Self::TileEntityData),
id::OPEN_SIGN_ENTITY => decode_exact(&raw.body).map(Self::OpenSignEntity),
id::STATISTICS => decode_exact(&raw.body).map(Self::Statistics),
id::PLAYER_INFO => decode_exact(&raw.body).map(Self::PlayerInfo),
id::ABILITIES => decode_exact(&raw.body).map(Self::Abilities),
id::TAB_COMPLETE => decode_exact(&raw.body).map(Self::TabComplete),
id::SCOREBOARD_OBJECTIVE => decode_exact(&raw.body).map(Self::ScoreboardObjective),
id::SCOREBOARD_SCORE => decode_exact(&raw.body).map(Self::ScoreboardScore),
id::SCOREBOARD_DISPLAY_OBJECTIVE => {
decode_exact(&raw.body).map(Self::ScoreboardDisplayObjective)
}
id::SCOREBOARD_TEAM => decode_exact(&raw.body).map(Self::ScoreboardTeam),
id::CUSTOM_PAYLOAD => decode_exact(&raw.body).map(Self::CustomPayload),
id::KICK_DISCONNECT => decode_exact(&raw.body).map(Self::KickDisconnect),
id::DIFFICULTY => decode_exact(&raw.body).map(Self::Difficulty),
id::COMBAT_EVENT => decode_exact(&raw.body).map(Self::CombatEvent),
id::CAMERA => decode_exact(&raw.body).map(Self::Camera),
id::WORLD_BORDER => decode_exact(&raw.body).map(Self::WorldBorder),
id::TITLE => decode_exact(&raw.body).map(Self::Title),
id::SET_COMPRESSION => decode_exact(&raw.body).map(Self::SetCompression),
id::PLAYERLIST_HEADER => decode_exact(&raw.body).map(Self::PlayerlistHeader),
id::RESOURCE_PACK_SEND => decode_exact(&raw.body).map(Self::ResourcePackSend),
id::UPDATE_ENTITY_NBT => decode_exact(&raw.body).map(Self::UpdateEntityNbt),
other => Err(DecodeError::UnknownPacketId(other)),
}
}
fn id(&self) -> i32 {
match *self {
Self::KeepAlive(_) => id::KEEP_ALIVE,
Self::Login(_) => id::LOGIN,
Self::Chat(_) => id::CHAT,
Self::UpdateTime(_) => id::UPDATE_TIME,
Self::EntityEquipment(_) => id::ENTITY_EQUIPMENT,
Self::SpawnPosition(_) => id::SPAWN_POSITION,
Self::UpdateHealth(_) => id::UPDATE_HEALTH,
Self::Respawn(_) => id::RESPAWN,
Self::Position(_) => id::POSITION,
Self::HeldItemSlot(_) => id::HELD_ITEM_SLOT,
Self::Bed(_) => id::BED,
Self::Animation(_) => id::ANIMATION,
Self::NamedEntitySpawn(_) => id::NAMED_ENTITY_SPAWN,
Self::Collect(_) => id::COLLECT,
Self::SpawnEntity(_) => id::SPAWN_ENTITY,
Self::SpawnEntityLiving(_) => id::SPAWN_ENTITY_LIVING,
Self::SpawnEntityPainting(_) => id::SPAWN_ENTITY_PAINTING,
Self::SpawnEntityExperienceOrb(_) => id::SPAWN_ENTITY_EXPERIENCE_ORB,
Self::EntityVelocity(_) => id::ENTITY_VELOCITY,
Self::EntityDestroy(_) => id::ENTITY_DESTROY,
Self::Entity(_) => id::ENTITY,
Self::RelEntityMove(_) => id::REL_ENTITY_MOVE,
Self::EntityLook(_) => id::ENTITY_LOOK,
Self::EntityMoveLook(_) => id::ENTITY_MOVE_LOOK,
Self::EntityTeleport(_) => id::ENTITY_TELEPORT,
Self::EntityHeadRotation(_) => id::ENTITY_HEAD_ROTATION,
Self::EntityStatus(_) => id::ENTITY_STATUS,
Self::AttachEntity(_) => id::ATTACH_ENTITY,
Self::EntityMetadata(_) => id::ENTITY_METADATA,
Self::EntityEffect(_) => id::ENTITY_EFFECT,
Self::RemoveEntityEffect(_) => id::REMOVE_ENTITY_EFFECT,
Self::Experience(_) => id::EXPERIENCE,
Self::UpdateAttributes(_) => id::UPDATE_ATTRIBUTES,
Self::MapChunk(_) => id::MAP_CHUNK,
Self::MultiBlockChange(_) => id::MULTI_BLOCK_CHANGE,
Self::BlockChange(_) => id::BLOCK_CHANGE,
Self::BlockAction(_) => id::BLOCK_ACTION,
Self::BlockBreakAnimation(_) => id::BLOCK_BREAK_ANIMATION,
Self::MapChunkBulk(_) => id::MAP_CHUNK_BULK,
Self::Explosion(_) => id::EXPLOSION,
Self::WorldEvent(_) => id::WORLD_EVENT,
Self::NamedSoundEffect(_) => id::NAMED_SOUND_EFFECT,
Self::WorldParticles(_) => id::WORLD_PARTICLES,
Self::GameStateChange(_) => id::GAME_STATE_CHANGE,
Self::SpawnEntityWeather(_) => id::SPAWN_ENTITY_WEATHER,
Self::OpenWindow(_) => id::OPEN_WINDOW,
Self::CloseWindow(_) => id::CLOSE_WINDOW,
Self::SetSlot(_) => id::SET_SLOT,
Self::WindowItems(_) => id::WINDOW_ITEMS,
Self::CraftProgressBar(_) => id::CRAFT_PROGRESS_BAR,
Self::Transaction(_) => id::TRANSACTION,
Self::UpdateSign(_) => id::UPDATE_SIGN,
Self::Map(_) => id::MAP,
Self::TileEntityData(_) => id::TILE_ENTITY_DATA,
Self::OpenSignEntity(_) => id::OPEN_SIGN_ENTITY,
Self::Statistics(_) => id::STATISTICS,
Self::PlayerInfo(_) => id::PLAYER_INFO,
Self::Abilities(_) => id::ABILITIES,
Self::TabComplete(_) => id::TAB_COMPLETE,
Self::ScoreboardObjective(_) => id::SCOREBOARD_OBJECTIVE,
Self::ScoreboardScore(_) => id::SCOREBOARD_SCORE,
Self::ScoreboardDisplayObjective(_) => id::SCOREBOARD_DISPLAY_OBJECTIVE,
Self::ScoreboardTeam(_) => id::SCOREBOARD_TEAM,
Self::CustomPayload(_) => id::CUSTOM_PAYLOAD,
Self::KickDisconnect(_) => id::KICK_DISCONNECT,
Self::Difficulty(_) => id::DIFFICULTY,
Self::CombatEvent(_) => id::COMBAT_EVENT,
Self::Camera(_) => id::CAMERA,
Self::WorldBorder(_) => id::WORLD_BORDER,
Self::Title(_) => id::TITLE,
Self::SetCompression(_) => id::SET_COMPRESSION,
Self::PlayerlistHeader(_) => id::PLAYERLIST_HEADER,
Self::ResourcePackSend(_) => id::RESOURCE_PACK_SEND,
Self::UpdateEntityNbt(_) => id::UPDATE_ENTITY_NBT,
}
}
fn name(&self) -> &'static str {
match *self {
Self::KeepAlive(_) => "keep_alive",
Self::Login(_) => "login",
Self::Chat(_) => "chat",
Self::UpdateTime(_) => "update_time",
Self::EntityEquipment(_) => "entity_equipment",
Self::SpawnPosition(_) => "spawn_position",
Self::UpdateHealth(_) => "update_health",
Self::Respawn(_) => "respawn",
Self::Position(_) => "position",
Self::HeldItemSlot(_) => "held_item_slot",
Self::Bed(_) => "bed",
Self::Animation(_) => "animation",
Self::NamedEntitySpawn(_) => "named_entity_spawn",
Self::Collect(_) => "collect",
Self::SpawnEntity(_) => "spawn_entity",
Self::SpawnEntityLiving(_) => "spawn_entity_living",
Self::SpawnEntityPainting(_) => "spawn_entity_painting",
Self::SpawnEntityExperienceOrb(_) => "spawn_entity_experience_orb",
Self::EntityVelocity(_) => "entity_velocity",
Self::EntityDestroy(_) => "entity_destroy",
Self::Entity(_) => "entity",
Self::RelEntityMove(_) => "rel_entity_move",
Self::EntityLook(_) => "entity_look",
Self::EntityMoveLook(_) => "entity_move_look",
Self::EntityTeleport(_) => "entity_teleport",
Self::EntityHeadRotation(_) => "entity_head_rotation",
Self::EntityStatus(_) => "entity_status",
Self::AttachEntity(_) => "attach_entity",
Self::EntityMetadata(_) => "entity_metadata",
Self::EntityEffect(_) => "entity_effect",
Self::RemoveEntityEffect(_) => "remove_entity_effect",
Self::Experience(_) => "experience",
Self::UpdateAttributes(_) => "update_attributes",
Self::MapChunk(_) => "map_chunk",
Self::MultiBlockChange(_) => "multi_block_change",
Self::BlockChange(_) => "block_change",
Self::BlockAction(_) => "block_action",
Self::BlockBreakAnimation(_) => "block_break_animation",
Self::MapChunkBulk(_) => "map_chunk_bulk",
Self::Explosion(_) => "explosion",
Self::WorldEvent(_) => "world_event",
Self::NamedSoundEffect(_) => "named_sound_effect",
Self::WorldParticles(_) => "world_particles",
Self::GameStateChange(_) => "game_state_change",
Self::SpawnEntityWeather(_) => "spawn_entity_weather",
Self::OpenWindow(_) => "open_window",
Self::CloseWindow(_) => "close_window",
Self::SetSlot(_) => "set_slot",
Self::WindowItems(_) => "window_items",
Self::CraftProgressBar(_) => "craft_progress_bar",
Self::Transaction(_) => "transaction",
Self::UpdateSign(_) => "update_sign",
Self::Map(_) => "map",
Self::TileEntityData(_) => "tile_entity_data",
Self::OpenSignEntity(_) => "open_sign_entity",
Self::Statistics(_) => "statistics",
Self::PlayerInfo(_) => "player_info",
Self::Abilities(_) => "abilities",
Self::TabComplete(_) => "tab_complete",
Self::ScoreboardObjective(_) => "scoreboard_objective",
Self::ScoreboardScore(_) => "scoreboard_score",
Self::ScoreboardDisplayObjective(_) => "scoreboard_display_objective",
Self::ScoreboardTeam(_) => "scoreboard_team",
Self::CustomPayload(_) => "custom_payload",
Self::KickDisconnect(_) => "kick_disconnect",
Self::Difficulty(_) => "difficulty",
Self::CombatEvent(_) => "combat_event",
Self::Camera(_) => "camera",
Self::WorldBorder(_) => "world_border",
Self::Title(_) => "title",
Self::SetCompression(_) => "set_compression",
Self::PlayerlistHeader(_) => "playerlist_header",
Self::ResourcePackSend(_) => "resource_pack_send",
Self::UpdateEntityNbt(_) => "update_entity_nbt",
}
}
fn encode_body(&self, w: &mut BytesMut) -> EncodeResult {
match *self {
Self::KeepAlive(ref p) => p.encode(w),
Self::Login(ref p) => p.encode(w),
Self::Chat(ref p) => p.encode(w),
Self::UpdateTime(ref p) => p.encode(w),
Self::EntityEquipment(ref p) => p.encode(w),
Self::SpawnPosition(ref p) => p.encode(w),
Self::UpdateHealth(ref p) => p.encode(w),
Self::Respawn(ref p) => p.encode(w),
Self::Position(ref p) => p.encode(w),
Self::HeldItemSlot(ref p) => p.encode(w),
Self::Bed(ref p) => p.encode(w),
Self::Animation(ref p) => p.encode(w),
Self::NamedEntitySpawn(ref p) => p.encode(w),
Self::Collect(ref p) => p.encode(w),
Self::SpawnEntity(ref p) => p.encode(w),
Self::SpawnEntityLiving(ref p) => p.encode(w),
Self::SpawnEntityPainting(ref p) => p.encode(w),
Self::SpawnEntityExperienceOrb(ref p) => p.encode(w),
Self::EntityVelocity(ref p) => p.encode(w),
Self::EntityDestroy(ref p) => p.encode(w),
Self::Entity(ref p) => p.encode(w),
Self::RelEntityMove(ref p) => p.encode(w),
Self::EntityLook(ref p) => p.encode(w),
Self::EntityMoveLook(ref p) => p.encode(w),
Self::EntityTeleport(ref p) => p.encode(w),
Self::EntityHeadRotation(ref p) => p.encode(w),
Self::EntityStatus(ref p) => p.encode(w),
Self::AttachEntity(ref p) => p.encode(w),
Self::EntityMetadata(ref p) => p.encode(w),
Self::EntityEffect(ref p) => p.encode(w),
Self::RemoveEntityEffect(ref p) => p.encode(w),
Self::Experience(ref p) => p.encode(w),
Self::UpdateAttributes(ref p) => p.encode(w),
Self::MapChunk(ref p) => p.encode(w),
Self::MultiBlockChange(ref p) => p.encode(w),
Self::BlockChange(ref p) => p.encode(w),
Self::BlockAction(ref p) => p.encode(w),
Self::BlockBreakAnimation(ref p) => p.encode(w),
Self::MapChunkBulk(ref p) => p.encode(w),
Self::Explosion(ref p) => p.encode(w),
Self::WorldEvent(ref p) => p.encode(w),
Self::NamedSoundEffect(ref p) => p.encode(w),
Self::WorldParticles(ref p) => p.encode(w),
Self::GameStateChange(ref p) => p.encode(w),
Self::SpawnEntityWeather(ref p) => p.encode(w),
Self::OpenWindow(ref p) => p.encode(w),
Self::CloseWindow(ref p) => p.encode(w),
Self::SetSlot(ref p) => p.encode(w),
Self::WindowItems(ref p) => p.encode(w),
Self::CraftProgressBar(ref p) => p.encode(w),
Self::Transaction(ref p) => p.encode(w),
Self::UpdateSign(ref p) => p.encode(w),
Self::Map(ref p) => p.encode(w),
Self::TileEntityData(ref p) => p.encode(w),
Self::OpenSignEntity(ref p) => p.encode(w),
Self::Statistics(ref p) => p.encode(w),
Self::PlayerInfo(ref p) => p.encode(w),
Self::Abilities(ref p) => p.encode(w),
Self::TabComplete(ref p) => p.encode(w),
Self::ScoreboardObjective(ref p) => p.encode(w),
Self::ScoreboardScore(ref p) => p.encode(w),
Self::ScoreboardDisplayObjective(ref p) => p.encode(w),
Self::ScoreboardTeam(ref p) => p.encode(w),
Self::CustomPayload(ref p) => p.encode(w),
Self::KickDisconnect(ref p) => p.encode(w),
Self::Difficulty(ref p) => p.encode(w),
Self::CombatEvent(ref p) => p.encode(w),
Self::Camera(ref p) => p.encode(w),
Self::WorldBorder(ref p) => p.encode(w),
Self::Title(ref p) => p.encode(w),
Self::SetCompression(ref p) => p.encode(w),
Self::PlayerlistHeader(ref p) => p.encode(w),
Self::ResourcePackSend(ref p) => p.encode(w),
Self::UpdateEntityNbt(ref p) => p.encode(w),
}
}
fn name_of(id: i32) -> Option<&'static str> {
match id {
id::KEEP_ALIVE => Some("keep_alive"),
id::LOGIN => Some("login"),
id::CHAT => Some("chat"),
id::UPDATE_TIME => Some("update_time"),
id::ENTITY_EQUIPMENT => Some("entity_equipment"),
id::SPAWN_POSITION => Some("spawn_position"),
id::UPDATE_HEALTH => Some("update_health"),
id::RESPAWN => Some("respawn"),
id::POSITION => Some("position"),
id::HELD_ITEM_SLOT => Some("held_item_slot"),
id::BED => Some("bed"),
id::ANIMATION => Some("animation"),
id::NAMED_ENTITY_SPAWN => Some("named_entity_spawn"),
id::COLLECT => Some("collect"),
id::SPAWN_ENTITY => Some("spawn_entity"),
id::SPAWN_ENTITY_LIVING => Some("spawn_entity_living"),
id::SPAWN_ENTITY_PAINTING => Some("spawn_entity_painting"),
id::SPAWN_ENTITY_EXPERIENCE_ORB => Some("spawn_entity_experience_orb"),
id::ENTITY_VELOCITY => Some("entity_velocity"),
id::ENTITY_DESTROY => Some("entity_destroy"),
id::ENTITY => Some("entity"),
id::REL_ENTITY_MOVE => Some("rel_entity_move"),
id::ENTITY_LOOK => Some("entity_look"),
id::ENTITY_MOVE_LOOK => Some("entity_move_look"),
id::ENTITY_TELEPORT => Some("entity_teleport"),
id::ENTITY_HEAD_ROTATION => Some("entity_head_rotation"),
id::ENTITY_STATUS => Some("entity_status"),
id::ATTACH_ENTITY => Some("attach_entity"),
id::ENTITY_METADATA => Some("entity_metadata"),
id::ENTITY_EFFECT => Some("entity_effect"),
id::REMOVE_ENTITY_EFFECT => Some("remove_entity_effect"),
id::EXPERIENCE => Some("experience"),
id::UPDATE_ATTRIBUTES => Some("update_attributes"),
id::MAP_CHUNK => Some("map_chunk"),
id::MULTI_BLOCK_CHANGE => Some("multi_block_change"),
id::BLOCK_CHANGE => Some("block_change"),
id::BLOCK_ACTION => Some("block_action"),
id::BLOCK_BREAK_ANIMATION => Some("block_break_animation"),
id::MAP_CHUNK_BULK => Some("map_chunk_bulk"),
id::EXPLOSION => Some("explosion"),
id::WORLD_EVENT => Some("world_event"),
id::NAMED_SOUND_EFFECT => Some("named_sound_effect"),
id::WORLD_PARTICLES => Some("world_particles"),
id::GAME_STATE_CHANGE => Some("game_state_change"),
id::SPAWN_ENTITY_WEATHER => Some("spawn_entity_weather"),
id::OPEN_WINDOW => Some("open_window"),
id::CLOSE_WINDOW => Some("close_window"),
id::SET_SLOT => Some("set_slot"),
id::WINDOW_ITEMS => Some("window_items"),
id::CRAFT_PROGRESS_BAR => Some("craft_progress_bar"),
id::TRANSACTION => Some("transaction"),
id::UPDATE_SIGN => Some("update_sign"),
id::MAP => Some("map"),
id::TILE_ENTITY_DATA => Some("tile_entity_data"),
id::OPEN_SIGN_ENTITY => Some("open_sign_entity"),
id::STATISTICS => Some("statistics"),
id::PLAYER_INFO => Some("player_info"),
id::ABILITIES => Some("abilities"),
id::TAB_COMPLETE => Some("tab_complete"),
id::SCOREBOARD_OBJECTIVE => Some("scoreboard_objective"),
id::SCOREBOARD_SCORE => Some("scoreboard_score"),
id::SCOREBOARD_DISPLAY_OBJECTIVE => Some("scoreboard_display_objective"),
id::SCOREBOARD_TEAM => Some("scoreboard_team"),
id::CUSTOM_PAYLOAD => Some("custom_payload"),
id::KICK_DISCONNECT => Some("kick_disconnect"),
id::DIFFICULTY => Some("difficulty"),
id::COMBAT_EVENT => Some("combat_event"),
id::CAMERA => Some("camera"),
id::WORLD_BORDER => Some("world_border"),
id::TITLE => Some("title"),
id::SET_COMPRESSION => Some("set_compression"),
id::PLAYERLIST_HEADER => Some("playerlist_header"),
id::RESOURCE_PACK_SEND => Some("resource_pack_send"),
id::UPDATE_ENTITY_NBT => Some("update_entity_nbt"),
_ => None,
}
}
}
impl ClientboundPlayPacket {
/// All packet ids of this set, ascending.
pub const IDS: &'static [i32] = &[
id::KEEP_ALIVE,
id::LOGIN,
id::CHAT,
id::UPDATE_TIME,
id::ENTITY_EQUIPMENT,
id::SPAWN_POSITION,
id::UPDATE_HEALTH,
id::RESPAWN,
id::POSITION,
id::HELD_ITEM_SLOT,
id::BED,
id::ANIMATION,
id::NAMED_ENTITY_SPAWN,
id::COLLECT,
id::SPAWN_ENTITY,
id::SPAWN_ENTITY_LIVING,
id::SPAWN_ENTITY_PAINTING,
id::SPAWN_ENTITY_EXPERIENCE_ORB,
id::ENTITY_VELOCITY,
id::ENTITY_DESTROY,
id::ENTITY,
id::REL_ENTITY_MOVE,
id::ENTITY_LOOK,
id::ENTITY_MOVE_LOOK,
id::ENTITY_TELEPORT,
id::ENTITY_HEAD_ROTATION,
id::ENTITY_STATUS,
id::ATTACH_ENTITY,
id::ENTITY_METADATA,
id::ENTITY_EFFECT,
id::REMOVE_ENTITY_EFFECT,
id::EXPERIENCE,
id::UPDATE_ATTRIBUTES,
id::MAP_CHUNK,
id::MULTI_BLOCK_CHANGE,
id::BLOCK_CHANGE,
id::BLOCK_ACTION,
id::BLOCK_BREAK_ANIMATION,
id::MAP_CHUNK_BULK,
id::EXPLOSION,
id::WORLD_EVENT,
id::NAMED_SOUND_EFFECT,
id::WORLD_PARTICLES,
id::GAME_STATE_CHANGE,
id::SPAWN_ENTITY_WEATHER,
id::OPEN_WINDOW,
id::CLOSE_WINDOW,
id::SET_SLOT,
id::WINDOW_ITEMS,
id::CRAFT_PROGRESS_BAR,
id::TRANSACTION,
id::UPDATE_SIGN,
id::MAP,
id::TILE_ENTITY_DATA,
id::OPEN_SIGN_ENTITY,
id::STATISTICS,
id::PLAYER_INFO,
id::ABILITIES,
id::TAB_COMPLETE,
id::SCOREBOARD_OBJECTIVE,
id::SCOREBOARD_SCORE,
id::SCOREBOARD_DISPLAY_OBJECTIVE,
id::SCOREBOARD_TEAM,
id::CUSTOM_PAYLOAD,
id::KICK_DISCONNECT,
id::DIFFICULTY,
id::COMBAT_EVENT,
id::CAMERA,
id::WORLD_BORDER,
id::TITLE,
id::SET_COMPRESSION,
id::PLAYERLIST_HEADER,
id::RESOURCE_PACK_SEND,
id::UPDATE_ENTITY_NBT,
];
/// 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::KEEP_ALIVE => Some(Self::KeepAlive(<KeepAlive as Generate>::generate(g))),
id::LOGIN => Some(Self::Login(<Login as Generate>::generate(g))),
id::CHAT => Some(Self::Chat(<Chat as Generate>::generate(g))),
id::UPDATE_TIME => Some(Self::UpdateTime(<UpdateTime as Generate>::generate(g))),
id::ENTITY_EQUIPMENT => Some(Self::EntityEquipment(
<EntityEquipment as Generate>::generate(g),
)),
id::SPAWN_POSITION => Some(Self::SpawnPosition(<SpawnPosition as Generate>::generate(
g,
))),
id::UPDATE_HEALTH => Some(Self::UpdateHealth(<UpdateHealth as Generate>::generate(g))),
id::RESPAWN => Some(Self::Respawn(<Respawn as Generate>::generate(g))),
id::POSITION => Some(Self::Position(<Position as Generate>::generate(g))),
id::HELD_ITEM_SLOT => Some(Self::HeldItemSlot(<HeldItemSlot as Generate>::generate(g))),
id::BED => Some(Self::Bed(<Bed as Generate>::generate(g))),
id::ANIMATION => Some(Self::Animation(<Animation as Generate>::generate(g))),
id::NAMED_ENTITY_SPAWN => Some(Self::NamedEntitySpawn(
<NamedEntitySpawn as Generate>::generate(g),
)),
id::COLLECT => Some(Self::Collect(<Collect as Generate>::generate(g))),
id::SPAWN_ENTITY => Some(Self::SpawnEntity(<SpawnEntity 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::SPAWN_ENTITY_EXPERIENCE_ORB => Some(Self::SpawnEntityExperienceOrb(
<SpawnEntityExperienceOrb as Generate>::generate(g),
)),
id::ENTITY_VELOCITY => Some(Self::EntityVelocity(
<EntityVelocity as Generate>::generate(g),
)),
id::ENTITY_DESTROY => Some(Self::EntityDestroy(<EntityDestroy 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_LOOK => Some(Self::EntityLook(<EntityLook as Generate>::generate(g))),
id::ENTITY_MOVE_LOOK => Some(Self::EntityMoveLook(
<EntityMoveLook as Generate>::generate(g),
)),
id::ENTITY_TELEPORT => Some(Self::EntityTeleport(
<EntityTeleport as Generate>::generate(g),
)),
id::ENTITY_HEAD_ROTATION => Some(Self::EntityHeadRotation(
<EntityHeadRotation as Generate>::generate(g),
)),
id::ENTITY_STATUS => Some(Self::EntityStatus(<EntityStatus as Generate>::generate(g))),
id::ATTACH_ENTITY => Some(Self::AttachEntity(<AttachEntity as Generate>::generate(g))),
id::ENTITY_METADATA => Some(Self::EntityMetadata(
<EntityMetadata as Generate>::generate(g),
)),
id::ENTITY_EFFECT => Some(Self::EntityEffect(<EntityEffect as Generate>::generate(g))),
id::REMOVE_ENTITY_EFFECT => Some(Self::RemoveEntityEffect(
<RemoveEntityEffect as Generate>::generate(g),
)),
id::EXPERIENCE => Some(Self::Experience(<Experience as Generate>::generate(g))),
id::UPDATE_ATTRIBUTES => Some(Self::UpdateAttributes(
<UpdateAttributes as Generate>::generate(g),
)),
id::MAP_CHUNK => Some(Self::MapChunk(<MapChunk as Generate>::generate(g))),
id::MULTI_BLOCK_CHANGE => Some(Self::MultiBlockChange(
<MultiBlockChange as Generate>::generate(g),
)),
id::BLOCK_CHANGE => Some(Self::BlockChange(<BlockChange as Generate>::generate(g))),
id::BLOCK_ACTION => Some(Self::BlockAction(<BlockAction as Generate>::generate(g))),
id::BLOCK_BREAK_ANIMATION => Some(Self::BlockBreakAnimation(
<BlockBreakAnimation as Generate>::generate(g),
)),
id::MAP_CHUNK_BULK => Some(Self::MapChunkBulk(<MapChunkBulk as Generate>::generate(g))),
id::EXPLOSION => Some(Self::Explosion(<Explosion as Generate>::generate(g))),
id::WORLD_EVENT => Some(Self::WorldEvent(<WorldEvent as Generate>::generate(g))),
id::NAMED_SOUND_EFFECT => Some(Self::NamedSoundEffect(
<NamedSoundEffect as Generate>::generate(g),
)),
id::WORLD_PARTICLES => Some(Self::WorldParticles(
<WorldParticles as Generate>::generate(g),
)),
id::GAME_STATE_CHANGE => Some(Self::GameStateChange(
<GameStateChange as Generate>::generate(g),
)),
id::SPAWN_ENTITY_WEATHER => Some(Self::SpawnEntityWeather(
<SpawnEntityWeather as Generate>::generate(g),
)),
id::OPEN_WINDOW => Some(Self::OpenWindow(<OpenWindow as Generate>::generate(g))),
id::CLOSE_WINDOW => Some(Self::CloseWindow(<CloseWindow as Generate>::generate(g))),
id::SET_SLOT => Some(Self::SetSlot(<SetSlot 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::TRANSACTION => Some(Self::Transaction(<Transaction as Generate>::generate(g))),
id::UPDATE_SIGN => Some(Self::UpdateSign(<UpdateSign as Generate>::generate(g))),
id::MAP => Some(Self::Map(<Map as Generate>::generate(g))),
id::TILE_ENTITY_DATA => Some(Self::TileEntityData(
<TileEntityData as Generate>::generate(g),
)),
id::OPEN_SIGN_ENTITY => Some(Self::OpenSignEntity(
<OpenSignEntity as Generate>::generate(g),
)),
id::STATISTICS => Some(Self::Statistics(<Statistics as Generate>::generate(g))),
id::PLAYER_INFO => Some(Self::PlayerInfo(<PlayerInfo as Generate>::generate(g))),
id::ABILITIES => Some(Self::Abilities(<Abilities as Generate>::generate(g))),
id::TAB_COMPLETE => Some(Self::TabComplete(<TabComplete as Generate>::generate(g))),
id::SCOREBOARD_OBJECTIVE => Some(Self::ScoreboardObjective(
<ScoreboardObjective as Generate>::generate(g),
)),
id::SCOREBOARD_SCORE => Some(Self::ScoreboardScore(
<ScoreboardScore as Generate>::generate(g),
)),
id::SCOREBOARD_DISPLAY_OBJECTIVE => Some(Self::ScoreboardDisplayObjective(
<ScoreboardDisplayObjective as Generate>::generate(g),
)),
id::SCOREBOARD_TEAM => Some(Self::ScoreboardTeam(
<ScoreboardTeam as Generate>::generate(g),
)),
id::CUSTOM_PAYLOAD => Some(Self::CustomPayload(<CustomPayload as Generate>::generate(
g,
))),
id::KICK_DISCONNECT => Some(Self::KickDisconnect(
<KickDisconnect as Generate>::generate(g),
)),
id::DIFFICULTY => Some(Self::Difficulty(<Difficulty as Generate>::generate(g))),
id::COMBAT_EVENT => Some(Self::CombatEvent(<CombatEvent as Generate>::generate(g))),
id::CAMERA => Some(Self::Camera(<Camera as Generate>::generate(g))),
id::WORLD_BORDER => Some(Self::WorldBorder(<WorldBorder as Generate>::generate(g))),
id::TITLE => Some(Self::Title(<Title as Generate>::generate(g))),
id::SET_COMPRESSION => Some(Self::SetCompression(
<SetCompression as Generate>::generate(g),
)),
id::PLAYERLIST_HEADER => Some(Self::PlayerlistHeader(
<PlayerlistHeader as Generate>::generate(g),
)),
id::RESOURCE_PACK_SEND => Some(Self::ResourcePackSend(
<ResourcePackSend as Generate>::generate(g),
)),
id::UPDATE_ENTITY_NBT => Some(Self::UpdateEntityNbt(
<UpdateEntityNbt as Generate>::generate(g),
)),
_ => None,
}
}
}