BlockState

Struct BlockState 

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

Represent a particular state of a block, this block state also know all its neighbors by their properties and values.

To build states, use BlockStateContainerBuilder and add all wanted properties.

Implementations§

Source§

impl BlockState

Source

pub fn get_index(&self) -> u16

Source

pub fn get_key(&'static self) -> BlockStateKey

Source

pub fn get_block(&self) -> &'static Block

Source

pub fn is_block(&self, block: &'static Block) -> bool

Source

pub fn get<T, P>(&self, property: &P) -> Option<T>

Get a block state property value if the property exists.

Source

pub fn expect<T, P>(&self, property: &P) -> T

Source

pub fn with<T, P>(&self, property: &P, value: T) -> Option<&BlockState>

Try to get a neighbor with all the same properties excepts the given one with the given value, if the property or its value is not valid for the block, None is returned.

Source

pub fn with_raw(&self, prop_name: &str, prop_value: &str) -> Option<&BlockState>

Try to get a neighbor with all the same properties excepts the given one with the given value, if the property or its value is not valid for the block, None is returned.

This version of with method take raw property name and value as strings.

Source

pub fn iter_raw_states<'a>( &'a self, ) -> Option<impl Iterator<Item = (&'static str, String)> + 'a>

Iterate over representations of each property of this state. No iterator is returned if the underlying block as no other state other than this one.

Trait Implementations§

Source§

impl Debug for BlockState

Source§

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

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

impl PartialEq for &'static BlockState

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for &'static BlockState

Source§

impl Send for BlockState

Source§

impl Sync for BlockState

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,