diff options
| author | mat <git@matdoes.dev> | 2026-03-21 08:05:27 +0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-21 11:35:31 +0700 |
| commit | 88606d9ce9e13fcdd4ab5ce26e52630dee614c1e (patch) | |
| tree | ee9d1db9871eba381a876e7472946f267280a8ff /azalea/examples | |
| parent | 7965bb7953bfcabd475e213db335d90e0db28497 (diff) | |
| download | azalea-drasl-88606d9ce9e13fcdd4ab5ce26e52630dee614c1e.tar.xz | |
Extensible ChunkStorage
Co-authored-by: sdwhw <191973436+sdwhw@users.noreply.github.com>
Diffstat (limited to 'azalea/examples')
| -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: {}", |
