aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-07 11:27:58 +0800
committermat <git@matdoes.dev>2025-05-07 11:27:58 +0800
commitaa0256da102103eedc9897458dd81516962a80a3 (patch)
tree9d01f879a7c75750acd8de0c308247c12bbeea9d
parente9452032bfc95cb7ad4a8798b13648e164536cf1 (diff)
downloadazalea-drasl-aa0256da102103eedc9897458dd81516962a80a3.tar.xz
upgrade rust version and fix clippy warnings
-rw-r--r--azalea-brigadier/src/command_dispatcher.rs2
-rw-r--r--azalea-client/src/local_player.rs6
-rw-r--r--azalea-client/src/plugins/auto_reconnect.rs4
-rw-r--r--azalea-client/src/plugins/mining.rs2
-rw-r--r--azalea-protocol/src/lib.rs2
-rw-r--r--azalea-protocol/src/packets/game/c_container_set_content.rs2
-rw-r--r--azalea-protocol/src/packets/game/c_server_links.rs2
-rw-r--r--azalea-protocol/src/packets/game/c_set_entity_data.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_set_player_team.rs2
-rw-r--r--azalea-protocol/src/packets/game/c_sound.rs2
-rw-r--r--azalea/examples/steal.rs9
-rw-r--r--azalea/examples/testbot/commands/debug.rs2
-rw-r--r--azalea/examples/testbot/commands/movement.rs2
-rw-r--r--azalea/examples/testbot/killaura.rs4
-rw-r--r--azalea/examples/testbot/main.rs2
-rw-r--r--azalea/src/auto_tool.rs10
-rw-r--r--azalea/src/pathfinder/mod.rs61
-rw-r--r--azalea/src/pathfinder/moves/basic.rs8
-rw-r--r--azalea/src/pathfinder/world.rs30
19 files changed, 78 insertions, 78 deletions
diff --git a/azalea-brigadier/src/command_dispatcher.rs b/azalea-brigadier/src/command_dispatcher.rs
index a5afe0da..4a3b51d7 100644
--- a/azalea-brigadier/src/command_dispatcher.rs
+++ b/azalea-brigadier/src/command_dispatcher.rs
@@ -467,7 +467,7 @@ impl<S> CommandDispatcher<S> {
Ordering::Equal => {
let usage = child_usage.into_iter().next().unwrap();
let usage = if child_optional {
- format!("[{}]", usage)
+ format!("[{usage}]")
} else {
usage
};
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index bf1609ab..26e08e9b 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -152,8 +152,10 @@ impl InstanceHolder {
pub fn reset(&mut self) {
let registries = self.instance.read().registries.clone();
- let mut new_instance = Instance::default();
- new_instance.registries = registries;
+ let new_instance = Instance {
+ registries,
+ ..Default::default()
+ };
self.instance = Arc::new(RwLock::new(new_instance));
self.partial_instance.write().reset();
diff --git a/azalea-client/src/plugins/auto_reconnect.rs b/azalea-client/src/plugins/auto_reconnect.rs
index 280aaa65..52c6e94b 100644
--- a/azalea-client/src/plugins/auto_reconnect.rs
+++ b/azalea-client/src/plugins/auto_reconnect.rs
@@ -72,10 +72,8 @@ fn get_delay(
) -> Option<Duration> {
if let Ok(c) = auto_reconnect_delay_query.get(entity) {
Some(c.delay)
- } else if let Some(r) = &auto_reconnect_delay_res {
- Some(r.delay)
} else {
- None
+ auto_reconnect_delay_res.as_ref().map(|r| r.delay)
}
}
diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs
index f2fb3361..7882ddc6 100644
--- a/azalea-client/src/plugins/mining.rs
+++ b/azalea-client/src/plugins/mining.rs
@@ -580,7 +580,7 @@ pub fn continue_mining_block(
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);
+ println!("target_block_state: {target_block_state:?}");
if target_block_state.is_air() {
commands.entity(entity).remove::<Mining>();
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs
index e0304979..7ac8756e 100644
--- a/azalea-protocol/src/lib.rs
+++ b/azalea-protocol/src/lib.rs
@@ -197,7 +197,7 @@ mod tests {
let buf = compression_encoder(&buf, compression_threshold).unwrap();
- println!("{:?}", buf);
+ println!("{buf:?}");
compression_decoder(&mut Cursor::new(&buf), compression_threshold).unwrap();
}
diff --git a/azalea-protocol/src/packets/game/c_container_set_content.rs b/azalea-protocol/src/packets/game/c_container_set_content.rs
index 77ea9ec7..0619eff1 100644
--- a/azalea-protocol/src/packets/game/c_container_set_content.rs
+++ b/azalea-protocol/src/packets/game/c_container_set_content.rs
@@ -29,7 +29,7 @@ mod tests {
];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundContainerSetContent::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
diff --git a/azalea-protocol/src/packets/game/c_server_links.rs b/azalea-protocol/src/packets/game/c_server_links.rs
index ac08ec27..e566b64e 100644
--- a/azalea-protocol/src/packets/game/c_server_links.rs
+++ b/azalea-protocol/src/packets/game/c_server_links.rs
@@ -28,7 +28,7 @@ mod tests {
];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundServerLinks::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
}
diff --git a/azalea-protocol/src/packets/game/c_set_entity_data.rs b/azalea-protocol/src/packets/game/c_set_entity_data.rs
index a7042417..2691d04b 100644
--- a/azalea-protocol/src/packets/game/c_set_entity_data.rs
+++ b/azalea-protocol/src/packets/game/c_set_entity_data.rs
@@ -23,7 +23,7 @@ mod tests {
let contents = [161, 226, 1, 10, 18, 1, 20, 38, 124, 175, 198, 255];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
@@ -44,7 +44,7 @@ mod tests {
];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
}
diff --git a/azalea-protocol/src/packets/game/c_set_player_team.rs b/azalea-protocol/src/packets/game/c_set_player_team.rs
index f73835f7..8c195154 100644
--- a/azalea-protocol/src/packets/game/c_set_player_team.rs
+++ b/azalea-protocol/src/packets/game/c_set_player_team.rs
@@ -63,7 +63,7 @@ mod tests {
];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundSetPlayerTeam::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
}
diff --git a/azalea-protocol/src/packets/game/c_sound.rs b/azalea-protocol/src/packets/game/c_sound.rs
index 1a54c7c8..bb037e97 100644
--- a/azalea-protocol/src/packets/game/c_sound.rs
+++ b/azalea-protocol/src/packets/game/c_sound.rs
@@ -47,7 +47,7 @@ mod tests {
];
let mut buf = Cursor::new(contents.as_slice());
let packet = ClientboundSound::azalea_read(&mut buf).unwrap();
- println!("{:?}", packet);
+ println!("{packet:?}");
assert_eq!(buf.position(), contents.len() as u64);
diff --git a/azalea/examples/steal.rs b/azalea/examples/steal.rs
index 3fa87cc4..028c1b5a 100644
--- a/azalea/examples/steal.rs
+++ b/azalea/examples/steal.rs
@@ -58,11 +58,10 @@ async fn steal(bot: Client, state: State) -> anyhow::Result<()> {
.world()
.read()
.find_blocks(bot.position(), &azalea::registry::Block::Chest.into())
- .filter(
- // filter for chests that haven't been checked
- |block_pos| !state.checked_chests.lock().contains(&block_pos),
- )
- .next();
+ .find(
+ // find the closest chest that hasn't been checked
+ |block_pos| !state.checked_chests.lock().contains(block_pos),
+ );
let Some(chest_block) = chest_block else {
break;
};
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index 3428d117..31b0ff91 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -226,7 +226,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
let instance_container = ecs.resource::<InstanceContainer>();
for (instance_name, instance) in &instance_container.instances {
- writeln!(report, "- Name: {}", instance_name).unwrap();
+ writeln!(report, "- Name: {instance_name}").unwrap();
writeln!(report, "- Reference count: {}", instance.strong_count())
.unwrap();
if let Some(instance) = instance.upgrade() {
diff --git a/azalea/examples/testbot/commands/movement.rs b/azalea/examples/testbot/commands/movement.rs
index 1596ce89..36ff42ff 100644
--- a/azalea/examples/testbot/commands/movement.rs
+++ b/azalea/examples/testbot/commands/movement.rs
@@ -116,7 +116,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
get_integer(ctx, "y").unwrap(),
get_integer(ctx, "z").unwrap(),
);
- println!("{:?}", pos);
+ println!("{pos:?}");
let source = ctx.source.lock();
source.bot.look_at(pos.center());
1
diff --git a/azalea/examples/testbot/killaura.rs b/azalea/examples/testbot/killaura.rs
index b47ac0df..5458ea4e 100644
--- a/azalea/examples/testbot/killaura.rs
+++ b/azalea/examples/testbot/killaura.rs
@@ -39,8 +39,8 @@ pub fn tick(bot: Client, state: State) -> anyhow::Result<()> {
}
}
if let Some(nearest_entity) = nearest_entity {
- println!("attacking {:?}", nearest_entity);
- println!("distance {:?}", nearest_distance);
+ println!("attacking {nearest_entity:?}");
+ println!("distance {nearest_distance:?}");
bot.attack(nearest_entity);
}
diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs
index 6733d797..487cea1e 100644
--- a/azalea/examples/testbot/main.rs
+++ b/azalea/examples/testbot/main.rs
@@ -241,7 +241,7 @@ fn parse_args() -> Args {
pathfinder_debug_particles = true;
}
_ => {
- eprintln!("Unknown argument: {}", arg);
+ eprintln!("Unknown argument: {arg}");
process::exit(1);
}
}
diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs
index 81fe3131..ace032d9 100644
--- a/azalea/src/auto_tool.rs
+++ b/azalea/src/auto_tool.rs
@@ -95,11 +95,11 @@ pub fn accurate_best_tool_in_hotbar_for_block(
}
}
}
- if let Some(this_item_speed) = this_item_speed {
- if this_item_speed > best_speed {
- best_slot = Some(i);
- best_speed = this_item_speed;
- }
+ if let Some(this_item_speed) = this_item_speed
+ && this_item_speed > best_speed
+ {
+ best_slot = Some(i);
+ best_speed = this_item_speed;
}
}
diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs
index aba8610a..820d6f8b 100644
--- a/azalea/src/pathfinder/mod.rs
+++ b/azalea/src/pathfinder/mod.rs
@@ -715,12 +715,12 @@ pub fn check_node_reached(
direction: WalkDirection::None,
});
commands.entity(entity).remove::<ExecutingPath>();
- if let Some(goal) = pathfinder.goal.clone() {
- if goal.success(movement.target) {
- info!("goal was reached!");
- pathfinder.goal = None;
- pathfinder.successors_fn = None;
- }
+ if let Some(goal) = pathfinder.goal.clone()
+ && goal.success(movement.target)
+ {
+ info!("goal was reached!");
+ pathfinder.goal = None;
+ pathfinder.successors_fn = None;
}
}
@@ -875,17 +875,17 @@ fn patch_path(
let mut is_patch_complete = false;
if let Some(path_found_event) = path_found_event {
- if let Some(found_path_patch) = path_found_event.path {
- if !found_path_patch.is_empty() {
- new_path.extend(found_path_patch);
-
- if !path_found_event.is_partial {
- new_path.extend(executing_path.path.iter().skip(*patch_nodes.end()).cloned());
- is_patch_complete = true;
- debug!("the patch is not partial :)");
- } else {
- debug!("the patch is partial, throwing away rest of path :(");
- }
+ if let Some(found_path_patch) = path_found_event.path
+ && !found_path_patch.is_empty()
+ {
+ new_path.extend(found_path_patch);
+
+ if !path_found_event.is_partial {
+ new_path.extend(executing_path.path.iter().skip(*patch_nodes.end()).cloned());
+ is_patch_complete = true;
+ debug!("the patch is not partial :)");
+ } else {
+ debug!("the patch is partial, throwing away rest of path :(");
}
}
} else {
@@ -1028,19 +1028,20 @@ pub fn recalculate_if_has_goal_but_no_path(
mut goto_events: EventWriter<GotoEvent>,
) {
for (entity, mut pathfinder) in &mut query {
- if pathfinder.goal.is_some() && !pathfinder.is_calculating {
- if let Some(goal) = pathfinder.goal.as_ref().cloned() {
- debug!("Recalculating path because it has a goal but no ExecutingPath");
- goto_events.write(GotoEvent {
- entity,
- goal,
- successors_fn: pathfinder.successors_fn.unwrap(),
- allow_mining: pathfinder.allow_mining,
- min_timeout: pathfinder.min_timeout.expect("min_timeout should be set"),
- max_timeout: pathfinder.max_timeout.expect("max_timeout should be set"),
- });
- pathfinder.is_calculating = true;
- }
+ if pathfinder.goal.is_some()
+ && !pathfinder.is_calculating
+ && let Some(goal) = pathfinder.goal.as_ref().cloned()
+ {
+ debug!("Recalculating path because it has a goal but no ExecutingPath");
+ goto_events.write(GotoEvent {
+ entity,
+ goal,
+ successors_fn: pathfinder.successors_fn.unwrap(),
+ allow_mining: pathfinder.allow_mining,
+ min_timeout: pathfinder.min_timeout.expect("min_timeout should be set"),
+ max_timeout: pathfinder.max_timeout.expect("max_timeout should be set"),
+ });
+ pathfinder.is_calculating = true;
}
}
}
diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs
index 354472a7..fe0d81f5 100644
--- a/azalea/src/pathfinder/moves/basic.rs
+++ b/azalea/src/pathfinder/moves/basic.rs
@@ -173,10 +173,10 @@ fn execute_ascend_move(mut ctx: ExecuteCtx) {
(-1, 0) => Some(properties::FacingCardinal::West),
_ => None,
};
- if let Some(expected_stair_facing) = expected_stair_facing {
- if stair_facing == expected_stair_facing {
- return;
- }
+ if let Some(expected_stair_facing) = expected_stair_facing
+ && stair_facing == expected_stair_facing
+ {
+ return;
}
}
diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs
index 3b1b36b9..940a7c84 100644
--- a/azalea/src/pathfinder/world.rs
+++ b/azalea/src/pathfinder/world.rs
@@ -47,10 +47,10 @@ impl CachedSections {
if let Some(last_item) = self.sections.get(self.last_index) {
if last_item.pos == pos {
return Some(&mut self.sections[self.last_index]);
- } else if let Some(second_last_item) = self.sections.get(self.second_last_index) {
- if second_last_item.pos == pos {
- return Some(&mut self.sections[self.second_last_index]);
- }
+ } else if let Some(second_last_item) = self.sections.get(self.second_last_index)
+ && second_last_item.pos == pos
+ {
+ return Some(&mut self.sections[self.second_last_index]);
}
}
@@ -134,17 +134,17 @@ impl CachedWorld {
// optimization: avoid doing the iter lookup if the last chunk we looked up is
// the same
- if let Some(last_chunk_cache_index) = *self.last_chunk_cache_index.borrow() {
- if cached_chunks[last_chunk_cache_index].0 == chunk_pos {
- // don't bother with the iter lookup
- let sections = &cached_chunks[last_chunk_cache_index].1;
- if section_index >= sections.len() {
- // y position is out of bounds
- return None;
- };
- let section: &azalea_world::palette::PalettedContainer = &sections[section_index];
- return Some(f(section));
- }
+ if let Some(last_chunk_cache_index) = *self.last_chunk_cache_index.borrow()
+ && cached_chunks[last_chunk_cache_index].0 == chunk_pos
+ {
+ // don't bother with the iter lookup
+ let sections = &cached_chunks[last_chunk_cache_index].1;
+ if section_index >= sections.len() {
+ // y position is out of bounds
+ return None;
+ };
+ let section: &azalea_world::palette::PalettedContainer = &sections[section_index];
+ return Some(f(section));
}
// get section from cache