diff options
| author | mat <git@matdoes.dev> | 2023-08-26 22:19:10 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-08-26 22:19:10 -0500 |
| commit | 12118ebfa3f8165c345c98596957b25a156c8b74 (patch) | |
| tree | 2295753dcacb488755d3b6c6ce405a7a91196f52 /azalea-entity/src | |
| parent | dea717b68e2945777c68d44ce321639cf09ea226 (diff) | |
| download | azalea-drasl-12118ebfa3f8165c345c98596957b25a156c8b74.tar.xz | |
use better pathfinder costs and also fix relative entity updates breaking sometimes
Diffstat (limited to 'azalea-entity/src')
| -rw-r--r-- | azalea-entity/src/plugin/indexing.rs | 2 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/mod.rs | 1 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/relative_updates.rs | 34 |
3 files changed, 12 insertions, 25 deletions
diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs index be5c0a5b..507e6737 100644 --- a/azalea-entity/src/plugin/indexing.rs +++ b/azalea-entity/src/plugin/indexing.rs @@ -290,7 +290,7 @@ pub fn remove_despawned_entities_from_indexes( warn!("Tried to remove entity from chunk {chunk:?} but the entity was not there."); } } else { - warn!("Tried to remove entity from chunk {chunk:?} but the chunk was not found."); + debug!("Tried to remove entity from chunk {chunk:?} but the chunk was not found."); } // remove it from the uuid index if entity_infos.entity_by_uuid.remove(uuid).is_none() { diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index 41ec4e6a..94e8e79d 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -59,7 +59,6 @@ impl Plugin for EntityPlugin { ) .in_set(EntityUpdateSet::Index), ( - relative_updates::add_updates_received, relative_updates::debug_detect_updates_received_on_local_entities, debug_new_entity, add_dead, diff --git a/azalea-entity/src/plugin/relative_updates.rs b/azalea-entity/src/plugin/relative_updates.rs index 7d01feda..21b57cff 100644 --- a/azalea-entity/src/plugin/relative_updates.rs +++ b/azalea-entity/src/plugin/relative_updates.rs @@ -20,8 +20,8 @@ use std::sync::Arc; use azalea_world::{MinecraftEntityId, PartialInstance}; use bevy_ecs::{ prelude::{Component, Entity}, - query::{Changed, With, Without}, - system::{Commands, EntityCommand, Query}, + query::With, + system::{EntityCommand, Query}, world::{EntityMut, World}, }; use derive_more::{Deref, DerefMut}; @@ -69,24 +69,29 @@ impl EntityCommand for RelativeEntityUpdate { }; let entity_id = *entity_mut.get::<MinecraftEntityId>().unwrap(); - let Some(updates_received) = entity_mut.get_mut::<UpdatesReceived>() else { + if entity_mut.contains::<Local>() { // a client tried to update another client, which isn't allowed return; - }; + } let this_client_updates_received = partial_entity_infos .updates_received .get(&entity_id) .copied(); - let can_update = this_client_updates_received.unwrap_or(1) == **updates_received; + let can_update = if let Some(updates_received) = entity_mut.get::<UpdatesReceived>() { + this_client_updates_received.unwrap_or(1) == **updates_received + } else { + // no UpdatesReceived means the entity was just spawned + true + }; if can_update { let new_updates_received = this_client_updates_received.unwrap_or(0) + 1; partial_entity_infos .updates_received .insert(entity_id, new_updates_received); - **entity_mut.get_mut::<UpdatesReceived>().unwrap() = new_updates_received; + entity_mut.insert(UpdatesReceived(new_updates_received)); let mut entity = world.entity_mut(entity); (self.update)(&mut entity); @@ -94,23 +99,6 @@ impl EntityCommand for RelativeEntityUpdate { } } -#[allow(clippy::type_complexity)] -pub fn add_updates_received( - mut commands: Commands, - query: Query< - Entity, - ( - Changed<MinecraftEntityId>, - (Without<UpdatesReceived>, Without<Local>), - ), - >, -) { - for entity in query.iter() { - // entities always start with 1 update received - commands.entity(entity).insert(UpdatesReceived(1)); - } -} - /// The [`UpdatesReceived`] component should never be on [`Local`] entities. /// This warns if an entity has both components. pub fn debug_detect_updates_received_on_local_entities( |
