pub enum LootFunction {
Show 41 variants
SetCount {
count: NumberProvider,
add: bool,
},
ExplosionDecay,
ApplyBonus {
enchantment: Identifier,
formula: BonusFormula,
},
EnchantedCountIncrease {
enchantment: Identifier,
count: NumberProvider,
limit: i32,
},
LimitCount {
min: Option<i32>,
max: Option<i32>,
},
SetDamage {
damage: NumberProvider,
add: bool,
},
EnchantRandomly {
options: EnchantmentOptions,
},
EnchantWithLevels {
levels: NumberProvider,
options: EnchantmentOptions,
},
CopyComponents {
source: CopySource,
include: &'static [Identifier],
},
CopyState {
block: Identifier,
properties: &'static [&'static str],
},
SetComponents {
components: &'static str,
},
SetCustomData {
tag: &'static str,
},
FurnaceSmelt,
ExplorationMap {
destination: Identifier,
decoration: Identifier,
zoom: i32,
skip_existing_chunks: bool,
},
SetName {
name: &'static str,
target: NameTarget,
},
SetOminousBottleAmplifier {
amplifier: NumberProvider,
},
SetPotion {
id: Identifier,
},
SetStewEffect {
effects: &'static [StewEffect],
},
SetInstrument {
options: Identifier,
},
SetEnchantments {
enchantments: &'static [(Identifier, NumberProvider)],
add: bool,
},
SetItem {
item: Identifier,
},
CopyName {
source: CopySource,
},
SetLore {
lore: &'static [&'static str],
mode: ListOperation,
},
SetContents {
entries: &'static [LootEntry],
component_type: Identifier,
},
ModifyContents {
modifier: &'static [ConditionalLootFunction],
component_type: Identifier,
},
SetLootTable {
loot_table: Identifier,
seed: Option<i64>,
},
SetAttributes {
modifiers: &'static [AttributeModifier],
replace: bool,
},
FillPlayerHead {
entity: LootContextEntity,
},
CopyCustomData {
source: CopySource,
operations: &'static [CopyDataOperation],
},
SetBannerPattern {
patterns: &'static [BannerPattern],
append: bool,
},
SetFireworks {
explosions: Option<&'static [FireworkExplosion]>,
flight_duration: Option<i32>,
},
SetFireworkExplosion {
explosion: FireworkExplosion,
},
SetBookCover {
title: Option<&'static str>,
author: Option<&'static str>,
generation: Option<i32>,
},
SetWrittenBookPages {
pages: &'static [&'static str],
mode: ListOperation,
},
SetWritableBookPages {
pages: &'static [&'static str],
mode: ListOperation,
},
ToggleTooltips {
toggles: &'static [(Identifier, bool)],
},
SetCustomModelData {
value: NumberProvider,
},
Discard,
Reference(Identifier),
Sequence {
functions: &'static [ConditionalLootFunction],
},
Filtered {
item_filter: ToolPredicate,
modifier: &'static ConditionalLootFunction,
},
}Expand description
A function that modifies loot items.
Variants§
SetCount
Set the count of the item.
ExplosionDecay
Apply explosion decay - each item has 1/radius chance to survive.
ApplyBonus
Apply bonus count based on enchantment level.
EnchantedCountIncrease
Increase count based on enchantment (like looting).
LimitCount
Limit the count to a range.
SetDamage
Set the damage of the item (0.0 = broken, 1.0 = full durability).
EnchantRandomly
Enchant the item randomly with enchantments from options.
Fields
options: EnchantmentOptionsEnchantWithLevels
Enchant the item as if using an enchanting table at the specified level.
CopyComponents
Copy components from the block entity to the item.
CopyState
Copy block state properties to the item.
SetComponents
Set components on the item.
SetCustomData
Set custom NBT data on the item (merges with existing custom_data).
FurnaceSmelt
Smelt the item (convert raw to cooked, ore to ingot, etc.).
ExplorationMap
Create an exploration map pointing to a structure.
SetName
Set the custom name of the item.
SetOminousBottleAmplifier
Set the ominous bottle amplifier.
Fields
amplifier: NumberProviderSetPotion
Set the potion type.
Fields
id: IdentifierSetStewEffect
Set the suspicious stew effects.
Fields
effects: &'static [StewEffect]SetInstrument
Set the instrument for goat horns.
Fields
options: IdentifierSetEnchantments
Set enchantments on the item.
SetItem
Change the item type entirely.
Fields
item: IdentifierCopyName
Copy name from source entity/block to item.
Fields
source: CopySourceSetLore
Add lore lines to the item.
SetContents
Set container inventory contents.
ModifyContents
Modify existing container contents.
SetLootTable
Set container’s loot table reference.
SetAttributes
Set attribute modifiers on the item.
FillPlayerHead
Fill player head with texture from entity.
Fields
entity: LootContextEntityCopyCustomData
Copy NBT/custom data from source.
SetBannerPattern
Set banner pattern layers.
SetFireworks
Set firework rocket properties.
SetFireworkExplosion
Set firework star explosion properties.
Fields
explosion: FireworkExplosionSetBookCover
Set book cover (title/author for written books).
SetWrittenBookPages
Set written book page contents.
SetWritableBookPages
Set writable book page contents.
ToggleTooltips
Toggle tooltip visibility.
Fields
toggles: &'static [(Identifier, bool)]SetCustomModelData
Set custom model data.
Fields
value: NumberProviderDiscard
Discard/delete the item entirely.
Reference(Identifier)
Reference to a named function in the registry.
Sequence
Apply multiple functions in sequence.
Fields
functions: &'static [ConditionalLootFunction]Filtered
Conditionally apply function to specific item predicate matches.
Implementations§
Source§impl LootFunction
impl LootFunction
Sourcepub fn apply<R: Rng>(&self, item: &mut ItemStack, ctx: &mut LootContext<'_, R>)
pub fn apply<R: Rng>(&self, item: &mut ItemStack, ctx: &mut LootContext<'_, R>)
Apply this function to modify the item stack.
This modifies the item in place. Functions can change:
- Count (SetCount, ExplosionDecay, ApplyBonus, etc.)
- Damage/durability (SetDamage)
- Enchantments (EnchantRandomly, EnchantWithLevels, SetEnchantments)
- Components/NBT (CopyComponents, SetComponents, CopyState)
- Item type (FurnaceSmelt)
- And more…
Trait Implementations§
Source§impl Clone for LootFunction
impl Clone for LootFunction
Source§fn clone(&self) -> LootFunction
fn clone(&self) -> LootFunction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more