pub enum LootCondition {
Show 19 variants
SurvivesExplosion,
BlockStateProperty {
block: Identifier,
properties: &'static [PropertyCheck],
},
RandomChance(f32),
RandomChanceWithEnchantedBonus {
enchantment: Identifier,
unenchanted_chance: f32,
enchanted_chance: EnchantedChance,
},
MatchTool(ToolPredicate),
TableBonus {
enchantment: Identifier,
chances: &'static [f32],
},
Inverted(&'static LootCondition),
AnyOf(&'static [LootCondition]),
AllOf(&'static [LootCondition]),
KilledByPlayer,
EntityProperties {
entity: LootContextEntity,
predicate: EntityPredicate,
},
DamageSourceProperties {
predicate: DamageSourcePredicate,
},
LocationCheck {
offset_x: i32,
offset_y: i32,
offset_z: i32,
predicate: LocationPredicate,
},
WeatherCheck {
raining: Option<bool>,
thundering: Option<bool>,
},
TimeCheck {
value: NumberProviderRange,
period: Option<i64>,
},
ValueCheck {
value: NumberProvider,
range: NumberProviderRange,
},
EnchantmentActiveCheck {
enchantment: Identifier,
active: bool,
},
EntityScores {
entity: LootContextEntity,
scores: &'static [(&'static str, NumberProviderRange)],
},
Reference(Identifier),
}Expand description
A condition that must be met for a loot entry or pool to apply.
Variants§
SurvivesExplosion
The loot survives explosion damage (random chance based on explosion radius). Vanilla: 1/radius chance to pass. If no explosion, always passes.
BlockStateProperty
Check block state properties match expected values.
RandomChance(f32)
Simple random chance (0.0 to 1.0).
RandomChanceWithEnchantedBonus
Random chance affected by an enchantment (e.g., looting). Vanilla 1.21+: uses enchanted_chance which can be constant or linear.
Fields
enchantment: Identifierenchanted_chance: EnchantedChanceFor linear formula: chance = base + per_level * (level - 1)
MatchTool(ToolPredicate)
Match tool predicate - checks if the tool matches certain criteria.
TableBonus
Table bonus condition - chance based on enchantment level from a table. The chances array is indexed by enchantment level (0 = no enchant, 1 = level 1, etc.)
Inverted(&'static LootCondition)
Inverted condition - passes if the inner condition fails.
AnyOf(&'static [LootCondition])
Any of the conditions pass (OR logic).
AllOf(&'static [LootCondition])
All of the conditions pass (AND logic).
KilledByPlayer
Killed by player condition.
EntityProperties
Entity properties condition - checks entity predicates.
DamageSourceProperties
Damage source properties condition - checks how the entity was damaged.
Fields
predicate: DamageSourcePredicateLocationCheck
Location check condition - checks the location predicate.
WeatherCheck
Weather check condition - checks current weather.
TimeCheck
Time check condition - checks game time.
ValueCheck
Value check condition - compares a number provider value against a range.
EnchantmentActiveCheck
Check if a specific enchantment is active.
EntityScores
Check entity scoreboard scores.
Reference(Identifier)
Reference to a named condition in the registry.
Implementations§
Source§impl LootCondition
impl LootCondition
Sourcepub fn test<R: Rng>(&self, ctx: &mut LootContext<'_, R>) -> bool
pub fn test<R: Rng>(&self, ctx: &mut LootContext<'_, R>) -> bool
Test if this condition passes given the loot context.
Trait Implementations§
Source§impl Clone for LootCondition
impl Clone for LootCondition
Source§fn clone(&self) -> LootCondition
fn clone(&self) -> LootCondition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more