mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
fix for hypixel (wasn't sending ClientInformation on configuration)
This commit is contained in:
parent
e08f2d842b
commit
69f7eebcb3
5 changed files with 98 additions and 23 deletions
|
@ -2,6 +2,7 @@ use crate::{
|
|||
attack::{self, AttackPlugin},
|
||||
chat::ChatPlugin,
|
||||
chunks::{ChunkBatchInfo, ChunkPlugin},
|
||||
configuration::ConfigurationPlugin,
|
||||
disconnect::{DisconnectEvent, DisconnectPlugin},
|
||||
events::{Event, EventPlugin, LocalPlayerEvents},
|
||||
interact::{CurrentSequenceNumber, InteractPlugin},
|
||||
|
@ -13,7 +14,6 @@ use crate::{
|
|||
mining::{self, MinePlugin},
|
||||
movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin},
|
||||
packet_handling::{
|
||||
game::{handle_send_packet_event, SendPacketEvent},
|
||||
login::{self, LoginSendPacketQueue},
|
||||
PacketHandlerPlugin,
|
||||
},
|
||||
|
@ -25,9 +25,8 @@ use crate::{
|
|||
};
|
||||
|
||||
use azalea_auth::{game_profile::GameProfile, sessionserver::ClientSessionServerError};
|
||||
use azalea_buf::McBufWritable;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_core::{position::Vec3, resource_location::ResourceLocation, tick::GameTick};
|
||||
use azalea_core::{position::Vec3, tick::GameTick};
|
||||
use azalea_entity::{
|
||||
indexing::{EntityIdIndex, EntityUuidIndex},
|
||||
metadata::Health,
|
||||
|
@ -39,7 +38,6 @@ use azalea_protocol::{
|
|||
packets::{
|
||||
configuration::{
|
||||
serverbound_client_information_packet::ClientInformation,
|
||||
serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
|
||||
ClientboundConfigurationPacket, ServerboundConfigurationPacket,
|
||||
},
|
||||
game::ServerboundGamePacket,
|
||||
|
@ -242,23 +240,11 @@ impl Client {
|
|||
};
|
||||
|
||||
let conn = Connection::new(resolved_address).await?;
|
||||
let (mut conn, game_profile) =
|
||||
let (conn, game_profile) =
|
||||
Self::handshake(ecs_lock.clone(), entity, conn, account, address).await?;
|
||||
|
||||
{
|
||||
// quickly send the brand here
|
||||
let mut brand_data = Vec::new();
|
||||
// they don't have to know :)
|
||||
"vanilla".write_into(&mut brand_data).unwrap();
|
||||
conn.write(
|
||||
ServerboundCustomPayloadPacket {
|
||||
identifier: ResourceLocation::new("brand"),
|
||||
data: brand_data.into(),
|
||||
}
|
||||
.get(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
// note that we send the proper packets in
|
||||
// crate::configuration::handle_in_configuration_state
|
||||
|
||||
let (read_conn, write_conn) = conn.into_split();
|
||||
let (read_conn, write_conn) = (read_conn.raw, write_conn.raw);
|
||||
|
@ -678,10 +664,8 @@ impl Plugin for AzaleaPlugin {
|
|||
death_event,
|
||||
// add GameProfileComponent when we get an AddPlayerEvent
|
||||
retroactively_add_game_profile_component.after(EntityUpdateSet::Index),
|
||||
handle_send_packet_event,
|
||||
),
|
||||
)
|
||||
.add_event::<SendPacketEvent>()
|
||||
.init_resource::<InstanceContainer>()
|
||||
.init_resource::<TabList>();
|
||||
}
|
||||
|
@ -838,6 +822,7 @@ impl PluginGroup for DefaultPlugins {
|
|||
.add(MinePlugin)
|
||||
.add(AttackPlugin)
|
||||
.add(ChunkPlugin)
|
||||
.add(ConfigurationPlugin)
|
||||
.add(TickBroadcastPlugin);
|
||||
#[cfg(feature = "log")]
|
||||
{
|
||||
|
|
53
azalea-client/src/configuration.rs
Normal file
53
azalea-client/src/configuration.rs
Normal file
|
@ -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(),
|
||||
});
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ pub mod attack;
|
|||
pub mod chat;
|
||||
pub mod chunks;
|
||||
mod client;
|
||||
pub mod configuration;
|
||||
pub mod disconnect;
|
||||
mod entity_query;
|
||||
mod events;
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>()
|
||||
|
|
Loading…
Add table
Reference in a new issue