aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/client_impl/mining.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/src/client_impl/mining.rs')
-rw-r--r--azalea/src/client_impl/mining.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/azalea/src/client_impl/mining.rs b/azalea/src/client_impl/mining.rs
new file mode 100644
index 00000000..14794765
--- /dev/null
+++ b/azalea/src/client_impl/mining.rs
@@ -0,0 +1,29 @@
+use azalea_client::mining::{LeftClickMine, StartMiningBlockEvent};
+use azalea_core::position::BlockPos;
+
+use crate::Client;
+
+impl Client {
+ pub fn start_mining(&self, position: BlockPos) {
+ let mut ecs = self.ecs.lock();
+
+ ecs.write_message(StartMiningBlockEvent {
+ entity: self.entity,
+ position,
+ force: true,
+ });
+ }
+
+ /// When enabled, the bot will mine any block that it is looking at if it is
+ /// reachable.
+ pub fn left_click_mine(&self, enabled: bool) {
+ let mut ecs = self.ecs.lock();
+ let mut entity_mut = ecs.entity_mut(self.entity);
+
+ if enabled {
+ entity_mut.insert(LeftClickMine);
+ } else {
+ entity_mut.remove::<LeftClickMine>();
+ }
+ }
+}