diff options
| author | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
| commit | 34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch) | |
| tree | 7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-world/src | |
| parent | bdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff) | |
| download | azalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz | |
update to rust edition 2024
Diffstat (limited to 'azalea-world/src')
| -rwxr-xr-x | azalea-world/src/chunk_storage.rs | 40 | ||||
| -rw-r--r-- | azalea-world/src/container.rs | 49 | ||||
| -rw-r--r-- | azalea-world/src/find_blocks.rs | 4 | ||||
| -rw-r--r-- | azalea-world/src/heightmap.rs | 2 | ||||
| -rw-r--r-- | azalea-world/src/world.rs | 2 |
5 files changed, 55 insertions, 42 deletions
diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index 8362385a..9852dd1a 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -556,21 +556,31 @@ mod tests { Some(Chunk::default()), &mut chunk_storage, ); - assert!(chunk_storage - .get_block_state(&BlockPos { x: 0, y: 319, z: 0 }) - .is_some()); - assert!(chunk_storage - .get_block_state(&BlockPos { x: 0, y: 320, z: 0 }) - .is_none()); - assert!(chunk_storage - .get_block_state(&BlockPos { x: 0, y: 338, z: 0 }) - .is_none()); - assert!(chunk_storage - .get_block_state(&BlockPos { x: 0, y: -64, z: 0 }) - .is_some()); - assert!(chunk_storage - .get_block_state(&BlockPos { x: 0, y: -65, z: 0 }) - .is_none()); + assert!( + chunk_storage + .get_block_state(&BlockPos { x: 0, y: 319, z: 0 }) + .is_some() + ); + assert!( + chunk_storage + .get_block_state(&BlockPos { x: 0, y: 320, z: 0 }) + .is_none() + ); + assert!( + chunk_storage + .get_block_state(&BlockPos { x: 0, y: 338, z: 0 }) + .is_none() + ); + assert!( + chunk_storage + .get_block_state(&BlockPos { x: 0, y: -64, z: 0 }) + .is_some() + ); + assert!( + chunk_storage + .get_block_state(&BlockPos { x: 0, y: -65, z: 0 }) + .is_none() + ); } #[test] diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index f7f05a89..8648d19e 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -53,31 +53,34 @@ impl InstanceContainer { min_y: i32, default_registries: &RegistryHolder, ) -> Arc<RwLock<Instance>> { - if let Some(existing_lock) = self.instances.get(&name).and_then(|world| world.upgrade()) { - let existing = existing_lock.read(); - if existing.chunks.height != height { - error!( - "Shared dimension height mismatch: {} != {height}", - existing.chunks.height - ); + match self.instances.get(&name).and_then(|world| world.upgrade()) { + Some(existing_lock) => { + let existing = existing_lock.read(); + if existing.chunks.height != height { + error!( + "Shared dimension height mismatch: {} != {height}", + existing.chunks.height + ); + } + if existing.chunks.min_y != min_y { + error!( + "Shared world min_y mismatch: {} != {min_y}", + existing.chunks.min_y + ); + } + existing_lock.clone() } - if existing.chunks.min_y != min_y { - error!( - "Shared world min_y mismatch: {} != {min_y}", - existing.chunks.min_y - ); + _ => { + let world = Arc::new(RwLock::new(Instance { + chunks: ChunkStorage::new(height, min_y), + entities_by_chunk: HashMap::new(), + entity_by_id: IntMap::default(), + registries: default_registries.clone(), + })); + debug!("Added new instance {name}"); + self.instances.insert(name, Arc::downgrade(&world)); + world } - existing_lock.clone() - } else { - let world = Arc::new(RwLock::new(Instance { - chunks: ChunkStorage::new(height, min_y), - entities_by_chunk: HashMap::new(), - entity_by_id: IntMap::default(), - registries: default_registries.clone(), - })); - debug!("Added new instance {name}"); - self.instances.insert(name, Arc::downgrade(&world)); - world } } } diff --git a/azalea-world/src/find_blocks.rs b/azalea-world/src/find_blocks.rs index 6228687f..068a5029 100644 --- a/azalea-world/src/find_blocks.rs +++ b/azalea-world/src/find_blocks.rs @@ -1,7 +1,7 @@ -use azalea_block::{block_state::BlockState, BlockStates}; +use azalea_block::{BlockStates, block_state::BlockState}; use azalea_core::position::{BlockPos, ChunkPos}; -use crate::{iterators::ChunkIterator, palette::Palette, ChunkStorage, Instance}; +use crate::{ChunkStorage, Instance, iterators::ChunkIterator, palette::Palette}; fn palette_maybe_has_block(palette: &Palette, block_states: &BlockStates) -> bool { match &palette { diff --git a/azalea-world/src/heightmap.rs b/azalea-world/src/heightmap.rs index c38f3edc..35142cf2 100644 --- a/azalea-world/src/heightmap.rs +++ b/azalea-world/src/heightmap.rs @@ -4,7 +4,7 @@ use azalea_block::BlockState; use azalea_core::{math, position::ChunkBlockPos}; use azalea_registry::tags::blocks::LEAVES; -use crate::{chunk_storage::get_block_state_from_sections, BitStorage, Section}; +use crate::{BitStorage, Section, chunk_storage::get_block_state_from_sections}; // (wg stands for worldgen) diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index ae257696..3428ab5e 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -6,8 +6,8 @@ use std::{ fmt::Debug, }; -use azalea_block::fluid_state::FluidState; use azalea_block::BlockState; +use azalea_block::fluid_state::FluidState; use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; use azalea_core::position::{BlockPos, ChunkPos}; use azalea_core::registry_holder::RegistryHolder; |
