pub struct BlockDefinition<V: VoxelType> { /* private fields */ }Expand description
Author-defined block content associated with a concrete voxel value.
Implementations§
Source§impl<V: VoxelType> BlockDefinition<V>
impl<V: VoxelType> BlockDefinition<V>
Sourcepub fn new(id: impl Into<ContentId>, voxel: V) -> Self
pub fn new(id: impl Into<ContentId>, voxel: V) -> Self
Creates a block definition for the given id and voxel value.
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Returns the display name intended for UI/docs.
Sourcepub fn engine(&self) -> BlockEngineProperties
pub fn engine(&self) -> BlockEngineProperties
Returns engine-facing technical properties.
Sourcepub fn engine_properties(self, engine: BlockEngineProperties) -> Self
pub fn engine_properties(self, engine: BlockEngineProperties) -> Self
Replaces engine-facing technical properties.
Sourcepub fn attribute(
self,
key: impl Into<String>,
value: impl Into<ContentValue>,
) -> Self
pub fn attribute( self, key: impl Into<String>, value: impl Into<ContentValue>, ) -> Self
Adds or replaces an author-defined gameplay attribute.
Sourcepub fn get_attribute(&self, key: &str) -> Option<&ContentValue>
pub fn get_attribute(&self, key: &str) -> Option<&ContentValue>
Returns a gameplay attribute by key.
Sourcepub fn bool_attribute(&self, key: &str) -> Option<bool>
pub fn bool_attribute(&self, key: &str) -> Option<bool>
Returns a boolean gameplay attribute by key.
Sourcepub fn integer_attribute(&self, key: &str) -> Option<i64>
pub fn integer_attribute(&self, key: &str) -> Option<i64>
Returns an integer gameplay attribute by key.
Sourcepub fn number_attribute(&self, key: &str) -> Option<f64>
pub fn number_attribute(&self, key: &str) -> Option<f64>
Returns a numeric gameplay attribute by key.
Both integer and float attributes are accepted.
Sourcepub fn text_attribute(&self, key: &str) -> Option<&str>
pub fn text_attribute(&self, key: &str) -> Option<&str>
Returns a text gameplay attribute by key.
Sourcepub fn text_list_attribute(&self, key: &str) -> Option<&[String]>
pub fn text_list_attribute(&self, key: &str) -> Option<&[String]>
Returns a text-list gameplay attribute by key.
Sourcepub fn number_list_attribute(&self, key: &str) -> Option<&[f64]>
pub fn number_list_attribute(&self, key: &str) -> Option<&[f64]>
Returns a number-list gameplay attribute by key.
Sourcepub fn color_attribute(&self, key: &str) -> Option<[f32; 4]>
pub fn color_attribute(&self, key: &str) -> Option<[f32; 4]>
Returns a color gameplay attribute by key.
Sourcepub fn attributes(&self) -> &HashMap<String, ContentValue>
pub fn attributes(&self) -> &HashMap<String, ContentValue>
Returns all gameplay attributes.
Returns all author-defined tags.
Sourcepub fn snapshot(&self) -> BlockContentSnapshot
pub fn snapshot(&self) -> BlockContentSnapshot
Creates a serializable, deterministic snapshot of this block definition.
Trait Implementations§
Source§impl<V: Clone + VoxelType> Clone for BlockDefinition<V>
impl<V: Clone + VoxelType> Clone for BlockDefinition<V>
Source§fn clone(&self) -> BlockDefinition<V>
fn clone(&self) -> BlockDefinition<V>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<V: PartialEq + VoxelType> StructuralPartialEq for BlockDefinition<V>
Auto Trait Implementations§
impl<V> Freeze for BlockDefinition<V>where
V: Freeze,
impl<V> RefUnwindSafe for BlockDefinition<V>where
V: RefUnwindSafe,
impl<V> Send for BlockDefinition<V>
impl<V> Sync for BlockDefinition<V>
impl<V> Unpin for BlockDefinition<V>where
V: Unpin,
impl<V> UnsafeUnpin for BlockDefinition<V>where
V: UnsafeUnpin,
impl<V> UnwindSafe for BlockDefinition<V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more