mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
add more packets
This commit is contained in:
14
pumpkin-protocol/src/bedrock/client/handshake.rs
Normal file
14
pumpkin-protocol/src/bedrock/client/handshake.rs
Normal 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 }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
46
pumpkin-protocol/src/bedrock/client/play_status.rs
Normal file
46
pumpkin-protocol/src/bedrock/client/play_status.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
20
pumpkin-protocol/src/bedrock/client/resource_pack_stack.rs
Normal file
20
pumpkin-protocol/src/bedrock/client/resource_pack_stack.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
21
pumpkin-protocol/src/bedrock/client/resource_packs_info.rs
Normal file
21
pumpkin-protocol/src/bedrock/client/resource_packs_info.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
9
pumpkin-protocol/src/bedrock/server/login.rs
Normal file
9
pumpkin-protocol/src/bedrock/server/login.rs
Normal 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,
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod login;
|
||||
pub mod raknet;
|
||||
pub mod request_network_settings;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user