pub struct BlockData<T: Debug> { /* private fields */ }
Implementations§
source§impl<T: Debug> BlockData<T>
impl<T: Debug> BlockData<T>
sourcepub fn at(&self, x: usize, sec_y: usize, z: usize) -> Option<&T>
pub fn at(&self, x: usize, sec_y: usize, z: usize) -> Option<&T>
Get the block data for the block at x,y,z, where x,y,z are relative to the section ie 0..16.
sourcepub fn try_iter_indices(&self) -> Option<StatesIter<'_>>
pub fn try_iter_indices(&self) -> Option<StatesIter<'_>>
Get iterator for the state indicies. This will increase in x, then z, then y. These indicies are used with the relevant palette to get the data for that block.
This returns None if no block states were present. This typically means the section was empty (ie filled with air).
You can recover the coordinate be enumerating the iterator:
for (i, block_index) in states.try_iter_indices().unwrap().enumerate() {
let x = i & 0x000F;
let y = (i & 0x0F00) >> 8;
let z = (i & 0x00F0) >> 4;
}
sourcepub fn palette(&self) -> &[T]
pub fn palette(&self) -> &[T]
Get the palette for this block data. Indicies into this palette can be
obtained via try_iter_indices
.
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for BlockData<T>where
T: Deserialize<'de> + Debug,
impl<'de, T> Deserialize<'de> for BlockData<T>where T: Deserialize<'de> + Debug,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more