From 11d14c74c53c07231c8ca33b622380df99bf9a59 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Thu, 24 Aug 2023 22:59:40 -0500 Subject: Support properly switching instances (#106) * start implementing switching dimensions * fix removeentity in shared worlds * also store entity ids per local player * uncomment a trace in pathfinder * cleanup --------- Co-authored-by: mat --- azalea-world/src/chunk_storage.rs | 6 +----- azalea-world/src/container.rs | 3 ++- azalea-world/src/world.rs | 8 ++------ 3 files changed, 5 insertions(+), 12 deletions(-) (limited to 'azalea-world/src') diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index f0f053fa..133d522b 100755 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -123,11 +123,7 @@ impl PartialChunkStorage { ) -> Result<(), BufReadError> { debug!("Replacing chunk at {:?}", pos); if !self.in_range(pos) { - trace!( - "Ignoring chunk since it's not in the view range: {}, {}", - pos.x, - pos.z - ); + warn!("Ignoring chunk since it's not in the view range: {pos:?}"); return Ok(()); } diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index 895d8d2d..866ac157 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -37,7 +37,8 @@ impl InstanceContainer { } } - /// Get a world from the container. + /// Get a world from the container. Returns `None` if none of the clients + /// are in this world. pub fn get(&self, name: &InstanceName) -> Option>> { self.worlds.get(name).and_then(|world| world.upgrade()) } diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index ecd2e653..df462be4 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -82,16 +82,12 @@ pub struct Instance { /// An index of all the entities we know are in the chunks of the world pub entities_by_chunk: HashMap>, - /// An index of Minecraft entity IDs to Azalea ECS entities. + /// An index of Minecraft entity IDs to Azalea ECS entities. You should + /// avoid using this and instead use `azalea_entity::EntityIdIndex` pub entity_by_id: IntMap, } impl Instance { - /// Get an ECS [`Entity`] from a Minecraft entity ID. - pub fn entity_by_id(&self, entity_id: &MinecraftEntityId) -> Option { - self.entity_by_id.get(entity_id).copied() - } - pub fn get_block_state(&self, pos: &BlockPos) -> Option { self.chunks.get_block_state(pos) } -- cgit v1.2.3