diff options
| author | mat <git@matdoes.dev> | 2024-02-18 02:25:20 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-02-18 02:25:27 -0600 |
| commit | 69f7eebcb300bbefdc8b10c191a09db250bde630 (patch) | |
| tree | 9701ba4bbc8c93429d1ac61dfe3ff40ff36fa9b7 /azalea-client/src/packet_handling | |
| parent | e08f2d842b7e4aad4e63a83bb9b30e53330d6139 (diff) | |
| download | azalea-drasl-69f7eebcb300bbefdc8b10c191a09db250bde630.tar.xz | |
fix for hypixel (wasn't sending ClientInformation on configuration)
Diffstat (limited to 'azalea-client/src/packet_handling')
| -rw-r--r-- | azalea-client/src/packet_handling/configuration.rs | 26 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling/mod.rs | 14 |
2 files changed, 38 insertions, 2 deletions
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<SendConfigurationPacketEvent>, + 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::<Events<game::PacketEvent>>() .init_resource::<Events<configuration::ConfigurationPacketEvent>>() + .add_event::<game::SendPacketEvent>() + .add_event::<configuration::SendConfigurationPacketEvent>() .add_event::<AddPlayerEvent>() .add_event::<RemovePlayerEvent>() .add_event::<UpdatePlayerEvent>() |
