mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26: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},
|
mining::{self, MinePlugin},
|
||||||
movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin},
|
movement::{LastSentLookDirection, PhysicsState, PlayerMovePlugin},
|
||||||
packet_handling::{
|
packet_handling::{
|
||||||
login::{self, LoginSendPacketQueue},
|
login::{self, InLoginState, LoginSendPacketQueue},
|
||||||
PacketHandlerPlugin,
|
PacketHandlerPlugin,
|
||||||
},
|
},
|
||||||
player::retroactively_add_game_profile_component,
|
player::retroactively_add_game_profile_component,
|
||||||
|
@ -371,6 +371,7 @@ impl Client {
|
||||||
ecs_lock.lock().entity_mut(entity).insert((
|
ecs_lock.lock().entity_mut(entity).insert((
|
||||||
LoginSendPacketQueue { tx: ecs_packets_tx },
|
LoginSendPacketQueue { tx: ecs_packets_tx },
|
||||||
login::IgnoreQueryIds::default(),
|
login::IgnoreQueryIds::default(),
|
||||||
|
InLoginState,
|
||||||
));
|
));
|
||||||
|
|
||||||
// login
|
// login
|
||||||
|
@ -457,6 +458,7 @@ impl Client {
|
||||||
p.game_profile
|
p.game_profile
|
||||||
);
|
);
|
||||||
conn.write(ServerboundLoginAcknowledged {}).await?;
|
conn.write(ServerboundLoginAcknowledged {}).await?;
|
||||||
|
|
||||||
break (conn.config(), p.game_profile);
|
break (conn.config(), p.game_profile);
|
||||||
}
|
}
|
||||||
ClientboundLoginPacket::LoginDisconnect(p) => {
|
ClientboundLoginPacket::LoginDisconnect(p) => {
|
||||||
|
@ -485,7 +487,8 @@ impl Client {
|
||||||
.lock()
|
.lock()
|
||||||
.entity_mut(entity)
|
.entity_mut(entity)
|
||||||
.remove::<login::IgnoreQueryIds>()
|
.remove::<login::IgnoreQueryIds>()
|
||||||
.remove::<LoginSendPacketQueue>();
|
.remove::<LoginSendPacketQueue>()
|
||||||
|
.remove::<InLoginState>();
|
||||||
|
|
||||||
Ok((conn, profile))
|
Ok((conn, profile))
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,25 +9,30 @@ use azalea_protocol::{
|
||||||
};
|
};
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::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;
|
pub struct ConfigurationPlugin;
|
||||||
impl Plugin for ConfigurationPlugin {
|
impl Plugin for ConfigurationPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
Update,
|
Update,
|
||||||
handle_in_configuration_state
|
handle_end_login_state
|
||||||
.before(crate::packet_handling::configuration::handle_send_packet_event),
|
.before(crate::packet_handling::configuration::handle_send_packet_event),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_in_configuration_state(
|
fn handle_end_login_state(
|
||||||
query: Query<(Entity, &ClientInformation), Added<InConfigState>>,
|
mut removed: RemovedComponents<InLoginState>,
|
||||||
|
query: Query<&ClientInformation>,
|
||||||
mut send_packet_events: EventWriter<SendConfigurationEvent>,
|
mut send_packet_events: EventWriter<SendConfigurationEvent>,
|
||||||
) {
|
) {
|
||||||
for (entity, client_information) in query.iter() {
|
for entity in removed.read() {
|
||||||
let mut brand_data = Vec::new();
|
let mut brand_data = Vec::new();
|
||||||
// they don't have to know :)
|
// they don't have to know :)
|
||||||
"vanilla".azalea_write(&mut brand_data).unwrap();
|
"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(
|
send_packet_events.send(SendConfigurationEvent::new(
|
||||||
entity,
|
entity,
|
||||||
ServerboundClientInformation {
|
ServerboundClientInformation {
|
||||||
|
|
|
@ -48,6 +48,11 @@ pub struct LoginSendPacketQueue {
|
||||||
pub tx: mpsc::UnboundedSender<ServerboundLoginPacket>,
|
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(
|
pub fn handle_send_packet_event(
|
||||||
mut send_packet_events: EventReader<SendLoginPacketEvent>,
|
mut send_packet_events: EventReader<SendLoginPacketEvent>,
|
||||||
mut query: Query<&mut LoginSendPacketQueue>,
|
mut query: Query<&mut LoginSendPacketQueue>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue