diff options
Diffstat (limited to 'azalea-entity/src')
| -rw-r--r-- | azalea-entity/src/lib.rs | 2 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/indexing.rs | 15 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/mod.rs | 6 | ||||
| -rw-r--r-- | azalea-entity/src/plugin/relative_updates.rs | 15 |
4 files changed, 23 insertions, 15 deletions
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index e13ec2f0..c2553102 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -354,7 +354,7 @@ pub struct PlayerBundle { /// A marker component that signifies that this entity is "local" and shouldn't /// be updated by other clients. #[derive(Component)] -pub struct Local; +pub struct LocalEntity; #[derive(Component, Clone, Debug, PartialEq, Deref, DerefMut)] pub struct FluidOnEyes(azalea_registry::Fluid); diff --git a/azalea-entity/src/plugin/indexing.rs b/azalea-entity/src/plugin/indexing.rs index eb874437..a8ea9d85 100644 --- a/azalea-entity/src/plugin/indexing.rs +++ b/azalea-entity/src/plugin/indexing.rs @@ -13,7 +13,7 @@ use nohash_hasher::IntMap; use std::{collections::HashMap, fmt::Debug}; use uuid::Uuid; -use crate::{EntityUuid, LastSentPosition, Local, Position}; +use crate::{EntityUuid, LastSentPosition, LocalEntity, Position}; use super::LoadedBy; @@ -87,7 +87,7 @@ pub fn deduplicate_entities( mut commands: Commands, mut query: Query< (Entity, &MinecraftEntityId, &InstanceName), - (Changed<MinecraftEntityId>, Without<Local>), + (Changed<MinecraftEntityId>, Without<LocalEntity>), >, mut loaded_by_query: Query<&mut LoadedBy>, mut entity_id_index_query: Query<&mut EntityIdIndex>, @@ -141,7 +141,7 @@ pub fn deduplicate_local_entities( mut commands: Commands, mut query: Query< (Entity, &MinecraftEntityId, &InstanceName), - (Changed<MinecraftEntityId>, With<Local>), + (Changed<MinecraftEntityId>, With<LocalEntity>), >, instance_container: Res<InstanceContainer>, ) { @@ -169,7 +169,7 @@ pub fn deduplicate_local_entities( pub fn update_uuid_index( mut entity_infos: ResMut<EntityUuidIndex>, - query: Query<(Entity, &EntityUuid, Option<&Local>), Changed<EntityUuid>>, + query: Query<(Entity, &EntityUuid, Option<&LocalEntity>), Changed<EntityUuid>>, ) { for (entity, &uuid, local) in query.iter() { // only add it if it doesn't already exist in @@ -189,7 +189,12 @@ pub fn update_uuid_index( /// System to keep the entity_by_id index up-to-date. pub fn update_entity_by_id_index( mut query: Query< - (Entity, &MinecraftEntityId, &InstanceName, Option<&Local>), + ( + Entity, + &MinecraftEntityId, + &InstanceName, + Option<&LocalEntity>, + ), Changed<MinecraftEntityId>, >, instance_container: Res<InstanceContainer>, diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index 10e2a2f3..a75673ab 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -5,13 +5,13 @@ use std::collections::HashSet; use azalea_core::{BlockPos, ChunkPos, Vec3}; use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId}; -use bevy_app::{App, FixedUpdate, Plugin, PostUpdate, PreUpdate, Update}; +use bevy_app::{App, Plugin, PostUpdate, PreUpdate, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; use log::debug; use crate::{ - metadata::Health, Dead, EyeHeight, FluidOnEyes, Local, LookDirection, Physics, Position, + metadata::Health, Dead, EyeHeight, FluidOnEyes, LocalEntity, LookDirection, Physics, Position, }; use indexing::EntityUuidIndex; @@ -73,7 +73,7 @@ impl Plugin for EntityPlugin { } } -fn debug_new_entity(query: Query<(Entity, Option<&Local>), Added<MinecraftEntityId>>) { +fn debug_new_entity(query: Query<(Entity, Option<&LocalEntity>), Added<MinecraftEntityId>>) { for (entity, local) in query.iter() { if local.is_some() { debug!("new local entity: {:?}", entity); diff --git a/azalea-entity/src/plugin/relative_updates.rs b/azalea-entity/src/plugin/relative_updates.rs index 21b57cff..45b85203 100644 --- a/azalea-entity/src/plugin/relative_updates.rs +++ b/azalea-entity/src/plugin/relative_updates.rs @@ -28,7 +28,7 @@ use derive_more::{Deref, DerefMut}; use log::warn; use parking_lot::RwLock; -use crate::Local; +use crate::LocalEntity; /// An [`EntityCommand`] that applies a "relative update" to an entity, which /// means this update won't be run multiple times by different clients in the @@ -69,7 +69,7 @@ impl EntityCommand for RelativeEntityUpdate { }; let entity_id = *entity_mut.get::<MinecraftEntityId>().unwrap(); - if entity_mut.contains::<Local>() { + if entity_mut.contains::<LocalEntity>() { // a client tried to update another client, which isn't allowed return; } @@ -99,12 +99,15 @@ impl EntityCommand for RelativeEntityUpdate { } } -/// The [`UpdatesReceived`] component should never be on [`Local`] entities. -/// This warns if an entity has both components. +/// The [`UpdatesReceived`] component should never be on [`LocalEntity`] +/// entities. This warns if an entity has both components. pub fn debug_detect_updates_received_on_local_entities( - query: Query<Entity, (With<Local>, With<UpdatesReceived>)>, + query: Query<Entity, (With<LocalEntity>, With<UpdatesReceived>)>, ) { for entity in &query { - warn!("Entity {:?} has both Local and UpdatesReceived", entity); + warn!( + "Entity {:?} has both LocalEntity and UpdatesReceived", + entity + ); } } |
