pub struct BlockDropDefinition<I: ItemType> { /* private fields */ }Expand description
Author-defined item drop attached to a block definition.
Implementations§
Source§impl<I: ItemType> BlockDropDefinition<I>
impl<I: ItemType> BlockDropDefinition<I>
Sourcepub fn new(item: I, count: DropCount) -> Self
pub fn new(item: I, count: DropCount) -> Self
Creates a guaranteed drop with the provided count range.
Sourcepub fn with_chance(self, chance: f32) -> Self
pub fn with_chance(self, chance: f32) -> Self
Sets the chance in 0.0..=1.0.
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.
Sourcepub fn to_drop_table_entry(&self) -> DropTableEntry<I>
pub fn to_drop_table_entry(&self) -> DropTableEntry<I>
Converts this author-defined drop into the runtime drop-table entry used
by crate::items::DropsPlugin.
Trait Implementations§
impl<I: PartialEq + ItemType> StructuralPartialEq for BlockDropDefinition<I>
Auto Trait Implementations§
impl<I> Freeze for BlockDropDefinition<I>where
I: Freeze,
impl<I> RefUnwindSafe for BlockDropDefinition<I>where
I: RefUnwindSafe,
impl<I> Send for BlockDropDefinition<I>
impl<I> Sync for BlockDropDefinition<I>
impl<I> Unpin for BlockDropDefinition<I>where
I: Unpin,
impl<I> UnsafeUnpin for BlockDropDefinition<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for BlockDropDefinition<I>where
I: 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
Return the
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Converts
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>
Converts
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)
Converts
&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)
Converts
&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> ⓘ
Converts
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> ⓘ
Converts
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Settings for T
Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.