fix: snap-to-top for above-world spawn, guard rabbit dig at world floor
- Entities spawn at z=35*TILE=560 but Z_ABOVE max is 15*TILE=240. Snap to Z_ABOVE*TILE instead of falling one tile per tick through unloaded space. - Skip rabbit dig when below_pos would be outside ChunkData z-bounds, preventing remove_floor assert panic.
This commit is contained in:
@@ -126,6 +126,11 @@ pub fn rabbit_dig_system(
|
||||
let entity_pos = transform.translation.as_ivec3();
|
||||
let below_pos = IVec3::new(entity_pos.x, entity_pos.y, entity_pos.z - ITILE_SIZE);
|
||||
|
||||
// Don't dig below world floor — would panic in remove_floor bounds check.
|
||||
if below_pos.z < -(crate::world::chunks::Z_BELOW as i32 - 1) * ITILE_SIZE {
|
||||
continue;
|
||||
}
|
||||
|
||||
if tilemap.remove_floor(&below_pos).is_some() {
|
||||
tile_changed.write(TileChangedEvent { pos: below_pos });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user