diff options
Diffstat (limited to 'azalea/examples/testbot')
| -rw-r--r-- | azalea/examples/testbot/commands/debug.rs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs index cd487abb..62baef1d 100644 --- a/azalea/examples/testbot/commands/debug.rs +++ b/azalea/examples/testbot/commands/debug.rs @@ -1,6 +1,6 @@ //! Commands for debugging and getting the current state of the bot. -use std::{env, fs::File, io::Write, thread, time::Duration}; +use std::{any::Any, env, fs::File, io::Write, thread, time::Duration}; use azalea::{ BlockPos, @@ -16,7 +16,7 @@ use azalea::{ use azalea_core::hit_result::HitResult; use azalea_entity::{EntityKindComponent, metadata}; use azalea_inventory::{Menu, components::MaxStackSize}; -use azalea_world::Worlds; +use azalea_world::{Worlds, chunk::storage::WeakChunkStorage}; use bevy_app::AppExit; use bevy_ecs::{message::Messages, query::With, world::EntityRef}; use parking_lot::Mutex; @@ -349,19 +349,22 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { .unwrap(); if let Some(world) = world.upgrade() { let world = world.read(); - let strong_chunks = world - .chunks - .map - .iter() - .filter(|(_, v)| v.strong_count() > 0) - .count(); - writeln!( - report, - "- Chunks: {} strongly referenced, {} in map", - strong_chunks, - world.chunks.map.len() - ) - .unwrap(); + let chunks = &world.chunks; + let chunks = (chunks as &dyn Any).downcast_ref::<WeakChunkStorage>(); + if let Some(chunks) = chunks { + let strong_chunks = chunks + .map + .iter() + .filter(|(_, v)| v.strong_count() > 0) + .count(); + writeln!( + report, + "- Chunks: {} strongly referenced, {} in map", + strong_chunks, + chunks.map.len() + ) + .unwrap(); + } writeln!( report, "- Entities: {}", |
