aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src/container.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-09-18 19:29:14 -0500
committermat <git@matdoes.dev>2023-09-18 19:29:14 -0500
commite6941b6a24deed617d09c6e08ba65278bb3bcf25 (patch)
treea647ca131cd87d7d6cdb463dd50f497f4320656b /azalea-world/src/container.rs
parent856a3252f693421df519cbc4d9bc03cfc0f0c212 (diff)
downloadazalea-drasl-e6941b6a24deed617d09c6e08ba65278bb3bcf25.tar.xz
instanceloadedevent and a few fixes
Diffstat (limited to 'azalea-world/src/container.rs')
-rw-r--r--azalea-world/src/container.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs
index 866ac157..79cf2105 100644
--- a/azalea-world/src/container.rs
+++ b/azalea-world/src/container.rs
@@ -27,20 +27,18 @@ pub struct InstanceContainer {
// telling them apart. We hope most servers are nice and don't do that though. It's only an
// issue when there's multiple clients with the same WorldContainer in different worlds
// anyways.
- pub worlds: HashMap<ResourceLocation, Weak<RwLock<Instance>>>,
+ pub instances: HashMap<ResourceLocation, Weak<RwLock<Instance>>>,
}
impl InstanceContainer {
pub fn new() -> Self {
- InstanceContainer {
- worlds: HashMap::new(),
- }
+ InstanceContainer::default()
}
/// Get a world from the container. Returns `None` if none of the clients
/// are in this world.
pub fn get(&self, name: &InstanceName) -> Option<Arc<RwLock<Instance>>> {
- self.worlds.get(name).and_then(|world| world.upgrade())
+ self.instances.get(name).and_then(|world| world.upgrade())
}
/// Add an empty world to the container (or not if it already exists) and
@@ -52,7 +50,7 @@ impl InstanceContainer {
height: u32,
min_y: i32,
) -> Arc<RwLock<Instance>> {
- if let Some(existing_lock) = self.worlds.get(&name).and_then(|world| world.upgrade()) {
+ 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!(
@@ -73,7 +71,7 @@ impl InstanceContainer {
entities_by_chunk: HashMap::new(),
entity_by_id: IntMap::default(),
}));
- self.worlds.insert(name, Arc::downgrade(&world));
+ self.instances.insert(name, Arc::downgrade(&world));
world
}
}