Skip to content

Commit 57f5652

Browse files
authored
fix(blocks): return void air above height limit (#830)
Without this, the code would panic. This can be triggered by shooting an arrow directly up.
1 parent 5e4648a commit 57f5652

File tree

1 file changed

+5
-0
lines changed
  • crates/hyperion/src/simulation/blocks

1 file changed

+5
-0
lines changed

crates/hyperion/src/simulation/blocks/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ impl Blocks {
379379
let y = u32::try_from(position.y - START_Y).unwrap();
380380
let z = u32::try_from(position.z - chunk_start_block[1]).unwrap();
381381

382+
if y >= chunk.height() {
383+
// This block is above the chunk maximum height
384+
return Some(BlockState::VOID_AIR);
385+
}
386+
382387
Some(chunk.block_state(x, y, z))
383388
}
384389

0 commit comments

Comments
 (0)