aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-04-17 16:16:51 -0500
committerGitHub <noreply@github.com>2025-04-17 16:16:51 -0500
commit3f60bdadac1a02e1109148bbbe5a8a3545f13849 (patch)
tree6c0460be61e715c1b789f81b16ce4c0fb986c3b4 /azalea-protocol
parent1989f4ec979c138f8f466ccebadca335eb2917d6 (diff)
downloadazalea-drasl-3f60bdadac1a02e1109148bbbe5a8a3545f13849.tar.xz
Move login state to the ECS (#213)
* use packet handlers code for login custom_query * initial broken implementation for ecs-only login * fixes * run Update schedule 60 times per second and delete code related to run_schedule_sender * fix tests * fix online-mode * reply to query packets in a separate system and make it easier for plugins to disable individual replies * remove unused imports
Diffstat (limited to 'azalea-protocol')
-rw-r--r--azalea-protocol/src/connect.rs5
-rw-r--r--azalea-protocol/src/packets/game/s_client_information.rs2
-rw-r--r--azalea-protocol/src/packets/login/s_custom_query.rs9
-rw-r--r--azalea-protocol/src/read.rs2
-rw-r--r--azalea-protocol/src/write.rs11
5 files changed, 16 insertions, 13 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs
index 13a86ed8..77968eed 100644
--- a/azalea-protocol/src/connect.rs
+++ b/azalea-protocol/src/connect.rs
@@ -344,8 +344,9 @@ impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> {
impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
/// Set our compression threshold, i.e. the maximum size that a packet is
- /// allowed to be without getting compressed. If you set it to less than 0
- /// then compression gets disabled.
+ /// allowed to be without getting compressed. Setting it to 0 means every
+ /// packet will be compressed. If you set it to less than 0,
+ /// then compression is disabled.
pub fn set_compression_threshold(&mut self, threshold: i32) {
// if you pass a threshold of less than 0, compression is disabled
if threshold >= 0 {
diff --git a/azalea-protocol/src/packets/game/s_client_information.rs b/azalea-protocol/src/packets/game/s_client_information.rs
index 5861212c..c8e76f63 100644
--- a/azalea-protocol/src/packets/game/s_client_information.rs
+++ b/azalea-protocol/src/packets/game/s_client_information.rs
@@ -5,5 +5,5 @@ use crate::common::client_information::ClientInformation;
#[derive(Clone, Debug, AzBuf, ServerboundGamePacket)]
pub struct ServerboundClientInformation {
- pub information: ClientInformation,
+ pub client_information: ClientInformation,
}
diff --git a/azalea-protocol/src/packets/login/s_custom_query.rs b/azalea-protocol/src/packets/login/s_custom_query.rs
deleted file mode 100644
index 39ecdcef..00000000
--- a/azalea-protocol/src/packets/login/s_custom_query.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use azalea_buf::{AzBuf, UnsizedByteArray};
-use azalea_protocol_macros::ServerboundLoginPacket;
-
-#[derive(Clone, Debug, AzBuf, ServerboundLoginPacket)]
-pub struct ServerboundCustomQuery {
- #[var]
- pub transaction_id: u32,
- pub data: Option<UnsizedByteArray>,
-}
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index 64d35a08..038af319 100644
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -285,6 +285,8 @@ where
buffer.get_mut().extend_from_slice(&bytes);
}
}
+/// Read a packet from the stream, then if necessary decrypt it, decompress
+/// it, and split it.
pub fn try_read_raw_packet<R>(
stream: &mut R,
buffer: &mut Cursor<Vec<u8>>,
diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs
index adefc340..dd863f9e 100644
--- a/azalea-protocol/src/write.rs
+++ b/azalea-protocol/src/write.rs
@@ -54,6 +54,15 @@ pub async fn write_raw_packet<W>(
where
W: AsyncWrite + Unpin + Send,
{
+ let network_packet = encode_to_network_packet(raw_packet, compression_threshold, cipher);
+ stream.write_all(&network_packet).await
+}
+
+pub fn encode_to_network_packet(
+ raw_packet: &[u8],
+ compression_threshold: Option<u32>,
+ cipher: &mut Option<Aes128CfbEnc>,
+) -> Vec<u8> {
trace!("Writing raw packet: {raw_packet:?}");
let mut raw_packet = raw_packet.to_vec();
if let Some(threshold) = compression_threshold {
@@ -64,7 +73,7 @@ where
if let Some(cipher) = cipher {
azalea_crypto::encrypt_packet(cipher, &mut raw_packet);
}
- stream.write_all(&raw_packet).await
+ raw_packet
}
pub fn compression_encoder(