Skip to content

Commit a6f4f73

Browse files
Refactor
1 parent 2adab7f commit a6f4f73

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/client/terrain/util/chunk.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ impl Chunk {
2020
}
2121

2222
pub fn get(&self, x: usize, y: usize, z: usize) -> BlockId {
23+
self.get_unpadded(x + 1, y + 1, z + 1)
24+
}
25+
26+
27+
pub fn get_unpadded(&self, x: usize, y: usize, z: usize) -> BlockId {
2328
self.data[Self::index(x, y, z)]
2429
}
2530

2631
pub fn set(&mut self, x: usize, y: usize, z: usize, value: BlockId) {
32+
self.set_unpadded(x + 1, y + 1, z + 1, value);
33+
}
34+
35+
pub fn set_unpadded(&mut self, x: usize, y: usize, z: usize, value: BlockId) {
2736
self.data[Self::index(x, y, z)] = value;
2837
}
2938

39+
3040
#[rustfmt::skip]
3141
pub fn index(x: usize, y: usize, z: usize) -> usize {
3242
if (x >= PADDED_CHUNK_SIZE as usize) || (y >= PADDED_CHUNK_SIZE as usize) || (z >= PADDED_CHUNK_SIZE as usize) {

src/client/terrain/util/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Generator {
2525
let local_position = Vec3::new(x as f32, y as f32, z as f32);
2626
let block_position = chunk_origin + local_position;
2727
let block = self.generate_block(block_position);
28-
chunk.set(x as usize, y as usize, z as usize, block);
28+
chunk.set_unpadded(x as usize, y as usize, z as usize, block);
2929
}
3030
}
3131
}

0 commit comments

Comments
 (0)