diff options
| author | mat <git@matdoes.dev> | 2026-01-06 06:34:19 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-06 06:34:19 -0500 |
| commit | fdbcfaab4813da928f9f27e119d4951088c3a853 (patch) | |
| tree | 19f33692f882ada386f8b6aea1e1a195a905e286 /azalea/src/client_impl/mod.rs | |
| parent | 9c2c7c3497a74e80d7186fdcd97ce2518520faa6 (diff) | |
| download | azalea-drasl-fdbcfaab4813da928f9f27e119d4951088c3a853.tar.xz | |
add a few more convenience functions and update some docs
Diffstat (limited to 'azalea/src/client_impl/mod.rs')
| -rw-r--r-- | azalea/src/client_impl/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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) + } } |
