aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/client_impl/attack.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-28 04:31:29 -0600
committerGitHub <noreply@github.com>2025-12-28 04:31:29 -0600
commit20c7e27250148f62bab9e7b99e4f0cd6deb82325 (patch)
tree163b312ef4dc72c5c23be923f8ca17cdf2a7278c /azalea/src/client_impl/attack.rs
parent7ab3b8924f64f7eadb6b8928b6fae73cb06e4c2f (diff)
downloadazalea-drasl-20c7e27250148f62bab9e7b99e4f0cd6deb82325.tar.xz
Change Client::component to return a reference (#298)
* change Client::component to return a reference * write docs * merge main * remove unused parking_lot feature
Diffstat (limited to 'azalea/src/client_impl/attack.rs')
-rw-r--r--azalea/src/client_impl/attack.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/azalea/src/client_impl/attack.rs b/azalea/src/client_impl/attack.rs
index f4cac51f..16721c1c 100644
--- a/azalea/src/client_impl/attack.rs
+++ b/azalea/src/client_impl/attack.rs
@@ -12,7 +12,7 @@ impl Client {
/// This doesn't automatically look at the entity or perform any
/// range/visibility checks, so it might trigger anticheats.
pub fn attack(&self, entity: Entity) {
- self.ecs.lock().write_message(AttackEvent {
+ self.ecs.write().write_message(AttackEvent {
entity: self.entity,
target: entity,
});
@@ -27,18 +27,19 @@ impl Client {
// attack? whatever, just return false
return false;
};
- *attack_strength_scale < 1.0
+ **attack_strength_scale < 1.0
}
/// Returns the number of ticks until we can attack at full strength again.
///
/// Also see [`Client::has_attack_cooldown`].
pub fn attack_cooldown_remaining_ticks(&self) -> usize {
- let mut ecs = self.ecs.lock();
- let Ok((attributes, ticks_since_last_attack)) = ecs
- .query::<(&Attributes, &TicksSinceLastAttack)>()
- .get(&ecs, self.entity)
- else {
+ let ecs = self.ecs.read();
+
+ let Some(attributes) = ecs.get::<Attributes>(self.entity) else {
+ return 0;
+ };
+ let Some(ticks_since_last_attack) = ecs.get::<TicksSinceLastAttack>(self.entity) else {
return 0;
};