Loot function
Helpers that build a minecraft:loot_function 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.
ApplyBonus
ApplyBonus makes minecraft:apply_bonus Raises the count by the level of an enchantment on the tool, as fortune does for ores.
ApplyBonus(enchantment, formula, condition?)
enchantment enchantment id The enchantment whose level raises the count.
formula ApplyBonusFormula How the level changes the count: ore_drops, uniform_bonus_count or binomial_with_bonus_count.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
CopyComponents
CopyComponents makes minecraft:copy_components Copies data components from a block entity, entity or item onto the item.
CopyComponents(source, include?, exclude?, condition?)
source BlockEntityTarget | EntityTarget | ItemStackTarget includeoptional list of data_component_type ids If omitted, all components present are included
excludeoptional list of data_component_type ids Defaults to none.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
CopyCustomData
CopyCustomData makes minecraft:copy_custom_data Copies NBT from an entity, block entity or storage into the item's custom_data.
CopyCustomData(source, ops, condition?)
source NbtProvider ops list of { source: string, target: string, op: CopyNbtStrategy } conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
CopyName
CopyName makes minecraft:copy_name Copies the custom name of an entity or block entity onto the item.
CopyName(source, condition?)
source EntityTarget | BlockEntityTarget conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
CopyState
CopyState makes minecraft:copy_state Copies block state properties of the broken block onto the item.
CopyState(block, properties, condition?)
block block id properties list of any conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
Discard
Discard makes minecraft:discard Removes the item.
Discard(condition?)
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
EnchantRandomly
EnchantRandomly makes minecraft:enchant_randomly Adds one random enchantment.
EnchantRandomly(options?, only_compatible?, include_additional_cost_component?, condition?)
optionsoptional enchantment id | #enchantment tag | list of enchantment ids The allowed enchantments. If omitted, all enchantments applicable to the item are possible.
only_compatibleoptional bool Whether to only enchant with item-compatible enchantments. Defaults to true.
Note: Books are considered compatible with all Enchantments.
include_additional_cost_componentoptional bool Whether to add additional_trade_cost component to the enchanted item.
Additional cost value is determined by the enchantment level, with the formula 2 + random(0, 5 + level * 10) + 3 * level.
Defaults to false.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
EnchantWithLevels
EnchantWithLevels makes minecraft:enchant_with_levels Enchants the item as an enchanting table would at this many levels.
EnchantWithLevels(levels, options?, include_additional_cost_component?, condition?)
levels IntNumberProviderRef The levels to enchant this item with.
optionsoptional enchantment id | #enchantment tag | list of enchantment ids The allowed enchantments. If omitted, all enchantments applicable to the item are possible.
include_additional_cost_componentoptional bool Whether to add additional_trade_cost component to the enchanted item.
Additional cost value is equal to the level cost determined by levels.
Defaults to false.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
EnchantedCountIncrease
EnchantedCountIncrease makes minecraft:enchanted_count_increase Adds to the count by the level of an enchantment on the attacker's weapon, as looting does.
EnchantedCountIncrease(count, enchantment, limit?, condition?)
count FloatNumberProviderRef Rounded *after* the number was multiplied by the looting level.
enchantment enchantment id Enchantment that increases yields.
limitoptional int Limits the count of the item to a range.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
ExplorationMap
ExplorationMap makes minecraft:exploration_map Turns an empty map into an explorer map that points to the nearest structure of a kind.
ExplorationMap(destination, decoration?, zoom?, search_radius?, skip_existing_chunks?, condition?)
destination structure id | #structure tag | list of structure ids Generated structure to locate. Accepts any of the structure types used by the /locate command.
decorationoptional map_decoration_type id The icon used to mark the destination on the map.
zoomoptional int Defaults to 2.
search_radiusoptional int The size, in chunks, of the area to search for structures.
The area checked is square, not circular.
Radius 0 causes only the current chunk to be searched, radius 1 causes the current chunk and eight adjacent chunks to be searched, and so on.
Defaults to 50.
skip_existing_chunksoptional bool Whether to not search in chunks that have already been generated. Defaults to true.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
ExplosionDecay
ExplosionDecay makes minecraft:explosion_decay Removes some of the stack when an explosion caused the drop, as vanilla blocks do.
ExplosionDecay(condition?)
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
FillPlayerHead
FillPlayerHead makes minecraft:fill_player_head Makes a player head show an entity's skin.
FillPlayerHead(entity, condition?)
entity EntityTarget this to use the entity that died or the player that gained the advancement, opened the container, or broke the block.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
Filtered
Filtered makes minecraft:filtered Applies on_pass to items that match item_filter and on_fail to those that don't.
Filtered(item_filter, on_pass?, on_fail?, condition?)
item_filter ItemPredicate Item predicate to select items to modify.
on_passoptional ItemModifier Loot function to apply to the item when item_filter passes.
on_failoptional ItemModifier Loot function to apply to the item when item_filter fails.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
FurnaceSmelt
FurnaceSmelt makes minecraft:furnace_smelt Replaces the item with what smelting it in a furnace gives, as vanilla does for mobs killed by fire.
FurnaceSmelt(condition?)
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
LimitCount
LimitCount makes minecraft:limit_count Keeps the count within a range.
LimitCount(limit, condition?)
limit { min?: IntNumberProviderRef, max?: IntNumberProviderRef } Limits the count of the item to a range.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
ModifyContents
ModifyContents makes minecraft:modify_contents Applies an item modifier to every item inside a container item.
ModifyContents(component, modifier, condition?)
component ContainerComponents Describes target component's items to modify.
modifier ItemModifier Applied to every item inside container.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
Sequence
Sequence makes minecraft:sequence Applies several item modifiers in order.
Sequence(functions, condition?)
functions ItemModifier List of functions to apply to this item.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetAttributes
SetAttributes makes minecraft:set_attributes Adds attribute modifiers, such as attack damage, to the item.
SetAttributes(modifiers, replace?, condition?)
modifiers list of AttributeModifier List of attribute modifiers to apply to this item.
replaceoptional bool Whether to replace existing attributes (otherwise append to existing). Defaults to true.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetBannerPattern
SetBannerPattern makes minecraft:set_banner_pattern SetBannerPattern(patterns, append, condition?)
patterns list of BannerPatternLayer List of banner pattern layers.
append bool Whether to add to the banner pattern list.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetBookCover
SetBookCover makes minecraft:set_book_cover SetBookCover(title?, author?, generation?, condition?)
titleoptional Filterable of string (0 to 32) If omitted, the original title is kept (or an empty string is used if there was no component)
authoroptional string If omitted, the original author is kept (or an empty string is used if there was no component)
generationoptional int 0..3 If omitted, the original generation is kept (or 0 is used if there was no component)
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetComponents
SetComponents makes minecraft:set_components Sets data components on the item, such as max_stack_size or rarity.
SetComponents(components, condition?)
components DataComponentPatch The components to set. A key starting with ! removes that component.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetContents
SetContents makes minecraft:set_contents Fills a container item, such as a shulker box or bundle, with entries.
SetContents(component, entries, condition?)
component ContainerComponents Describes target component to be filled with items.
entries list of LootPoolEntry conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetCount
SetCount makes minecraft:set_count Sets the stack size, or adds to it with add.
SetCount(count, add?, condition?)
count IntNumberProviderRef The count: a number, or a range such as 1..3 for a random count.
addoptional bool Whether to add to the existing count. Defaults to false.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
ItemModifier few = SetCount(1..3)
SetCustomData
SetCustomData makes minecraft:set_custom_data Sets the item's custom_data component.
SetCustomData(tag, condition?)
tag CustomData conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetCustomModelData
SetCustomModelData makes minecraft:set_custom_model_data SetCustomModelData(floats?, flags?, strings?, colors?, condition?)
floatsoptional list_operation flagsoptional list_operation stringsoptional list_operation colorsoptional list_operation conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetDamage
SetDamage makes minecraft:set_damage Sets how damaged a tool or armour piece is.
SetDamage(damage, add?, condition?)
damage FloatNumberProviderRef Decimal percentage. Can be negative when used in combination with add.
Accepts a value between -1 & 1 (inclusive).
addoptional bool Whether to add to the existing damage of the item. Defaults to false.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetEnchantments
SetEnchantments makes minecraft:set_enchantments Sets enchantment levels on the item.
SetEnchantments(enchantments, add?, condition?)
enchantments map of enchantment id to IntNumberProviderRef A map of enchantments to levels. Setting an enchantment to 0 removes it from the item.
addoptional bool Whether to add to the level of each enchantment. Defaults to false.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetFireworkExplosion
SetFireworkExplosion makes minecraft:set_firework_explosion SetFireworkExplosion(shape?, colors?, fade_colors?, trail?, twinkle?, condition?)
shapeoptional FireworkShape If omitted, the original shape is kept (or small_ball is used if there was no component).
colorsoptional list of int If omitted, the original colors are kept (or [] is used if there was no component).
Calculated as RED << 16 | GREEN << 8 | BLUE. Each of these fields must be between 0 and 255, inclusive.
fade_colorsoptional list of int If omitted, the original fade colors are kept (or [] is used if there was no component).
Calculated as RED << 16 | GREEN << 8 | BLUE. Each of these fields must be between 0 and 255, inclusive.
trailoptional bool If omitted, the original has_trail value is kept (or false is used if there was no component).
twinkleoptional bool If omitted, the original has_twinkle value is kept (or false is used if there was no component).
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetFireworks
SetFireworks makes minecraft:set_fireworks SetFireworks(flight_duration?, explosions?, condition?)
flight_durationoptional int 0..255 If omitted, the flight duration of the item is left untouched - or set to 0 if the component did not exist before.
explosionsoptional list_operation conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetInstrument
SetInstrument makes minecraft:set_instrument SetInstrument(options, condition?)
options instrument id | #instrument tag | list of instrument ids Sets the instrument tag for a goat horn.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetItem
SetItem makes minecraft:set_item Changes the item to another one, keeping count and components.
SetItem(item, condition?)
item item id The new item.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetLootTable
SetLootTable makes minecraft:set_loot_table Sets the loot table a container item, such as a chest, rolls when placed and opened.
SetLootTable(loot_table_id, seed?, condition?)
loot_table_id loot_table id The loot table to set to the container block item.
seedoptional int The container seed to use. Defaults to a random seed.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetLore
SetLore makes minecraft:set_lore Sets or changes the item's lore lines.
SetLore(lore, mode, entity?, condition?)
lore list of Text The lore lines, as text components.
mode ListOperationMode Determines how the existing list should be modified.
entityoptional EntityTarget The entity used to resolve the text components.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetName
SetName makes minecraft:set_name Sets the item's name.
SetName(name, entity?, target?, condition?)
name Text The name, as a text component.
entityoptional EntityTarget Specifies the entity to act as the target @s in the JSON text component.
targetoptional SetNameTarget Which name component to set. Defaults to custom_name.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetOminousBottleAmplifier
SetOminousBottleAmplifier makes minecraft:set_ominous_bottle_amplifier SetOminousBottleAmplifier(amplifier, condition?)
amplifier IntNumberProviderRef conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetPotion
SetPotion makes minecraft:set_potion Sets the potion of a potion, splash potion, lingering potion or tipped arrow.
SetPotion(id, condition?)
id potion id The potion identifier.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetRandomDyes
SetRandomDyes makes minecraft:set_random_dyes SetRandomDyes(number_of_dyes, condition?)
number_of_dyes IntNumberProviderRef Applies specified number of random dyes to the item.
For example, one possible outcome of "number_of_dyes": 2 is #2C3065, which is the combination of a blue dye and a black dye.
The same dye color can be selected multiple times.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetRandomPotion
SetRandomPotion makes minecraft:set_random_potion SetRandomPotion(options?, condition?)
optionsoptional potion id | #potion tag | list of potion ids Possible potions to select from.
Defaults to all potions.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetStewEffect
SetStewEffect makes minecraft:set_stew_effect SetStewEffect(effects?, condition?)
effectsoptional list of StewEffect Sets the status effects for suspicious stew.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetWritableBookPages
SetWritableBookPages makes minecraft:set_writable_book_pages SetWritableBookPages(pages, mode, condition?)
pages list of Filterable of string Sets the pages of a book and quill.
mode ListOperationMode Determines how the existing list should be modified.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
SetWrittenBookPages
SetWrittenBookPages makes minecraft:set_written_book_pages SetWrittenBookPages(pages, mode, condition?)
pages list of Filterable of Text Sets the pages of a written book.
mode ListOperationMode Determines how the existing list should be modified.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.
ToggleTooltips makes minecraft:toggle_tooltips Shows or hides tooltip parts of the item, such as enchantments or attribute modifiers.
ToggleTooltips(toggles, condition?)
toggles map of data_component_type id to bool Toggles which tooltips are shown.
conditionoptional PredicateRef Conditions that must all pass for the function to apply. Combine several with && and ||.