Skip to main content

BlockView

Trait BlockView 

Source
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§

Source

type State: Copy

Block state type of the protocol version (ghast_data::v1_8::BlockState for 1.8).

Required Methods§

Source

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).

Source

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§

Source

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".

Implementations on Foreign Types§

Source§

impl<W: BlockView + ?Sized> BlockView for &W

Source§

type State = <W as BlockView>::State

Source§

fn block(&self, x: i32, y: i32, z: i32) -> Self::State

Source§

fn is_chunk_loaded(&self, chunk_x: i32, chunk_z: i32) -> bool

Source§

fn world_border(&self) -> WorldBorder

Implementors§