aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/configuration.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-02-18 02:25:20 -0600
committermat <git@matdoes.dev>2024-02-18 02:25:27 -0600
commit69f7eebcb300bbefdc8b10c191a09db250bde630 (patch)
tree9701ba4bbc8c93429d1ac61dfe3ff40ff36fa9b7 /azalea-client/src/configuration.rs
parente08f2d842b7e4aad4e63a83bb9b30e53330d6139 (diff)
downloadazalea-drasl-69f7eebcb300bbefdc8b10c191a09db250bde630.tar.xz
fix for hypixel (wasn't sending ClientInformation on configuration)
Diffstat (limited to 'azalea-client/src/configuration.rs')
-rw-r--r--azalea-client/src/configuration.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/azalea-client/src/configuration.rs b/azalea-client/src/configuration.rs
new file mode 100644
index 00000000..21e31b24
--- /dev/null
+++ b/azalea-client/src/configuration.rs
@@ -0,0 +1,53 @@
+use azalea_buf::McBufWritable;
+use azalea_core::resource_location::ResourceLocation;
+use azalea_protocol::packets::configuration::{
+ serverbound_client_information_packet::{
+ ClientInformation, ServerboundClientInformationPacket,
+ },
+ serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
+};
+use bevy_app::prelude::*;
+use bevy_ecs::prelude::*;
+
+use crate::{
+ client::InConfigurationState, packet_handling::configuration::SendConfigurationPacketEvent,
+};
+
+pub struct ConfigurationPlugin;
+impl Plugin for ConfigurationPlugin {
+ fn build(&self, app: &mut App) {
+ app.add_systems(
+ Update,
+ handle_in_configuration_state
+ .after(crate::packet_handling::configuration::handle_send_packet_event),
+ );
+ }
+}
+
+fn handle_in_configuration_state(
+ query: Query<(Entity, &ClientInformation), Added<InConfigurationState>>,
+ mut send_packet_events: EventWriter<SendConfigurationPacketEvent>,
+) {
+ for (entity, client_information) in query.iter() {
+ // quickly send the brand here
+ let mut brand_data = Vec::new();
+ // they don't have to know :)
+ "vanilla".write_into(&mut brand_data).unwrap();
+ send_packet_events.send(SendConfigurationPacketEvent {
+ entity,
+ packet: ServerboundCustomPayloadPacket {
+ identifier: ResourceLocation::new("brand"),
+ data: brand_data.into(),
+ }
+ .get(),
+ });
+
+ send_packet_events.send(SendConfigurationPacketEvent {
+ entity,
+ packet: ServerboundClientInformationPacket {
+ information: client_information.clone(),
+ }
+ .get(),
+ });
+ }
+}