Minior packet changes

This commit is contained in:
Alexander Medvedev
2025-02-23 13:35:22 +01:00
parent f71ec64e22
commit 26b69eae33
146 changed files with 413 additions and 419 deletions

View File

@@ -154,26 +154,7 @@ pub fn send_cancellable(input: TokenStream) -> TokenStream {
}
#[proc_macro_attribute]
pub fn client_packet(input: TokenStream, item: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(item.clone()).unwrap();
let name = &ast.ident;
let (impl_generics, ty_generics, _) = ast.generics.split_for_impl();
let input: proc_macro2::TokenStream = input.into();
let item: proc_macro2::TokenStream = item.into();
let code = quote! {
#item
impl #impl_generics crate::bytebuf::packet::Packet for #name #ty_generics {
const PACKET_ID: i32 = #input;
}
};
code.into()
}
#[proc_macro_attribute]
pub fn server_packet(input: TokenStream, item: TokenStream) -> TokenStream {
pub fn packet(input: TokenStream, item: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(item.clone()).unwrap();
let name = &ast.ident;
let (impl_generics, ty_generics, _) = ast.generics.split_for_impl();

View File

@@ -207,7 +207,7 @@ impl<B: BufMut> ser::Serializer for &mut Serializer<B> {
unimplemented!()
}
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {
todo!()
Ok(())
}
fn serialize_unit_variant(
self,

View File

@@ -1,12 +1,12 @@
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use pumpkin_data::packet::clientbound::CONFIG_RESOURCE_PACK_PUSH;
#[derive(Serialize)]
#[client_packet(CONFIG_RESOURCE_PACK_PUSH)]
#[packet(CONFIG_RESOURCE_PACK_PUSH)]
pub struct CConfigAddResourcePack<'a> {
uuid: uuid::Uuid,
url: &'a str,

View File

@@ -1,9 +1,9 @@
use pumpkin_macros::client_packet;
use pumpkin_data::packet::clientbound::CONFIG_DISCONNECT;
use pumpkin_macros::packet;
use serde::Deserialize;
#[derive(serde::Serialize)]
#[client_packet(CONFIG_DISCONNECT)]
#[derive(serde::Serialize, Deserialize)]
#[packet(CONFIG_DISCONNECT)]
pub struct CConfigDisconnect<'a> {
reason: &'a str,
}

View File

@@ -1,10 +1,10 @@
use pumpkin_data::packet::clientbound::CONFIG_COOKIE_REQUEST;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::codec::identifier::Identifier;
#[derive(serde::Serialize)]
#[client_packet(CONFIG_COOKIE_REQUEST)]
#[packet(CONFIG_COOKIE_REQUEST)]
/// Requests a cookie that was previously stored.
pub struct CCookieRequest<'a> {
key: &'a Identifier,

View File

@@ -1,18 +1,7 @@
use pumpkin_data::packet::clientbound::CONFIG_FINISH_CONFIGURATION;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(serde::Serialize)]
#[client_packet(CONFIG_FINISH_CONFIGURATION)]
pub struct CFinishConfig {}
impl Default for CFinishConfig {
fn default() -> Self {
Self::new()
}
}
impl CFinishConfig {
pub fn new() -> Self {
Self {}
}
}
#[derive(Serialize)]
#[packet(CONFIG_FINISH_CONFIGURATION)]
pub struct CFinishConfig;

View File

@@ -1,10 +1,10 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::CONFIG_SELECT_KNOWN_PACKS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::{ClientPacket, KnownPack, bytebuf::ByteBufMut};
#[client_packet(CONFIG_SELECT_KNOWN_PACKS)]
#[packet(CONFIG_SELECT_KNOWN_PACKS)]
pub struct CKnownPacks<'a> {
known_packs: &'a [KnownPack<'a>],
}

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::CONFIG_CUSTOM_PAYLOAD;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(CONFIG_CUSTOM_PAYLOAD)]
#[packet(CONFIG_CUSTOM_PAYLOAD)]
pub struct CPluginMessage<'a> {
channel: &'a str,
data: &'a [u8],

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::CONFIG_REGISTRY_DATA;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{ClientPacket, bytebuf::ByteBufMut, codec::identifier::Identifier};
#[client_packet(CONFIG_REGISTRY_DATA)]
#[packet(CONFIG_REGISTRY_DATA)]
pub struct CRegistryData<'a> {
registry_id: &'a Identifier,
entries: &'a [RegistryEntry],

View File

@@ -1,10 +1,10 @@
use crate::{Link, VarInt};
use pumpkin_data::packet::clientbound::CONFIG_SERVER_LINKS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(CONFIG_SERVER_LINKS)]
#[packet(CONFIG_SERVER_LINKS)]
pub struct CConfigServerLinks<'a> {
links_count: &'a VarInt,
links: &'a [Link<'a>],

View File

@@ -1,9 +1,9 @@
use crate::{VarInt, codec::identifier::Identifier};
use pumpkin_data::packet::clientbound::CONFIG_STORE_COOKIE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
#[derive(serde::Serialize)]
#[client_packet(CONFIG_STORE_COOKIE)]
#[packet(CONFIG_STORE_COOKIE)]
/// Stores some arbitrary data on the client, which persists between server transfers.
/// The Notchian (vanilla) client only accepts cookies of up to 5 kiB in size.
pub struct CStoreCookie<'a> {

View File

@@ -1,10 +1,10 @@
use crate::VarInt;
use pumpkin_data::packet::clientbound::CONFIG_TRANSFER;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(CONFIG_TRANSFER)]
#[packet(CONFIG_TRANSFER)]
pub struct CTransfer<'a> {
host: &'a str,
port: &'a VarInt,

View File

@@ -4,7 +4,7 @@ use pumpkin_data::{
packet::clientbound::CONFIG_UPDATE_TAGS,
tag::{RegistryKey, TAGS},
};
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_world::block::registry;
use crate::{
@@ -13,7 +13,7 @@ use crate::{
codec::{identifier::Identifier, var_int::VarInt},
};
#[client_packet(CONFIG_UPDATE_TAGS)]
#[packet(CONFIG_UPDATE_TAGS)]
pub struct CUpdateTags<'a> {
tags: &'a [pumpkin_data::tag::RegistryKey],
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::LOGIN_COOKIE_REQUEST;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::codec::identifier::Identifier;
#[derive(Serialize)]
#[client_packet(LOGIN_COOKIE_REQUEST)]
#[packet(LOGIN_COOKIE_REQUEST)]
/// Requests a cookie that was previously stored.
pub struct CLoginCookieRequest<'a> {
key: &'a Identifier,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::LOGIN_HELLO;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(LOGIN_HELLO)]
#[derive(Serialize, Deserialize)]
#[packet(LOGIN_HELLO)]
pub struct CEncryptionRequest<'a> {
server_id: &'a str, // 20
public_key_length: VarInt,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_DISCONNECT;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(LOGIN_LOGIN_DISCONNECT)]
#[derive(Serialize, Deserialize)]
#[packet(LOGIN_LOGIN_DISCONNECT)]
pub struct CLoginDisconnect<'a> {
json_reason: &'a str,
}

View File

@@ -1,10 +1,10 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_FINISHED;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::{ClientPacket, Property, bytebuf::ByteBufMut};
#[client_packet(LOGIN_LOGIN_FINISHED)]
#[packet(LOGIN_LOGIN_FINISHED)]
pub struct CLoginSuccess<'a> {
pub uuid: &'a uuid::Uuid,
pub username: &'a str, // 16

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::LOGIN_CUSTOM_QUERY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(LOGIN_CUSTOM_QUERY)]
#[packet(LOGIN_CUSTOM_QUERY)]
pub struct CLoginPluginRequest<'a> {
message_id: VarInt,
channel: &'a str,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_COMPRESSION;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(LOGIN_LOGIN_COMPRESSION)]
#[derive(Serialize, Deserialize)]
#[packet(LOGIN_LOGIN_COMPRESSION)]
pub struct CSetCompression {
threshold: VarInt,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_CHANGED_ACK;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_CHANGED_ACK)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_BLOCK_CHANGED_ACK)]
pub struct CAcknowledgeBlockChange {
sequence_id: VarInt,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_ACTION_BAR_TEXT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_ACTION_BAR_TEXT)]
#[packet(PLAY_SET_ACTION_BAR_TEXT)]
pub struct CActionBar<'a> {
action_bar: &'a TextComponent,
}

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_DESTRUCTION;
use pumpkin_util::math::position::BlockPos;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_DESTRUCTION)]
#[packet(PLAY_BLOCK_DESTRUCTION)]
pub struct CSetBlockDestroyStage {
entity_id: VarInt,
location: BlockPos,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_ENTITY_DATA;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_ENTITY_DATA)]
#[packet(PLAY_BLOCK_ENTITY_DATA)]
pub struct CBlockEntityData {
location: BlockPos,
r#type: VarInt,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_EVENT;
use pumpkin_util::math::position::BlockPos;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_EVENT)]
#[packet(PLAY_BLOCK_EVENT)]
pub struct CBlockAction<'a> {
location: &'a BlockPos,
action_id: u8,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_BLOCK_UPDATE;
use pumpkin_util::math::position::BlockPos;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_BLOCK_UPDATE)]
#[packet(PLAY_BLOCK_UPDATE)]
pub struct CBlockUpdate<'a> {
location: &'a BlockPos,
block_id: VarInt,

View File

@@ -3,9 +3,9 @@ use crate::client::play::bossevent_action::BosseventAction;
use crate::{ClientPacket, VarInt};
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_BOSS_EVENT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
#[client_packet(PLAY_BOSS_EVENT)]
#[packet(PLAY_BOSS_EVENT)]
pub struct CBossEvent<'a> {
pub uuid: &'a uuid::Uuid,
pub action: BosseventAction,

View File

@@ -1,10 +1,10 @@
use pumpkin_data::packet::clientbound::PLAY_SET_CHUNK_CACHE_CENTER;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::VarInt;
#[derive(serde::Serialize)]
#[client_packet(PLAY_SET_CHUNK_CACHE_CENTER)]
#[packet(PLAY_SET_CHUNK_CACHE_CENTER)]
pub struct CCenterChunk {
pub chunk_x: VarInt,
pub chunk_z: VarInt,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_CHANGE_DIFFICULTY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_CHANGE_DIFFICULTY)]
#[packet(PLAY_CHANGE_DIFFICULTY)]
pub struct CChangeDifficulty {
difficulty: u8,
locked: bool,

View File

@@ -2,13 +2,13 @@ use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut, codec::bit_set::BitSet};
use bytes::{BufMut, BytesMut};
use pumpkin_data::packet::clientbound::PLAY_LEVEL_CHUNK_WITH_LIGHT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_world::{
DIRECT_PALETTE_BITS,
chunk::{ChunkData, SUBCHUNKS_COUNT},
};
#[client_packet(PLAY_LEVEL_CHUNK_WITH_LIGHT)]
#[packet(PLAY_LEVEL_CHUNK_WITH_LIGHT)]
pub struct CChunkData<'a>(pub &'a ChunkData);
impl ClientPacket for CChunkData<'_> {

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_CLEAR_TITLES;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_CLEAR_TITLES)]
#[packet(PLAY_CLEAR_TITLES)]
pub struct CClearTtitle {
reset: bool,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_CLOSE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_CONTAINER_CLOSE)]
#[packet(PLAY_CONTAINER_CLOSE)]
pub struct CCloseContainer {
window_id: VarInt,
}

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_PLAYER_COMBAT_KILL;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::text::TextComponent;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_PLAYER_COMBAT_KILL)]
#[packet(PLAY_PLAYER_COMBAT_KILL)]
pub struct CCombatDeath<'a> {
player_id: VarInt,
message: &'a TextComponent,

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_COMMAND_SUGGESTIONS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::text::TextComponent;
use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_COMMAND_SUGGESTIONS)]
#[packet(PLAY_COMMAND_SUGGESTIONS)]
pub struct CCommandSuggestions {
id: VarInt,
start: VarInt,

View File

@@ -1,10 +1,10 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_COMMANDS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::{ClientPacket, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_COMMANDS)]
#[packet(PLAY_COMMANDS)]
pub struct CCommands<'a> {
pub nodes: Vec<ProtoNode<'a>>,
pub root_node_index: VarInt,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_COOKIE_REQUEST;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::codec::identifier::Identifier;
#[derive(Serialize)]
#[client_packet(PLAY_COOKIE_REQUEST)]
#[packet(PLAY_COOKIE_REQUEST)]
/// Requests a cookie that was previously stored.
pub struct CPlayCookieRequest<'a> {
key: &'a Identifier,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_DAMAGE_EVENT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_DAMAGE_EVENT)]
#[packet(PLAY_DAMAGE_EVENT)]
pub struct CDamageEvent {
entity_id: VarInt,
source_type_id: VarInt,

View File

@@ -1,17 +1,17 @@
use pumpkin_data::packet::clientbound::PLAY_DISCONNECT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_DISCONNECT)]
pub struct CPlayDisconnect<'a> {
reason: &'a TextComponent,
#[derive(Serialize, Deserialize)]
#[packet(PLAY_DISCONNECT)]
pub struct CPlayDisconnect {
reason: TextComponent,
}
impl<'a> CPlayDisconnect<'a> {
pub fn new(reason: &'a TextComponent) -> Self {
impl CPlayDisconnect {
pub fn new(reason: TextComponent) -> Self {
Self { reason }
}
}

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_DISGUISED_CHAT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_DISGUISED_CHAT)]
#[packet(PLAY_DISGUISED_CHAT)]
pub struct CDisguisedChatMessage<'a> {
message: &'a TextComponent,
chat_type: VarInt,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::{
packet::clientbound::PLAY_SET_DISPLAY_OBJECTIVE, scoreboard::ScoreboardDisplaySlot,
};
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_DISPLAY_OBJECTIVE)]
#[packet(PLAY_SET_DISPLAY_OBJECTIVE)]
pub struct CDisplayObjective<'a> {
position: VarInt,
score_name: &'a str,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_ANIMATE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_ANIMATE)]
#[packet(PLAY_ANIMATE)]
pub struct CEntityAnimation {
entity_id: VarInt,
/// See `Animation`

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_ENTITY_DATA;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_ENTITY_DATA)]
#[packet(PLAY_SET_ENTITY_DATA)]
pub struct CSetEntityMetadata<T> {
entity_id: VarInt,
metadata: Metadata<T>,

View File

@@ -1,10 +1,10 @@
use bytes::BufMut;
use pumpkin_data::{packet::clientbound::PLAY_SOUND_ENTITY, sound::SoundCategory};
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::{ClientPacket, IDOrSoundEvent, SoundEvent, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_SOUND_ENTITY)]
#[packet(PLAY_SOUND_ENTITY)]
pub struct CEntitySoundEffect {
sound_event: IDOrSoundEvent,
sound_category: VarInt,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_ENTITY_EVENT;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_ENTITY_EVENT)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_ENTITY_EVENT)]
pub struct CEntityStatus {
entity_id: i32,
entity_status: i8,

View File

@@ -1,19 +1,19 @@
use pumpkin_data::packet::clientbound::PLAY_SET_ENTITY_MOTION;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_ENTITY_MOTION)]
pub struct CEntityVelocity<'a> {
entity_id: &'a VarInt,
#[packet(PLAY_SET_ENTITY_MOTION)]
pub struct CEntityVelocity {
entity_id: VarInt,
velocity: Vector3<i16>,
}
impl<'a> CEntityVelocity<'a> {
pub fn new(entity_id: &'a VarInt, velocity_x: f64, velocity_y: f64, velocity_z: f64) -> Self {
impl CEntityVelocity {
pub fn new(entity_id: VarInt, velocity_x: f64, velocity_y: f64, velocity_z: f64) -> Self {
Self {
entity_id,
velocity: Vector3::new(

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_GAME_EVENT;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_GAME_EVENT)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_GAME_EVENT)]
pub struct CGameEvent {
event: u8,
value: f32,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_ROTATE_HEAD;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_ROTATE_HEAD)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_ROTATE_HEAD)]
pub struct CHeadRot {
entity_id: VarInt,
head_yaw: u8,

View File

@@ -1,18 +1,18 @@
use pumpkin_data::packet::clientbound::PLAY_HURT_ANIMATION;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_HURT_ANIMATION)]
pub struct CHurtAnimation<'a> {
entity_id: &'a VarInt,
#[derive(Serialize, Deserialize)]
#[packet(PLAY_HURT_ANIMATION)]
pub struct CHurtAnimation {
entity_id: VarInt,
yaw: f32,
}
impl<'a> CHurtAnimation<'a> {
pub fn new(entity_id: &'a VarInt, yaw: f32) -> Self {
impl CHurtAnimation {
pub fn new(entity_id: VarInt, yaw: f32) -> Self {
Self { entity_id, yaw }
}
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_INITIALIZE_BORDER;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{VarInt, codec::var_long::VarLong};
#[derive(Serialize)]
#[client_packet(PLAY_INITIALIZE_BORDER)]
#[packet(PLAY_INITIALIZE_BORDER)]
pub struct CInitializeWorldBorder {
x: f64,
z: f64,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_KEEP_ALIVE;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_KEEP_ALIVE)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_KEEP_ALIVE)]
pub struct CKeepAlive {
keep_alive_id: i64,
}

View File

@@ -1,10 +1,10 @@
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_LEVEL_EVENT)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_LEVEL_EVENT)]
pub struct CLevelEvent {
event: i32,
location: BlockPos,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_LOGIN;
use pumpkin_util::math::position::BlockPos;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{VarInt, codec::identifier::Identifier};
#[derive(Serialize)]
#[client_packet(PLAY_LOGIN)]
#[packet(PLAY_LOGIN)]
pub struct CLogin<'a> {
entity_id: i32,
is_hardcore: bool,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_OPEN_SCREEN;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_OPEN_SCREEN)]
#[packet(PLAY_OPEN_SCREEN)]
pub struct COpenScreen<'a> {
window_id: VarInt,
window_type: VarInt,

View File

@@ -1,10 +1,10 @@
use pumpkin_data::packet::clientbound::PLAY_OPEN_SIGN_EDITOR;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_OPEN_SIGN_EDITOR)]
#[packet(PLAY_OPEN_SIGN_EDITOR)]
pub struct COpenSignEditor {
location: BlockPos,
is_front_text: bool,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_LEVEL_PARTICLES;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_LEVEL_PARTICLES)]
#[packet(PLAY_LEVEL_PARTICLES)]
pub struct CParticle<'a> {
force_spawn: bool,
/// If true, particle distance increases from 256 to 65536.

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_PONG_RESPONSE;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_PONG_RESPONSE)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_PONG_RESPONSE)]
pub struct CPingResponse {
payload: i64,
}

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_PLAYER_ABILITIES;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_PLAYER_ABILITIES)]
#[packet(PLAY_PLAYER_ABILITIES)]
pub struct CPlayerAbilities {
flags: i8,
flying_speed: f32,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_PLAYER_CHAT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{VarInt, codec::bit_set::BitSet};
#[derive(Serialize)]
#[client_packet(PLAY_PLAYER_CHAT)]
#[packet(PLAY_PLAYER_CHAT)]
pub struct CPlayerChatMessage<'a> {
#[serde(with = "uuid::serde::compact")]
sender: uuid::Uuid,

View File

@@ -1,12 +1,12 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_UPDATE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use crate::{ClientPacket, Property, bytebuf::ByteBufMut};
use super::PlayerAction;
#[client_packet(PLAY_PLAYER_INFO_UPDATE)]
#[packet(PLAY_PLAYER_INFO_UPDATE)]
pub struct CPlayerInfoUpdate<'a> {
pub actions: i8,
pub players: &'a [Player<'a>],

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_PLAYER_POSITION;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use crate::{ClientPacket, PositionFlag, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_PLAYER_POSITION)]
#[packet(PLAY_PLAYER_POSITION)]
pub struct CPlayerPosition<'a> {
teleport_id: VarInt,
position: Vector3<f64>,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_REMOVE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::{Serialize, ser::SerializeSeq};
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_PLAYER_INFO_REMOVE)]
#[packet(PLAY_PLAYER_INFO_REMOVE)]
pub struct CRemovePlayerInfo<'a> {
players_count: VarInt,
#[serde(serialize_with = "serialize_slice_uuids")]

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_REMOVE_ENTITIES;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_REMOVE_ENTITIES)]
#[packet(PLAY_REMOVE_ENTITIES)]
pub struct CRemoveEntities<'a> {
count: VarInt,
entity_ids: &'a [VarInt],

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_RESET_SCORE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_RESET_SCORE)]
#[packet(PLAY_RESET_SCORE)]
pub struct CResetScore {
entity_name: String,
objective_name: Option<String>,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_RESPAWN;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::position::BlockPos;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use crate::{VarInt, codec::identifier::Identifier};
#[derive(Serialize)]
#[client_packet(PLAY_RESPAWN)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_RESPAWN)]
pub struct CRespawn {
dimension_type: VarInt,
dimension_name: Identifier,

View File

@@ -1,10 +1,10 @@
use crate::{Link, VarInt};
use pumpkin_data::packet::clientbound::PLAY_SERVER_LINKS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SERVER_LINKS)]
#[packet(PLAY_SERVER_LINKS)]
pub struct CPlayServerLinks<'a> {
links_count: &'a VarInt,
links: &'a [Link<'a>],

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_CENTER;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_BORDER_CENTER)]
#[packet(PLAY_SET_BORDER_CENTER)]
pub struct CSetBorderCenter {
x: f64,
z: f64,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_LERP_SIZE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::codec::var_long::VarLong;
#[derive(Serialize)]
#[client_packet(PLAY_SET_BORDER_LERP_SIZE)]
#[packet(PLAY_SET_BORDER_LERP_SIZE)]
pub struct CSetBorderLerpSize {
old_diameter: f64,
new_diameter: f64,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_SIZE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_BORDER_SIZE)]
#[packet(PLAY_SET_BORDER_SIZE)]
pub struct CSetBorderSize {
diameter: f64,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_WARNING_DELAY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_BORDER_WARNING_DELAY)]
#[packet(PLAY_SET_BORDER_WARNING_DELAY)]
pub struct CSetBorderWarningDelay {
warning_time: VarInt,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_WARNING_DISTANCE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_BORDER_WARNING_DISTANCE)]
#[packet(PLAY_SET_BORDER_WARNING_DISTANCE)]
pub struct CSetBorderWarningDistance {
warning_blocks: VarInt,
}

View File

@@ -2,11 +2,11 @@ use crate::VarInt;
use crate::codec::slot::Slot;
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_CONTENT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_CONTAINER_SET_CONTENT)]
#[packet(PLAY_CONTAINER_SET_CONTENT)]
pub struct CSetContainerContent<'a> {
window_id: VarInt,
state_id: VarInt,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_DATA;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_CONTAINER_SET_DATA)]
#[packet(PLAY_CONTAINER_SET_DATA)]
pub struct CSetContainerProperty {
window_id: VarInt,
property: i16,

View File

@@ -2,11 +2,11 @@ use crate::VarInt;
use crate::codec::slot::Slot;
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_SLOT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_CONTAINER_SET_SLOT)]
#[packet(PLAY_CONTAINER_SET_SLOT)]
pub struct CSetContainerSlot<'a> {
window_id: i8,
state_id: VarInt,

View File

@@ -1,7 +1,7 @@
use crate::bytebuf::{ByteBufMut, serializer::Serializer};
use bytes::BytesMut;
use pumpkin_data::packet::clientbound::PLAY_SET_EQUIPMENT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{
@@ -9,7 +9,7 @@ use crate::{
codec::{slot::Slot, var_int::VarInt},
};
#[client_packet(PLAY_SET_EQUIPMENT)]
#[packet(PLAY_SET_EQUIPMENT)]
pub struct CSetEquipment {
entity_id: VarInt,
equipment: Vec<(EquipmentSlot, Slot)>,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_EXPERIENCE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_EXPERIENCE)]
#[packet(PLAY_SET_EXPERIENCE)]
pub struct CSetExperience {
progress: f32,
level: VarInt,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_HEALTH;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_SET_HEALTH)]
#[packet(PLAY_SET_HEALTH)]
pub struct CSetHealth {
health: f32,
food: VarInt,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_SET_HELD_SLOT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_HELD_SLOT)]
#[packet(PLAY_SET_HELD_SLOT)]
pub struct CSetHeldItem {
slot: i8,
}

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_SET_TIME;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_TIME)]
#[packet(PLAY_SET_TIME)]
pub struct CUpdateTime {
world_age: i64,
time_of_day: i64,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_TITLE_TEXT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_TITLE_TEXT)]
#[packet(PLAY_SET_TITLE_TEXT)]
pub struct CTitleText<'a> {
title: &'a TextComponent,
}

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::{packet::clientbound::PLAY_SOUND, sound::SoundCategory};
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use crate::{ClientPacket, IDOrSoundEvent, SoundEvent, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_SOUND)]
#[packet(PLAY_SOUND)]
pub struct CSoundEffect {
sound_event: IDOrSoundEvent,
sound_category: VarInt,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_ADD_ENTITY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_ADD_ENTITY)]
#[packet(PLAY_ADD_ENTITY)]
pub struct CSpawnEntity {
entity_id: VarInt,
#[serde(with = "uuid::serde::compact")]

View File

@@ -1,12 +1,12 @@
use crate::{VarInt, codec::identifier::Identifier};
use pumpkin_data::packet::clientbound::PLAY_STORE_COOKIE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
/// Stores some arbitrary data on the client, which persists between server transfers.
/// The Notchian client only accepts cookies of up to 5 kiB in size.
#[derive(Serialize)]
#[client_packet(PLAY_STORE_COOKIE)]
#[packet(PLAY_STORE_COOKIE)]
pub struct CStoreCookie<'a> {
key: &'a Identifier,
payload_length: VarInt,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SET_SUBTITLE_TEXT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SET_SUBTITLE_TEXT)]
#[packet(PLAY_SET_SUBTITLE_TEXT)]
pub struct CSubtitle<'a> {
subtitle: &'a TextComponent,
}

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_SYSTEM_CHAT;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_SYSTEM_CHAT)]
#[packet(PLAY_SYSTEM_CHAT)]
pub struct CSystemChatMessage<'a> {
content: &'a TextComponent,
overlay: bool,

View File

@@ -1,10 +1,10 @@
use crate::VarInt;
use pumpkin_data::packet::clientbound::PLAY_TAKE_ITEM_ENTITY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_TAKE_ITEM_ENTITY)]
#[packet(PLAY_TAKE_ITEM_ENTITY)]
pub struct CTakeItemEntity {
/// The Entity ID of the Item Entity
entity_id: VarInt,

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_TELEPORT_ENTITY;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use crate::{ClientPacket, PositionFlag, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_TELEPORT_ENTITY)]
#[packet(PLAY_TELEPORT_ENTITY)]
pub struct CTeleportEntity<'a> {
entity_id: VarInt,
position: Vector3<f64>,

View File

@@ -1,17 +1,17 @@
use crate::VarInt;
use pumpkin_data::packet::clientbound::PLAY_TRANSFER;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(PLAY_TRANSFER)]
#[derive(Serialize, Deserialize)]
#[packet(PLAY_TRANSFER)]
pub struct CTransfer<'a> {
host: &'a str,
port: &'a VarInt,
port: VarInt,
}
impl<'a> CTransfer<'a> {
pub fn new(host: &'a str, port: &'a VarInt) -> Self {
pub fn new(host: &'a str, port: VarInt) -> Self {
Self { host, port }
}
}

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::PLAY_FORGET_LEVEL_CHUNK;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_FORGET_LEVEL_CHUNK)]
#[packet(PLAY_FORGET_LEVEL_CHUNK)]
pub struct CUnloadChunk {
z: i32,
x: i32,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_POS;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_MOVE_ENTITY_POS)]
#[packet(PLAY_MOVE_ENTITY_POS)]
pub struct CUpdateEntityPos {
entity_id: VarInt,
delta: Vector3<i16>,

View File

@@ -1,12 +1,12 @@
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_POS_ROT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::math::vector3::Vector3;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_MOVE_ENTITY_POS_ROT)]
#[packet(PLAY_MOVE_ENTITY_POS_ROT)]
pub struct CUpdateEntityPosRot {
entity_id: VarInt,
delta: Vector3<i16>,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_ROT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_MOVE_ENTITY_ROT)]
#[packet(PLAY_MOVE_ENTITY_ROT)]
pub struct CUpdateEntityRot {
entity_id: VarInt,
yaw: u8,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_UPDATE_MOB_EFFECT;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::codec::var_int::VarInt;
#[derive(Serialize)]
#[client_packet(PLAY_UPDATE_MOB_EFFECT)]
#[packet(PLAY_UPDATE_MOB_EFFECT)]
pub struct CUpdateMobEffect {
entity_id: VarInt,
effect_id: VarInt,

View File

@@ -1,11 +1,11 @@
use bytes::BufMut;
use pumpkin_data::packet::clientbound::PLAY_SET_OBJECTIVE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use pumpkin_util::text::TextComponent;
use crate::{ClientPacket, NumberFormat, VarInt, bytebuf::ByteBufMut};
#[client_packet(PLAY_SET_OBJECTIVE)]
#[packet(PLAY_SET_OBJECTIVE)]
pub struct CUpdateObjectives<'a> {
objective_name: &'a str,
mode: u8,

View File

@@ -1,13 +1,13 @@
use pumpkin_data::packet::clientbound::PLAY_SET_SCORE;
use pumpkin_util::text::TextComponent;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::{NumberFormat, VarInt};
#[derive(Serialize)]
#[client_packet(PLAY_SET_SCORE)]
#[packet(PLAY_SET_SCORE)]
pub struct CUpdateScore<'a> {
entity_name: &'a str,
objective_name: &'a str,

View File

@@ -1,11 +1,11 @@
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
use pumpkin_util::math::position::BlockPos;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(Serialize)]
#[client_packet(PLAY_LEVEL_EVENT)]
#[packet(PLAY_LEVEL_EVENT)]
pub struct CWorldEvent<'a> {
event: i32,
location: &'a BlockPos,

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::STATUS_PONG_RESPONSE;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(STATUS_PONG_RESPONSE)]
#[derive(Serialize, Deserialize)]
#[packet(STATUS_PONG_RESPONSE)]
pub struct CPingResponse {
payload: i64, // must respond with the same as in `SPingRequest`
}

View File

@@ -1,9 +1,9 @@
use pumpkin_data::packet::clientbound::STATUS_STATUS_RESPONSE;
use pumpkin_macros::client_packet;
use serde::Serialize;
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize)]
#[client_packet(STATUS_STATUS_RESPONSE)]
#[derive(Serialize, Deserialize)]
#[packet(STATUS_STATUS_RESPONSE)]
pub struct CStatusResponse<'a> {
json_response: &'a str, // 32767
}

View File

@@ -222,12 +222,12 @@ mod tests {
use cfb8::cipher::AsyncStreamCipher;
use libdeflater::{DecompressionError, Decompressor};
use pumpkin_data::packet::clientbound::STATUS_STATUS_RESPONSE;
use pumpkin_macros::client_packet;
use pumpkin_macros::packet;
use serde::Serialize;
/// Define a custom packet for testing maximum packet size
#[derive(Serialize)]
#[client_packet(STATUS_STATUS_RESPONSE)]
#[packet(STATUS_STATUS_RESPONSE)]
pub struct MaxSizePacket {
data: Vec<u8>,
}

View File

@@ -1,6 +1,7 @@
use pumpkin_data::packet::serverbound::CONFIG_FINISH_CONFIGURATION;
use pumpkin_macros::server_packet;
use pumpkin_macros::packet;
use serde::Serialize;
#[derive(serde::Deserialize)]
#[server_packet(CONFIG_FINISH_CONFIGURATION)]
pub struct SAcknowledgeFinishConfig {}
#[derive(Serialize)]
#[packet(CONFIG_FINISH_CONFIGURATION)]
pub struct SAcknowledgeFinishConfig;

View File

@@ -1,10 +1,11 @@
use pumpkin_data::packet::serverbound::CONFIG_CLIENT_INFORMATION;
use pumpkin_macros::server_packet;
use pumpkin_macros::packet;
use serde::Serialize;
use crate::VarInt;
#[derive(serde::Deserialize)]
#[server_packet(CONFIG_CLIENT_INFORMATION)]
#[derive(serde::Deserialize, Serialize)]
#[packet(CONFIG_CLIENT_INFORMATION)]
pub struct SClientInformationConfig {
pub locale: String, // 16
pub view_distance: i8,

View File

@@ -1,6 +1,6 @@
use bytes::Buf;
use pumpkin_data::packet::serverbound::CONFIG_COOKIE_RESPONSE;
use pumpkin_macros::server_packet;
use pumpkin_macros::packet;
use crate::{
ServerPacket, VarInt,
@@ -8,7 +8,7 @@ use crate::{
codec::identifier::Identifier,
};
#[server_packet(CONFIG_COOKIE_RESPONSE)]
#[packet(CONFIG_COOKIE_RESPONSE)]
/// Response to a Cookie Request (configuration) from the server.
/// The Notchian (vanilla) server only accepts responses of up to 5 kiB in size.
pub struct SConfigCookieResponse {

Some files were not shown because too many files have changed in this diff Show More