mirror of
https://github.com/mat-1/azalea.git
synced 2024-11-03 08:04:00 +00:00
fix warning when entities that didn't move chunks despawn
This commit is contained in:
parent
3b635c1d6d
commit
79a0d58cc5
2 changed files with 25 additions and 2 deletions
|
@ -5,7 +5,7 @@ use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId}
|
|||
use bevy_ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
query::Changed,
|
||||
query::{Added, Changed},
|
||||
system::{Commands, Query, Res, ResMut, Resource},
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
@ -119,6 +119,24 @@ pub fn update_entity_chunk_positions(
|
|||
}
|
||||
}
|
||||
|
||||
/// Insert new entities into [`Instance::entities_by_chunk`].
|
||||
pub fn insert_entity_chunk_position(
|
||||
query: Query<(Entity, &Position, &InstanceName), Added<EntityChunkPos>>,
|
||||
instance_container: Res<InstanceContainer>,
|
||||
) {
|
||||
for (entity, pos, world_name) in query.iter() {
|
||||
let instance_lock = instance_container.get(world_name).unwrap();
|
||||
let mut instance = instance_lock.write();
|
||||
|
||||
let chunk = ChunkPos::from(*pos);
|
||||
instance
|
||||
.entities_by_chunk
|
||||
.entry(chunk)
|
||||
.or_default()
|
||||
.insert(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// Despawn entities that aren't being loaded by anything.
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn remove_despawned_entities_from_indexes(
|
||||
|
|
|
@ -43,7 +43,12 @@ impl Plugin for EntityPlugin {
|
|||
.add_systems(
|
||||
Update,
|
||||
(
|
||||
(indexing::update_entity_chunk_positions).in_set(EntityUpdateSet::Index),
|
||||
(
|
||||
indexing::update_entity_chunk_positions,
|
||||
indexing::insert_entity_chunk_position,
|
||||
)
|
||||
.chain()
|
||||
.in_set(EntityUpdateSet::Index),
|
||||
(
|
||||
relative_updates::debug_detect_updates_received_on_local_entities,
|
||||
debug_new_entity,
|
||||
|
|
Loading…
Reference in a new issue