pub enum NumberProvider {
Constant(f32),
Uniform {
min: f32,
max: f32,
},
Binomial {
n: i32,
p: f32,
},
Score {
target: ScoreboardTarget,
score: &'static str,
scale: f32,
},
Storage {
storage: Identifier,
path: &'static str,
},
EnchantmentLevel {
enchantment: Identifier,
},
}Expand description
A number provider that can be constant or random.
Variants§
Constant(f32)
Uniform
Binomial
Score
Get value from entity scoreboard score.
Storage
Get value from command storage.
EnchantmentLevel
Get enchantment level from context tool.
Fields
§
enchantment: IdentifierImplementations§
Source§impl NumberProvider
impl NumberProvider
Sourcepub fn get<R: Rng>(&self, rng: &mut R, ctx: Option<&LootContextRef<'_>>) -> f32
pub fn get<R: Rng>(&self, rng: &mut R, ctx: Option<&LootContextRef<'_>>) -> f32
Get a value from this provider using the given RNG.
Sourcepub fn get_simple(&self, rng: &mut impl Rng) -> f32
pub fn get_simple(&self, rng: &mut impl Rng) -> f32
Get a value without context (for backwards compatibility).
Sourcepub fn get_int_with_ctx<R: Rng>(
&self,
rng: &mut R,
ctx: Option<&LootContextRef<'_>>,
) -> i32
pub fn get_int_with_ctx<R: Rng>( &self, rng: &mut R, ctx: Option<&LootContextRef<'_>>, ) -> i32
Get the value as an integer with context.
Trait Implementations§
Source§impl Clone for NumberProvider
impl Clone for NumberProvider
Source§fn clone(&self) -> NumberProvider
fn clone(&self) -> NumberProvider
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 moreAuto Trait Implementations§
impl Freeze for NumberProvider
impl RefUnwindSafe for NumberProvider
impl Send for NumberProvider
impl Sync for NumberProvider
impl Unpin for NumberProvider
impl UnsafeUnpin for NumberProvider
impl UnwindSafe for NumberProvider
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