aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-02-25 17:32:15 -0600
committerGitHub <noreply@github.com>2023-02-25 17:32:15 -0600
commitc1588ef66e844c067112ea880a54b4de9ec5a062 (patch)
tree76e4f73a5f5392e1bef1f0560ed2f2c56b0d50fb /azalea
parentf5a8a59467a0aac3ae2f728961559217f1e1242d (diff)
downloadazalea-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')
-rw-r--r--azalea/Cargo.toml2
-rwxr-xr-xazalea/README.md21
-rwxr-xr-xazalea/examples/echo.rs2
-rw-r--r--azalea/examples/testbot.rs5
-rw-r--r--azalea/src/bot.rs10
-rw-r--r--azalea/src/pathfinder/mod.rs6
6 files changed, 32 insertions, 14 deletions
diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml
index 69129d4c..f64959ed 100644
--- a/azalea/Cargo.toml
+++ b/azalea/Cargo.toml
@@ -36,5 +36,3 @@ thiserror = "^1.0.37"
tokio = "^1.24.2"
uuid = "1.2.2"
-[dev-dependencies]
-env_logger = "^0.10.0"
diff --git a/azalea/README.md b/azalea/README.md
index a9c44461..21be566a 100755
--- a/azalea/README.md
+++ b/azalea/README.md
@@ -83,4 +83,25 @@ Also note that just because something is an entity in the ECS doesn't mean that
See the [Bevy Cheatbook](https://bevy-cheatbook.github.io/programming/ecs-intro.html) to learn more about Bevy ECS (and the ECS paradigm in general).
+# Debugging
+
+Azalea uses several relatively complex features of Rust, which may make debugging certain issues more tricky if you're not familiar with them.
+
+## Logging
+
+One of the most useful tools for debugging issues is logging. The default log level is `info`, but you can make it show more or less information by changing the log level. Enabling logging is done with `RUST_LOG=debug cargo run` on Linux/bash or `set RUST_LOG=debug && cargo run` on Windows. The log levels are `trace`, `debug`, `info`, `warn`, and `error`, in ascending priority.
+
+If it's a crash/panic and you believe it has to do with parsing a packet, you might want to set the level to `trace` since that'll make it show the first few hundred bytes of every packet received. This may produce a lot of logs, so pipe it into a file with `&> azalea.log` (on Linux).
+
+Note: If you get a `SetLoggerError`, it's because you have multiple loggers. Azalea comes with a logger by default, see [`bevy_log`] for more information.
+
+## Deadlocks
+
+If your code is simply hanging, it might be a deadlock. Copy the deadlock block in [`azalea/examples/testbot.rs`](https://github.com/mat-1/azalea/blob/main/azalea/examples/testbot.rs) to the beginning of your code and it'll print a long backtrace if a deadlock is detected.
+
+## Backtraces
+
+Backtraces are also useful, though they're sometimes hard to read and don't always contain the actual location of the error. Run your code with `RUST_BACKTRACE=1` to enable full backtraces. If it's very long, often searching for the keyword "azalea" will help you filter out unrelated things and find the actual source of the issue.
+
[`azalea_client`]: https://docs.rs/azalea-client
+[`bevy_log`]: https://docs.rs/bevy_log
diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs
index 46853bf4..292e12cd 100755
--- a/azalea/examples/echo.rs
+++ b/azalea/examples/echo.rs
@@ -4,8 +4,6 @@ use azalea::prelude::*;
#[tokio::main]
async fn main() {
- env_logger::init();
-
let account = Account::offline("bot");
// or let account = Account::microsoft("email").await;
diff --git a/azalea/examples/testbot.rs b/azalea/examples/testbot.rs
index af236dc4..053e29b3 100644
--- a/azalea/examples/testbot.rs
+++ b/azalea/examples/testbot.rs
@@ -19,13 +19,10 @@ struct SwarmState {}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- env_logger::init();
-
{
use parking_lot::deadlock;
use std::thread;
use std::time::Duration;
-
// Create a background thread which checks for deadlocks every 10s
thread::spawn(move || loop {
thread::sleep(Duration::from_secs(10));
@@ -48,7 +45,7 @@ async fn main() -> anyhow::Result<()> {
let mut accounts = Vec::new();
let mut states = Vec::new();
- for i in 0..1 {
+ for i in 0..5 {
accounts.push(Account::offline(&format!("bot{i}")));
states.push(State::default());
}
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs
index 1f3822ac..ce5b9fdc 100644
--- a/azalea/src/bot.rs
+++ b/azalea/src/bot.rs
@@ -20,9 +20,13 @@ impl Plugin for BotPlugin {
fn build(&self, app: &mut App) {
app.add_event::<LookAtEvent>()
.add_event::<JumpEvent>()
- .add_system(insert_bot.before("deduplicate_entities"))
- .add_system(look_at_listener)
- .add_system(jump_listener.label("jump_listener").before("ai_step"))
+ .add_system(insert_bot)
+ .add_system(
+ look_at_listener
+ .before("force_jump_listener")
+ .before(azalea_world::entity::update_bounding_box),
+ )
+ .add_system(jump_listener.label("jump_listener"))
.add_tick_system(stop_jumping.after("ai_step"));
}
}
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index 1dfb7a9b..8289d9c4 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -36,10 +36,10 @@ impl Plugin for PathfinderPlugin {
fn build(&self, app: &mut App) {
app.add_event::<GotoEvent>()
.add_event::<PathFoundEvent>()
- .add_tick_system(tick_execute_path.before("walk_listener"))
+ .add_tick_system(tick_execute_path.before("ai_step"))
.add_system(goto_listener)
- .add_system(add_default_pathfinder.after("deduplicate_entities"))
- .add_system(handle_tasks)
+ .add_system(add_default_pathfinder)
+ .add_system(handle_tasks.before(path_found_listener))
.add_system(path_found_listener);
}
}