Struct fastanvil::BlockData

source ·
pub struct BlockData<T: Debug> { /* private fields */ }

Implementations§

source§

impl<T: Debug> BlockData<T>

source

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.

source

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;
}
source

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<T: Debug + Debug> Debug for BlockData<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Debug> Default for BlockData<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BlockData<T>where T: RefUnwindSafe,

§

impl<T> Send for BlockData<T>where T: Send,

§

impl<T> Sync for BlockData<T>where T: Sync,

§

impl<T> Unpin for BlockData<T>where T: Unpin,

§

impl<T> UnwindSafe for BlockData<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,