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