diff --git a/CHANGELOG.md b/CHANGELOG.md index ee926c7103..de1a7c7400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Animation and terrain math were switched to use SIMD where possible, improving performance. - The way we cache glyphs was refactored, fixed, and optimized. - Colors for models and figures were adjusted to account for the saturation hack. +- Fixed a bug where the closest item would be picked up instead of a selected item ### Removed diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index a12398c265..c01bce33d0 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -496,19 +496,22 @@ impl PlayState for SessionState { .copied(); if let Some(player_pos) = player_pos { - let entity = ( - &client.state().ecs().entities(), - &client.state().ecs().read_storage::(), - &client.state().ecs().read_storage::(), - ) - .join() - .filter(|(_, pos, _)| { - pos.0.distance_squared(player_pos.0) < MAX_PICKUP_RANGE_SQR - }) - .min_by_key(|(_, pos, _)| { - (pos.0.distance_squared(player_pos.0) * 1000.0) as i32 - }) - .map(|(entity, _, _)| entity); + let entity = self.target_entity.or_else(|| { + ( + &client.state().ecs().entities(), + &client.state().ecs().read_storage::(), + &client.state().ecs().read_storage::(), + ) + .join() + .filter(|(_, pos, _)| { + pos.0.distance_squared(player_pos.0) + < MAX_PICKUP_RANGE_SQR + }) + .min_by_key(|(_, pos, _)| { + (pos.0.distance_squared(player_pos.0) * 1000.0) as i32 + }) + .map(|(entity, _, _)| entity) + }); if let Some(entity) = entity { client.pick_up(entity);