diff options
Diffstat (limited to 'azalea-entity/src/plugin')
| -rw-r--r-- | azalea-entity/src/plugin/indexing.rs | 25 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/mod.rs | 6 |
2 files changed, 18 insertions, 13 deletions
diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs index 78d5fb7e..21dd273a 100644 --- a/azalea-entity/src/plugin/indexing.rs +++ b/azalea-entity/src/plugin/indexing.rs @@ -181,19 +181,24 @@ pub fn remove_despawned_entities_from_indexes( // remove the entity from the chunk index let chunk = ChunkPos::from(*position); - if let Some(entities_in_chunk) = instance.entities_by_chunk.get_mut(&chunk) { - if entities_in_chunk.remove(&entity) { - // remove the chunk if there's no entities in it anymore - if entities_in_chunk.is_empty() { - instance.entities_by_chunk.remove(&chunk); + match instance.entities_by_chunk.get_mut(&chunk) { + Some(entities_in_chunk) => { + if entities_in_chunk.remove(&entity) { + // remove the chunk if there's no entities in it anymore + if entities_in_chunk.is_empty() { + instance.entities_by_chunk.remove(&chunk); + } + } else { + warn!( + "Tried to remove entity {entity:?} from chunk {chunk:?} but the entity was not there." + ); } - } else { - warn!( - "Tried to remove entity {entity:?} from chunk {chunk:?} but the entity was not there." + } + _ => { + debug!( + "Tried to remove entity {entity:?} from chunk {chunk:?} but the chunk was not found." ); } - } else { - debug!("Tried to remove entity {entity:?} from chunk {chunk:?} but the chunk was not found."); } // remove it from the uuid index if entity_uuid_index.entity_by_uuid.remove(uuid).is_none() { diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index 560d0ec6..bddb4b66 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -3,7 +3,7 @@ mod relative_updates; use std::collections::HashSet; -use azalea_block::{fluid_state::FluidKind, BlockState}; +use azalea_block::{BlockState, fluid_state::FluidKind}; use azalea_core::{ position::{BlockPos, ChunkPos, Vec3}, tick::GameTick, @@ -17,8 +17,8 @@ pub use relative_updates::RelativeEntityUpdate; use tracing::debug; use crate::{ - metadata::Health, Dead, EyeHeight, FluidOnEyes, LocalEntity, LookDirection, OnClimbable, - Physics, Position, + Dead, EyeHeight, FluidOnEyes, LocalEntity, LookDirection, OnClimbable, Physics, Position, + metadata::Health, }; /// A Bevy [`SystemSet`] for various types of entity updates. |
