Loot condition

Helpers that build a minecraft:loot_condition object, one for each of its types. Where a field takes one, write the helper's call; its name is the type it makes. Click a type to see what it accepts.

AllOf

AllOf

Passes when every condition passes. Usually written with &&.

AllOf(terms)
terms
PredicateListRef

Passes when all of these conditions pass.

AnyOf

AnyOf

Passes when any condition passes. Usually written with ||.

AnyOf(terms)
terms
PredicateListRef

Passes when any of these conditions pass.

DamageSourceProperties

DamageSourceProperties

Passes when the damage that killed the entity matches a damage source predicate.

DamageSourceProperties(predicate)
predicate
DamageSourcePredicate

EnchantmentActiveCheck

EnchantmentActiveCheck

Inside an enchantment's effects, passes when the enchantment is active (true) or inactive (false).

EnchantmentActiveCheck(active)
active
bool

EntityProperties

EntityProperties

Passes when an entity matches an entity predicate.

EntityProperties(entity, predicate)
entity
EntityTarget

Which entity to check: this (the entity that died, or the player that opened or broke something), attacker, direct_attacker or attacking_player.

predicate
EntityPredicate

What the entity must be.

EntityScores

EntityScores

Passes when an entity's scoreboard scores are in the given ranges.

EntityScores(entity, scores)
entity
EntityTarget

Which entity to check: this (the entity that died, or the player that opened or broke something), attacker, direct_attacker or attacking_player.

scores
map of string to IntRange

A map from objective name to a range of scores.

EnvironmentAttributeCheck

EnvironmentAttributeCheck
EnvironmentAttributeCheck(attribute, value)
attribute
environment_attribute id
value
any (depends on attribute)

FloatValueCheck

FloatValueCheck

Passes when a number is in a range.

FloatValueCheck(value, test)
value
FloatNumberProviderRef
test
FloatRange

Passes when value is within the test range.

IntValueCheck

IntValueCheck

Passes when a whole number is in a range.

IntValueCheck(value, test)
value
IntNumberProviderRef
test
IntRange

Passes when value is within the test range.

Inverted

Inverted

Passes when term fails. Usually written with !.

Inverted(term)
term
PredicateRef

The condition to invert.

KilledByPlayer

KilledByPlayer

Passes when a player killed the entity.

KilledByPlayer(inverse?)
inverseoptional
bool

true to pass when no player killed it instead.

LocationCheck

LocationCheck

Passes when the position, shifted by the offsets, matches a location predicate: biome, structure, light, block and more.

- offsetX: Blocks added to x before checking. - offsetY: Blocks added to y before checking. - offsetZ: Blocks added to z before checking.

LocationCheck(predicate, offsetX?, offsetY?, offsetZ?)
predicate
LocationPredicate

What the location must be.

offsetXoptional
int
offsetYoptional
int
offsetZoptional
int

MatchBlock

MatchBlock

Passes when the block, such as the one being broken, matches.

MatchBlock(blocks?, state?, nbt?, components?, predicates?)
blocksoptional
block id | #block tag | list of block ids

The blocks or block tag that pass.

stateoptional
BlockPredicateState

Block states the block must have, such as age = "7".

nbtoptional
string | any (depends on blocks)
componentsoptional
DataComponentExactPredicate

Match exact data component values on the block entity.

predicatesoptional
DataComponentPredicate

Test data component values on the block entity.

MatchTool

MatchTool

Passes when the tool used, such as the pickaxe that broke a block, matches an item predicate.

MatchTool(predicate)
predicate
ItemPredicate

What the tool must be.

RandomChance

RandomChance

Passes at random, with probability chance.

RandomChance(chance)
chance
FloatNumberProviderRef

Accepts a value between 0 & 1 (inclusive).

Predicate coin_flip = RandomChance(0.5)

RandomChanceWithEnchantedBonus

RandomChanceWithEnchantedBonus

Passes at random, with a higher chance when the attacker's weapon has an enchantment, as looting does for rare drops.

RandomChanceWithEnchantedBonus(unenchanted_chance, enchanted_chance, enchantment)
unenchanted_chance
number 0..1

The chance without the enchantment, from 0 to 1.

enchanted_chance
LevelBasedValue

The chance by enchantment level.

enchantment
enchantment id

The enchantment that raises the chance.

SurvivesExplosion

SurvivesExplosion

Passes with a chance of 1 divided by the explosion's radius, and always when there was no explosion. Vanilla block drops use it so explosions destroy some items.

SurvivesExplosion()

TableBonus

TableBonus

Passes at random, with the chance picked by the level of an enchantment on the tool. Vanilla uses it for saplings and flint.

TableBonus(enchantment, chances)
enchantment
enchantment id

The enchantment whose level picks the chance.

chances
list of number 0..1

Probabilities for each enchantment level

TimeCheck

TimeCheck

Passes when a world clock's time is in a range.

TimeCheck(clock, value, period?)
clock
world_clock id

The world clock to check.

value
IntRange

Check the current game tick.

periodoptional
int

Game tick supplied to value check gets modulo-divided by this. For example, if set to 24000, value operates on a time period of days.

Predicate night = TimeCheck(clock = overworld, value = 13000..23000, period = 24000)

WeatherCheck

WeatherCheck

Passes when the weather matches. Leave out what doesn't matter.

WeatherCheck(raining?, thundering?)
rainingoptional
bool

true to require rain, false to require no rain.

thunderingoptional
bool

true to require a thunderstorm, false to require none.

Predicate storm = WeatherCheck(thundering = true)