diff options
Diffstat (limited to 'azalea-client/src/plugins')
| -rw-r--r-- | azalea-client/src/plugins/connection.rs | 19 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/mining.rs | 23 |
3 files changed, 36 insertions, 18 deletions
diff --git a/azalea-client/src/plugins/connection.rs b/azalea-client/src/plugins/connection.rs index a929a4c7..f439ac33 100644 --- a/azalea-client/src/plugins/connection.rs +++ b/azalea-client/src/plugins/connection.rs @@ -1,4 +1,12 @@ -use std::{fmt::Debug, io::Cursor, mem, sync::Arc}; +use std::{ + fmt::Debug, + io::Cursor, + mem, + sync::{ + Arc, + atomic::{self, AtomicBool}, + }, +}; use azalea_crypto::Aes128CfbEnc; use azalea_protocol::{ @@ -232,9 +240,12 @@ impl RawConnection { if let Some(network) = &mut self.network { network.write(packet)?; } else { - debug!( - "tried to write packet to the network but there is no NetworkConnection. if you're trying to send a packet from the handler function, use self.write instead" - ); + static WARNED: AtomicBool = AtomicBool::new(false); + if !WARNED.swap(true, atomic::Ordering::Relaxed) { + debug!( + "tried to write packet to the network but there is no NetworkConnection. if you're trying to send a packet from the handler function, use self.write instead" + ); + } } Ok(()) } diff --git a/azalea-client/src/plugins/inventory.rs b/azalea-client/src/plugins/inventory.rs index ecc8e826..8037f8fc 100644 --- a/azalea-client/src/plugins/inventory.rs +++ b/azalea-client/src/plugins/inventory.rs @@ -1,7 +1,4 @@ -use std::{ - cmp, - collections::{HashMap, HashSet}, -}; +use std::{cmp, collections::HashSet}; use azalea_chat::FormattedText; use azalea_entity::PlayerAbilities; @@ -22,6 +19,7 @@ use azalea_registry::MenuKind; use azalea_world::{InstanceContainer, InstanceName}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; +use indexmap::IndexMap; use tracing::{error, warn}; use crate::{Client, packet::game::SendPacketEvent, respawn::perform_respawn}; @@ -869,9 +867,9 @@ pub fn handle_container_click_event( let registry_holder = &instance.read().registries; - // see which slots changed after clicking and put them in the hashmap - // the server uses this to check if we desynced - let mut changed_slots: HashMap<u16, HashedStack> = HashMap::new(); + // see which slots changed after clicking and put them in the map the server + // uses this to check if we desynced + let mut changed_slots: IndexMap<u16, HashedStack> = IndexMap::new(); for (slot_index, old_slot) in old_slots.iter().enumerate() { let new_slot = &new_slots[slot_index]; if old_slot != new_slot { diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index 1b7adadc..b6ac113a 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -8,7 +8,7 @@ use azalea_world::{InstanceContainer, InstanceName}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; -use tracing::trace; +use tracing::{debug, trace}; use crate::{ Client, @@ -35,14 +35,14 @@ impl Plugin for MiningPlugin { GameTick, ( update_mining_component, - continue_mining_block, handle_auto_mine, handle_mining_queued, + continue_mining_block, ) .chain() - .after(PhysicsSet) - .after(super::movement::send_position) - .after(super::attack::handle_attack_queued) + .before(PhysicsSet) + .before(super::movement::send_position) + .before(super::interact::handle_start_use_item_queued) .in_set(MiningSet), ) .add_systems( @@ -358,9 +358,9 @@ fn handle_mining_queued( seq: sequence_number.start_predicting(), }, )); - // vanilla really does send two swing arm packets - commands.trigger(SwingArmEvent { entity }); commands.trigger(SwingArmEvent { entity }); + // another swing packet gets sent in the same tick in + // continue_mining_block, vanilla does this too } } } @@ -687,9 +687,18 @@ pub fn update_mining_component( ) { for (entity, mut mining, hit_result_component) in &mut query.iter_mut() { if let Some(block_hit_result) = hit_result_component.as_block_hit_result_if_not_miss() { + if mining.force && block_hit_result.block_pos != mining.pos { + continue; + } + mining.pos = block_hit_result.block_pos; mining.dir = block_hit_result.direction; } else { + if mining.force { + continue; + } + + debug!("Removing mining component because we're no longer looking at the block"); commands.entity(entity).remove::<Mining>(); } } |
