From 11d14c74c53c07231c8ca33b622380df99bf9a59 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Thu, 24 Aug 2023 22:59:40 -0500 Subject: Support properly switching instances (#106) * start implementing switching dimensions * fix removeentity in shared worlds * also store entity ids per local player * uncomment a trace in pathfinder * cleanup --------- Co-authored-by: mat --- azalea-client/src/entity_query.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'azalea-client/src/entity_query.rs') diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index d3fa522b..ca41c872 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -71,6 +71,16 @@ impl Client { .expect("Entity components must be present in Client::entity)components."); components.clone() } + + /// Get a component from an entity, if it exists. This is similar to + /// [`Self::entity_component`] but returns an `Option` instead of panicking + /// if the component isn't present. + pub fn get_entity_component(&mut self, entity: Entity) -> Option { + let mut ecs = self.ecs.lock(); + let mut q = ecs.query::<&Q>(); + let components = q.get(&ecs, entity).ok(); + components.cloned() + } } pub trait EntityPredicate { -- cgit v1.2.3