aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2026-03-21 08:05:27 +0330
committermat <git@matdoes.dev>2026-03-21 11:35:31 +0700
commit88606d9ce9e13fcdd4ab5ce26e52630dee614c1e (patch)
treeee9d1db9871eba381a876e7472946f267280a8ff /azalea
parent7965bb7953bfcabd475e213db335d90e0db28497 (diff)
downloadazalea-drasl-88606d9ce9e13fcdd4ab5ce26e52630dee614c1e.tar.xz
Extensible ChunkStorage
Co-authored-by: sdwhw <191973436+sdwhw@users.noreply.github.com>
Diffstat (limited to 'azalea')
-rw-r--r--azalea/benches/pathfinder.rs8
-rw-r--r--azalea/benches/physics.rs2
-rw-r--r--azalea/examples/testbot/commands/debug.rs33
-rw-r--r--azalea/src/pathfinder/world.rs4
4 files changed, 25 insertions, 22 deletions
diff --git a/azalea/benches/pathfinder.rs b/azalea/benches/pathfinder.rs
index defd7c18..3adb9903 100644
--- a/azalea/benches/pathfinder.rs
+++ b/azalea/benches/pathfinder.rs
@@ -46,13 +46,13 @@ fn generate_bedrock_world(
chunk.set_block_state(
&ChunkBlockPos::new(x, 1, z),
BlockKind::Bedrock.into(),
- chunks.min_y,
+ chunks.min_y(),
);
if rng.random_bool(0.5) {
chunk.set_block_state(
&ChunkBlockPos::new(x, 2, z),
BlockKind::Bedrock.into(),
- chunks.min_y,
+ chunks.min_y(),
);
}
}
@@ -98,13 +98,13 @@ fn generate_mining_world(
let chunk_pos = ChunkPos::new(chunk_x, chunk_z);
let chunk = chunks.get(&chunk_pos).unwrap();
let mut chunk = chunk.write();
- for y in chunks.min_y..(chunks.min_y + chunks.height as i32) {
+ for y in chunks.min_y()..(chunks.min_y() + chunks.height() as i32) {
for x in 0..16_u8 {
for z in 0..16_u8 {
chunk.set_block_state(
&ChunkBlockPos::new(x, y, z),
BlockKind::Stone.into(),
- chunks.min_y,
+ chunks.min_y(),
);
}
}
diff --git a/azalea/benches/physics.rs b/azalea/benches/physics.rs
index 8b15cc6c..430809cc 100644
--- a/azalea/benches/physics.rs
+++ b/azalea/benches/physics.rs
@@ -33,7 +33,7 @@ fn generate_world(partial_chunks: &mut PartialChunkStorage, size: u32) -> ChunkS
chunk.set_block_state(
&ChunkBlockPos::new(x, 1, z),
BlockKind::Stone.into(),
- chunks.min_y,
+ chunks.min_y(),
);
}
}
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: {}",
diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs
index 98b22d70..6c5d84d2 100644
--- a/azalea/src/pathfinder/world.rs
+++ b/azalea/src/pathfinder/world.rs
@@ -110,7 +110,7 @@ pub struct SectionBitsets {
impl CachedWorld {
pub fn new(world_lock: Arc<RwLock<World>>, origin: BlockPos) -> Self {
- let min_y = world_lock.read().chunks.min_y;
+ let min_y = world_lock.read().chunks.min_y();
Self {
origin,
min_y,
@@ -145,7 +145,7 @@ impl CachedWorld {
let chunk_pos = ChunkPos::new(section_pos.x as i32, section_pos.z as i32);
let section_index =
- azalea_world::chunk_storage::section_index(section_pos.y * 16, self.min_y) as usize;
+ azalea_world::chunk::section_index(section_pos.y * 16, self.min_y) as usize;
let mut cache_idx = 0;