add more packets

This commit is contained in:
Alexander Medvedev
2025-07-02 15:48:57 +02:00
parent f21f552680
commit 2e643cdeb1
14 changed files with 216 additions and 17 deletions

View File

@@ -0,0 +1,14 @@
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[packet(0x03)]
pub struct CHandshake {
jwt_data: String,
}
impl CHandshake {
pub fn new(jwt_data: String) -> Self {
Self { jwt_data }
}
}

View File

@@ -1,2 +1,6 @@
pub mod handshake;
pub mod network_settings;
pub mod play_status;
pub mod raknet;
pub mod resource_pack_stack;
pub mod resource_packs_info;

View File

@@ -2,7 +2,7 @@ use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[packet(0x8F)]
#[packet(143)]
pub struct CNetworkSettings {
compression_threshold: u16,
compression_method: u16,

View File

@@ -0,0 +1,46 @@
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
#[packet(0x02)]
pub struct CPlayStatus {
status: i32,
}
impl CPlayStatus {
pub fn new(status: PlayStatus) -> Self {
Self {
status: status.to_index(),
}
}
}
pub enum PlayStatus {
LoginSuccess,
OutdatedClient,
OutdatedServer,
PlayerSpawn,
InvalidTenant,
EditionMismatchEduToVanilla,
EditionMismatchVanillaToEdu,
ServerFullSubClient,
EditorMismatchEditorToVanilla,
EditorMismatchVanillaToEditor,
}
impl PlayStatus {
pub fn to_index(&self) -> i32 {
match self {
PlayStatus::LoginSuccess => 0,
PlayStatus::OutdatedClient => 1,
PlayStatus::OutdatedServer => 2,
PlayStatus::PlayerSpawn => 3,
PlayStatus::InvalidTenant => 4,
PlayStatus::EditionMismatchEduToVanilla => 5,
PlayStatus::EditionMismatchVanillaToEdu => 6,
PlayStatus::ServerFullSubClient => 7,
PlayStatus::EditorMismatchEditorToVanilla => 8,
PlayStatus::EditorMismatchVanillaToEditor => 9,
}
}
}

View File

@@ -3,6 +3,22 @@ use serde::{Deserialize, Serialize};
use crate::codec::socket_address::SocketAddress;
#[derive(Serialize, Deserialize)]
#[packet(0x03)]
pub struct CConnectedPong {
ping_time: u64,
pong_time: u64,
}
impl CConnectedPong {
pub fn new(ping_time: u64, pong_time: u64) -> Self {
Self {
ping_time,
pong_time,
}
}
}
#[derive(Serialize, Deserialize)]
#[packet(0x10)]
pub struct CConnectionRequestAccepted {

View File

@@ -0,0 +1,20 @@
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
use crate::codec::var_uint::VarUInt;
#[derive(Serialize, Deserialize)]
#[packet(0x07)]
pub struct CResourcePackStackPacket {
resource_pack_required: bool,
addons_list_size: VarUInt,
}
impl CResourcePackStackPacket {
pub fn new(resource_pack_required: bool, addons_list_size: VarUInt) -> Self {
Self {
resource_pack_required,
addons_list_size,
}
}
}

View File

@@ -0,0 +1,21 @@
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[packet(0x06)]
pub struct CResourcePacksInfo {
resource_pack_required: bool,
has_addon_packs: bool,
has_scripts: bool,
// TODO: Add more
}
impl CResourcePacksInfo {
pub fn new(resource_pack_required: bool, has_addon_packs: bool, has_scripts: bool) -> Self {
Self {
resource_pack_required,
has_addon_packs,
has_scripts,
}
}
}

View File

@@ -131,7 +131,6 @@ impl UDPNetworkDecoder {
})?;
let packet_len = packet_len.0 as u64;
dbg!(packet_len);
// This is the default MTU size
if !(0..=1492).contains(&packet_len) {

View File

@@ -0,0 +1,9 @@
use pumpkin_macros::packet;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[packet(0x01)]
pub struct SLogin {
pub protocol_version: i32,
pub connection_request: String,
}

View File

@@ -1,2 +1,3 @@
pub mod login;
pub mod raknet;
pub mod request_network_settings;

View File

@@ -3,6 +3,13 @@ use serde::{Deserialize, Serialize};
use crate::codec::socket_address::SocketAddress;
#[derive(Serialize, Deserialize)]
#[packet(0x00)]
pub struct SConnectedPing {
/// Time since start
pub time: u64,
}
#[derive(Serialize, Deserialize)]
#[packet(0x09)]
pub struct SConnectionRequest {