pub struct SubChunk { /* private fields */ }
Expand description
A sub chunk, 16x16x16 blocks.
Implementations§
Source§impl SubChunk
impl SubChunk
Sourcepub fn new(env: Arc<LevelEnv>) -> Self
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).
pub fn get_block(&self, x: u8, y: u8, z: u8) -> &'static BlockState
Sourcepub fn set_block(
&mut self,
x: u8,
y: u8,
z: u8,
state: &'static BlockState,
) -> ChunkResult<()>
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.
Sourcepub fn fill_block(&mut self, state: &'static BlockState) -> ChunkResult<()>
pub fn fill_block(&mut self, state: &'static BlockState) -> ChunkResult<()>
Force fill all the sub chunk with the given block state.
Sourcepub unsafe fn set_blocks_raw<I>(
&mut self,
palette: Vec<&'static BlockState>,
blocks: I,
)
pub unsafe fn set_blocks_raw<I>( &mut self, palette: Vec<&'static BlockState>, blocks: I, )
§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.
Sourcepub fn iter_blocks(&self) -> impl Iterator<Item = &'static BlockState> + '_
pub fn iter_blocks(&self) -> impl Iterator<Item = &'static BlockState> + '_
Iterate over all blocks in this chunk, ordered by X, Z then Y.
pub fn non_null_blocks_count(&self) -> u16
pub fn null_blocks_count(&self) -> u16
pub fn has_non_null_block(&self) -> bool
Auto Trait Implementations§
impl Freeze for SubChunk
impl !RefUnwindSafe for SubChunk
impl Send for SubChunk
impl Sync for SubChunk
impl Unpin for SubChunk
impl !UnwindSafe for SubChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more