diff options
| author | mat <git@matdoes.dev> | 2023-10-06 16:08:19 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-06 16:08:26 -0500 |
| commit | 94ef48d9f2e362167c077b9584e42ed2c71d679f (patch) | |
| tree | 1670cbdc946ce9574f20f6ed6a49e061394bf602 /azalea-client/src/entity_query.rs | |
| parent | 30702d94f65a2bd86c9ac0a7c402675b89ac4364 (diff) | |
| download | azalea-drasl-94ef48d9f2e362167c077b9584e42ed2c71d679f.tar.xz | |
make sure pathfinder is always centered on the destination block (fixes tests)
Diffstat (limited to 'azalea-client/src/entity_query.rs')
| -rw-r--r-- | azalea-client/src/entity_query.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index 7b140825..484da6f8 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -23,10 +23,14 @@ 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(&format!( - "Our client is missing a required component {:?}", - std::any::type_name::<Q>() - )) + ecs.query::<Q>() + .get_mut(ecs, self.entity) + .unwrap_or_else(|_| { + panic!( + "Our client is missing a required component {:?}", + std::any::type_name::<Q>() + ) + }) } /// Return a lightweight [`Entity`] for the entity that matches the given @@ -67,10 +71,12 @@ 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(&format!( - "Entity is missing a required component {:?}", - std::any::type_name::<Q>() - )); + let components = q.get(&ecs, entity).unwrap_or_else(|_| { + panic!( + "Entity is missing a required component {:?}", + std::any::type_name::<Q>() + ) + }); components.clone() } |
