diff --git a/azalea-client/src/plugins/interact.rs b/azalea-client/src/plugins/interact.rs index 95f7c17c..2e2b039f 100644 --- a/azalea-client/src/plugins/interact.rs +++ b/azalea-client/src/plugins/interact.rs @@ -343,7 +343,7 @@ pub fn pick_block( /// adventure mode check. pub fn check_is_interaction_restricted( instance: &Instance, - block_pos: &BlockPos, + block_pos: BlockPos, game_mode: &GameMode, inventory: &Inventory, ) -> bool { diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index 89e3d0e2..51bb5529 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -246,7 +246,7 @@ fn handle_mining_queued( let instance = instance_holder.instance.read(); if check_is_interaction_restricted( &instance, - &mining_queued.position, + mining_queued.position, &game_mode.current, inventory, ) { @@ -286,7 +286,7 @@ fn handle_mining_queued( } let target_block_state = instance - .get_block_state(&mining_queued.position) + .get_block_state(mining_queued.position) .unwrap_or_default(); // we can't break blocks if they don't have a bounding box @@ -450,7 +450,7 @@ pub fn handle_finish_mining_block_observer( query.get_mut(trigger.target()).unwrap(); let instance_lock = instances.get(instance_name).unwrap(); let instance = instance_lock.read(); - if check_is_interaction_restricted(&instance, &event.position, &game_mode.current, inventory) { + if check_is_interaction_restricted(&instance, event.position, &game_mode.current, inventory) { return; } @@ -465,7 +465,7 @@ pub fn handle_finish_mining_block_observer( } } - let Some(block_state) = instance.get_block_state(&event.position) else { + let Some(block_state) = instance.get_block_state(event.position) else { return; }; @@ -485,7 +485,7 @@ pub fn handle_finish_mining_block_observer( // when we break a waterlogged block we want to keep the water there let fluid_state = FluidState::from(block_state); let block_state_for_fluid = BlockState::from(fluid_state); - instance.set_block_state(&event.position, block_state_for_fluid); + instance.set_block_state(event.position, block_state_for_fluid); } /// Abort mining a block. @@ -595,7 +595,7 @@ pub fn continue_mining_block( 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(); + let target_block_state = instance.get_block_state(mining.pos).unwrap_or_default(); trace!("target_block_state: {target_block_state:?}"); diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 1307473d..a49a0209 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -1066,7 +1066,7 @@ impl GamePacketHandler<'_> { let world = local_player.instance.write(); - world.chunks.set_block_state(&p.pos, p.block_state); + world.chunks.set_block_state(p.pos, p.block_state); }); } @@ -1083,7 +1083,7 @@ impl GamePacketHandler<'_> { for state in &p.states { world .chunks - .set_block_state(&(p.section_pos + state.pos), state.state); + .set_block_state(p.section_pos + state.pos, state.state); } }); } diff --git a/azalea-core/src/aabb.rs b/azalea-core/src/aabb.rs index 42ae797d..03a754f0 100644 --- a/azalea-core/src/aabb.rs +++ b/azalea-core/src/aabb.rs @@ -211,7 +211,7 @@ impl AABB { boxes: &Vec, from: &Vec3, to: &Vec3, - pos: &BlockPos, + pos: BlockPos, ) -> Option { let mut t = 1.0; let mut dir = None; @@ -230,7 +230,7 @@ impl AABB { Some(BlockHitResult { location: from + &(delta * t), direction: dir, - block_pos: *pos, + block_pos: pos, inside: false, miss: false, world_border: false, @@ -500,7 +500,7 @@ mod tests { }], &Vec3::new(-1., -1., -1.), &Vec3::new(1., 1., 1.), - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), ), None ); diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index 7cb8b143..b1560577 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -589,6 +589,12 @@ impl From<&ChunkBiomePos> for ChunkSectionBiomePos { } } } +impl From for ChunkSectionBiomePos { + #[inline] + fn from(pos: ChunkBiomePos) -> Self { + Self::from(&pos) + } +} vec3_impl!(ChunkSectionBiomePos, u8); /// The coordinates of a biome inside a chunk. Biomes are 4x4 blocks. @@ -604,6 +610,12 @@ impl From<&BlockPos> for ChunkBiomePos { ChunkBiomePos::from(&ChunkBlockPos::from(pos)) } } +impl From for ChunkBiomePos { + #[inline] + fn from(pos: BlockPos) -> Self { + ChunkBiomePos::from(&ChunkBlockPos::from(pos)) + } +} impl From<&ChunkBlockPos> for ChunkBiomePos { #[inline] fn from(pos: &ChunkBlockPos) -> Self { diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 0f33e01e..7b971c27 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -106,10 +106,10 @@ pub fn on_pos(offset: f32, chunk_storage: &ChunkStorage, pos: &Position) -> Bloc // TODO: check if block below is a fence, wall, or fence gate let block_pos = pos.down(1); - let block_state = chunk_storage.get_block_state(&block_pos); + let block_state = chunk_storage.get_block_state(block_pos); if block_state == Some(BlockState::AIR) { let block_pos_below = block_pos.down(1); - let block_state_below = chunk_storage.get_block_state(&block_pos_below); + let block_state_below = chunk_storage.get_block_state(block_pos_below); if let Some(_block_state_below) = block_state_below { // if block_state_below.is_fence() // || block_state_below.is_wall() diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index 03afe7cd..e64f9823 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -103,7 +103,7 @@ pub fn update_fluid_on_eyes( let eye_block_pos = BlockPos::from(Vec3::new(position.x, adjusted_eye_y, position.z)); let fluid_at_eye = instance .read() - .get_fluid_state(&eye_block_pos) + .get_fluid_state(eye_block_pos) .unwrap_or_default(); let fluid_cutoff_y = (eye_block_pos.y as f32 + fluid_at_eye.height()) as f64; if fluid_cutoff_y > adjusted_eye_y { @@ -134,7 +134,7 @@ pub fn update_on_climbable( let instance = instance.read(); let block_pos = BlockPos::from(position); - let block_state_at_feet = instance.get_block_state(&block_pos).unwrap_or_default(); + let block_state_at_feet = instance.get_block_state(block_pos).unwrap_or_default(); let block_at_feet = Box::::from(block_state_at_feet); let registry_block_at_feet = block_at_feet.as_registry_block(); @@ -159,7 +159,7 @@ fn is_trapdoor_useable_as_ladder( // block below must be a ladder let block_below = instance - .get_block_state(&block_pos.down(1)) + .get_block_state(block_pos.down(1)) .unwrap_or_default(); let registry_block_below = Box::::from(block_below).as_registry_block(); @@ -255,7 +255,7 @@ mod tests { &mut chunks, ); partial_instance.chunks.set_block_state( - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), azalea_registry::Block::Stone.into(), &chunks, ); @@ -266,7 +266,7 @@ mod tests { }; partial_instance .chunks - .set_block_state(&BlockPos::new(0, 0, 0), ladder.into(), &chunks); + .set_block_state(BlockPos::new(0, 0, 0), ladder.into(), &chunks); let trapdoor = OakTrapdoor { facing: FacingCardinal::East, @@ -277,12 +277,12 @@ mod tests { }; partial_instance .chunks - .set_block_state(&BlockPos::new(0, 1, 0), trapdoor.into(), &chunks); + .set_block_state(BlockPos::new(0, 1, 0), trapdoor.into(), &chunks); let instance = Instance::from(chunks); let trapdoor_matches_ladder = is_trapdoor_useable_as_ladder( instance - .get_block_state(&BlockPos::new(0, 1, 0)) + .get_block_state(BlockPos::new(0, 1, 0)) .unwrap_or_default(), BlockPos::new(0, 1, 0), &instance, diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs index e7d203d8..2cef15c4 100644 --- a/azalea-physics/src/clip.rs +++ b/azalea-physics/src/clip.rs @@ -49,7 +49,7 @@ impl ClipContext { &self, fluid_state: FluidState, world: &ChunkStorage, - pos: &BlockPos, + pos: BlockPos, ) -> &VoxelShape { if self.fluid_pick_type.can_pick(&fluid_state) { crate::collision::fluid_shape(&fluid_state, world, pos) @@ -139,7 +139,7 @@ pub fn clip(chunk_storage: &ChunkStorage, context: ClipContext) -> BlockHitResul fn clip_with_interaction_override( from: &Vec3, to: &Vec3, - block_pos: &BlockPos, + block_pos: BlockPos, block_shape: &VoxelShape, _block_state: &BlockState, ) -> Option { @@ -168,7 +168,7 @@ pub fn traverse_blocks( from: Vec3, to: Vec3, context: C, - get_hit_result: impl Fn(&C, &BlockPos) -> Option, + get_hit_result: impl Fn(&C, BlockPos) -> Option, get_miss_result: impl Fn(&C) -> T, ) -> T { if from == to { @@ -188,7 +188,7 @@ pub fn traverse_blocks( }; let mut current_block = BlockPos::from(right_before_start); - if let Some(data) = get_hit_result(&context, ¤t_block) { + if let Some(data) = get_hit_result(&context, current_block) { return data; } @@ -249,7 +249,7 @@ pub fn traverse_blocks( percentage.z += percentage_step.z; } - if let Some(data) = get_hit_result(&context, ¤t_block) { + if let Some(data) = get_hit_result(&context, current_block) { return data; } } diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs index 2e46970d..ef994deb 100644 --- a/azalea-physics/src/collision/mod.rs +++ b/azalea-physics/src/collision/mod.rs @@ -322,13 +322,9 @@ fn collide_with_shapes( /// /// The instance and position are required so it can check if the block above is /// also the same fluid type. -pub fn fluid_shape( - fluid: &FluidState, - world: &ChunkStorage, - pos: &BlockPos, -) -> &'static VoxelShape { +pub fn fluid_shape(fluid: &FluidState, world: &ChunkStorage, pos: BlockPos) -> &'static VoxelShape { if fluid.amount == 9 { - let fluid_state_above = world.get_fluid_state(&pos.up(1)).unwrap_or_default(); + let fluid_state_above = world.get_fluid_state(pos.up(1)).unwrap_or_default(); if fluid_state_above.kind == fluid.kind { return &BLOCK_SHAPE; } diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs index 59671622..4d430ee7 100644 --- a/azalea-physics/src/collision/shape.rs +++ b/azalea-physics/src/collision/shape.rs @@ -408,7 +408,7 @@ impl VoxelShape { } } - pub fn clip(&self, from: &Vec3, to: &Vec3, block_pos: &BlockPos) -> Option { + pub fn clip(&self, from: &Vec3, to: &Vec3, block_pos: BlockPos) -> Option { if self.is_empty() { return None; } @@ -424,7 +424,7 @@ impl VoxelShape { self.find_index(Axis::Z, right_after_start.z - block_pos.z as f64), ) { Some(BlockHitResult { - block_pos: *block_pos, + block_pos, direction: Direction::nearest(vector).opposite(), location: right_after_start, inside: true, @@ -755,7 +755,7 @@ mod tests { .clip( &Vec3::new(-0.3, 0.5, 0.), &Vec3::new(5.3, 0.5, 0.), - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), ) .unwrap(); diff --git a/azalea-physics/src/fluids.rs b/azalea-physics/src/fluids.rs index c4716a27..5ea6194a 100644 --- a/azalea-physics/src/fluids.rs +++ b/azalea-physics/src/fluids.rs @@ -116,7 +116,7 @@ fn update_fluid_height_and_do_fluid_pushing( for cur_y in min_y..max_y { for cur_z in min_z..max_z { let cur_pos = BlockPos::new(cur_x, cur_y, cur_z); - let Some(fluid_at_cur_pos) = world.get_fluid_state(&cur_pos) else { + let Some(fluid_at_cur_pos) = world.get_fluid_state(cur_pos) else { continue; }; if fluid_at_cur_pos.kind != checking_fluid { @@ -192,7 +192,7 @@ pub fn get_fluid_flow(fluid: &FluidState, world: &Instance, pos: BlockPos) -> Ve let adjacent_block_pos = pos.offset_with_direction(direction); let adjacent_block_state = world - .get_block_state(&adjacent_block_pos) + .get_block_state(adjacent_block_pos) .unwrap_or_default(); let adjacent_fluid_state = FluidState::from(adjacent_block_state); @@ -206,7 +206,7 @@ pub fn get_fluid_flow(fluid: &FluidState, world: &Instance, pos: BlockPos) -> Ve if !legacy_blocks_motion(adjacent_block_state) { let block_pos_below_adjacent = adjacent_block_pos.down(1); let fluid_below_adjacent = world - .get_fluid_state(&block_pos_below_adjacent) + .get_fluid_state(block_pos_below_adjacent) .unwrap_or_default(); if fluid.affects_flow(&fluid_below_adjacent) { @@ -250,8 +250,8 @@ fn is_solid_face( adjacent_pos: BlockPos, direction: Direction, ) -> bool { - let block_state = world.get_block_state(&adjacent_pos).unwrap_or_default(); - let fluid_state = world.get_fluid_state(&adjacent_pos).unwrap_or_default(); + let block_state = world.get_block_state(adjacent_pos).unwrap_or_default(); + let fluid_state = world.get_fluid_state(adjacent_pos).unwrap_or_default(); if fluid_state.is_same_kind(fluid) { return false; } diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs index f384a90f..1f381174 100644 --- a/azalea-physics/src/lib.rs +++ b/azalea-physics/src/lib.rs @@ -8,7 +8,7 @@ pub mod travel; use std::collections::HashSet; -use azalea_block::{BlockTrait, BlockState, fluid_state::FluidState, properties}; +use azalea_block::{BlockState, BlockTrait, fluid_state::FluidState, properties}; use azalea_core::{ math, position::{BlockPos, Vec3}, @@ -197,7 +197,7 @@ fn check_inside_blocks( // return; // } - let traversed_block_state = world.get_block_state(&traversed_block).unwrap_or_default(); + let traversed_block_state = world.get_block_state(traversed_block).unwrap_or_default(); if traversed_block_state.is_air() { continue; } @@ -268,7 +268,7 @@ fn handle_entity_inside_block( #[allow(clippy::single_match)] match registry_block { azalea_registry::Block::BubbleColumn => { - let block_above = world.get_block_state(&block_pos.up(1)).unwrap_or_default(); + let block_above = world.get_block_state(block_pos.up(1)).unwrap_or_default(); let is_block_above_empty = block_above.is_collision_shape_empty() && FluidState::from(block_above).is_empty(); let drag_down = block @@ -417,7 +417,7 @@ fn handle_relative_friction_and_calculate_movement( if physics.horizontal_collision || **jumping { let block_at_feet: azalea_registry::Block = world .chunks - .get_block_state(&(*position).into()) + .get_block_state((*position).into()) .unwrap_or_default() .into(); @@ -454,7 +454,7 @@ fn handle_on_climbable( && azalea_registry::Block::from( world .chunks - .get_block_state(&position.into()) + .get_block_state(position.into()) .unwrap_or_default(), ) != azalea_registry::Block::Scaffolding { @@ -486,10 +486,10 @@ fn get_friction_influenced_speed( /// Returns the what the entity's jump should be multiplied by based on the /// block they're standing on. fn block_jump_factor(world: &Instance, position: &Position) -> f32 { - let block_at_pos = world.chunks.get_block_state(&position.into()); + let block_at_pos = world.chunks.get_block_state(position.into()); let block_below = world .chunks - .get_block_state(&get_block_pos_below_that_affects_movement(position)); + .get_block_state(get_block_pos_below_that_affects_movement(position)); let block_at_pos_jump_factor = if let Some(block) = block_at_pos { Box::::from(block).behavior().jump_factor diff --git a/azalea-physics/src/travel.rs b/azalea-physics/src/travel.rs index 741267c2..a442f629 100644 --- a/azalea-physics/src/travel.rs +++ b/azalea-physics/src/travel.rs @@ -1,4 +1,4 @@ -use azalea_block::{BlockTrait, BlockState, fluid_state::FluidState}; +use azalea_block::{BlockState, BlockTrait, fluid_state::FluidState}; use azalea_core::{ aabb::AABB, position::{BlockPos, Vec3}, @@ -122,7 +122,7 @@ fn travel_in_air( let block_state_below = world .chunks - .get_block_state(&block_pos_below) + .get_block_state(block_pos_below) .unwrap_or(BlockState::AIR); let block_below: Box = block_state_below.into(); let block_friction = block_below.behavior().friction; @@ -392,7 +392,7 @@ fn contains_any_liquid(world: &Instance, bounding_box: AABB) -> bool { for z in min.z..max.z { let block_state = world .chunks - .get_block_state(&BlockPos::new(x, y, z)) + .get_block_state(BlockPos::new(x, y, z)) .unwrap_or_default(); if !FluidState::from(block_state).is_empty() { return true; diff --git a/azalea-physics/tests/physics.rs b/azalea-physics/tests/physics.rs index ebe1cfad..8150e5b0 100644 --- a/azalea-physics/tests/physics.rs +++ b/azalea-physics/tests/physics.rs @@ -121,7 +121,7 @@ fn test_collision() { )) .id(); let block_state = partial_world.chunks.set_block_state( - &BlockPos { x: 0, y: 69, z: 0 }, + BlockPos { x: 0, y: 69, z: 0 }, azalea_registry::Block::Stone.into(), &world_lock.write().chunks, ); @@ -177,7 +177,7 @@ fn test_slab_collision() { )) .id(); let block_state = partial_world.chunks.set_block_state( - &BlockPos { x: 0, y: 69, z: 0 }, + BlockPos { x: 0, y: 69, z: 0 }, azalea_block::blocks::StoneSlab { kind: azalea_block::properties::Type::Bottom, waterlogged: false, @@ -227,7 +227,7 @@ fn test_top_slab_collision() { )) .id(); let block_state = world_lock.write().chunks.set_block_state( - &BlockPos { x: 0, y: 69, z: 0 }, + BlockPos { x: 0, y: 69, z: 0 }, azalea_block::blocks::StoneSlab { kind: azalea_block::properties::Type::Top, waterlogged: false, @@ -284,7 +284,7 @@ fn test_weird_wall_collision() { )) .id(); let block_state = world_lock.write().chunks.set_block_state( - &BlockPos { x: 0, y: 69, z: 0 }, + BlockPos { x: 0, y: 69, z: 0 }, azalea_block::blocks::CobblestoneWall { east: azalea_block::properties::WallEast::Low, north: azalea_block::properties::WallNorth::Low, @@ -346,7 +346,7 @@ fn test_negative_coordinates_weird_wall_collision() { )) .id(); let block_state = world_lock.write().chunks.set_block_state( - &BlockPos { + BlockPos { x: -8, y: 69, z: -8, @@ -440,7 +440,7 @@ fn test_afk_pool() { world_lock .write() .chunks - .set_block_state(&BlockPos { x, y, z }, b); + .set_block_state(BlockPos { x, y, z }, b); }; let stone = azalea_block::blocks::Stone {}.into(); diff --git a/azalea-world/src/chunk_storage.rs b/azalea-world/src/chunk_storage.rs index a6e33739..2efd002d 100644 --- a/azalea-world/src/chunk_storage.rs +++ b/azalea-world/src/chunk_storage.rs @@ -155,7 +155,7 @@ impl PartialChunkStorage { pub fn set_block_state( &self, - pos: &BlockPos, + pos: BlockPos, state: BlockState, chunk_storage: &ChunkStorage, ) -> Option { @@ -293,26 +293,26 @@ impl ChunkStorage { self.map.get(pos).and_then(|chunk| chunk.upgrade()) } - pub fn get_block_state(&self, pos: &BlockPos) -> Option { + pub fn get_block_state(&self, pos: BlockPos) -> Option { let chunk_pos = ChunkPos::from(pos); let chunk = self.get(&chunk_pos)?; let chunk = chunk.read(); chunk.get_block_state(&ChunkBlockPos::from(pos), self.min_y) } - pub fn get_fluid_state(&self, pos: &BlockPos) -> Option { + pub fn get_fluid_state(&self, pos: BlockPos) -> Option { let block_state = self.get_block_state(pos)?; Some(FluidState::from(block_state)) } - pub fn get_biome(&self, pos: &BlockPos) -> Option { + pub fn get_biome(&self, pos: BlockPos) -> Option { let chunk_pos = ChunkPos::from(pos); let chunk = self.get(&chunk_pos)?; let chunk = chunk.read(); - chunk.get_biome(&ChunkBiomePos::from(pos), self.min_y) + chunk.get_biome(ChunkBiomePos::from(pos), self.min_y) } - pub fn set_block_state(&self, pos: &BlockPos, state: BlockState) -> Option { + pub fn set_block_state(&self, pos: BlockPos, state: BlockState) -> Option { if pos.y < self.min_y || pos.y >= (self.min_y + self.height as i32) { return None; } @@ -404,7 +404,7 @@ impl Chunk { } } - pub fn get_biome(&self, pos: &ChunkBiomePos, min_y: i32) -> Option { + pub fn get_biome(&self, pos: ChunkBiomePos, min_y: i32) -> Option { if pos.y < min_y { // y position is out of bounds return None; @@ -580,27 +580,27 @@ mod tests { ); assert!( chunk_storage - .get_block_state(&BlockPos { x: 0, y: 319, z: 0 }) + .get_block_state(BlockPos { x: 0, y: 319, z: 0 }) .is_some() ); assert!( chunk_storage - .get_block_state(&BlockPos { x: 0, y: 320, z: 0 }) + .get_block_state(BlockPos { x: 0, y: 320, z: 0 }) .is_none() ); assert!( chunk_storage - .get_block_state(&BlockPos { x: 0, y: 338, z: 0 }) + .get_block_state(BlockPos { x: 0, y: 338, z: 0 }) .is_none() ); assert!( chunk_storage - .get_block_state(&BlockPos { x: 0, y: -64, z: 0 }) + .get_block_state(BlockPos { x: 0, y: -64, z: 0 }) .is_some() ); assert!( chunk_storage - .get_block_state(&BlockPos { x: 0, y: -65, z: 0 }) + .get_block_state(BlockPos { x: 0, y: -65, z: 0 }) .is_none() ); } diff --git a/azalea-world/src/find_blocks.rs b/azalea-world/src/find_blocks.rs index 10068243..4086358f 100644 --- a/azalea-world/src/find_blocks.rs +++ b/azalea-world/src/find_blocks.rs @@ -7,7 +7,7 @@ impl Instance { /// Find the coordinates of a block in the world. /// /// Note that this is sorted by `x+y+z` and not `x^2+y^2+z^2` for - /// optimization purposes. + /// performance purposes. /// /// ``` /// # fn example(client: &azalea_client::Client) { @@ -93,7 +93,7 @@ impl Instance { /// are in the given block states. /// /// Note that this is sorted by `x+y+z` and not `x^2+y^2+z^2` for - /// optimization purposes. + /// performance purposes. pub fn find_blocks<'a>( &'a self, nearest_to: impl Into, @@ -274,8 +274,8 @@ mod tests { chunk_storage, ); - chunk_storage.set_block_state(&BlockPos { x: 17, y: 0, z: 0 }, Block::Stone.into()); - chunk_storage.set_block_state(&BlockPos { x: 0, y: 18, z: 0 }, Block::Stone.into()); + chunk_storage.set_block_state(BlockPos { x: 17, y: 0, z: 0 }, Block::Stone.into()); + chunk_storage.set_block_state(BlockPos { x: 0, y: 18, z: 0 }, Block::Stone.into()); let pos = instance.find_block(BlockPos { x: 0, y: 0, z: 0 }, &Block::Stone.into()); assert_eq!(pos, Some(BlockPos { x: 17, y: 0, z: 0 })); @@ -301,8 +301,8 @@ mod tests { chunk_storage, ); - chunk_storage.set_block_state(&BlockPos { x: -1, y: 0, z: 0 }, Block::Stone.into()); - chunk_storage.set_block_state(&BlockPos { x: 15, y: 0, z: 0 }, Block::Stone.into()); + chunk_storage.set_block_state(BlockPos { x: -1, y: 0, z: 0 }, Block::Stone.into()); + chunk_storage.set_block_state(BlockPos { x: 15, y: 0, z: 0 }, Block::Stone.into()); let pos = instance.find_block(BlockPos { x: 0, y: 0, z: 0 }, &Block::Stone.into()); assert_eq!(pos, Some(BlockPos { x: -1, y: 0, z: 0 })); diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index 3e6359ff..89132a73 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -171,11 +171,11 @@ pub struct Instance { } impl Instance { - pub fn get_block_state(&self, pos: &BlockPos) -> Option { + pub fn get_block_state(&self, pos: BlockPos) -> Option { self.chunks.get_block_state(pos) } - pub fn get_fluid_state(&self, pos: &BlockPos) -> Option { + pub fn get_fluid_state(&self, pos: BlockPos) -> Option { self.chunks.get_block_state(pos).map(FluidState::from) } @@ -187,11 +187,11 @@ impl Instance { /// Note that biomes are internally stored as 4x4x4 blocks, so if you're /// writing code that searches for a specific biome it'll probably be more /// efficient to avoid scanning every single block. - pub fn get_biome(&self, pos: &BlockPos) -> Option { + pub fn get_biome(&self, pos: BlockPos) -> Option { self.chunks.get_biome(pos) } - pub fn set_block_state(&self, pos: &BlockPos, state: BlockState) -> Option { + pub fn set_block_state(&self, pos: BlockPos, state: BlockState) -> Option { self.chunks.set_block_state(pos, state) } } diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs index b97ad71d..ea5dbe6f 100644 --- a/azalea/examples/testbot/commands/debug.rs +++ b/azalea/examples/testbot/commands/debug.rs @@ -110,7 +110,7 @@ pub fn register(commands: &mut CommandDispatcher>) { }; let block_pos = hit_result.block_pos; - let block = source.bot.world().read().get_block_state(&block_pos); + let block = source.bot.world().read().get_block_state(block_pos); source.reply(&format!("I'm looking at {block:?} at {block_pos:?}")); @@ -125,7 +125,7 @@ pub fn register(commands: &mut CommandDispatcher>) { let z = get_integer(ctx, "z").unwrap(); println!("getblock xyz {x} {y} {z}"); let block_pos = BlockPos::new(x, y, z); - let block = source.bot.world().read().get_block_state(&block_pos); + let block = source.bot.world().read().get_block_state(block_pos); source.reply(&format!("Block at {block_pos} is {block:?}")); 1 })), @@ -138,7 +138,7 @@ pub fn register(commands: &mut CommandDispatcher>) { let z = get_integer(ctx, "z").unwrap(); println!("getfluid xyz {x} {y} {z}"); let block_pos = BlockPos::new(x, y, z); - let block = source.bot.world().read().get_fluid_state(&block_pos); + let block = source.bot.world().read().get_fluid_state(block_pos); source.reply(&format!("Fluid at {block_pos} is {block:?}")); 1 })), diff --git a/azalea/src/auto_tool.rs b/azalea/src/auto_tool.rs index 63561772..1f339c85 100644 --- a/azalea/src/auto_tool.rs +++ b/azalea/src/auto_tool.rs @@ -31,7 +31,7 @@ impl AutoToolClientExt for Client { let block_state = self .world() .read() - .get_block_state(&block_pos) + .get_block_state(block_pos) .unwrap_or_default(); let best_tool_result = self.best_tool_in_hotbar_for_block(block_state); self.set_selected_hotbar_slot(best_tool_result.index as u8); diff --git a/azalea/src/container.rs b/azalea/src/container.rs index f452b1be..ee618df2 100644 --- a/azalea/src/container.rs +++ b/azalea/src/container.rs @@ -84,7 +84,7 @@ impl ContainerClientExt for Client { if !self .world() .read() - .get_block_state(&pos) + .get_block_state(pos) .unwrap_or_default() .is_collision_shape_empty() { diff --git a/azalea/src/pathfinder/debug.rs b/azalea/src/pathfinder/debug.rs index b00e4272..6b319531 100644 --- a/azalea/src/pathfinder/debug.rs +++ b/azalea/src/pathfinder/debug.rs @@ -67,9 +67,9 @@ pub fn debug_render_path_with_particles( let step_count = (start_vec3.distance_squared_to(&end_vec3).sqrt() * 4.0) as usize; - let target_block_state = chunks.get_block_state(&movement.target).unwrap_or_default(); + let target_block_state = chunks.get_block_state(movement.target).unwrap_or_default(); let above_target_block_state = chunks - .get_block_state(&movement.target.up(1)) + .get_block_state(movement.target.up(1)) .unwrap_or_default(); // this isn't foolproof, there might be another block that could be mined // depending on the move, but it's good enough for debugging diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index c4586d29..c72573f5 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -1334,10 +1334,10 @@ mod tests { partial_chunks.set(&chunk_pos, Some(Chunk::default()), &mut chunks); } for block_pos in solid_blocks { - chunks.set_block_state(block_pos, azalea_registry::Block::Stone.into()); + chunks.set_block_state(*block_pos, azalea_registry::Block::Stone.into()); } for (block_pos, block_state) in extra_blocks { - chunks.set_block_state(block_pos, *block_state); + chunks.set_block_state(*block_pos, *block_state); } let player = SimulatedPlayerBundle::new(Vec3::new( diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index 44d31bfb..6d1c7c55 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -122,7 +122,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> { let block_state = self .instance .read() - .get_block_state(&block) + .get_block_state(block) .unwrap_or_default(); if is_block_state_passable(block_state) { // block is already passable, no need to mine it @@ -138,7 +138,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> { let block_state = self .instance .read() - .get_block_state(&block) + .get_block_state(block) .unwrap_or_default(); if is_block_state_passable(block_state) { // block is already passable, no need to mine it @@ -191,7 +191,7 @@ impl ExecuteCtx<'_, '_, '_, '_, '_, '_, '_> { pub fn get_block_state(&self, block: BlockPos) -> BlockState { self.instance .read() - .get_block_state(&block) + .get_block_state(block) .unwrap_or_default() } } diff --git a/azalea/src/pathfinder/world.rs b/azalea/src/pathfinder/world.rs index 3ec95136..e9337503 100644 --- a/azalea/src/pathfinder/world.rs +++ b/azalea/src/pathfinder/world.rs @@ -625,13 +625,13 @@ mod tests { .chunks .set(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default()), &mut world); partial_world.chunks.set_block_state( - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), azalea_registry::Block::Stone.into(), &world, ); partial_world .chunks - .set_block_state(&BlockPos::new(0, 1, 0), BlockState::AIR, &world); + .set_block_state(BlockPos::new(0, 1, 0), BlockState::AIR, &world); let ctx = CachedWorld::new(Arc::new(RwLock::new(world.into())), BlockPos::default()); assert!(!ctx.is_block_pos_passable(BlockPos::new(0, 0, 0))); @@ -646,13 +646,13 @@ mod tests { .chunks .set(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default()), &mut world); partial_world.chunks.set_block_state( - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), azalea_registry::Block::Stone.into(), &world, ); partial_world .chunks - .set_block_state(&BlockPos::new(0, 1, 0), BlockState::AIR, &world); + .set_block_state(BlockPos::new(0, 1, 0), BlockState::AIR, &world); let ctx = CachedWorld::new(Arc::new(RwLock::new(world.into())), BlockPos::default()); assert!(ctx.is_block_pos_solid(BlockPos::new(0, 0, 0))); @@ -667,19 +667,19 @@ mod tests { .chunks .set(&ChunkPos { x: 0, z: 0 }, Some(Chunk::default()), &mut world); partial_world.chunks.set_block_state( - &BlockPos::new(0, 0, 0), + BlockPos::new(0, 0, 0), azalea_registry::Block::Stone.into(), &world, ); partial_world .chunks - .set_block_state(&BlockPos::new(0, 1, 0), BlockState::AIR, &world); + .set_block_state(BlockPos::new(0, 1, 0), BlockState::AIR, &world); partial_world .chunks - .set_block_state(&BlockPos::new(0, 2, 0), BlockState::AIR, &world); + .set_block_state(BlockPos::new(0, 2, 0), BlockState::AIR, &world); partial_world .chunks - .set_block_state(&BlockPos::new(0, 3, 0), BlockState::AIR, &world); + .set_block_state(BlockPos::new(0, 3, 0), BlockState::AIR, &world); let ctx = CachedWorld::new(Arc::new(RwLock::new(world.into())), BlockPos::default()); assert!(ctx.is_standable_at_block_pos(BlockPos::new(0, 1, 0)));