pub trait BlockView {
type State: Copy;
// Required methods
fn block(&self, x: i32, y: i32, z: i32) -> Self::State;
fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool;
// Provided method
fn world_border(&self) -> WorldBorder { ... }
}Expand description
Read access to the blocks around a player, implemented by the world crate.
The physics only calls BlockView::block for valid positions: |x|, |z| < 30_000_000 and
0 <= y < 256 (vanilla returns air outside that range without asking the chunk). The
implementation must
- return the state as vanilla decodes it from chunk data: for 1.8 that is
BlockState::from_raw_vanilla(unknown ids and unregistered metas read as air); - return air for positions in columns that are not loaded (vanilla’s client uses an empty chunk there — never “solid”, never an error).
Required Associated Types§
Required Methods§
Sourcefn block(&self, x: i32, y: i32, z: i32) -> Self::State
fn block(&self, x: i32, y: i32, z: i32) -> Self::State
The block state at a valid position (air when the column is not loaded).
Sourcefn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool
fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool
true when the chunk column (chunk_x, chunk_z) has been received from the server.
Provided Methods§
Sourcefn world_border(&self) -> WorldBorder
fn world_border(&self) -> WorldBorder
The current world border (default: vanilla’s initial border, centre 0, 0, size 6e7).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".