aboutsummaryrefslogtreecommitdiff
path: root/azalea/src/client_impl/attack.rs
diff options
context:
space:
mode:
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;
};