diff options
| author | mat <git@matdoes.dev> | 2023-10-06 15:23:36 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-06 15:23:36 -0500 |
| commit | 30702d94f65a2bd86c9ac0a7c402675b89ac4364 (patch) | |
| tree | 1d4399d168e49479161f3dfa046a58442fcccb04 /azalea-client/src/entity_query.rs | |
| parent | 177864be60c08cb61fd577eb99ee5c99481fc03e (diff) | |
| download | azalea-drasl-30702d94f65a2bd86c9ac0a7c402675b89ac4364.tar.xz | |
fix QueryDoesNotMatch and improve error
Diffstat (limited to 'azalea-client/src/entity_query.rs')
| -rw-r--r-- | azalea-client/src/entity_query.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index ca41c872..7b140825 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -23,9 +23,10 @@ impl Client { /// # } /// ``` pub fn query<'w, Q: WorldQuery>(&self, ecs: &'w mut World) -> <Q as WorldQuery>::Item<'w> { - ecs.query::<Q>() - .get_mut(ecs, self.entity) - .expect("Our client is missing a required component.") + ecs.query::<Q>().get_mut(ecs, self.entity).expect(&format!( + "Our client is missing a required component {:?}", + std::any::type_name::<Q>() + )) } /// Return a lightweight [`Entity`] for the entity that matches the given @@ -66,9 +67,10 @@ impl Client { pub fn entity_component<Q: Component + Clone>(&mut self, entity: Entity) -> Q { let mut ecs = self.ecs.lock(); let mut q = ecs.query::<&Q>(); - let components = q - .get(&ecs, entity) - .expect("Entity components must be present in Client::entity)components."); + let components = q.get(&ecs, entity).expect(&format!( + "Entity is missing a required component {:?}", + std::any::type_name::<Q>() + )); components.clone() } |
