diff --git a/azalea-client/examples/echo.rs b/azalea-client/examples/echo.rs index 2f5baccd..5e7b751d 100644 --- a/azalea-client/examples/echo.rs +++ b/azalea-client/examples/echo.rs @@ -4,6 +4,29 @@ use azalea_client::{Account, Client, Event}; #[tokio::main] async fn main() { + // deadlock detection, you can safely delete this block if you're not trying to + // debug deadlocks in azalea + { + use parking_lot::deadlock; + use std::thread; + use std::time::Duration; + thread::spawn(move || loop { + thread::sleep(Duration::from_secs(10)); + let deadlocks = deadlock::check_deadlock(); + if deadlocks.is_empty() { + continue; + } + println!("{} deadlocks detected", deadlocks.len()); + for (i, threads) in deadlocks.iter().enumerate() { + println!("Deadlock #{i}"); + for t in threads { + println!("Thread Id {:#?}", t.thread_id()); + println!("{:#?}", t.backtrace()); + } + } + }); + } + let account = Account::offline("bot"); // or let account = Account::microsoft("email").await; diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 0f49b99f..2b84d5f5 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -504,7 +504,9 @@ async fn run_schedule_loop( loop { // whenever we get an event from run_schedule_receiver, run the schedule run_schedule_receiver.recv().await; + println!("run_schedule_loop tick"); schedule.run(&mut ecs.lock()); + println!("run_schedule_loop ticked"); } } @@ -515,9 +517,13 @@ pub async fn tick_run_schedule_loop(run_schedule_sender: mpsc::UnboundedSender<( // TODO: Minecraft bursts up to 10 ticks and then skips, we should too game_tick_interval.set_missed_tick_behavior(time::MissedTickBehavior::Burst); + println!("tick_run_schedule_loop started"); + loop { game_tick_interval.tick().await; - if run_schedule_sender.send(()).is_err() { + println!("tick_run_schedule_loop tick"); + if let Err(e) = run_schedule_sender.send(()) { + println!("tick_run_schedule_loop error: {}", e); // the sender is closed so end the task return; } diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index da9d4639..e3955f78 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -318,6 +318,7 @@ pub fn local_player_ai_step( &LocalPlayerInLoadedChunk, >, ) { + println!("local_player_ai_step"); for (mut local_player, mut physics, mut position, mut sprinting, mut attributes) in query.iter_mut() {