mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
fix brand and client info so they're only sent when leaving login instead of entering config
closes #206
This commit is contained in:
parent
444993b609
commit
6fdf5fce49
3 changed files with 29 additions and 7 deletions
|
@ -76,7 +76,7 @@ use crate::{
|
|||
mining::{self, MinePlugin},
|
||||
movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin},
|
||||
packet_handling::{
|
||||
login::{self, LoginSendPacketQueue},
|
||||
login::{self, InLoginState, LoginSendPacketQueue},
|
||||
PacketHandlerPlugin,
|
||||
},
|
||||
player::retroactively_add_game_profile_component,
|
||||
|
@ -371,6 +371,7 @@ impl Client {
|
|||
ecs_lock.lock().entity_mut(entity).insert((
|
||||
LoginSendPacketQueue { tx: ecs_packets_tx },
|
||||
login::IgnoreQueryIds::default(),
|
||||
InLoginState,
|
||||
));
|
||||
|
||||
// login
|
||||
|
@ -457,6 +458,7 @@ impl Client {
|
|||
p.game_profile
|
||||
);
|
||||
conn.write(ServerboundLoginAcknowledged {}).await?;
|
||||
|
||||
break (conn.config(), p.game_profile);
|
||||
}
|
||||
ClientboundLoginPacket::LoginDisconnect(p) => {
|
||||
|
@ -485,7 +487,8 @@ impl Client {
|
|||
.lock()
|
||||
.entity_mut(entity)
|
||||
.remove::<login::IgnoreQueryIds>()
|
||||
.remove::<LoginSendPacketQueue>();
|
||||
.remove::<LoginSendPacketQueue>()
|
||||
.remove::<InLoginState>();
|
||||
|
||||
Ok((conn, profile))
|
||||
}
|
||||
|
|
|
@ -9,25 +9,30 @@ use azalea_protocol::{
|
|||
};
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_ecs::prelude::*;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::{client::InConfigState, packet_handling::configuration::SendConfigurationEvent};
|
||||
use crate::{
|
||||
client::InConfigState,
|
||||
packet_handling::{configuration::SendConfigurationEvent, login::InLoginState},
|
||||
};
|
||||
|
||||
pub struct ConfigurationPlugin;
|
||||
impl Plugin for ConfigurationPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
Update,
|
||||
handle_in_configuration_state
|
||||
handle_end_login_state
|
||||
.before(crate::packet_handling::configuration::handle_send_packet_event),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_in_configuration_state(
|
||||
query: Query<(Entity, &ClientInformation), Added<InConfigState>>,
|
||||
fn handle_end_login_state(
|
||||
mut removed: RemovedComponents<InLoginState>,
|
||||
query: Query<&ClientInformation>,
|
||||
mut send_packet_events: EventWriter<SendConfigurationEvent>,
|
||||
) {
|
||||
for (entity, client_information) in query.iter() {
|
||||
for entity in removed.read() {
|
||||
let mut brand_data = Vec::new();
|
||||
// they don't have to know :)
|
||||
"vanilla".azalea_write(&mut brand_data).unwrap();
|
||||
|
@ -39,6 +44,15 @@ fn handle_in_configuration_state(
|
|||
},
|
||||
));
|
||||
|
||||
let client_information = match query.get(entity).ok() {
|
||||
Some(i) => i,
|
||||
None => {
|
||||
warn!("ClientInformation component was not set before leaving login state, using a default");
|
||||
&ClientInformation::default()
|
||||
}
|
||||
};
|
||||
|
||||
debug!("Writing ClientInformation while in config state: {client_information:?}");
|
||||
send_packet_events.send(SendConfigurationEvent::new(
|
||||
entity,
|
||||
ServerboundClientInformation {
|
||||
|
|
|
@ -48,6 +48,11 @@ pub struct LoginSendPacketQueue {
|
|||
pub tx: mpsc::UnboundedSender<ServerboundLoginPacket>,
|
||||
}
|
||||
|
||||
/// A marker component for local players that are currently in the
|
||||
/// `login` state.
|
||||
#[derive(Component, Clone, Debug)]
|
||||
pub struct InLoginState;
|
||||
|
||||
pub fn handle_send_packet_event(
|
||||
mut send_packet_events: EventReader<SendLoginPacketEvent>,
|
||||
mut query: Query<&mut LoginSendPacketQueue>,
|
||||
|
|
Loading…
Add table
Reference in a new issue