From f9e4b65713bbacabcd54416a388a92b90f56ab47 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 26 Jun 2025 12:32:01 +0930 Subject: start adding packet_order test --- azalea-client/src/plugins/attack.rs | 1 + azalea-client/src/plugins/loading.rs | 9 ++++--- azalea-client/src/plugins/movement.rs | 36 +++++++++++++++------------- azalea-client/src/plugins/packet/game/mod.rs | 17 ++++--------- 4 files changed, 31 insertions(+), 32 deletions(-) (limited to 'azalea-client/src/plugins') diff --git a/azalea-client/src/plugins/attack.rs b/azalea-client/src/plugins/attack.rs index 86ed5de5..ec4337e5 100644 --- a/azalea-client/src/plugins/attack.rs +++ b/azalea-client/src/plugins/attack.rs @@ -90,6 +90,7 @@ impl Client { pub struct AttackQueued { pub target: Entity, } +#[allow(clippy::type_complexity)] pub fn handle_attack_queued( mut commands: Commands, mut query: Query<( diff --git a/azalea-client/src/plugins/loading.rs b/azalea-client/src/plugins/loading.rs index 217d6f75..b195868b 100644 --- a/azalea-client/src/plugins/loading.rs +++ b/azalea-client/src/plugins/loading.rs @@ -14,8 +14,8 @@ impl Plugin for PlayerLoadedPlugin { GameTick, player_loaded_packet .after(PhysicsSet) - .after(MiningSet) - .after(crate::movement::send_position), + .before(MiningSet) + .before(crate::movement::send_position), ); } } @@ -36,8 +36,11 @@ pub fn player_loaded_packet( Entity, ( With, - With, Without, + // the vanilla client waits for the chunk mesh to be "compiled" for the renderer (or + // some other conditions) before sending PlayerLoaded. see LevelLoadStatusManager.tick + // in the decompiled source + With, ), >, ) { diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index b4649f20..5d43261f 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -6,14 +6,17 @@ use azalea_entity::{ metadata::Sprinting, }; use azalea_physics::{PhysicsSet, ai_step}; -use azalea_protocol::packets::{ - Packet, - game::{ - ServerboundPlayerCommand, ServerboundPlayerInput, - s_move_player_pos::ServerboundMovePlayerPos, - s_move_player_pos_rot::ServerboundMovePlayerPosRot, - s_move_player_rot::ServerboundMovePlayerRot, - s_move_player_status_only::ServerboundMovePlayerStatusOnly, +use azalea_protocol::{ + common::movements::MoveFlags, + packets::{ + Packet, + game::{ + ServerboundPlayerCommand, ServerboundPlayerInput, + s_move_player_pos::ServerboundMovePlayerPos, + s_move_player_pos_rot::ServerboundMovePlayerPosRot, + s_move_player_rot::ServerboundMovePlayerRot, + s_move_player_status_only::ServerboundMovePlayerStatusOnly, + }, }, }; use azalea_world::{MinecraftEntityId, MoveEntityError}; @@ -186,12 +189,16 @@ pub fn send_position( // if self.is_passenger() { // TODO: posrot packet for being a passenger // } + let flags = MoveFlags { + on_ground: physics.on_ground(), + horizontal_collision: physics.horizontal_collision, + }; let packet = if sending_position && sending_direction { Some( ServerboundMovePlayerPosRot { pos: **position, look_direction: *direction, - on_ground: physics.on_ground(), + flags, } .into_variant(), ) @@ -199,7 +206,7 @@ pub fn send_position( Some( ServerboundMovePlayerPos { pos: **position, - on_ground: physics.on_ground(), + flags, } .into_variant(), ) @@ -207,17 +214,12 @@ pub fn send_position( Some( ServerboundMovePlayerRot { look_direction: *direction, - on_ground: physics.on_ground(), + flags, } .into_variant(), ) } else if physics.last_on_ground() != physics.on_ground() { - Some( - ServerboundMovePlayerStatusOnly { - on_ground: physics.on_ground(), - } - .into_variant(), - ) + Some(ServerboundMovePlayerStatusOnly { flags }.into_variant()) } else { None }; diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 1ea4db10..d9940937 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -12,7 +12,10 @@ use azalea_entity::{ indexing::{EntityIdIndex, EntityUuidIndex}, metadata::{Health, apply_metadata}, }; -use azalea_protocol::packets::{ConnectionProtocol, game::*}; +use azalea_protocol::{ + common::movements::MoveFlags, + packets::{ConnectionProtocol, game::*}, +}; use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId, PartialInstance}; use bevy_ecs::{prelude::*, system::SystemState}; pub use events::*; @@ -319,15 +322,6 @@ impl GamePacketHandler<'_> { .entity(self.player) .insert(LoadedBy(HashSet::from_iter(vec![self.player]))); } - - // send the client information that we have set - debug!( - "Sending client information because login: {:?}", - client_information - ); - commands.trigger(SendPacketEvent::new(self.player, - azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { client_information: client_information.clone() }, - )); }, ); } @@ -443,8 +437,7 @@ impl GamePacketHandler<'_> { ServerboundMovePlayerPosRot { pos: **position, look_direction: *direction, - // this is always false - on_ground: false, + flags: MoveFlags::default(), }, )); }); -- cgit v1.2.3