From 69f7eebcb300bbefdc8b10c191a09db250bde630 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 18 Feb 2024 02:25:20 -0600 Subject: fix for hypixel (wasn't sending ClientInformation on configuration) --- azalea-client/src/packet_handling/configuration.rs | 26 +++++++++++++++++++++- azalea-client/src/packet_handling/mod.rs | 14 +++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'azalea-client/src/packet_handling') diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs index ddf77a52..da5ce57f 100644 --- a/azalea-client/src/packet_handling/configuration.rs +++ b/azalea-client/src/packet_handling/configuration.rs @@ -6,7 +6,9 @@ use azalea_protocol::packets::configuration::serverbound_finish_configuration_pa use azalea_protocol::packets::configuration::serverbound_keep_alive_packet::ServerboundKeepAlivePacket; use azalea_protocol::packets::configuration::serverbound_pong_packet::ServerboundPongPacket; use azalea_protocol::packets::configuration::serverbound_resource_pack_packet::ServerboundResourcePackPacket; -use azalea_protocol::packets::configuration::ClientboundConfigurationPacket; +use azalea_protocol::packets::configuration::{ + ClientboundConfigurationPacket, ServerboundConfigurationPacket, +}; use azalea_protocol::packets::ConnectionProtocol; use azalea_protocol::read::deserialize_packet; use azalea_world::Instance; @@ -201,3 +203,25 @@ pub fn process_packet_events(ecs: &mut World) { } } } + +/// An event for sending a packet to the server while we're in the +/// `configuration` state. +#[derive(Event)] +pub struct SendConfigurationPacketEvent { + pub entity: Entity, + pub packet: ServerboundConfigurationPacket, +} + +pub fn handle_send_packet_event( + mut send_packet_events: EventReader, + mut query: Query<&mut RawConnection>, +) { + for event in send_packet_events.read() { + if let Ok(raw_connection) = query.get_mut(event.entity) { + // debug!("Sending packet: {:?}", event.packet); + if let Err(e) = raw_connection.write_packet(event.packet.clone()) { + error!("Failed to send packet: {e}"); + } + } + } +} diff --git a/azalea-client/src/packet_handling/mod.rs b/azalea-client/src/packet_handling/mod.rs index 9823035d..19de27eb 100644 --- a/azalea-client/src/packet_handling/mod.rs +++ b/azalea-client/src/packet_handling/mod.rs @@ -49,10 +49,22 @@ impl Plugin for PacketHandlerPlugin { login::process_packet_events, ), ) - .add_systems(Update, death_event_on_0_health.before(death_listener)) + .add_systems( + Update, + ( + ( + configuration::handle_send_packet_event, + game::handle_send_packet_event, + ) + .chain(), + death_event_on_0_health.before(death_listener), + ), + ) // we do this instead of add_event so we can handle the events ourselves .init_resource::>() .init_resource::>() + .add_event::() + .add_event::() .add_event::() .add_event::() .add_event::() -- cgit v1.2.3