mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
fix panic when entity goes out of render distance and then back in render distance
This commit is contained in:
parent
11d14c74c5
commit
9c31f8033f
1 changed files with 15 additions and 2 deletions
|
@ -233,9 +233,19 @@ pub fn remove_despawned_entities_from_indexes(
|
|||
mut commands: Commands,
|
||||
mut entity_infos: ResMut<EntityUuidIndex>,
|
||||
instance_container: Res<InstanceContainer>,
|
||||
query: Query<(Entity, &EntityUuid, &Position, &InstanceName, &LoadedBy), Changed<LoadedBy>>,
|
||||
query: Query<
|
||||
(
|
||||
Entity,
|
||||
&EntityUuid,
|
||||
&MinecraftEntityId,
|
||||
&Position,
|
||||
&InstanceName,
|
||||
&LoadedBy,
|
||||
),
|
||||
Changed<LoadedBy>,
|
||||
>,
|
||||
) {
|
||||
for (entity, uuid, position, world_name, loaded_by) in &query {
|
||||
for (entity, uuid, minecraft_id, position, world_name, loaded_by) in &query {
|
||||
let Some(instance_lock) = instance_container.get(world_name) else {
|
||||
// the instance isn't even loaded by us, so we can safely delete the entity
|
||||
debug!(
|
||||
|
@ -277,6 +287,9 @@ pub fn remove_despawned_entities_from_indexes(
|
|||
if entity_infos.entity_by_uuid.remove(uuid).is_none() {
|
||||
warn!("Tried to remove entity {entity:?} from the uuid index but it was not there.");
|
||||
}
|
||||
if instance.entity_by_id.remove(minecraft_id).is_none() {
|
||||
warn!("Tried to remove entity {entity:?} from the id index but it was not there.");
|
||||
}
|
||||
// and now remove the entity from the ecs
|
||||
commands.entity(entity).despawn();
|
||||
debug!("Despawned entity {entity:?} because it was not loaded by anything.");
|
||||
|
|
Loading…
Add table
Reference in a new issue