From 73091d8f937192aca4c4bbc740c78d4d188f6ee1 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 15 Aug 2024 01:25:11 +0000 Subject: fix sometimes being able to mine blocks through walls --- azalea/src/pathfinder/simulation.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'azalea/src/pathfinder/simulation.rs') diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs index 2803b846..e8ba4dbd 100644 --- a/azalea/src/pathfinder/simulation.rs +++ b/azalea/src/pathfinder/simulation.rs @@ -144,8 +144,21 @@ impl Simulation { self.app.update(); self.app.world.run_schedule(GameTick); } + pub fn component(&self) -> T { + self.app.world.get::(self.entity).unwrap().clone() + } + pub fn get_component(&self) -> Option { + self.app.world.get::(self.entity).cloned() + } pub fn position(&self) -> Vec3 { - **self.app.world.get::(self.entity).unwrap() + *self.component::() + } + pub fn is_mining(&self) -> bool { + // return true if the component is present and Some + self.get_component::() + .map(|c| *c) + .flatten() + .is_some() } } -- cgit v1.2.3