SubChunk

Struct SubChunk 

Source
pub struct SubChunk { /* private fields */ }
Expand description

A sub chunk, 16x16x16 blocks.

Implementations§

Source§

impl SubChunk

Source

pub fn new(env: Arc<LevelEnv>) -> Self

Construct a new sub chunk with the given level environment. The default block is the “null-block” which is the block with save ID 0 in the global blocks palette (which is air in vanilla global palette).

Source

pub fn get_block(&self, x: u8, y: u8, z: u8) -> &'static BlockState

Source

pub fn set_block( &mut self, x: u8, y: u8, z: u8, state: &'static BlockState, ) -> ChunkResult<()>

§Caution

This method will not update heightmaps of the owner chunk.

Source

pub fn fill_block(&mut self, state: &'static BlockState) -> ChunkResult<()>

Force fill all the sub chunk with the given block state.

Source

pub unsafe fn set_blocks_raw<I>( &mut self, palette: Vec<&'static BlockState>, blocks: I, )
where I: Iterator<Item = usize>,

§Safety:

You must ensure that the given palette contains only valid states for this chunk’s level’s environment.

The blocks iterator must return only valid indices for the given palette.

Source

pub fn iter_blocks(&self) -> impl Iterator<Item = &'static BlockState> + '_

Iterate over all blocks in this chunk, ordered by X, Z then Y.

Source

pub fn non_null_blocks_count(&self) -> u16

Source

pub fn null_blocks_count(&self) -> u16

Source

pub fn has_non_null_block(&self) -> bool

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Component for T
where T: Send + Sync + 'static,