Struct BlockState
#[non_exhaustive]pub struct BlockState { /* private fields */ }Expand description
A block and its local state ordinal. Persist canonical names and properties, not this value.
Implementations§
§impl BlockState
impl BlockState
pub const fn block(self) -> BlockKey
pub const fn block(self) -> BlockKey
The block this state belongs to, without needing a host or metadata lookup.
pub const fn ordinal(self) -> u16
pub const fn ordinal(self) -> u16
Its process-local ordinal, not the game’s numeric state identifier.
pub fn property<'a>(
self,
metadata: &'a dyn BlockMetadata,
name: &str,
) -> Result<Option<&'a str>, BlockStateError>
pub fn property<'a>( self, metadata: &'a dyn BlockMetadata, name: &str, ) -> Result<Option<&'a str>, BlockStateError>
Borrow a property from the supplied immutable metadata; a missing property is None.
pub fn with(
self,
metadata: &dyn BlockMetadata,
name: &str,
value: &str,
) -> Result<BlockState, BlockStateError>
pub fn with( self, metadata: &dyn BlockMetadata, name: &str, value: &str, ) -> Result<BlockState, BlockStateError>
Return a state with one property changed, without mutating metadata or the world.
pub fn of(
metadata: &dyn BlockMetadata,
block: BlockKey,
properties: &[StateConstraint],
) -> Result<BlockState, BlockStateError>
pub fn of( metadata: &dyn BlockMetadata, block: BlockKey, properties: &[StateConstraint], ) -> Result<BlockState, BlockStateError>
Start at the block’s default and apply partial property constraints.
Trait Implementations§
§impl Clone for BlockState
impl Clone for BlockState
§fn clone(&self) -> BlockState
fn clone(&self) -> BlockState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for BlockState
§impl Debug for BlockState
impl Debug for BlockState
impl Eq for BlockState
§impl Hash for BlockState
impl Hash for BlockState
§impl PartialEq for BlockState
impl PartialEq for BlockState
impl StructuralPartialEq for BlockState
Auto Trait Implementations§
impl Freeze for BlockState
impl RefUnwindSafe for BlockState
impl Send for BlockState
impl Sync for BlockState
impl Unpin for BlockState
impl UnsafeUnpin for BlockState
impl UnwindSafe for BlockState
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