Parse Serverbound Packet IDs from JSON as well
Before only Clientbound Packet IDs where parsed from JSON, Now Serverbound Packet IDs are parsed from JSON as well. This makes porting to new minecraft version much easier
This commit is contained in:
parent
8f90b29cfe
commit
1842e8e6b1
@ -28,7 +28,7 @@ class Extractor : ModInitializer {
|
|||||||
Particles(),
|
Particles(),
|
||||||
SyncedRegistries(),
|
SyncedRegistries(),
|
||||||
Packet(),
|
Packet(),
|
||||||
Screen(),
|
Screens(),
|
||||||
Items(),
|
Items(),
|
||||||
Blocks(),
|
Blocks(),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -46,7 +46,6 @@ class Recipes : Extractor.Extractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
recipeJson.add("ingredients", ingredientArray)
|
recipeJson.add("ingredients", ingredientArray)
|
||||||
// recipeJson.addProperty("placementSlots", gson.toJson(recipe.ingredientPlacement.placementSlots))
|
|
||||||
|
|
||||||
recipesJson.add(recipeJson)
|
recipesJson.add(recipeJson)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import de.snowii.extractor.Extractor
|
|||||||
import net.minecraft.registry.Registries
|
import net.minecraft.registry.Registries
|
||||||
import net.minecraft.server.MinecraftServer
|
import net.minecraft.server.MinecraftServer
|
||||||
|
|
||||||
class Screen : Extractor.Extractor {
|
class Screens : Extractor.Extractor {
|
||||||
override fun fileName(): String {
|
override fun fileName(): String {
|
||||||
return "screens.json"
|
return "screens.json"
|
||||||
}
|
}
|
||||||
@ -17,7 +17,28 @@ pub fn client_packet(input: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
let gen = quote! {
|
let gen = quote! {
|
||||||
#item
|
#item
|
||||||
impl #impl_generics crate::bytebuf::packet_id::ClientPacketID for #name #ty_generics {
|
impl #impl_generics crate::bytebuf::packet_id::Packet for #name #ty_generics {
|
||||||
|
const PACKET_ID: i32 = #input as i32;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gen.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn server_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_serverbound(input);
|
||||||
|
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 as i32;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,7 +30,6 @@ pub(crate) fn packet_clientbound(item: TokenStream) -> proc_macro2::TokenStream
|
|||||||
quote! { #id }
|
quote! { #id }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(dead_code)]
|
|
||||||
pub(crate) fn packet_serverbound(item: TokenStream) -> proc_macro2::TokenStream {
|
pub(crate) fn packet_serverbound(item: TokenStream) -> proc_macro2::TokenStream {
|
||||||
let input_string = item.to_string();
|
let input_string = item.to_string();
|
||||||
let packet_name = input_string.trim_matches('"');
|
let packet_name = input_string.trim_matches('"');
|
||||||
|
|||||||
@ -130,13 +130,13 @@ impl<'de> Deserialize<'de> for VarLong {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ClientPacketID {
|
pub trait Packet {
|
||||||
const PACKET_ID: VarIntType;
|
const PACKET_ID: VarIntType;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P> ClientPacket for P
|
impl<P> ClientPacket for P
|
||||||
where
|
where
|
||||||
P: ClientPacketID + Serialize,
|
P: Packet + Serialize,
|
||||||
{
|
{
|
||||||
fn write(&self, bytebuf: &mut ByteBuffer) {
|
fn write(&self, bytebuf: &mut ByteBuffer) {
|
||||||
let mut serializer = serializer::Serializer::new(ByteBuffer::empty());
|
let mut serializer = serializer::Serializer::new(ByteBuffer::empty());
|
||||||
@ -151,7 +151,7 @@ where
|
|||||||
|
|
||||||
impl<P> ServerPacket for P
|
impl<P> ServerPacket for P
|
||||||
where
|
where
|
||||||
P: DeserializeOwned,
|
P: Packet + DeserializeOwned,
|
||||||
{
|
{
|
||||||
fn read(bytebuf: &mut ByteBuffer) -> Result<P, DeserializerError> {
|
fn read(bytebuf: &mut ByteBuffer) -> Result<P, DeserializerError> {
|
||||||
let deserializer = deserializer::Deserializer::new(bytebuf);
|
let deserializer = deserializer::Deserializer::new(bytebuf);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use bytebuf::{packet_id::ClientPacketID, ByteBuffer, DeserializerError};
|
use bytebuf::{packet_id::Packet, ByteBuffer, DeserializerError};
|
||||||
use pumpkin_core::text::{style::Style, TextComponent};
|
use pumpkin_core::text::{style::Style, TextComponent};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -72,11 +72,11 @@ pub struct RawPacket {
|
|||||||
pub bytebuf: ByteBuffer,
|
pub bytebuf: ByteBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ClientPacket: ClientPacketID {
|
pub trait ClientPacket: Packet {
|
||||||
fn write(&self, bytebuf: &mut ByteBuffer);
|
fn write(&self, bytebuf: &mut ByteBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ServerPacket: Sized {
|
pub trait ServerPacket: Packet + Sized {
|
||||||
fn read(bytebuf: &mut ByteBuffer) -> Result<Self, DeserializerError>;
|
fn read(bytebuf: &mut ByteBuffer) -> Result<Self, DeserializerError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,22 +3,7 @@ mod s_client_information;
|
|||||||
mod s_known_packs;
|
mod s_known_packs;
|
||||||
mod s_plugin_message;
|
mod s_plugin_message;
|
||||||
|
|
||||||
use num_derive::FromPrimitive;
|
|
||||||
pub use s_acknowledge_finish_config::*;
|
pub use s_acknowledge_finish_config::*;
|
||||||
pub use s_client_information::*;
|
pub use s_client_information::*;
|
||||||
pub use s_known_packs::*;
|
pub use s_known_packs::*;
|
||||||
pub use s_plugin_message::*;
|
pub use s_plugin_message::*;
|
||||||
|
|
||||||
/// DO NOT CHANGE ORDER
|
|
||||||
/// This Enum has the exact order like vanilla, Vanilla parses their Packet IDs from the enum order. Its also way easier to port.
|
|
||||||
#[derive(FromPrimitive)]
|
|
||||||
pub enum ServerboundConfigPackets {
|
|
||||||
ClientInformation,
|
|
||||||
CookieResponse,
|
|
||||||
PluginMessage,
|
|
||||||
AcknowledgedFinish,
|
|
||||||
KeepAlive,
|
|
||||||
Pong,
|
|
||||||
ResourcePackResponse,
|
|
||||||
KnownPacks,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,2 +1,5 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("configuration:finish_configuration")]
|
||||||
pub struct SAcknowledgeFinishConfig {}
|
pub struct SAcknowledgeFinishConfig {}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("configuration:client_information")]
|
||||||
pub struct SClientInformationConfig {
|
pub struct SClientInformationConfig {
|
||||||
pub locale: String, // 16
|
pub locale: String, // 16
|
||||||
pub view_distance: i8,
|
pub view_distance: i8,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("configuration:select_known_packs")]
|
||||||
pub struct SKnownPacks {
|
pub struct SKnownPacks {
|
||||||
pub known_pack_count: VarInt,
|
pub known_pack_count: VarInt,
|
||||||
// known_packs: &'a [KnownPack]
|
// known_packs: &'a [KnownPack]
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytebuf::{ByteBuffer, DeserializerError},
|
bytebuf::{ByteBuffer, DeserializerError},
|
||||||
Identifier, ServerPacket,
|
Identifier, ServerPacket,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[server_packet("configuration:custom_payload")]
|
||||||
pub struct SPluginMessage {
|
pub struct SPluginMessage {
|
||||||
pub channel: Identifier,
|
pub channel: Identifier,
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytebuf::{ByteBuffer, DeserializerError},
|
bytebuf::{ByteBuffer, DeserializerError},
|
||||||
ConnectionState, ServerPacket, VarInt,
|
ConnectionState, ServerPacket, VarInt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[server_packet("handshake:intention")]
|
||||||
pub struct SHandShake {
|
pub struct SHandShake {
|
||||||
pub protocol_version: VarInt,
|
pub protocol_version: VarInt,
|
||||||
pub server_address: String, // 255
|
pub server_address: String, // 255
|
||||||
|
|||||||
@ -3,19 +3,7 @@ mod s_login_response;
|
|||||||
mod s_login_start;
|
mod s_login_start;
|
||||||
mod s_plugin_response;
|
mod s_plugin_response;
|
||||||
|
|
||||||
use num_derive::FromPrimitive;
|
|
||||||
pub use s_encryption_response::*;
|
pub use s_encryption_response::*;
|
||||||
pub use s_login_response::*;
|
pub use s_login_response::*;
|
||||||
pub use s_login_start::*;
|
pub use s_login_start::*;
|
||||||
pub use s_plugin_response::*;
|
pub use s_plugin_response::*;
|
||||||
|
|
||||||
/// DO NOT CHANGE ORDER
|
|
||||||
/// This Enum has the exact order like vanilla, Vanilla parses their Packet IDs from the enum order. Its also way easier to port.
|
|
||||||
#[derive(FromPrimitive)]
|
|
||||||
pub enum ServerboundLoginPackets {
|
|
||||||
LoginStart,
|
|
||||||
EncryptionResponse,
|
|
||||||
PluginResponse,
|
|
||||||
LoginAcknowledged,
|
|
||||||
CookieResponse,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytebuf::{ByteBuffer, DeserializerError},
|
bytebuf::{ByteBuffer, DeserializerError},
|
||||||
ServerPacket, VarInt,
|
ServerPacket, VarInt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[server_packet("login:key")]
|
||||||
pub struct SEncryptionResponse {
|
pub struct SEncryptionResponse {
|
||||||
pub shared_secret_length: VarInt,
|
pub shared_secret_length: VarInt,
|
||||||
pub shared_secret: Vec<u8>,
|
pub shared_secret: Vec<u8>,
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
// Acknowledgement to the Login Success packet sent to the server.
|
// Acknowledgement to the Login Success packet sent to the server.
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("login:login_acknowledged")]
|
||||||
pub struct SLoginAcknowledged {}
|
pub struct SLoginAcknowledged {}
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytebuf::{ByteBuffer, DeserializerError},
|
bytebuf::{ByteBuffer, DeserializerError},
|
||||||
ServerPacket,
|
ServerPacket,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[server_packet("login:hello")]
|
||||||
pub struct SLoginStart {
|
pub struct SLoginStart {
|
||||||
pub name: String, // 16
|
pub name: String, // 16
|
||||||
pub uuid: uuid::Uuid,
|
pub uuid: uuid::Uuid,
|
||||||
|
|||||||
@ -3,7 +3,9 @@ use crate::{
|
|||||||
ServerPacket, VarInt,
|
ServerPacket, VarInt,
|
||||||
};
|
};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
|
#[server_packet("login:custom_query_answer")]
|
||||||
pub struct SLoginPluginResponse {
|
pub struct SLoginPluginResponse {
|
||||||
pub message_id: VarInt,
|
pub message_id: VarInt,
|
||||||
pub data: Option<BytesMut>,
|
pub data: Option<BytesMut>,
|
||||||
|
|||||||
@ -20,7 +20,6 @@ mod s_swing_arm;
|
|||||||
mod s_use_item;
|
mod s_use_item;
|
||||||
mod s_use_item_on;
|
mod s_use_item_on;
|
||||||
|
|
||||||
use num_derive::FromPrimitive;
|
|
||||||
pub use s_chat_command::*;
|
pub use s_chat_command::*;
|
||||||
pub use s_chat_message::*;
|
pub use s_chat_message::*;
|
||||||
pub use s_click_container::*;
|
pub use s_click_container::*;
|
||||||
@ -42,72 +41,3 @@ pub use s_set_held_item::*;
|
|||||||
pub use s_swing_arm::*;
|
pub use s_swing_arm::*;
|
||||||
pub use s_use_item::*;
|
pub use s_use_item::*;
|
||||||
pub use s_use_item_on::*;
|
pub use s_use_item_on::*;
|
||||||
|
|
||||||
/// DO NOT CHANGE ORDER
|
|
||||||
/// This Enum has the exact order like vanilla, Vanilla parses their Packet IDs from the enum order. Its also way easier to port.
|
|
||||||
#[derive(FromPrimitive)]
|
|
||||||
pub enum ServerboundPlayPackets {
|
|
||||||
TeleportConfirm,
|
|
||||||
QueryBlockNbt,
|
|
||||||
SelectBundleItem,
|
|
||||||
SetDifficulty,
|
|
||||||
ChatAck,
|
|
||||||
ChatCommandUnsigned,
|
|
||||||
ChatCommand,
|
|
||||||
ChatMessage,
|
|
||||||
ChatSessionUpdate,
|
|
||||||
ChunkBatchAck,
|
|
||||||
ClientStatus,
|
|
||||||
ClientTickEnd,
|
|
||||||
ClientSettings,
|
|
||||||
TabComplete,
|
|
||||||
ConfigurationAck,
|
|
||||||
ClickWindowButton,
|
|
||||||
ClickWindow,
|
|
||||||
CloseWindow,
|
|
||||||
SlotStateChange,
|
|
||||||
CookieResponse,
|
|
||||||
PluginMessage,
|
|
||||||
DebugSampleSubscription,
|
|
||||||
EditBook,
|
|
||||||
QueryEntityNbt,
|
|
||||||
InteractEntity,
|
|
||||||
GenerateStructure,
|
|
||||||
KeepAlive,
|
|
||||||
LockDifficulty,
|
|
||||||
PlayerPosition,
|
|
||||||
PlayerPositionAndRotation,
|
|
||||||
PlayerRotation,
|
|
||||||
PlayerFlying,
|
|
||||||
|
|
||||||
VehicleMove,
|
|
||||||
SteerBoat,
|
|
||||||
PickItem,
|
|
||||||
DebugPing,
|
|
||||||
CraftRecipeRequest,
|
|
||||||
PlayerAbilities,
|
|
||||||
PlayerDigging,
|
|
||||||
EntityAction,
|
|
||||||
PlayerInput,
|
|
||||||
Pong,
|
|
||||||
SetRecipeBookState,
|
|
||||||
SetDisplayedRecipe,
|
|
||||||
NameItem,
|
|
||||||
ResourcePackStatus,
|
|
||||||
AdvancementTab,
|
|
||||||
SelectTrade,
|
|
||||||
SetBeaconEffect,
|
|
||||||
HeldItemChange,
|
|
||||||
|
|
||||||
UpdateCommandBlock,
|
|
||||||
UpdateCommandBlockMinecart,
|
|
||||||
CreativeInventoryAction,
|
|
||||||
UpdateJigsawBlock,
|
|
||||||
UpdateStructureBlock,
|
|
||||||
UpdateSign,
|
|
||||||
|
|
||||||
Animation,
|
|
||||||
Spectate,
|
|
||||||
PlayerBlockPlacement,
|
|
||||||
UseItem,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:chat_command")]
|
||||||
pub struct SChatCommand {
|
pub struct SChatCommand {
|
||||||
pub command: String,
|
pub command: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bytebuf::{ByteBuffer, DeserializerError},
|
bytebuf::{ByteBuffer, DeserializerError},
|
||||||
@ -6,6 +7,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
// derive(Deserialize)]
|
// derive(Deserialize)]
|
||||||
|
#[server_packet("play:chat")]
|
||||||
pub struct SChatMessage {
|
pub struct SChatMessage {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
use crate::slot::Slot;
|
use crate::slot::Slot;
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::de::SeqAccess;
|
use serde::de::SeqAccess;
|
||||||
use serde::{de, Deserialize};
|
use serde::{de, Deserialize};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[server_packet("play:container_click")]
|
||||||
pub struct SClickContainer {
|
pub struct SClickContainer {
|
||||||
pub window_id: VarInt,
|
pub window_id: VarInt,
|
||||||
pub state_id: VarInt,
|
pub state_id: VarInt,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:client_information")]
|
||||||
pub struct SClientInformationPlay {
|
pub struct SClientInformationPlay {
|
||||||
pub locale: String, // 16
|
pub locale: String, // 16
|
||||||
pub view_distance: i8,
|
pub view_distance: i8,
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:container_close")]
|
||||||
pub struct SCloseContainer {
|
pub struct SCloseContainer {
|
||||||
pub window_id: VarInt,
|
pub window_id: VarInt,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:accept_teleportation")]
|
||||||
pub struct SConfirmTeleport {
|
pub struct SConfirmTeleport {
|
||||||
pub teleport_id: VarInt,
|
pub teleport_id: VarInt,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
||||||
|
|
||||||
|
#[server_packet("play:interact")]
|
||||||
pub struct SInteract {
|
pub struct SInteract {
|
||||||
pub entity_id: VarInt,
|
pub entity_id: VarInt,
|
||||||
pub typ: VarInt,
|
pub typ: VarInt,
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:keep_alive")]
|
||||||
pub struct SKeepAlive {
|
pub struct SKeepAlive {
|
||||||
pub keep_alive_id: i64,
|
pub keep_alive_id: i64,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:ping_request")]
|
||||||
pub struct SPlayPingRequest {
|
pub struct SPlayPingRequest {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
//The vanilla client sends this packet when the player starts/stops flying. Bitmask 0x02 is set when the player is flying.
|
//The vanilla client sends this packet when the player starts/stops flying. Bitmask 0x02 is set when the player is flying.
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:player_abilities")]
|
||||||
pub struct SPlayerAbilities {
|
pub struct SPlayerAbilities {
|
||||||
pub flags: i8,
|
pub flags: i8,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use pumpkin_core::math::position::WorldPosition;
|
use pumpkin_core::math::position::WorldPosition;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:player_action")]
|
||||||
pub struct SPlayerAction {
|
pub struct SPlayerAction {
|
||||||
pub status: VarInt,
|
pub status: VarInt,
|
||||||
pub location: WorldPosition,
|
pub location: WorldPosition,
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
||||||
|
|
||||||
|
#[server_packet("play:player_command")]
|
||||||
pub struct SPlayerCommand {
|
pub struct SPlayerCommand {
|
||||||
pub entity_id: VarInt,
|
pub entity_id: VarInt,
|
||||||
pub action: VarInt,
|
pub action: VarInt,
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:move_player_status_only")]
|
||||||
pub struct SSetPlayerGround {
|
pub struct SSetPlayerGround {
|
||||||
pub on_ground: bool,
|
pub on_ground: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:move_player_pos")]
|
||||||
pub struct SPlayerPosition {
|
pub struct SPlayerPosition {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
pub feet_y: f64,
|
pub feet_y: f64,
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:move_player_pos_rot")]
|
||||||
pub struct SPlayerPositionRotation {
|
pub struct SPlayerPositionRotation {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
pub feet_y: f64,
|
pub feet_y: f64,
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:move_player_rot")]
|
||||||
pub struct SPlayerRotation {
|
pub struct SPlayerRotation {
|
||||||
pub yaw: f32,
|
pub yaw: f32,
|
||||||
pub pitch: f32,
|
pub pitch: f32,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::slot::Slot;
|
use crate::slot::Slot;
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug)]
|
#[derive(serde::Deserialize, Debug)]
|
||||||
|
#[server_packet("play:set_creative_mode_slot")]
|
||||||
pub struct SSetCreativeSlot {
|
pub struct SSetCreativeSlot {
|
||||||
pub slot: i16,
|
pub slot: i16,
|
||||||
pub clicked_item: Slot,
|
pub clicked_item: Slot,
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:pick_item")]
|
||||||
pub struct SSetHeldItem {
|
pub struct SSetHeldItem {
|
||||||
pub slot: i16,
|
pub slot: i16,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("play:swing")]
|
||||||
pub struct SSwingArm {
|
pub struct SSwingArm {
|
||||||
pub hand: VarInt,
|
pub hand: VarInt,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:use_item")]
|
||||||
pub struct SUseItem {
|
pub struct SUseItem {
|
||||||
// 0 for main hand, 1 for off hand
|
// 0 for main hand, 1 for off hand
|
||||||
pub hand: VarInt,
|
pub hand: VarInt,
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
use pumpkin_core::math::position::WorldPosition;
|
use pumpkin_core::math::position::WorldPosition;
|
||||||
|
use pumpkin_macros::server_packet;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[server_packet("play:use_item_on")]
|
||||||
pub struct SUseItemOn {
|
pub struct SUseItemOn {
|
||||||
pub hand: VarInt,
|
pub hand: VarInt,
|
||||||
pub location: WorldPosition,
|
pub location: WorldPosition,
|
||||||
|
|||||||
@ -1,14 +1,5 @@
|
|||||||
mod s_ping_request;
|
mod s_ping_request;
|
||||||
mod s_status_request;
|
mod s_status_request;
|
||||||
|
|
||||||
use num_derive::FromPrimitive;
|
|
||||||
pub use s_ping_request::*;
|
pub use s_ping_request::*;
|
||||||
pub use s_status_request::*;
|
pub use s_status_request::*;
|
||||||
|
|
||||||
/// DO NOT CHANGE ORDER
|
|
||||||
/// This Enum has the exact order like vanilla, Vanilla parses their Packet IDs from the enum order. Its also way easier to port.
|
|
||||||
#[derive(FromPrimitive)]
|
|
||||||
pub enum ServerboundStatusPackets {
|
|
||||||
StatusRequest,
|
|
||||||
PingRequest,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("status:ping_request")]
|
||||||
pub struct SStatusPingRequest {
|
pub struct SStatusPingRequest {
|
||||||
pub payload: i64,
|
pub payload: i64,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use pumpkin_macros::server_packet;
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
#[server_packet("status:status_request")]
|
||||||
pub struct SStatusRequest {
|
pub struct SStatusRequest {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,25 +14,18 @@ use crate::{
|
|||||||
|
|
||||||
use authentication::GameProfile;
|
use authentication::GameProfile;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use num_traits::FromPrimitive;
|
|
||||||
use pumpkin_config::compression::CompressionInfo;
|
use pumpkin_config::compression::CompressionInfo;
|
||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
bytebuf::DeserializerError,
|
bytebuf::{packet_id::Packet, DeserializerError},
|
||||||
client::{config::CConfigDisconnect, login::CLoginDisconnect, play::CPlayDisconnect},
|
client::{config::CConfigDisconnect, login::CLoginDisconnect, play::CPlayDisconnect},
|
||||||
packet_decoder::PacketDecoder,
|
packet_decoder::PacketDecoder,
|
||||||
packet_encoder::{PacketEncodeError, PacketEncoder},
|
packet_encoder::{PacketEncodeError, PacketEncoder},
|
||||||
server::{
|
server::{
|
||||||
config::{
|
config::{SAcknowledgeFinishConfig, SClientInformationConfig, SKnownPacks, SPluginMessage},
|
||||||
SAcknowledgeFinishConfig, SClientInformationConfig, SKnownPacks, SPluginMessage,
|
|
||||||
ServerboundConfigPackets,
|
|
||||||
},
|
|
||||||
handshake::SHandShake,
|
handshake::SHandShake,
|
||||||
login::{
|
login::{SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart},
|
||||||
SEncryptionResponse, SLoginAcknowledged, SLoginPluginResponse, SLoginStart,
|
status::{SStatusPingRequest, SStatusRequest},
|
||||||
ServerboundLoginPackets,
|
|
||||||
},
|
|
||||||
status::{SStatusPingRequest, SStatusRequest, ServerboundStatusPackets},
|
|
||||||
},
|
},
|
||||||
ClientPacket, ConnectionState, RawPacket, ServerPacket,
|
ClientPacket, ConnectionState, RawPacket, ServerPacket,
|
||||||
};
|
};
|
||||||
@ -397,24 +390,24 @@ impl Client {
|
|||||||
) -> Result<(), DeserializerError> {
|
) -> Result<(), DeserializerError> {
|
||||||
log::debug!("Handling status group");
|
log::debug!("Handling status group");
|
||||||
let bytebuf = &mut packet.bytebuf;
|
let bytebuf = &mut packet.bytebuf;
|
||||||
if let Some(packet) = ServerboundStatusPackets::from_i32(packet.id.0) {
|
match packet.id.0 {
|
||||||
match packet {
|
SStatusRequest::PACKET_ID => {
|
||||||
ServerboundStatusPackets::StatusRequest => {
|
self.handle_status_request(server, SStatusRequest::read(bytebuf)?)
|
||||||
self.handle_status_request(server, SStatusRequest::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
SStatusPingRequest::PACKET_ID => {
|
||||||
ServerboundStatusPackets::PingRequest => {
|
self.handle_ping_request(SStatusPingRequest::read(bytebuf)?)
|
||||||
self.handle_ping_request(SStatusPingRequest::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
_ => {
|
||||||
};
|
log::error!(
|
||||||
} else {
|
"Failed to handle client packet id {:#04x} in Status State",
|
||||||
log::error!(
|
packet.id.0
|
||||||
"Failed to handle client packet id {:#04x} in Status State",
|
);
|
||||||
packet.id.0
|
return Err(DeserializerError::UnknownPacket);
|
||||||
);
|
}
|
||||||
return Err(DeserializerError::UnknownPacket);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,32 +418,30 @@ impl Client {
|
|||||||
) -> Result<(), DeserializerError> {
|
) -> Result<(), DeserializerError> {
|
||||||
log::debug!("Handling login group for id");
|
log::debug!("Handling login group for id");
|
||||||
let bytebuf = &mut packet.bytebuf;
|
let bytebuf = &mut packet.bytebuf;
|
||||||
if let Some(packet) = ServerboundLoginPackets::from_i32(packet.id.0) {
|
match packet.id.0 {
|
||||||
match packet {
|
SLoginStart::PACKET_ID => {
|
||||||
ServerboundLoginPackets::LoginStart => {
|
self.handle_login_start(server, SLoginStart::read(bytebuf)?)
|
||||||
self.handle_login_start(server, SLoginStart::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
SEncryptionResponse::PACKET_ID => {
|
||||||
ServerboundLoginPackets::EncryptionResponse => {
|
self.handle_encryption_response(server, SEncryptionResponse::read(bytebuf)?)
|
||||||
self.handle_encryption_response(server, SEncryptionResponse::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
SLoginPluginResponse::PACKET_ID => {
|
||||||
ServerboundLoginPackets::PluginResponse => {
|
self.handle_plugin_response(SLoginPluginResponse::read(bytebuf)?)
|
||||||
self.handle_plugin_response(SLoginPluginResponse::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
SLoginAcknowledged::PACKET_ID => {
|
||||||
ServerboundLoginPackets::LoginAcknowledged => {
|
self.handle_login_acknowledged(server, SLoginAcknowledged::read(bytebuf)?)
|
||||||
self.handle_login_acknowledged(server, SLoginAcknowledged::read(bytebuf)?)
|
.await;
|
||||||
.await;
|
}
|
||||||
}
|
_ => {
|
||||||
ServerboundLoginPackets::CookieResponse => {}
|
log::error!(
|
||||||
};
|
"Failed to handle client packet id {:#04x} in Login State",
|
||||||
} else {
|
packet.id.0
|
||||||
log::error!(
|
);
|
||||||
"Failed to handle client packet id {:#04x} in Login State",
|
return Ok(());
|
||||||
packet.id.0
|
}
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -462,35 +453,29 @@ impl Client {
|
|||||||
) -> Result<(), DeserializerError> {
|
) -> Result<(), DeserializerError> {
|
||||||
log::debug!("Handling config group");
|
log::debug!("Handling config group");
|
||||||
let bytebuf = &mut packet.bytebuf;
|
let bytebuf = &mut packet.bytebuf;
|
||||||
if let Some(packet) = ServerboundConfigPackets::from_i32(packet.id.0) {
|
match packet.id.0 {
|
||||||
#[expect(clippy::match_same_arms)]
|
SClientInformationConfig::PACKET_ID => {
|
||||||
match packet {
|
self.handle_client_information_config(SClientInformationConfig::read(bytebuf)?)
|
||||||
ServerboundConfigPackets::ClientInformation => {
|
.await;
|
||||||
self.handle_client_information_config(SClientInformationConfig::read(bytebuf)?)
|
}
|
||||||
.await;
|
SPluginMessage::PACKET_ID => {
|
||||||
}
|
self.handle_plugin_message(SPluginMessage::read(bytebuf)?)
|
||||||
ServerboundConfigPackets::CookieResponse => {}
|
.await;
|
||||||
ServerboundConfigPackets::PluginMessage => {
|
}
|
||||||
self.handle_plugin_message(SPluginMessage::read(bytebuf)?)
|
SAcknowledgeFinishConfig::PACKET_ID => {
|
||||||
.await;
|
self.handle_config_acknowledged(&SAcknowledgeFinishConfig::read(bytebuf)?);
|
||||||
}
|
}
|
||||||
ServerboundConfigPackets::AcknowledgedFinish => {
|
SKnownPacks::PACKET_ID => {
|
||||||
self.handle_config_acknowledged(&SAcknowledgeFinishConfig::read(bytebuf)?);
|
self.handle_known_packs(server, SKnownPacks::read(bytebuf)?)
|
||||||
}
|
.await;
|
||||||
ServerboundConfigPackets::KeepAlive => {}
|
}
|
||||||
ServerboundConfigPackets::Pong => {}
|
_ => {
|
||||||
ServerboundConfigPackets::ResourcePackResponse => {}
|
log::error!(
|
||||||
ServerboundConfigPackets::KnownPacks => {
|
"Failed to handle client packet id {:#04x} in Config State",
|
||||||
self.handle_known_packs(server, SKnownPacks::read(bytebuf)?)
|
packet.id.0
|
||||||
.await;
|
);
|
||||||
}
|
return Err(DeserializerError::UnknownPacket);
|
||||||
};
|
}
|
||||||
} else {
|
|
||||||
log::error!(
|
|
||||||
"Failed to handle client packet id {:#04x} in Config State",
|
|
||||||
packet.id.0
|
|
||||||
);
|
|
||||||
return Err(DeserializerError::UnknownPacket);
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use std::{
|
|||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
use num_traits::ToPrimitive;
|
||||||
use pumpkin_config::ADVANCED_CONFIG;
|
use pumpkin_config::ADVANCED_CONFIG;
|
||||||
use pumpkin_core::{
|
use pumpkin_core::{
|
||||||
math::{boundingbox::BoundingBox, position::WorldPosition, vector2::Vector2, vector3::Vector3},
|
math::{boundingbox::BoundingBox, position::WorldPosition, vector2::Vector2, vector3::Vector3},
|
||||||
@ -21,7 +21,7 @@ use pumpkin_entity::{entity_type::EntityType, EntityId};
|
|||||||
use pumpkin_inventory::player::PlayerInventory;
|
use pumpkin_inventory::player::PlayerInventory;
|
||||||
use pumpkin_macros::sound;
|
use pumpkin_macros::sound;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
bytebuf::DeserializerError,
|
bytebuf::packet_id::Packet,
|
||||||
client::play::{
|
client::play::{
|
||||||
CGameEvent, CHurtAnimation, CKeepAlive, CPlayDisconnect, CPlayerAbilities,
|
CGameEvent, CHurtAnimation, CKeepAlive, CPlayDisconnect, CPlayerAbilities,
|
||||||
CPlayerInfoUpdate, CSetHealth, CSyncPlayerPosition, CSystemChatMessage, GameEvent,
|
CPlayerInfoUpdate, CSetHealth, CSyncPlayerPosition, CSystemChatMessage, GameEvent,
|
||||||
@ -31,7 +31,7 @@ use pumpkin_protocol::{
|
|||||||
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||||
SPlayerAbilities, SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
SPlayerAbilities, SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
||||||
SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSetPlayerGround, SSwingArm, SUseItem,
|
SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSetPlayerGround, SSwingArm, SUseItem,
|
||||||
SUseItemOn, ServerboundPlayPackets,
|
SUseItemOn,
|
||||||
},
|
},
|
||||||
RawPacket, ServerPacket, SoundCategory, VarInt,
|
RawPacket, ServerPacket, SoundCategory, VarInt,
|
||||||
};
|
};
|
||||||
@ -653,124 +653,80 @@ impl Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(clippy::too_many_lines)]
|
|
||||||
pub async fn handle_play_packet(
|
pub async fn handle_play_packet(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
server: &Arc<Server>,
|
server: &Arc<Server>,
|
||||||
packet: &mut RawPacket,
|
packet: &mut RawPacket,
|
||||||
) -> Result<(), Box<dyn PumpkinError>> {
|
) -> Result<(), Box<dyn PumpkinError>> {
|
||||||
let bytebuf = &mut packet.bytebuf;
|
let bytebuf = &mut packet.bytebuf;
|
||||||
if let Some(packet) = ServerboundPlayPackets::from_i32(packet.id.0) {
|
match packet.id.0 {
|
||||||
#[expect(clippy::match_same_arms)]
|
SConfirmTeleport::PACKET_ID => {
|
||||||
match packet {
|
self.handle_confirm_teleport(SConfirmTeleport::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::TeleportConfirm => {
|
.await;
|
||||||
self.handle_confirm_teleport(SConfirmTeleport::read(bytebuf)?)
|
}
|
||||||
.await;
|
SChatCommand::PACKET_ID => {
|
||||||
}
|
self.handle_chat_command(server, SChatCommand::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::QueryBlockNbt => {}
|
.await;
|
||||||
ServerboundPlayPackets::SelectBundleItem => {}
|
}
|
||||||
ServerboundPlayPackets::SetDifficulty => {}
|
SChatMessage::PACKET_ID => {
|
||||||
ServerboundPlayPackets::ChatAck => {}
|
self.handle_chat_message(SChatMessage::read(bytebuf)?).await;
|
||||||
ServerboundPlayPackets::ChatCommandUnsigned => {
|
}
|
||||||
self.handle_chat_command(server, SChatCommand::read(bytebuf)?)
|
SClientInformationPlay::PACKET_ID => {
|
||||||
.await;
|
self.handle_client_information(SClientInformationPlay::read(bytebuf)?)
|
||||||
}
|
.await;
|
||||||
ServerboundPlayPackets::ChatCommand => {}
|
}
|
||||||
ServerboundPlayPackets::ChatMessage => {
|
SInteract::PACKET_ID => {
|
||||||
self.handle_chat_message(SChatMessage::read(bytebuf)?).await;
|
self.handle_interact(server, SInteract::read(bytebuf)?)
|
||||||
}
|
.await;
|
||||||
ServerboundPlayPackets::ChatSessionUpdate => {}
|
}
|
||||||
ServerboundPlayPackets::ChunkBatchAck => {}
|
SKeepAlive::PACKET_ID => {
|
||||||
ServerboundPlayPackets::ClientStatus => {}
|
self.handle_keep_alive(SKeepAlive::read(bytebuf)?).await;
|
||||||
ServerboundPlayPackets::ClientTickEnd => {}
|
}
|
||||||
ServerboundPlayPackets::ClientSettings => {
|
SPlayerPosition::PACKET_ID => {
|
||||||
self.handle_client_information(SClientInformationPlay::read(bytebuf)?)
|
self.handle_position(SPlayerPosition::read(bytebuf)?).await;
|
||||||
.await;
|
}
|
||||||
}
|
SPlayerPositionRotation::PACKET_ID => {
|
||||||
ServerboundPlayPackets::TabComplete => {}
|
self.handle_position_rotation(SPlayerPositionRotation::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::ConfigurationAck => {}
|
.await;
|
||||||
ServerboundPlayPackets::ClickWindowButton => {}
|
}
|
||||||
ServerboundPlayPackets::ClickWindow => {}
|
SPlayerRotation::PACKET_ID => {
|
||||||
ServerboundPlayPackets::CloseWindow => {}
|
self.handle_rotation(SPlayerRotation::read(bytebuf)?).await;
|
||||||
ServerboundPlayPackets::SlotStateChange => {}
|
}
|
||||||
ServerboundPlayPackets::CookieResponse => {}
|
SSetPlayerGround::PACKET_ID => {
|
||||||
ServerboundPlayPackets::PluginMessage => {}
|
self.handle_player_ground(&SSetPlayerGround::read(bytebuf)?);
|
||||||
ServerboundPlayPackets::DebugSampleSubscription => {}
|
}
|
||||||
ServerboundPlayPackets::EditBook => {}
|
SPlayerAbilities::PACKET_ID => {
|
||||||
ServerboundPlayPackets::QueryEntityNbt => {}
|
self.handle_player_abilities(SPlayerAbilities::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::InteractEntity => {
|
.await;
|
||||||
self.handle_interact(server, SInteract::read(bytebuf)?)
|
}
|
||||||
.await;
|
SPlayerAction::PACKET_ID => {
|
||||||
}
|
self.handle_player_action(SPlayerAction::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::GenerateStructure => {}
|
.await;
|
||||||
ServerboundPlayPackets::KeepAlive => {
|
}
|
||||||
self.handle_keep_alive(SKeepAlive::read(bytebuf)?).await;
|
SPlayerCommand::PACKET_ID => {
|
||||||
}
|
self.handle_player_command(SPlayerCommand::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::LockDifficulty => {}
|
.await;
|
||||||
ServerboundPlayPackets::PlayerPosition => {
|
}
|
||||||
self.handle_position(SPlayerPosition::read(bytebuf)?).await;
|
SSetHeldItem::PACKET_ID => {
|
||||||
}
|
self.handle_set_held_item(SSetHeldItem::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::PlayerPositionAndRotation => {
|
.await;
|
||||||
self.handle_position_rotation(SPlayerPositionRotation::read(bytebuf)?)
|
}
|
||||||
.await;
|
SSetCreativeSlot::PACKET_ID => {
|
||||||
}
|
self.handle_set_creative_slot(SSetCreativeSlot::read(bytebuf)?)
|
||||||
ServerboundPlayPackets::PlayerRotation => {
|
.await?;
|
||||||
self.handle_rotation(SPlayerRotation::read(bytebuf)?).await;
|
}
|
||||||
}
|
SSwingArm::PACKET_ID => {
|
||||||
ServerboundPlayPackets::PlayerFlying => {
|
self.handle_swing_arm(SSwingArm::read(bytebuf)?).await;
|
||||||
self.handle_player_ground(&SSetPlayerGround::read(bytebuf)?);
|
}
|
||||||
}
|
SUseItemOn::PACKET_ID => {
|
||||||
ServerboundPlayPackets::VehicleMove => {}
|
self.handle_use_item_on(SUseItemOn::read(bytebuf)?).await;
|
||||||
ServerboundPlayPackets::SteerBoat => {}
|
}
|
||||||
ServerboundPlayPackets::PickItem => {}
|
SUseItem::PACKET_ID => self.handle_use_item(&SUseItem::read(bytebuf)?),
|
||||||
ServerboundPlayPackets::DebugPing => {}
|
_ => {
|
||||||
ServerboundPlayPackets::CraftRecipeRequest => {}
|
log::warn!("Failed to handle player packet id {:#04x}", packet.id.0);
|
||||||
ServerboundPlayPackets::PlayerAbilities => {
|
// TODO: We give an error if all play packets are implemented
|
||||||
self.handle_player_abilities(SPlayerAbilities::read(bytebuf)?)
|
// return Err(Box::new(DeserializerError::UnknownPacket));
|
||||||
.await;
|
}
|
||||||
}
|
|
||||||
ServerboundPlayPackets::PlayerDigging => {
|
|
||||||
self.handle_player_action(SPlayerAction::read(bytebuf)?)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::EntityAction => {
|
|
||||||
self.handle_player_command(SPlayerCommand::read(bytebuf)?)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::PlayerInput => {}
|
|
||||||
ServerboundPlayPackets::Pong => {}
|
|
||||||
ServerboundPlayPackets::SetRecipeBookState => {}
|
|
||||||
ServerboundPlayPackets::SetDisplayedRecipe => {}
|
|
||||||
ServerboundPlayPackets::NameItem => {}
|
|
||||||
ServerboundPlayPackets::ResourcePackStatus => {}
|
|
||||||
ServerboundPlayPackets::AdvancementTab => {}
|
|
||||||
ServerboundPlayPackets::SelectTrade => {}
|
|
||||||
ServerboundPlayPackets::SetBeaconEffect => {}
|
|
||||||
ServerboundPlayPackets::HeldItemChange => {
|
|
||||||
self.handle_set_held_item(SSetHeldItem::read(bytebuf)?)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::UpdateCommandBlock => {}
|
|
||||||
ServerboundPlayPackets::UpdateCommandBlockMinecart => {}
|
|
||||||
ServerboundPlayPackets::CreativeInventoryAction => {
|
|
||||||
self.handle_set_creative_slot(SSetCreativeSlot::read(bytebuf)?)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::UpdateJigsawBlock => {}
|
|
||||||
ServerboundPlayPackets::UpdateStructureBlock => {}
|
|
||||||
ServerboundPlayPackets::UpdateSign => {}
|
|
||||||
ServerboundPlayPackets::Animation => {
|
|
||||||
self.handle_swing_arm(SSwingArm::read(bytebuf)?).await;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::Spectate => {}
|
|
||||||
ServerboundPlayPackets::PlayerBlockPlacement => {
|
|
||||||
self.handle_use_item_on(SUseItemOn::read(bytebuf)?).await;
|
|
||||||
}
|
|
||||||
ServerboundPlayPackets::UseItem => self.handle_use_item(&SUseItem::read(bytebuf)?),
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
log::error!("Failed to handle player packet id {:#04x}", packet.id.0);
|
|
||||||
return Err(Box::new(DeserializerError::UnknownPacket));
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user