aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/client_impl
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/src/client_impl')
-rw-r--r--azalea/src/client_impl/mining.rs7
-rw-r--r--azalea/src/client_impl/mod.rs11
2 files changed, 17 insertions, 1 deletions
diff --git a/azalea/src/client_impl/mining.rs b/azalea/src/client_impl/mining.rs
index 980fc47f..11c74480 100644
--- a/azalea/src/client_impl/mining.rs
+++ b/azalea/src/client_impl/mining.rs
@@ -1,4 +1,4 @@
-use azalea_client::mining::{LeftClickMine, StartMiningBlockEvent};
+use azalea_client::mining::{LeftClickMine, Mining, StartMiningBlockEvent};
use azalea_core::position::BlockPos;
use crate::Client;
@@ -14,6 +14,11 @@ impl Client {
});
}
+ /// Returns true if the client is currently trying to mine a block.
+ pub fn is_mining(&self) -> bool {
+ self.get_component::<Mining>().is_some()
+ }
+
/// 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) {
diff --git a/azalea/src/client_impl/mod.rs b/azalea/src/client_impl/mod.rs
index db9ecf91..dc4ab90f 100644
--- a/azalea/src/client_impl/mod.rs
+++ b/azalea/src/client_impl/mod.rs
@@ -11,6 +11,7 @@ use azalea_client::{
packet::game::SendGamePacketEvent,
player::{GameProfileComponent, PlayerInfo},
start_ecs_runner,
+ tick_counter::TicksConnected,
};
use azalea_core::data_registry::{DataRegistryWithKey, ResolvableDataRegistry};
use azalea_entity::indexing::{EntityIdIndex, EntityUuidIndex};
@@ -450,4 +451,14 @@ impl Client {
.map(|(name, data)| f(name, data))
})
}
+
+ /// Returns the number of ticks since the `login` packet was received, or 0
+ /// if the client isn't in the world.
+ ///
+ /// This is a shortcut for getting the [`TicksConnected`] component.
+ pub fn ticks_connected(&self) -> u64 {
+ self.get_component::<TicksConnected>()
+ .map(|c| c.0)
+ .unwrap_or(0)
+ }
}