aboutsummaryrefslogtreecommitdiff
path: root/azalea-world/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-06-11 16:55:33 +1100
committermat <git@matdoes.dev>2025-06-11 16:55:33 +1100
commit9b0bd29db4faa9d94df0cec472346b814e7efcb9 (patch)
tree4f681b5143eb5ebe69a0b5b53125ea7509f8026a /azalea-world/src
parent2a6ac0764fe9975f9b16d495ce773e4ae1f097e0 (diff)
downloadazalea-drasl-9b0bd29db4faa9d94df0cec472346b814e7efcb9.tar.xz
take BlockPos instead of &BlockPos in all function arguments
Diffstat (limited to 'azalea-world/src')
-rw-r--r--azalea-world/src/chunk_storage.rs24
-rw-r--r--azalea-world/src/find_blocks.rs12
-rw-r--r--azalea-world/src/world.rs8
3 files changed, 22 insertions, 22 deletions
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<BlockState> {
@@ -293,26 +293,26 @@ impl ChunkStorage {
self.map.get(pos).and_then(|chunk| chunk.upgrade())
}
- pub fn get_block_state(&self, pos: &BlockPos) -> Option<BlockState> {
+ pub fn get_block_state(&self, pos: BlockPos) -> Option<BlockState> {
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<FluidState> {
+ pub fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState> {
let block_state = self.get_block_state(pos)?;
Some(FluidState::from(block_state))
}
- pub fn get_biome(&self, pos: &BlockPos) -> Option<Biome> {
+ pub fn get_biome(&self, pos: BlockPos) -> Option<Biome> {
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<BlockState> {
+ pub fn set_block_state(&self, pos: BlockPos, state: BlockState) -> Option<BlockState> {
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<Biome> {
+ pub fn get_biome(&self, pos: ChunkBiomePos, min_y: i32) -> Option<Biome> {
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<BlockPos>,
@@ -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<BlockState> {
+ pub fn get_block_state(&self, pos: BlockPos) -> Option<BlockState> {
self.chunks.get_block_state(pos)
}
- pub fn get_fluid_state(&self, pos: &BlockPos) -> Option<FluidState> {
+ pub fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState> {
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<Biome> {
+ pub fn get_biome(&self, pos: BlockPos) -> Option<Biome> {
self.chunks.get_biome(pos)
}
- pub fn set_block_state(&self, pos: &BlockPos, state: BlockState) -> Option<BlockState> {
+ pub fn set_block_state(&self, pos: BlockPos, state: BlockState) -> Option<BlockState> {
self.chunks.set_block_state(pos, state)
}
}