From 6b5f60f08bfceb2d5efc8977f823594388a6256b Mon Sep 17 00:00:00 2001 From: TestingPlant <44930139+TestingPlant@users.noreply.github.com> Date: Wed, 22 Jan 2025 01:55:52 +0000 Subject: [PATCH] fix(blocks): return void air above height limit Without this, the code would panic. This can be triggered by shooting an arrow directly up. --- crates/hyperion/src/simulation/blocks/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/hyperion/src/simulation/blocks/mod.rs b/crates/hyperion/src/simulation/blocks/mod.rs index 66c62dee..d0922673 100644 --- a/crates/hyperion/src/simulation/blocks/mod.rs +++ b/crates/hyperion/src/simulation/blocks/mod.rs @@ -379,6 +379,11 @@ impl Blocks { let y = u32::try_from(position.y - START_Y).unwrap(); let z = u32::try_from(position.z - chunk_start_block[1]).unwrap(); + if y >= chunk.height() { + // This block is above the chunk maximum height + return Some(BlockState::VOID_AIR); + } + Some(chunk.block_state(x, y, z)) }