aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/plugins
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-02 03:44:24 -0100
committermat <git@matdoes.dev>2025-06-02 03:44:24 -0100
commit3d121722d7b995de1346f9838df15386aea5acc8 (patch)
treef970e92883a0530fa683a5b5aaf51355deb0158a /azalea-client/src/plugins
parent99659bd9a33fad276c2a5ecfb68f094c4f544d48 (diff)
downloadazalea-drasl-3d121722d7b995de1346f9838df15386aea5acc8.tar.xz
several pathfinder fixes
Diffstat (limited to 'azalea-client/src/plugins')
-rw-r--r--azalea-client/src/plugins/auto_reconnect.rs8
-rw-r--r--azalea-client/src/plugins/connection.rs4
-rw-r--r--azalea-client/src/plugins/mining.rs22
3 files changed, 23 insertions, 11 deletions
diff --git a/azalea-client/src/plugins/auto_reconnect.rs b/azalea-client/src/plugins/auto_reconnect.rs
index 52c6e94b..1391545f 100644
--- a/azalea-client/src/plugins/auto_reconnect.rs
+++ b/azalea-client/src/plugins/auto_reconnect.rs
@@ -70,11 +70,17 @@ fn get_delay(
auto_reconnect_delay_query: Query<&AutoReconnectDelay>,
entity: Entity,
) -> Option<Duration> {
- if let Ok(c) = auto_reconnect_delay_query.get(entity) {
+ let delay = if let Ok(c) = auto_reconnect_delay_query.get(entity) {
Some(c.delay)
} else {
auto_reconnect_delay_res.as_ref().map(|r| r.delay)
+ };
+
+ if delay == Some(Duration::MAX) {
+ // if the duration is set to max, treat that as autoreconnect being disabled
+ return None;
}
+ delay
}
pub fn rejoin_after_delay(
diff --git a/azalea-client/src/plugins/connection.rs b/azalea-client/src/plugins/connection.rs
index 36aa2ee7..a929a4c7 100644
--- a/azalea-client/src/plugins/connection.rs
+++ b/azalea-client/src/plugins/connection.rs
@@ -169,9 +169,9 @@ pub struct RawConnection {
///
/// To check if we haven't disconnected from the server, use
/// [`Self::is_alive`].
- network: Option<NetworkConnection>,
+ pub(crate) network: Option<NetworkConnection>,
pub state: ConnectionProtocol,
- is_alive: bool,
+ pub(crate) is_alive: bool,
/// This exists for internal testing purposes and probably shouldn't be used
/// for normal bots. It's basically a way to make our client think it
diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs
index 797c4361..260f7140 100644
--- a/azalea-client/src/plugins/mining.rs
+++ b/azalea-client/src/plugins/mining.rs
@@ -8,6 +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 crate::{
Client, InstanceHolder,
@@ -148,7 +149,7 @@ fn handle_auto_mine(
/// Information about the block we're currently mining. This is only present if
/// we're currently mining a block.
-#[derive(Component)]
+#[derive(Component, Debug, Clone)]
pub struct Mining {
pub pos: BlockPos,
pub dir: Direction,
@@ -308,10 +309,12 @@ fn handle_mining_queued(
position: mining_queued.position,
});
} else {
- commands.entity(entity).insert(Mining {
+ let mining = Mining {
pos: mining_queued.position,
dir: mining_queued.direction,
- });
+ };
+ trace!("inserting mining component {mining:?} for entity {entity:?}");
+ commands.entity(entity).insert(mining);
**current_mining_pos = Some(mining_queued.position);
**current_mining_item = held_item;
**mine_progress = 0.;
@@ -332,6 +335,7 @@ fn handle_mining_queued(
sequence: sequence_number.get_and_increment(),
},
));
+ // vanilla really does send two swing arm packets
commands.trigger(SwingArmEvent { entity });
commands.trigger(SwingArmEvent { entity });
}
@@ -578,12 +582,12 @@ pub fn continue_mining_block(
current_mining_pos,
current_mining_item,
) {
- println!("continue mining block at {:?}", mining.pos);
+ trace!("continue mining block at {:?}", mining.pos);
let instance_lock = instances.get(instance_name).unwrap();
let instance = instance_lock.read();
let target_block_state = instance.get_block_state(&mining.pos).unwrap_or_default();
- println!("target_block_state: {target_block_state:?}");
+ trace!("target_block_state: {target_block_state:?}");
if target_block_state.is_air() {
commands.entity(entity).remove::<Mining>();
@@ -604,8 +608,10 @@ pub fn continue_mining_block(
**mine_ticks += 1.;
if **mine_progress >= 1. {
- commands.entity(entity).remove::<Mining>();
- println!("finished mining block at {:?}", mining.pos);
+ // MiningQueued is removed in case we were doing an infinite loop that
+ // repeatedly inserts MiningQueued
+ commands.entity(entity).remove::<(Mining, MiningQueued)>();
+ trace!("finished mining block at {:?}", mining.pos);
finish_mining_events.write(FinishMiningBlockEvent {
entity,
position: mining.pos,
@@ -631,7 +637,7 @@ pub fn continue_mining_block(
});
commands.trigger(SwingArmEvent { entity });
} else {
- println!("switching mining target to {:?}", mining.pos);
+ trace!("switching mining target to {:?}", mining.pos);
commands.entity(entity).insert(MiningQueued {
position: mining.pos,
direction: mining.dir,