ghast-world 0.5.3

Chunk storage for the ghast Minecraft Java Edition client library: compact, O(1) block lookup, explicit loaded/unloaded columns, decoding of 1.8.9, 1.12.2, 1.16.5, 26.1, 26.2 and 26.3 chunk and block-change packets
Documentation
//! The `ghast-physics` world traits for the modern [`World`](super::World) and
//! [`View`](super::View) (feature `physics`).

use super::{BlockState, View, World, void_air};

/// The border collision reads (`WorldBorder.getMinX()` etc.: a moving border at its size
/// before the last tick).
fn border(w: &World) -> ghast_physics::WorldBorder {
    w.collision_border.collision_border()
}

impl ghast_physics::BlockView for World {
    type State = BlockState;

    /// Vanilla semantics: unloaded columns (the client's empty chunk) and positions outside
    /// the build height read as `void_air`.
    #[inline(always)]
    fn block(&self, x: i32, y: i32, z: i32) -> BlockState {
        self.block_state(x, y, z).unwrap_or_else(void_air)
    }

    #[inline]
    fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool {
        self.columns.contains(chunk_x, chunk_z)
    }

    fn world_border(&self) -> ghast_physics::WorldBorder {
        border(self)
    }
}

impl ghast_physics::BlockView for View<'_> {
    type State = BlockState;

    #[inline(always)]
    fn block(&self, x: i32, y: i32, z: i32) -> BlockState {
        self.block_state(x, y, z).unwrap_or_else(void_air)
    }

    #[inline]
    fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool {
        self.is_column_loaded(chunk_x, chunk_z)
    }

    fn world_border(&self) -> ghast_physics::WorldBorder {
        border(self.world)
    }
}