pub struct LootTable {
pub key: Identifier,
pub loot_type: LootType,
pub pools: &'static [LootPool],
pub functions: &'static [ConditionalLootFunction],
pub random_sequence: Option<Identifier>,
}Expand description
A complete loot table definition.
Fields§
§key: Identifier§loot_type: LootType§pools: &'static [LootPool]§functions: &'static [ConditionalLootFunction]§random_sequence: Option<Identifier>Implementations§
Source§impl LootTable
impl LootTable
Sourcepub fn get_random_items<R: Rng>(
&self,
ctx: &mut LootContext<'_, R>,
) -> Vec<ItemStack>
pub fn get_random_items<R: Rng>( &self, ctx: &mut LootContext<'_, R>, ) -> Vec<ItemStack>
Generate random items from this loot table.
§Arguments
ctx- The loot context containing RNG, luck, block state, tool, etc.
This follows vanilla’s approach:
- For each pool, check conditions
- Roll
rolls + floor(bonus_rolls * luck)times - Each roll does weighted random selection among valid entries
- Apply entry-level functions to each item
- Apply pool-level functions to all items from that pool
- Apply table-level functions to all items from the table
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LootTable
impl RefUnwindSafe for LootTable
impl Send for LootTable
impl Sync for LootTable
impl Unpin for LootTable
impl UnsafeUnpin for LootTable
impl UnwindSafe for LootTable
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreWraps this value in an
Arc<SyncMutex<>>