transfer packet id parsing to build time
This also allows now to create custom packets with a custom packet id which is not in the packets.json
This commit is contained in:
parent
7885da726f
commit
03e81a1436
@ -9,7 +9,7 @@ members = [
|
||||
"pumpkin-protocol/",
|
||||
"pumpkin-registry/",
|
||||
"pumpkin-world",
|
||||
"pumpkin/",
|
||||
"pumpkin/", "pumpkin-data",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
|
||||
1
assets/noise_parameters.json
Normal file
1
assets/noise_parameters.json
Normal file
@ -0,0 +1 @@
|
||||
{"aquifer_barrier":{"first_octave":-3,"amplitudes":[1.0]},"aquifer_fluid_level_floodedness":{"first_octave":-7,"amplitudes":[1.0]},"aquifer_fluid_level_spread":{"first_octave":-5,"amplitudes":[1.0]},"aquifer_lava":{"first_octave":-1,"amplitudes":[1.0]},"badlands_pillar":{"first_octave":-2,"amplitudes":[1.0,1.0,1.0,1.0]},"badlands_pillar_roof":{"first_octave":-8,"amplitudes":[1.0]},"badlands_surface":{"first_octave":-6,"amplitudes":[1.0,1.0,1.0]},"calcite":{"first_octave":-9,"amplitudes":[1.0,1.0,1.0,1.0]},"cave_cheese":{"first_octave":-8,"amplitudes":[0.5,1.0,2.0,1.0,2.0,1.0,0.0,2.0,0.0]},"cave_entrance":{"first_octave":-7,"amplitudes":[0.4,0.5,1.0]},"cave_layer":{"first_octave":-8,"amplitudes":[1.0]},"clay_bands_offset":{"first_octave":-8,"amplitudes":[1.0]},"continentalness":{"first_octave":-9,"amplitudes":[1.0,1.0,2.0,2.0,2.0,1.0,1.0,1.0,1.0]},"continentalness_large":{"first_octave":-11,"amplitudes":[1.0,1.0,2.0,2.0,2.0,1.0,1.0,1.0,1.0]},"erosion":{"first_octave":-9,"amplitudes":[1.0,1.0,0.0,1.0,1.0]},"erosion_large":{"first_octave":-11,"amplitudes":[1.0,1.0,0.0,1.0,1.0]},"gravel":{"first_octave":-8,"amplitudes":[1.0,1.0,1.0,1.0]},"gravel_layer":{"first_octave":-8,"amplitudes":[1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.013333333333333334]},"ice":{"first_octave":-4,"amplitudes":[1.0,1.0,1.0,1.0]},"iceberg_pillar":{"first_octave":-6,"amplitudes":[1.0,1.0,1.0,1.0]},"iceberg_pillar_roof":{"first_octave":-3,"amplitudes":[1.0]},"iceberg_surface":{"first_octave":-6,"amplitudes":[1.0,1.0,1.0]},"jagged":{"first_octave":-16,"amplitudes":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]},"nether_state_selector":{"first_octave":-4,"amplitudes":[1.0]},"nether_wart":{"first_octave":-3,"amplitudes":[1.0,0.0,0.0,0.9]},"netherrack":{"first_octave":-3,"amplitudes":[1.0,0.0,0.0,0.35]},"noodle":{"first_octave":-8,"amplitudes":[1.0]},"noodle_ridge_a":{"first_octave":-7,"amplitudes":[1.0]},"noodle_ridge_b":{"first_octave":-7,"amplitudes":[1.0]},"noodle_thickness":{"first_octave":-8,"amplitudes":[1.0]},"offset":{"first_octave":-3,"amplitudes":[1.0,1.0,1.0,0.0]},"ore_gap":{"first_octave":-5,"amplitudes":[1.0]},"ore_vein_a":{"first_octave":-7,"amplitudes":[1.0]},"ore_vein_b":{"first_octave":-7,"amplitudes":[1.0]},"ore_veininess":{"first_octave":-8,"amplitudes":[1.0]},"packed_ice":{"first_octave":-7,"amplitudes":[1.0,1.0,1.0,1.0]},"patch":{"first_octave":-5,"amplitudes":[1.0,0.0,0.0,0.0,0.0,0.013333333333333334]},"pillar":{"first_octave":-7,"amplitudes":[1.0,1.0]},"pillar_rareness":{"first_octave":-8,"amplitudes":[1.0]},"pillar_thickness":{"first_octave":-8,"amplitudes":[1.0]},"powder_snow":{"first_octave":-6,"amplitudes":[1.0,1.0,1.0,1.0]},"ridge":{"first_octave":-7,"amplitudes":[1.0,2.0,1.0,0.0,0.0,0.0]},"soul_sand_layer":{"first_octave":-8,"amplitudes":[1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.013333333333333334]},"spaghetti_2d":{"first_octave":-7,"amplitudes":[1.0]},"spaghetti_2d_elevation":{"first_octave":-8,"amplitudes":[1.0]},"spaghetti_2d_modulator":{"first_octave":-11,"amplitudes":[1.0]},"spaghetti_2d_thickness":{"first_octave":-11,"amplitudes":[1.0]},"spaghetti_3d_1":{"first_octave":-7,"amplitudes":[1.0]},"spaghetti_3d_2":{"first_octave":-7,"amplitudes":[1.0]},"spaghetti_3d_rarity":{"first_octave":-11,"amplitudes":[1.0]},"spaghetti_3d_thickness":{"first_octave":-8,"amplitudes":[1.0]},"spaghetti_roughness":{"first_octave":-5,"amplitudes":[1.0]},"spaghetti_roughness_modulator":{"first_octave":-8,"amplitudes":[1.0]},"surface":{"first_octave":-6,"amplitudes":[1.0,1.0,1.0]},"surface_secondary":{"first_octave":-6,"amplitudes":[1.0,1.0,0.0,1.0]},"surface_swamp":{"first_octave":-2,"amplitudes":[1.0]},"temperature":{"first_octave":-10,"amplitudes":[1.5,0.0,1.0,0.0,0.0,0.0]},"temperature_large":{"first_octave":-12,"amplitudes":[1.5,0.0,1.0,0.0,0.0,0.0]},"vegetation":{"first_octave":-8,"amplitudes":[1.0,1.0,0.0,0.0,0.0,0.0]},"vegetation_large":{"first_octave":-10,"amplitudes":[1.0,1.0,0.0,0.0,0.0,0.0]}}
|
||||
13
pumpkin-data/Cargo.toml
Normal file
13
pumpkin-data/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "pumpkin-data"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
build = "build/build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = "2.0"
|
||||
3
pumpkin-data/src/lib.rs
Normal file
3
pumpkin-data/src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod packet {
|
||||
include!(concat!(env!("OUT_DIR"), "/packet.rs"));
|
||||
}
|
||||
@ -3,20 +3,19 @@ use quote::quote;
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
mod packet;
|
||||
#[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 = packet::packet_clientbound(input);
|
||||
let input: proc_macro2::TokenStream = input.into();
|
||||
let item: proc_macro2::TokenStream = item.into();
|
||||
|
||||
let gen = quote! {
|
||||
#item
|
||||
impl #impl_generics crate::bytebuf::packet_id::Packet for #name #ty_generics {
|
||||
const PACKET_ID: i32 = #input as i32;
|
||||
const PACKET_ID: i32 = #input;
|
||||
}
|
||||
};
|
||||
|
||||
@ -29,13 +28,13 @@ pub fn server_packet(input: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let name = &ast.ident;
|
||||
let (impl_generics, ty_generics, _) = ast.generics.split_for_impl();
|
||||
|
||||
let input: proc_macro2::TokenStream = packet::packet_serverbound(input);
|
||||
let input: proc_macro2::TokenStream = input.into();
|
||||
let item: proc_macro2::TokenStream = item.into();
|
||||
|
||||
let gen = quote! {
|
||||
#item
|
||||
impl #impl_generics crate::bytebuf::packet_id::Packet for #name #ty_generics {
|
||||
const PACKET_ID: i32 = #input as i32;
|
||||
const PACKET_ID: i32 = #input;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
use std::{collections::HashMap, sync::LazyLock};
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Packets {
|
||||
serverbound: HashMap<String, Vec<String>>,
|
||||
clientbound: HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
static PACKETS: LazyLock<Packets> = LazyLock::new(|| {
|
||||
serde_json::from_str(include_str!("../../assets/packets.json"))
|
||||
.expect("Could not parse packets.json registry.")
|
||||
});
|
||||
|
||||
pub(crate) fn packet_clientbound(item: TokenStream) -> proc_macro2::TokenStream {
|
||||
let input_string = item.to_string();
|
||||
let packet_name = input_string.trim_matches('"');
|
||||
let packet_name_split: Vec<&str> = packet_name.split(":").collect();
|
||||
let phase = PACKETS
|
||||
.clientbound
|
||||
.get(packet_name_split[0])
|
||||
.expect("Invalid Phase");
|
||||
let id = phase
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|s| s.1 == packet_name_split[1])
|
||||
.map(|(i, _)| i)
|
||||
.expect("Invalid Packet name");
|
||||
quote! { #id }
|
||||
}
|
||||
|
||||
pub(crate) fn packet_serverbound(item: TokenStream) -> proc_macro2::TokenStream {
|
||||
let input_string = item.to_string();
|
||||
let packet_name = input_string.trim_matches('"');
|
||||
let packet_name_split: Vec<&str> = packet_name.split(":").collect();
|
||||
|
||||
let phase = PACKETS
|
||||
.serverbound
|
||||
.get(packet_name_split[0])
|
||||
.expect("Invalid Phase");
|
||||
let id = phase
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|s| s.1 == packet_name_split[1])
|
||||
.map(|(i, _)| i)
|
||||
.expect("Invalid Packet name");
|
||||
quote! { #id }
|
||||
}
|
||||
@ -12,6 +12,7 @@ query = []
|
||||
|
||||
[dependencies]
|
||||
pumpkin-nbt = { path = "../pumpkin-nbt" }
|
||||
pumpkin-data = { path = "../pumpkin-data" }
|
||||
pumpkin-macros = { path = "../pumpkin-macros" }
|
||||
pumpkin-world = { path = "../pumpkin-world" }
|
||||
pumpkin-util = { path = "../pumpkin-util" }
|
||||
|
||||
@ -3,8 +3,10 @@ use pumpkin_util::text::TextComponent;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use pumpkin_data::packet::clientbound::CONFIG_RESOURCE_PACK_PUSH;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("config:resource_pack_push")]
|
||||
#[client_packet(CONFIG_RESOURCE_PACK_PUSH)]
|
||||
pub struct CConfigAddResourcePack<'a> {
|
||||
uuid: uuid::Uuid,
|
||||
url: &'a str,
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use pumpkin_data::packet::clientbound::CONFIG_DISCONNECT;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[client_packet("config:disconnect")]
|
||||
#[client_packet(CONFIG_DISCONNECT)]
|
||||
pub struct CConfigDisconnect<'a> {
|
||||
reason: &'a str,
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use pumpkin_data::packet::clientbound::CONFIG_COOKIE_REQUEST;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::codec::identifier::Identifier;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[client_packet("config:cookie_request")]
|
||||
#[client_packet(CONFIG_COOKIE_REQUEST)]
|
||||
/// Requests a cookie that was previously stored.
|
||||
pub struct CCookieRequest<'a> {
|
||||
key: &'a Identifier,
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
use pumpkin_data::packet::clientbound::CONFIG_FINISH_CONFIGURATION;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[client_packet("config:finish_configuration")]
|
||||
#[client_packet(CONFIG_FINISH_CONFIGURATION)]
|
||||
pub struct CFinishConfig {}
|
||||
|
||||
impl Default for CFinishConfig {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::CONFIG_SELECT_KNOWN_PACKS;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, KnownPack};
|
||||
|
||||
#[client_packet("config:select_known_packs")]
|
||||
#[client_packet(CONFIG_SELECT_KNOWN_PACKS)]
|
||||
pub struct CKnownPacks<'a> {
|
||||
known_packs: &'a [KnownPack<'a>],
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::CONFIG_CUSTOM_PAYLOAD;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("config:custom_payload")]
|
||||
#[client_packet(CONFIG_CUSTOM_PAYLOAD)]
|
||||
pub struct CPluginMessage<'a> {
|
||||
channel: &'a str,
|
||||
data: &'a [u8],
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use pumpkin_data::packet::clientbound::CONFIG_REGISTRY_DATA;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, codec::identifier::Identifier, ClientPacket};
|
||||
|
||||
#[client_packet("config:registry_data")]
|
||||
#[client_packet(CONFIG_REGISTRY_DATA)]
|
||||
pub struct CRegistryData<'a> {
|
||||
registry_id: &'a Identifier,
|
||||
entries: &'a [RegistryEntry],
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use crate::{Link, VarInt};
|
||||
use pumpkin_data::packet::clientbound::CONFIG_SERVER_LINKS;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("config:server_links")]
|
||||
#[client_packet(CONFIG_SERVER_LINKS)]
|
||||
pub struct CConfigServerLinks<'a> {
|
||||
links_count: &'a VarInt,
|
||||
links: &'a [Link<'a>],
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use crate::{codec::identifier::Identifier, VarInt};
|
||||
use pumpkin_data::packet::clientbound::CONFIG_STORE_COOKIE;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[client_packet("config:store_cookie")]
|
||||
#[client_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> {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use crate::VarInt;
|
||||
use pumpkin_data::packet::clientbound::CONFIG_TRANSFER;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("config:transfer")]
|
||||
#[client_packet(CONFIG_TRANSFER)]
|
||||
pub struct CTransfer<'a> {
|
||||
host: &'a str,
|
||||
port: &'a VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::LOGIN_COOKIE_REQUEST;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::codec::identifier::Identifier;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("login:cookie_request")]
|
||||
#[client_packet(LOGIN_COOKIE_REQUEST)]
|
||||
/// Requests a cookie that was previously stored.
|
||||
pub struct CLoginCookieRequest<'a> {
|
||||
key: &'a Identifier,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::LOGIN_HELLO;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("login:hello")]
|
||||
#[client_packet(LOGIN_HELLO)]
|
||||
pub struct CEncryptionRequest<'a> {
|
||||
server_id: &'a str, // 20
|
||||
public_key_length: VarInt,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_DISCONNECT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("login:login_disconnect")]
|
||||
#[client_packet(LOGIN_LOGIN_DISCONNECT)]
|
||||
pub struct CLoginDisconnect<'a> {
|
||||
json_reason: &'a str,
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_FINISHED;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, Property};
|
||||
|
||||
#[client_packet("login:login_finished")]
|
||||
#[client_packet(LOGIN_LOGIN_FINISHED)]
|
||||
pub struct CLoginSuccess<'a> {
|
||||
pub uuid: &'a uuid::Uuid,
|
||||
pub username: &'a str, // 16
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::LOGIN_CUSTOM_QUERY;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("login:custom_query")]
|
||||
#[client_packet(LOGIN_CUSTOM_QUERY)]
|
||||
pub struct CLoginPluginRequest<'a> {
|
||||
message_id: VarInt,
|
||||
channel: &'a str,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::LOGIN_LOGIN_COMPRESSION;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("login:login_compression")]
|
||||
#[client_packet(LOGIN_LOGIN_COMPRESSION)]
|
||||
pub struct CSetCompression {
|
||||
threshold: VarInt,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_BLOCK_CHANGED_ACK;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:block_changed_ack")]
|
||||
#[client_packet(PLAY_BLOCK_CHANGED_ACK)]
|
||||
pub struct CAcknowledgeBlockChange {
|
||||
sequence_id: VarInt,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_ACTION_BAR_TEXT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_action_bar_text")]
|
||||
#[client_packet(PLAY_SET_ACTION_BAR_TEXT)]
|
||||
pub struct CActionBar<'a> {
|
||||
action_bar: &'a TextComponent,
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_BLOCK_DESTRUCTION;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:block_destruction")]
|
||||
#[client_packet(PLAY_BLOCK_DESTRUCTION)]
|
||||
pub struct CSetBlockDestroyStage {
|
||||
entity_id: VarInt,
|
||||
location: WorldPosition,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_BLOCK_EVENT;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:block_event")]
|
||||
#[client_packet(PLAY_BLOCK_EVENT)]
|
||||
pub struct CBlockAction<'a> {
|
||||
location: &'a WorldPosition,
|
||||
action_id: u8,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_BLOCK_UPDATE;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:block_update")]
|
||||
#[client_packet(PLAY_BLOCK_UPDATE)]
|
||||
pub struct CBlockUpdate<'a> {
|
||||
location: &'a WorldPosition,
|
||||
block_id: VarInt,
|
||||
|
||||
@ -2,9 +2,10 @@ use crate::bytebuf::ByteBufMut;
|
||||
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;
|
||||
|
||||
#[client_packet("play:boss_event")]
|
||||
#[client_packet(PLAY_BOSS_EVENT)]
|
||||
pub struct CBossEvent<'a> {
|
||||
pub uuid: &'a uuid::Uuid,
|
||||
pub action: BosseventAction,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_CHUNK_CACHE_CENTER;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
#[client_packet("play:set_chunk_cache_center")]
|
||||
#[client_packet(PLAY_SET_CHUNK_CACHE_CENTER)]
|
||||
pub struct CCenterChunk {
|
||||
pub chunk_x: VarInt,
|
||||
pub chunk_z: VarInt,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_CHANGE_DIFFICULTY;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:change_difficulty")]
|
||||
#[client_packet(PLAY_CHANGE_DIFFICULTY)]
|
||||
pub struct CChangeDifficulty {
|
||||
difficulty: u8,
|
||||
locked: bool,
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
use crate::{bytebuf::ByteBufMut, codec::bit_set::BitSet, ClientPacket, VarInt};
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use pumpkin_data::packet::clientbound::PLAY_LEVEL_CHUNK_WITH_LIGHT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_world::{
|
||||
chunk::{ChunkData, SUBCHUNKS_COUNT},
|
||||
DIRECT_PALETTE_BITS,
|
||||
};
|
||||
|
||||
#[client_packet("play:level_chunk_with_light")]
|
||||
#[client_packet(PLAY_LEVEL_CHUNK_WITH_LIGHT)]
|
||||
pub struct CChunkData<'a>(pub &'a ChunkData);
|
||||
|
||||
impl ClientPacket for CChunkData<'_> {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_CLOSE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:container_close")]
|
||||
#[client_packet(PLAY_CONTAINER_CLOSE)]
|
||||
pub struct CCloseContainer {
|
||||
window_id: VarInt,
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_COMBAT_KILL;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:player_combat_kill")]
|
||||
#[client_packet(PLAY_PLAYER_COMBAT_KILL)]
|
||||
pub struct CCombatDeath<'a> {
|
||||
player_id: VarInt,
|
||||
message: &'a TextComponent,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_COMMAND_SUGGESTIONS;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt};
|
||||
|
||||
#[client_packet("play:command_suggestions")]
|
||||
#[client_packet(PLAY_COMMAND_SUGGESTIONS)]
|
||||
pub struct CCommandSuggestions {
|
||||
id: VarInt,
|
||||
start: VarInt,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_COMMANDS;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt};
|
||||
|
||||
#[client_packet("play:commands")]
|
||||
#[client_packet(PLAY_COMMANDS)]
|
||||
pub struct CCommands<'a> {
|
||||
pub nodes: Vec<ProtoNode<'a>>,
|
||||
pub root_node_index: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_COOKIE_REQUEST;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::codec::identifier::Identifier;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:cookie_request")]
|
||||
#[client_packet(PLAY_COOKIE_REQUEST)]
|
||||
/// Requests a cookie that was previously stored.
|
||||
pub struct CPlayCookieRequest<'a> {
|
||||
key: &'a Identifier,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_DAMAGE_EVENT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:damage_event")]
|
||||
#[client_packet(PLAY_DAMAGE_EVENT)]
|
||||
pub struct CDamageEvent {
|
||||
entity_id: VarInt,
|
||||
source_type_id: VarInt,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_DISGUISED_CHAT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:disguised_chat")]
|
||||
#[client_packet(PLAY_DISGUISED_CHAT)]
|
||||
pub struct CDisguisedChatMessage<'a> {
|
||||
message: &'a TextComponent,
|
||||
chat_type: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_DISPLAY_OBJECTIVE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_display_objective")]
|
||||
#[client_packet(PLAY_SET_DISPLAY_OBJECTIVE)]
|
||||
pub struct CDisplayObjective<'a> {
|
||||
position: VarInt,
|
||||
score_name: &'a str,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_ANIMATE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:animate")]
|
||||
#[client_packet(PLAY_ANIMATE)]
|
||||
pub struct CEntityAnimation {
|
||||
entity_id: VarInt,
|
||||
/// See `Animation`
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_ENTITY_DATA;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_entity_data")]
|
||||
#[client_packet(PLAY_SET_ENTITY_DATA)]
|
||||
pub struct CSetEntityMetadata<T> {
|
||||
entity_id: VarInt,
|
||||
metadata: Metadata<T>,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_SOUND_ENTITY;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, IDOrSoundEvent, SoundCategory, SoundEvent, VarInt};
|
||||
|
||||
#[client_packet("play:sound_entity")]
|
||||
#[client_packet(PLAY_SOUND_ENTITY)]
|
||||
pub struct CEntitySoundEffect {
|
||||
sound_event: IDOrSoundEvent,
|
||||
sound_category: VarInt,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_ENTITY_EVENT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:entity_event")]
|
||||
#[client_packet(PLAY_ENTITY_EVENT)]
|
||||
pub struct CEntityStatus {
|
||||
entity_id: i32,
|
||||
entity_status: i8,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_ENTITY_MOTION;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_entity_motion")]
|
||||
#[client_packet(PLAY_SET_ENTITY_MOTION)]
|
||||
pub struct CEntityVelocity<'a> {
|
||||
entity_id: &'a VarInt,
|
||||
velocity_x: i16,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_GAME_EVENT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:game_event")]
|
||||
#[client_packet(PLAY_GAME_EVENT)]
|
||||
pub struct CGameEvent {
|
||||
event: u8,
|
||||
value: f32,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_ROTATE_HEAD;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:rotate_head")]
|
||||
#[client_packet(PLAY_ROTATE_HEAD)]
|
||||
pub struct CHeadRot {
|
||||
entity_id: VarInt,
|
||||
head_yaw: u8,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_HURT_ANIMATION;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:hurt_animation")]
|
||||
#[client_packet(PLAY_HURT_ANIMATION)]
|
||||
pub struct CHurtAnimation<'a> {
|
||||
entity_id: &'a VarInt,
|
||||
yaw: f32,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_INITIALIZE_BORDER;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{codec::var_long::VarLong, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:initialize_border")]
|
||||
#[client_packet(PLAY_INITIALIZE_BORDER)]
|
||||
pub struct CInitializeWorldBorder {
|
||||
x: f64,
|
||||
z: f64,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_KEEP_ALIVE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:keep_alive")]
|
||||
#[client_packet(PLAY_KEEP_ALIVE)]
|
||||
pub struct CKeepAlive {
|
||||
keep_alive_id: i64,
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:level_event")]
|
||||
#[client_packet(PLAY_LEVEL_EVENT)]
|
||||
pub struct CLevelEvent {
|
||||
event: i32,
|
||||
location: WorldPosition,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_LOGIN;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::{codec::identifier::Identifier, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:login")]
|
||||
#[client_packet(PLAY_LOGIN)]
|
||||
pub struct CLogin<'a> {
|
||||
entity_id: i32,
|
||||
is_hardcore: bool,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_OPEN_SCREEN;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:open_screen")]
|
||||
#[client_packet(PLAY_OPEN_SCREEN)]
|
||||
pub struct COpenScreen<'a> {
|
||||
window_id: VarInt,
|
||||
window_type: VarInt,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_LEVEL_PARTICLES;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:level_particles")]
|
||||
#[client_packet(PLAY_LEVEL_PARTICLES)]
|
||||
pub struct CParticle<'a> {
|
||||
/// If true, particle distance increases from 256 to 65536.
|
||||
long_distance: bool,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_PONG_RESPONSE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:pong_response")]
|
||||
#[client_packet(PLAY_PONG_RESPONSE)]
|
||||
pub struct CPingResponse {
|
||||
payload: i64,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_DISCONNECT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:disconnect")]
|
||||
#[client_packet(PLAY_DISCONNECT)]
|
||||
pub struct CPlayDisconnect<'a> {
|
||||
reason: &'a TextComponent,
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_ABILITIES;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:player_abilities")]
|
||||
#[client_packet(PLAY_PLAYER_ABILITIES)]
|
||||
pub struct CPlayerAbilities {
|
||||
flags: i8,
|
||||
flying_speed: f32,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_CHAT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::{codec::bit_set::BitSet, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:player_chat")]
|
||||
#[client_packet(PLAY_PLAYER_CHAT)]
|
||||
pub struct CPlayerChatMessage<'a> {
|
||||
#[serde(with = "uuid::serde::compact")]
|
||||
sender: uuid::Uuid,
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_UPDATE;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, Property};
|
||||
|
||||
use super::PlayerAction;
|
||||
|
||||
#[client_packet("play:player_info_update")]
|
||||
#[client_packet(PLAY_PLAYER_INFO_UPDATE)]
|
||||
pub struct CPlayerInfoUpdate<'a> {
|
||||
pub actions: i8,
|
||||
pub players: &'a [Player<'a>],
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_POSITION;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, PositionFlag, VarInt};
|
||||
|
||||
#[client_packet("play:player_position")]
|
||||
#[client_packet(PLAY_PLAYER_POSITION)]
|
||||
pub struct CPlayerPosition<'a> {
|
||||
teleport_id: VarInt,
|
||||
position: Vector3<f64>,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_PLAYER_INFO_REMOVE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::{ser::SerializeSeq, Serialize};
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:player_info_remove")]
|
||||
#[client_packet(PLAY_PLAYER_INFO_REMOVE)]
|
||||
pub struct CRemovePlayerInfo<'a> {
|
||||
players_count: VarInt,
|
||||
#[serde(serialize_with = "serialize_slice_uuids")]
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_REMOVE_ENTITIES;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:remove_entities")]
|
||||
#[client_packet(PLAY_REMOVE_ENTITIES)]
|
||||
pub struct CRemoveEntities<'a> {
|
||||
count: VarInt,
|
||||
entity_ids: &'a [VarInt],
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_RESET_SCORE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:reset_score")]
|
||||
#[client_packet(PLAY_RESET_SCORE)]
|
||||
pub struct CResetScore {
|
||||
entity_name: String,
|
||||
objective_name: Option<String>,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_RESPAWN;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::{codec::identifier::Identifier, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:respawn")]
|
||||
#[client_packet(PLAY_RESPAWN)]
|
||||
pub struct CRespawn {
|
||||
dimension_type: VarInt,
|
||||
dimension_name: Identifier,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use crate::{Link, VarInt};
|
||||
use pumpkin_data::packet::clientbound::PLAY_SERVER_LINKS;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:server_links")]
|
||||
#[client_packet(PLAY_SERVER_LINKS)]
|
||||
pub struct CPlayServerLinks<'a> {
|
||||
links_count: &'a VarInt,
|
||||
links: &'a [Link<'a>],
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_CENTER;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_border_center")]
|
||||
#[client_packet(PLAY_SET_BORDER_CENTER)]
|
||||
pub struct CSetBorderCenter {
|
||||
x: f64,
|
||||
z: f64,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_LERP_SIZE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::codec::var_long::VarLong;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_border_lerp_size")]
|
||||
#[client_packet(PLAY_SET_BORDER_LERP_SIZE)]
|
||||
pub struct CSetBorderLerpSize {
|
||||
old_diameter: f64,
|
||||
new_diameter: f64,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_SIZE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_border_size")]
|
||||
#[client_packet(PLAY_SET_BORDER_SIZE)]
|
||||
pub struct CSetBorderSize {
|
||||
diameter: f64,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_WARNING_DELAY;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_border_warning_delay")]
|
||||
#[client_packet(PLAY_SET_BORDER_WARNING_DELAY)]
|
||||
pub struct CSetBorderWarningDelay {
|
||||
warning_time: VarInt,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_BORDER_WARNING_DISTANCE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_border_warning_distance")]
|
||||
#[client_packet(PLAY_SET_BORDER_WARNING_DISTANCE)]
|
||||
pub struct CSetBorderWarningDistance {
|
||||
warning_blocks: VarInt,
|
||||
}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use crate::codec::slot::Slot;
|
||||
use crate::VarInt;
|
||||
|
||||
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_CONTENT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:container_set_content")]
|
||||
#[client_packet(PLAY_CONTAINER_SET_CONTENT)]
|
||||
pub struct CSetContainerContent<'a> {
|
||||
window_id: VarInt,
|
||||
state_id: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_DATA;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:container_set_data")]
|
||||
#[client_packet(PLAY_CONTAINER_SET_DATA)]
|
||||
pub struct CSetContainerProperty {
|
||||
window_id: VarInt,
|
||||
property: i16,
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use crate::codec::slot::Slot;
|
||||
use crate::VarInt;
|
||||
|
||||
use pumpkin_data::packet::clientbound::PLAY_CONTAINER_SET_SLOT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:container_set_slot")]
|
||||
#[client_packet(PLAY_CONTAINER_SET_SLOT)]
|
||||
pub struct CSetContainerSlot<'a> {
|
||||
window_id: i8,
|
||||
state_id: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_HEALTH;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_health")]
|
||||
#[client_packet(PLAY_SET_HEALTH)]
|
||||
pub struct CSetHealth {
|
||||
health: f32,
|
||||
food: VarInt,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_HELD_SLOT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_held_slot")]
|
||||
#[client_packet(PLAY_SET_HELD_SLOT)]
|
||||
pub struct CSetHeldItem {
|
||||
slot: i8,
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_TIME;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_time")]
|
||||
#[client_packet(PLAY_SET_TIME)]
|
||||
pub struct CUpdateTime {
|
||||
world_age: i64,
|
||||
time_of_day: i64,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_TITLE_TEXT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_title_text")]
|
||||
#[client_packet(PLAY_SET_TITLE_TEXT)]
|
||||
pub struct CTitleText<'a> {
|
||||
title: &'a TextComponent,
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_SOUND;
|
||||
use pumpkin_macros::client_packet;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, IDOrSoundEvent, SoundCategory, SoundEvent, VarInt};
|
||||
|
||||
#[client_packet("play:sound")]
|
||||
#[client_packet(PLAY_SOUND)]
|
||||
pub struct CSoundEffect {
|
||||
sound_event: IDOrSoundEvent,
|
||||
sound_category: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_ADD_ENTITY;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:add_entity")]
|
||||
#[client_packet(PLAY_ADD_ENTITY)]
|
||||
pub struct CSpawnEntity {
|
||||
entity_id: VarInt,
|
||||
#[serde(with = "uuid::serde::compact")]
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use crate::{codec::identifier::Identifier, VarInt};
|
||||
use pumpkin_data::packet::clientbound::PLAY_STORE_COOKIE;
|
||||
use pumpkin_macros::client_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")]
|
||||
#[client_packet(PLAY_STORE_COOKIE)]
|
||||
pub struct CStoreCookie<'a> {
|
||||
key: &'a Identifier,
|
||||
payload_length: VarInt,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_SUBTITLE_TEXT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_subtitle_text")]
|
||||
#[client_packet(PLAY_SET_SUBTITLE_TEXT)]
|
||||
pub struct CSubtitle<'a> {
|
||||
subtitle: &'a TextComponent,
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SYSTEM_CHAT;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:system_chat")]
|
||||
#[client_packet(PLAY_SYSTEM_CHAT)]
|
||||
pub struct CSystemChatMessage<'a> {
|
||||
content: &'a TextComponent,
|
||||
overlay: bool,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_TELEPORT_ENTITY;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, PositionFlag, VarInt};
|
||||
|
||||
#[client_packet("play:teleport_entity")]
|
||||
#[client_packet(PLAY_TELEPORT_ENTITY)]
|
||||
pub struct CTeleportEntity<'a> {
|
||||
entity_id: VarInt,
|
||||
position: Vector3<f64>,
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use crate::VarInt;
|
||||
use pumpkin_data::packet::clientbound::PLAY_TRANSFER;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:transfer")]
|
||||
#[client_packet(PLAY_TRANSFER)]
|
||||
pub struct CTransfer<'a> {
|
||||
host: &'a str,
|
||||
port: &'a VarInt,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_FORGET_LEVEL_CHUNK;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:forget_level_chunk")]
|
||||
#[client_packet(PLAY_FORGET_LEVEL_CHUNK)]
|
||||
pub struct CUnloadChunk {
|
||||
z: i32,
|
||||
x: i32,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_POS;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:move_entity_pos")]
|
||||
#[client_packet(PLAY_MOVE_ENTITY_POS)]
|
||||
pub struct CUpdateEntityPos {
|
||||
entity_id: VarInt,
|
||||
delta: Vector3<i16>,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_POS_ROT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::math::vector3::Vector3;
|
||||
use serde::Serialize;
|
||||
@ -5,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:move_entity_pos_rot")]
|
||||
#[client_packet(PLAY_MOVE_ENTITY_POS_ROT)]
|
||||
pub struct CUpdateEntityPosRot {
|
||||
entity_id: VarInt,
|
||||
delta: Vector3<i16>,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_MOVE_ENTITY_ROT;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:move_entity_rot")]
|
||||
#[client_packet(PLAY_MOVE_ENTITY_ROT)]
|
||||
pub struct CUpdateEntityRot {
|
||||
entity_id: VarInt,
|
||||
yaw: u8,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use bytes::BufMut;
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_OBJECTIVE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use crate::{bytebuf::ByteBufMut, ClientPacket, NumberFormat, VarInt};
|
||||
|
||||
#[client_packet("play:set_objective")]
|
||||
#[client_packet(PLAY_SET_OBJECTIVE)]
|
||||
pub struct CUpdateObjectives<'a> {
|
||||
objective_name: &'a str,
|
||||
mode: u8,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_SET_SCORE;
|
||||
use pumpkin_util::text::TextComponent;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
@ -6,7 +7,7 @@ use serde::Serialize;
|
||||
use crate::{NumberFormat, VarInt};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:set_score")]
|
||||
#[client_packet(PLAY_SET_SCORE)]
|
||||
pub struct CUpdateScore<'a> {
|
||||
entity_name: &'a str,
|
||||
objective_name: &'a str,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use pumpkin_data::packet::clientbound::PLAY_LEVEL_EVENT;
|
||||
use pumpkin_util::math::position::WorldPosition;
|
||||
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("play:level_event")]
|
||||
#[client_packet(PLAY_LEVEL_EVENT)]
|
||||
pub struct CWorldEvent<'a> {
|
||||
event: i32,
|
||||
location: &'a WorldPosition,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::STATUS_PONG_RESPONSE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("status:pong_response")]
|
||||
#[client_packet(STATUS_PONG_RESPONSE)]
|
||||
pub struct CPingResponse {
|
||||
payload: i64, // must responde with the same as in `SPingRequest`
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
use pumpkin_data::packet::clientbound::STATUS_STATUS_RESPONSE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("status:status_response")]
|
||||
#[client_packet(STATUS_STATUS_RESPONSE)]
|
||||
pub struct CStatusResponse<'a> {
|
||||
json_response: &'a str, // 32767
|
||||
}
|
||||
|
||||
@ -221,12 +221,13 @@ mod tests {
|
||||
use cfb8::cipher::AsyncStreamCipher;
|
||||
use cfb8::Decryptor as Cfb8Decryptor;
|
||||
use libdeflater::{DecompressionError, Decompressor};
|
||||
use pumpkin_data::packet::clientbound::STATUS_STATUS_RESPONSE;
|
||||
use pumpkin_macros::client_packet;
|
||||
use serde::Serialize;
|
||||
|
||||
/// Define a custom packet for testing maximum packet size
|
||||
#[derive(Serialize)]
|
||||
#[client_packet("status:status_response")]
|
||||
#[client_packet(STATUS_STATUS_RESPONSE)]
|
||||
pub struct MaxSizePacket {
|
||||
data: Vec<u8>,
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use pumpkin_data::packet::serverbound::CONFIG_FINISH_CONFIGURATION;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[server_packet("config:finish_configuration")]
|
||||
#[server_packet(CONFIG_FINISH_CONFIGURATION)]
|
||||
pub struct SAcknowledgeFinishConfig {}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use pumpkin_data::packet::serverbound::CONFIG_CLIENT_INFORMATION;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[server_packet("config:client_information")]
|
||||
#[server_packet(CONFIG_CLIENT_INFORMATION)]
|
||||
pub struct SClientInformationConfig {
|
||||
pub locale: String, // 16
|
||||
pub view_distance: i8,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use bytes::Buf;
|
||||
use pumpkin_data::packet::serverbound::CONFIG_COOKIE_RESPONSE;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
use crate::{
|
||||
@ -7,7 +8,7 @@ use crate::{
|
||||
ServerPacket, VarInt,
|
||||
};
|
||||
|
||||
#[server_packet("config:cookie_response")]
|
||||
#[server_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 {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
use pumpkin_data::packet::serverbound::CONFIG_SELECT_KNOWN_PACKS;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[server_packet("config:select_known_packs")]
|
||||
#[server_packet(CONFIG_SELECT_KNOWN_PACKS)]
|
||||
pub struct SKnownPacks {
|
||||
pub known_pack_count: VarInt,
|
||||
// known_packs: &'a [KnownPack]
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use bytes::Buf;
|
||||
use pumpkin_data::packet::serverbound::CONFIG_CUSTOM_PAYLOAD;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
use crate::{
|
||||
@ -8,7 +9,7 @@ use crate::{
|
||||
};
|
||||
const MAX_PAYLOAD_SIZE: usize = 1048576;
|
||||
|
||||
#[server_packet("config:custom_payload")]
|
||||
#[server_packet(CONFIG_CUSTOM_PAYLOAD)]
|
||||
pub struct SPluginMessage {
|
||||
pub channel: Identifier,
|
||||
pub data: bytes::Bytes,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use bytes::Buf;
|
||||
use pumpkin_data::packet::serverbound::HANDSHAKE_INTENTION;
|
||||
use pumpkin_macros::server_packet;
|
||||
|
||||
use crate::{
|
||||
@ -6,7 +7,7 @@ use crate::{
|
||||
ConnectionState, ServerPacket, VarInt,
|
||||
};
|
||||
|
||||
#[server_packet("handshake:intention")]
|
||||
#[server_packet(HANDSHAKE_INTENTION)]
|
||||
pub struct SHandShake {
|
||||
pub protocol_version: VarInt,
|
||||
pub server_address: String, // 255
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user