diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-02-25 17:32:15 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-25 17:32:15 -0600 |
| commit | c1588ef66e844c067112ea880a54b4de9ec5a062 (patch) | |
| tree | 76e4f73a5f5392e1bef1f0560ed2f2c56b0d50fb /azalea-client/src | |
| parent | f5a8a59467a0aac3ae2f728961559217f1e1242d (diff) | |
| download | azalea-drasl-c1588ef66e844c067112ea880a54b4de9ec5a062.tar.xz | |
Fix system order ambiguities (#74)
* start fixing stuff where systems run in the wrong order
* fix ordering ambiguity
* add debugging guide
* some fixes
* fix panic for swarms
* fix some warnings
Diffstat (limited to 'azalea-client/src')
| -rwxr-xr-x | azalea-client/src/chat.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/client.rs | 30 | ||||
| -rw-r--r-- | azalea-client/src/disconnect.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling.rs | 21 | ||||
| -rwxr-xr-x | azalea-client/src/player.rs | 6 |
5 files changed, 38 insertions, 39 deletions
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index ac119f24..202cf47c 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -19,7 +19,10 @@ use std::{ }; use uuid::Uuid; -use crate::{client::Client, local_player::SendPacketEvent}; +use crate::{ + client::Client, + local_player::{handle_send_packet_event, SendPacketEvent}, +}; /// A chat packet, either a system message or a chat message. #[derive(Debug, Clone, PartialEq)] @@ -155,15 +158,12 @@ impl Plugin for ChatPlugin { app.add_event::<SendChatEvent>() .add_event::<SendChatKindEvent>() .add_event::<ChatReceivedEvent>() - .add_system( - handle_send_chat_event - .label("handle_send_chat_event") - .after("packet"), - ) + .add_system(handle_send_chat_event.label("handle_send_chat_event")) .add_system( handle_send_chat_kind_event .label("handle_send_chat_kind_event") - .after("handle_send_chat_event"), + .after(handle_send_chat_event) + .after(handle_send_packet_event), ); } } diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 69a50c33..661858db 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -20,7 +20,7 @@ use azalea_ecs::{ bundle::Bundle, component::Component, entity::Entity, - schedule::{IntoSystemDescriptor, Schedule, Stage, SystemSet}, + schedule::{IntoSystemDescriptor, ReportExecutionOrderAmbiguities, Schedule, Stage, SystemSet}, AppTickExt, }; use azalea_ecs::{ecs::Ecs, TickPlugin}; @@ -49,6 +49,7 @@ use azalea_world::{ entity::{EntityPlugin, Local, WorldName}, PartialWorld, World, WorldContainer, }; +use bevy_log::LogPlugin; use log::{debug, error}; use parking_lot::{Mutex, RwLock}; use std::{collections::HashMap, fmt::Debug, io, net::SocketAddr, sync::Arc}; @@ -497,36 +498,31 @@ impl Plugin for AzaleaPlugin { app.add_tick_system_set( SystemSet::new() - .with_system(send_position) - .with_system(update_in_loaded_chunk) + .with_system(send_position.after("ai_step")) + .with_system(update_in_loaded_chunk.before(send_position).after("travel")) .with_system( local_player_ai_step - .before("ai_step") - .after("sprint_listener"), + .before(azalea_physics::ai_step) + .label("ai_step"), ), ); // fire the Death event when the player dies. - app.add_system(death_event.after("tick").after("packet")); + app.add_system(death_event); // walk and sprint event listeners - app.add_system(walk_listener.label("walk_listener").before("travel")) + app.add_system(walk_listener.label("walk_listener")) .add_system( sprint_listener .label("sprint_listener") - .before("travel") .before("walk_listener"), ); // add GameProfileComponent when we get an AddPlayerEvent - app.add_system( - retroactively_add_game_profile_component - .after("tick") - .after("packet"), - ); + app.add_system(retroactively_add_game_profile_component.after("update_indexes")); app.add_event::<SendPacketEvent>() - .add_system(handle_send_packet_event.after("tick").after("packet")); + .add_system(handle_send_packet_event); app.init_resource::<WorldContainer>(); } @@ -547,6 +543,9 @@ pub fn init_ecs_app() -> App { // you might be able to just drop the lock or put it in its own scope to fix let mut app = App::new(); + + app.insert_resource(ReportExecutionOrderAmbiguities); + app.add_plugins(DefaultPlugins); app } @@ -609,9 +608,10 @@ pub struct DefaultPlugins; impl PluginGroup for DefaultPlugins { fn build(self) -> PluginGroupBuilder { PluginGroupBuilder::start::<Self>() + .add(LogPlugin::default()) .add(TickPlugin::default()) - .add(AzaleaPlugin) .add(PacketHandlerPlugin) + .add(AzaleaPlugin) .add(EntityPlugin) .add(PhysicsPlugin) .add(EventPlugin) diff --git a/azalea-client/src/disconnect.rs b/azalea-client/src/disconnect.rs index 83870e69..9fd57e57 100644 --- a/azalea-client/src/disconnect.rs +++ b/azalea-client/src/disconnect.rs @@ -12,7 +12,7 @@ use azalea_ecs::{ }; use derive_more::Deref; -use crate::{client::JoinedClientBundle, LocalPlayer}; +use crate::{client::JoinedClientBundle, movement::send_position, LocalPlayer}; pub struct DisconnectPlugin; impl Plugin for DisconnectPlugin { @@ -20,7 +20,9 @@ impl Plugin for DisconnectPlugin { app.add_event::<DisconnectEvent>() .add_system_to_stage(CoreStage::PostUpdate, handle_disconnect) .add_tick_system( - update_read_packets_task_running_component.before(disconnect_on_read_packets_ended), + update_read_packets_task_running_component + .before(disconnect_on_read_packets_ended) + .before(send_position), ) .add_tick_system(disconnect_on_read_packets_ended); } diff --git a/azalea-client/src/packet_handling.rs b/azalea-client/src/packet_handling.rs index d5cce3a8..a4d638a4 100644 --- a/azalea-client/src/packet_handling.rs +++ b/azalea-client/src/packet_handling.rs @@ -2,13 +2,12 @@ use std::{collections::HashSet, io::Cursor, sync::Arc}; use azalea_core::{ChunkPos, ResourceLocation, Vec3}; use azalea_ecs::{ - app::{App, Plugin}, + app::{App, CoreStage, Plugin}, component::Component, ecs::Ecs, entity::Entity, event::EventWriter, query::Changed, - schedule::{IntoSystemDescriptor, SystemSet}, system::{Commands, Query, ResMut, SystemState}, }; use azalea_protocol::{ @@ -47,15 +46,13 @@ pub struct PacketHandlerPlugin; impl Plugin for PacketHandlerPlugin { fn build(&self, app: &mut App) { - app.add_system_set( - SystemSet::new().with_system(handle_packets.label("packet").before("tick")), - ) - .add_event::<AddPlayerEvent>() - .add_event::<RemovePlayerEvent>() - .add_event::<UpdatePlayerEvent>() - .add_event::<ChatReceivedEvent>() - .add_event::<DeathEvent>() - .add_event::<KeepAliveEvent>(); + app.add_system_to_stage(CoreStage::PreUpdate, handle_packets) + .add_event::<AddPlayerEvent>() + .add_event::<RemovePlayerEvent>() + .add_event::<UpdatePlayerEvent>() + .add_event::<ChatReceivedEvent>() + .add_event::<DeathEvent>() + .add_event::<KeepAliveEvent>(); } } @@ -110,7 +107,7 @@ pub struct PacketReceiver { pub run_schedule_sender: mpsc::UnboundedSender<()>, } -fn handle_packets(ecs: &mut Ecs) { +pub fn handle_packets(ecs: &mut Ecs) { let mut events_owned = Vec::new(); { diff --git a/azalea-client/src/player.rs b/azalea-client/src/player.rs index 8bccedc8..3680e2d0 100755 --- a/azalea-client/src/player.rs +++ b/azalea-client/src/player.rs @@ -36,9 +36,9 @@ pub fn retroactively_add_game_profile_component( ) { for event in events.iter() { if let Some(entity) = entity_infos.get_entity_by_uuid(&event.info.uuid) { - if let Some(mut entity_commands) = commands.get_entity(entity) { - entity_commands.insert(GameProfileComponent(event.info.profile.clone())); - } + commands + .entity(entity) + .insert(GameProfileComponent(event.info.profile.clone())); } } } |
