aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/client_impl/mining.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-27 22:02:00 -0600
committerGitHub <noreply@github.com>2025-12-27 22:02:00 -0600
commit9513f42e87f64c409cdb2a100500a50e5a713bac (patch)
treebb6aa8b6d50fddf967bcb1f759e023754ea84e49 /azalea/src/client_impl/mining.rs
parent588902ba4a3965982bdd84d92b20c6f7613f3978 (diff)
downloadazalea-drasl-9513f42e87f64c409cdb2a100500a50e5a713bac.tar.xz
Move Client struct to azalea crate (#297)
* move the Client struct out of azalea-client into azalea * actually add client impls in azalea
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>();
+ }
+ }
+}