diff options
| author | mat <git@matdoes.dev> | 2025-06-11 22:58:41 -0630 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-11 22:58:41 -0630 |
| commit | a2606569bb79867d07a075bcf7b05730e4264d72 (patch) | |
| tree | fb97fb52aa0c4d7575f6bd5e4e36c2f01c87f942 /azalea/src | |
| parent | 89ddd5e85f4f2fb98697df15528df6e07a3ddd07 (diff) | |
| download | azalea-drasl-a2606569bb79867d07a075bcf7b05730e4264d72.tar.xz | |
use owned instead of borrowed Vec3 more
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/bot.rs | 4 | ||||
| -rw-r--r-- | azalea/src/nearest_entity.rs | 10 | ||||
| -rw-r--r-- | azalea/src/pathfinder/debug.rs | 2 | ||||
| -rw-r--r-- | azalea/src/pathfinder/goals.rs | 10 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs index 9e8566bf..745f3fdb 100644 --- a/azalea/src/bot.rs +++ b/azalea/src/bot.rs @@ -229,7 +229,7 @@ fn look_at_listener( for event in events.read() { if let Ok((position, eye_height, mut look_direction)) = query.get_mut(event.entity) { let new_look_direction = - direction_looking_at(&position.up(eye_height.into()), &event.position); + direction_looking_at(position.up(eye_height.into()), event.position); trace!("look at {} (currently at {})", event.position, **position); *look_direction = new_look_direction; } @@ -238,7 +238,7 @@ fn look_at_listener( /// Return the look direction that would make a client at `current` be /// looking at `target`. -pub fn direction_looking_at(current: &Vec3, target: &Vec3) -> LookDirection { +pub fn direction_looking_at(current: Vec3, target: Vec3) -> LookDirection { // borrowed from mineflayer's Bot.lookAt because i didn't want to do math let delta = target - current; let y_rot = (PI - f64::atan2(-delta.x, -delta.z)) * (180.0 / PI); diff --git a/azalea/src/nearest_entity.rs b/azalea/src/nearest_entity.rs index 7ac4fff0..df54273a 100644 --- a/azalea/src/nearest_entity.rs +++ b/azalea/src/nearest_entity.rs @@ -69,7 +69,7 @@ where /// multiple entities are within range, only the closest one is returned. pub fn nearest_to_position( &'a self, - position: &Position, + position: Position, instance_name: &InstanceName, max_distance: f64, ) -> Option<Entity> { @@ -81,7 +81,7 @@ where continue; } - let target_distance = position.distance_to(e_pos); + let target_distance = position.distance_to(**e_pos); if target_distance < min_distance { nearest_entity = Some(target_entity); min_distance = target_distance; @@ -111,7 +111,7 @@ where continue; } - let target_distance = position.distance_to(e_pos); + let target_distance = position.distance_to(**e_pos); if target_distance < min_distance { nearest_entity = Some(target_entity); min_distance = target_distance; @@ -140,7 +140,7 @@ where return None; } - let distance = position.distance_to(e_pos); + let distance = position.distance_to(**e_pos); if distance < max_distance { Some((target_entity, distance)) } else { @@ -181,7 +181,7 @@ where return None; } - let distance = position.distance_to(e_pos); + let distance = position.distance_to(**e_pos); if distance < max_distance { Some((target_entity, distance)) } else { diff --git a/azalea/src/pathfinder/debug.rs b/azalea/src/pathfinder/debug.rs index 6b319531..d0d264d3 100644 --- a/azalea/src/pathfinder/debug.rs +++ b/azalea/src/pathfinder/debug.rs @@ -65,7 +65,7 @@ pub fn debug_render_path_with_particles( let start_vec3 = start.center(); let end_vec3 = end.center(); - let step_count = (start_vec3.distance_squared_to(&end_vec3).sqrt() * 4.0) as usize; + let step_count = (start_vec3.distance_to(end_vec3) * 4.0) as usize; let target_block_state = chunks.get_block_state(movement.target).unwrap_or_default(); let above_target_block_state = chunks diff --git a/azalea/src/pathfinder/goals.rs b/azalea/src/pathfinder/goals.rs index c19bf504..95786561 100644 --- a/azalea/src/pathfinder/goals.rs +++ b/azalea/src/pathfinder/goals.rs @@ -230,16 +230,16 @@ impl Goal for ReachBlockPosGoal { } // only do the expensive check if we're close enough - let distance = self.pos.distance_squared_to(&n); - if distance > self.max_check_distance.pow(2) { + let distance_squared = self.pos.distance_squared_to(n); + if distance_squared > self.max_check_distance.pow(2) { return false; } let eye_position = n.center_bottom().up(1.62); - let look_direction = crate::direction_looking_at(&eye_position, &self.pos.center()); + let look_direction = crate::direction_looking_at(eye_position, self.pos.center()); let block_hit_result = azalea_client::interact::pick_block( - &look_direction, - &eye_position, + look_direction, + eye_position, &self.chunk_storage, self.distance, ); diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index e75c99c4..9786e1de 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -641,7 +641,7 @@ pub fn timeout_movement( // don't timeout if we're mining if let Some(mining) = mining { // also make sure we're close enough to the block that's being mined - if mining.pos.distance_squared_to(&BlockPos::from(position)) < 6_i32.pow(2) { + if mining.pos.distance_squared_to(position.into()) < 6_i32.pow(2) { // also reset the last_node_reached_at so we don't timeout after we finish // mining executing_path.last_node_reached_at = Instant::now(); |
