From cde7e35046b726b07bf3e067c080b85a12b2fd74 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 15 Jul 2023 04:39:43 -0500 Subject: Attacking (#96) * add Client::attack * partially implement attack cooldowns * attack speed modifiers * don't care clippy --------- Co-authored-by: mat --- azalea/src/container.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'azalea/src/container.rs') diff --git a/azalea/src/container.rs b/azalea/src/container.rs index dc0ba169..2261469d 100644 --- a/azalea/src/container.rs +++ b/azalea/src/container.rs @@ -3,7 +3,7 @@ use std::fmt::Formatter; use azalea_client::{ inventory::{CloseContainerEvent, ContainerClickEvent, InventoryComponent}, packet_handling::PacketEvent, - Client, TickBroadcast, + Client, }; use azalea_core::BlockPos; use azalea_inventory::{operations::ClickOperation, ItemSlot, Menu}; @@ -12,6 +12,8 @@ use bevy_app::{App, Plugin, Update}; use bevy_ecs::{component::Component, prelude::EventReader, system::Commands}; use std::fmt::Debug; +use crate::bot::BotClientExt; + pub struct ContainerPlugin; impl Plugin for ContainerPlugin { fn build(&self, app: &mut App) { @@ -49,11 +51,7 @@ impl ContainerClientExt for Client { .insert(WaitingForInventoryOpen); self.block_interact(pos); - let mut receiver = { - let ecs = self.ecs.lock(); - let tick_broadcast = ecs.resource::(); - tick_broadcast.subscribe() - }; + let mut receiver = self.get_tick_broadcaster(); while receiver.recv().await.is_ok() { let ecs = self.ecs.lock(); if ecs.get::(self.entity).is_none() { -- cgit v1.2.3