diff options
| author | mat <git@matdoes.dev> | 2024-08-15 01:25:11 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-08-15 01:25:11 +0000 |
| commit | 73091d8f937192aca4c4bbc740c78d4d188f6ee1 (patch) | |
| tree | 440e804d3a84583fb1b6b43a47724f5a17d001b7 /azalea/src/pathfinder/simulation.rs | |
| parent | dec544a52ba738e2d0e2c3a042e5ccc0cb336ffb (diff) | |
| download | azalea-drasl-73091d8f937192aca4c4bbc740c78d4d188f6ee1.tar.xz | |
fix sometimes being able to mine blocks through walls
Diffstat (limited to 'azalea/src/pathfinder/simulation.rs')
| -rw-r--r-- | azalea/src/pathfinder/simulation.rs | 15 |
1 files changed, 14 insertions, 1 deletions
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<T: Component + Clone>(&self) -> T { + self.app.world.get::<T>(self.entity).unwrap().clone() + } + pub fn get_component<T: Component + Clone>(&self) -> Option<T> { + self.app.world.get::<T>(self.entity).cloned() + } pub fn position(&self) -> Vec3 { - **self.app.world.get::<Position>(self.entity).unwrap() + *self.component::<Position>() + } + pub fn is_mining(&self) -> bool { + // return true if the component is present and Some + self.get_component::<azalea_client::mining::MineBlockPos>() + .map(|c| *c) + .flatten() + .is_some() } } |
