From 24babbdbe5b54fec277b48833cf8fec9928ca873 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 21 Feb 2025 20:17:47 +0000 Subject: [PATCH] GameTick should only happen after Update --- azalea-client/src/client.rs | 3 +-- azalea-client/src/disconnect.rs | 3 ++- azalea-core/src/tick.rs | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 63026c96..c81f6f28 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -869,6 +869,7 @@ async fn run_schedule_loop( let mut ecs = ecs.lock(); // if last tick is None or more than 50ms ago, run the GameTick schedule + ecs.run_schedule(outer_schedule_label); if last_tick .map(|last_tick| last_tick.elapsed() > Duration::from_millis(50)) .unwrap_or(true) @@ -881,8 +882,6 @@ async fn run_schedule_loop( ecs.run_schedule(GameTick); } - ecs.run_schedule(outer_schedule_label); - ecs.clear_trackers(); } } diff --git a/azalea-client/src/disconnect.rs b/azalea-client/src/disconnect.rs index 5b377ce2..06648691 100644 --- a/azalea-client/src/disconnect.rs +++ b/azalea-client/src/disconnect.rs @@ -1,7 +1,7 @@ //! Disconnect a client from the server. use azalea_chat::FormattedText; -use azalea_entity::LocalEntity; +use azalea_entity::{EntityBundle, LocalEntity}; use bevy_app::{App, Plugin, PostUpdate}; use bevy_ecs::{ component::Component, @@ -50,6 +50,7 @@ pub fn remove_components_from_disconnected_players( commands .entity(*entity) .remove::() + .remove::() // this makes it close the tcp connection .remove::() // swarm detects when this tx gets dropped to fire SwarmEvent::Disconnect diff --git a/azalea-core/src/tick.rs b/azalea-core/src/tick.rs index c6f02c12..09b45be4 100644 --- a/azalea-core/src/tick.rs +++ b/azalea-core/src/tick.rs @@ -4,5 +4,7 @@ use bevy_ecs::schedule::ScheduleLabel; /// /// Many client systems run on this schedule, the most important one being /// physics. +/// +/// This schedule runs either zero or one times after every Bevy `Update`. #[derive(ScheduleLabel, Hash, Copy, Clone, Debug, Default, Eq, PartialEq)] pub struct GameTick;