diff --git a/CHANGELOG.md b/CHANGELOG.md index 734b6c53a7..c5458fa2ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved hammer leap attack to skillbar - Reworked fire staff - Overhauled cloud shaders to add mist, light attenuation, an approximation of rayleigh scattering, etc. +- Fixed a bug where a nearby item would also be collected when collecting collectible blocks +- Allowed collecting nearby blocks without aiming at them +- Made voxygen wait until singleplayer server is initialized before attempting to connect, removing the chance for it to give up on connecting if the server takes a while to start +- Log where userdata folder is located ### Removed diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 1f6c8b72a5..3711dbb952 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -66,7 +66,7 @@ hashbrown = {version = "0.7.2", features = ["rayon", "serde", "nightly"]} image = {version = "0.23.8", default-features = false, features = ["ico", "png"]} native-dialog = { version = "0.4.2", default-features = false, optional = true } num = "0.2" -ordered-float = "2.0.0" +ordered-float = { version = "2.0.0", default-features = false } rand = "0.7" rodio = {version = "0.11", default-features = false, features = ["wav", "vorbis"]} ron = {version = "0.6", default-features = false} diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 60afcb961c..f99d8890c4 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -15,9 +15,7 @@ use client::{self, Client}; use common::{ assets::Asset, comp, - comp::{ - ChatMsg, ChatType, InventoryUpdateEvent, Pos, Vel, - }, + comp::{ChatMsg, ChatType, InventoryUpdateEvent, Pos, Vel}, consts::{MAX_MOUNT_RANGE, MAX_PICKUP_RANGE}, event::EventBus, outcome::Outcome, @@ -274,18 +272,24 @@ impl PlayState for SessionState { .get(self.client.borrow().entity()) .is_some(); - let interactable = select_interactable(&self.client.borrow(), self.target_entity, select_pos, &self.scene); + let interactable = select_interactable( + &self.client.borrow(), + self.target_entity, + select_pos, + &self.scene, + ); // Only highlight interactables // unless in build mode where select_pos highlighted - self.scene.set_select_pos( - select_pos - .filter(|_| can_build) - .or_else(|| match interactable { - Some(Interactable::Block(_, block_pos)) => Some(block_pos), - _ => None, - }) - ); + self.scene + .set_select_pos( + select_pos + .filter(|_| can_build) + .or_else(|| match interactable { + Some(Interactable::Block(_, block_pos)) => Some(block_pos), + _ => None, + }), + ); // Handle window events. for event in events { @@ -467,10 +471,13 @@ impl PlayState for SessionState { &client.state().ecs().read_storage::(), ) .join() - .filter(|(entity, _, mount_state)| *entity != client.entity() - && **mount_state == comp::MountState::Unmounted - ) - .map(|(entity, pos, _)| (entity, player_pos.0.distance_squared(pos.0))) + .filter(|(entity, _, mount_state)| { + *entity != client.entity() + && **mount_state == comp::MountState::Unmounted + }) + .map(|(entity, pos, _)| { + (entity, player_pos.0.distance_squared(pos.0)) + }) .filter(|(_, dist_sqr)| *dist_sqr < MAX_MOUNT_RANGE.powi(2)) .min_by_key(|(_, dist_sqr)| OrderedFloat(*dist_sqr)); if let Some((mountee_entity, _)) = closest_mountable_entity { @@ -488,17 +495,21 @@ impl PlayState for SessionState { if let Some(interactable) = interactable { let mut client = self.client.borrow_mut(); match interactable { - Interactable::Block(block, pos) => if block.is_collectible() { - client.collect_block(pos); + Interactable::Block(block, pos) => { + if block.is_collectible() { + client.collect_block(pos); + } }, - Interactable::Entity(entity) => if client - .state() - .ecs() - .read_storage::() - .get(entity) - .is_some() - { - client.pick_up(entity); + Interactable::Entity(entity) => { + if client + .state() + .ecs() + .read_storage::() + .get(entity) + .is_some() + { + client.pick_up(entity); + } }, } } @@ -1242,13 +1253,9 @@ fn select_interactable( scene: &Scene, ) -> Option { span!(_guard, "select_interactable"); - use common::{ - spiral::Spiral2d, - terrain::TerrainChunk, - vol::RectRasterableVol, - }; + use common::{spiral::Spiral2d, terrain::TerrainChunk, vol::RectRasterableVol}; target_entity.map(Interactable::Entity) - .or_else(|| selected_pos.and_then(|sp| + .or_else(|| selected_pos.and_then(|sp| client.state().terrain().get(sp).ok().copied() .filter(Block::is_collectible).map(|b| Interactable::Block(b, sp)) )) @@ -1300,7 +1307,7 @@ fn select_interactable( .take(((search_dist / TerrainChunk::RECT_SIZE.x as f32).ceil() as usize * 2 + 1).pow(2)) .flat_map(|offset| { let chunk_pos = player_chunk + offset; - let chunk_voxel_pos = + let chunk_voxel_pos = Vec3::::from(chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32)); terrain.get(chunk_pos).map(|data| (data, chunk_voxel_pos)) }) @@ -1311,7 +1318,7 @@ fn select_interactable( .blocks_of_interest .interactables .iter() - .map(move |block_offset| chunk_pos + block_offset) + .map(move |block_offset| chunk_pos + block_offset) }) // TODO: confirm that adding 0.5 here is correct .map(|block_pos| (