aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src/container.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-world/src/container.rs')
-rw-r--r--azalea-world/src/container.rs49
1 files changed, 26 insertions, 23 deletions
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
}
}
}