Item modifier

Item modifiers are technical JSON files can be created inside data packs and are used to add loot functions into existing items using the command.

Usage
An item modifier is a loot function or an array of functions to apply at the item. They can be applied using the command.

 item modify (block | entity )   item replace (block | entity ) from (block | entity ) [ ] 

Item modifiers are defined using the JSON format. The root tag of an item modifier can be either an, following the structure of a loot function below, or an , containing multiple loot functions.

Loot function JSON format

 * The root tag of the loot function.
 * : Resource location of the function to apply. Valid functions are described below.
 * : A list of loot conditions, of which all must pass, for this function to be applied.
 * A loot condition. The JSON structure of this tag is defined on the Predicates page.
 * Other parameters of the function, described below.

The possible resource locations for and associated extra contents:


 * apply_bonus&mdash;Applies a predefined bonus formula.
 * : Enchantment ID used for level calculation.
 * : Can be  for a binomial distribution (with ,  ),   for uniform distribution (from   to  ), or   for a special function used for ore drops in the vanilla game.
 * : Values required for the formula.
 * : For formula 'binomial_with_bonus_count', the extra value.
 * : For formula 'binomial_with_bonus_count', the probability.
 * : For formula 'uniform_bonus_count', the bonus multiplier.


 * copy_name&mdash;For loot table type, copies a block entity's   tag into the item's   tag.
 * - The target with the . Currently, this needs to be set to.


 * copy_nbt&mdash;Copies NBT values from a specified block entity or entity, or from command storage to the item's  tag.
 * Shorthand form of below with  set to  . Set to ,  ,  , or.
 * : Information of the block entity, entity or storage to copy NBT from.
 * Set to  to use a block entity or an entity as the source, or   to use a command storage as the source.
 * Included only if  is set to  . Specifies the source block entity or entity to copy NBT from. Set to   for the block entity of the destroyed block,   for the entity triggering this item modifier,   for the entity that killed the entity triggering this item modifier, or   to only target the killer if they are a player.
 * Included only if  is set to  . A resource location specifying the storage ID to copy NBT from.
 * A list of copy operations.
 * An NBT operation
 * The NBT path to copy from.
 * The NBT path to copy to, starting from the item's  tag.
 * Set to  to replace any existing contents of the target NBT path,   to append to a list or array, or   to merge into a compound tag.


 * copy_state&mdash;Copies state properties from dropped block to the item's  tag.
 * A block ID. Function fails if the block doesn't match.
 * A list of property names to copy.
 * A block state name to copy.


 * enchant_randomly&mdash;Enchants the item with one randomly-selected enchantment. The level of the enchantment, if applicable, is random.
 * List of enchantment IDs to choose from. If omitted, all enchantments applicable to the item are possible.


 * enchant_with_levels&mdash;Enchants the item, with the specified enchantment level (roughly equivalent to using an enchantment table at that level).
 * Determines whether treasure enchantments are allowed on this item.
 * Number provider. Specifies the exact enchantment level to use.


 * exploration_map&mdash;Converts an empty map into an explorer map leading to a nearby generated structure.
 * : The type of generated structure to locate. Accepts any of the s used by the  command (case insensitive).
 * : The icon used to mark the destination on the map. Accepts any of the map icon text IDs (case insensitive). If  or   is used, the color of the lines on the item texture changes to match the corresponding explorer map.
 * : The zoom level of the resulting map. Defaults to 2.
 * : 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.
 * : Don't search in chunks that have already been generated. Defaults to true.


 * explosion_decay&mdash;For loot tables of type, removes some items from a stack, if there was an explosion. Each item has a chance of 1/explosion radius to be lost.

 
 * furnace_smelt&mdash;Smelts the item as it would be in a furnace. Used in combination with the  condition to cook food from animals on death.
 * fill_player_head&mdash;Adds required item tags of a player head.
 * : Specifies an entity to be used for the player head. Set to  the entity triggering this item modifier,   for the killer, or   for a killer that is a player.


 * limit_count&mdash;Limits the count of every item stack.
 * : Number provider. Specifies the exact limit to use.
 * : Limits the count between a minimum and maximum value. Both are not required.
 * : Number provider. Minimum limit to use.
 * : Number provider. Maximum limit to use.

 <div id="function_set_attributes" style="margin-block-end: 1em;"> <div id="function_set_banner_pattern" style="margin-block-end: 1em;">
 * looting_enchant&mdash;Adjusts the stack size based on the level of the Looting enchantment on the entity that killed the entity triggering this item modifier.
 * Number provider. Specifies the number of additional items per level of looting. Note the number may be fractional, rounded after multiplying by the looting level.
 * : Specifies the maximum amount of items in the stack after the looting calculation. If the value is 0, no limit is applied.
 * set_attributes&mdash;Add attribute modifiers to the item.
 * : An attribute modifier to add.
 * : Name of the modifier.
 * : The name of the attribute this modifier is to act upon.
 * : The operation of this attribute modifier. One of,  , or.
 * : Number provider. Specifies the amount of the modifier.
 * : Optional. UUID to assign the modifier, in hyphenated hexadecimal format. If none specified, a new random UUID is generated.
 * : Sets the slots the item must be in for the modifier to take effect. One of:,  ,  ,  ,  ,.
 * : To choose randomly from a set of possible slots. List contains strings of one of the above slot choices, to choose randomly from. The random selection cannot be weighted by listing the same slot multiple times.
 * : To choose randomly from a set of possible slots. List contains strings of one of the above slot choices, to choose randomly from. The random selection cannot be weighted by listing the same slot multiple times.
 * set_banner_pattern&mdash;Adds or replaces banner patterns of a banner. Function fails if invoked on a non-banner.
 * : List of patterns to add or replace with.
 * : A pattern.
 * : The pattern type. For example,.
 * : The color for this pattern. One of,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,.
 * : Optional. If true, the patterns will be applied on top of the banner's existing patterns.

<div id="function_set_contents" style="margin-block-end: 1em;">
 * set_contents - For loot tables of type, sets the contents of a container block item to a list of entries.
 * : A list of loot table entries to use as contents.
 * : the type to be written in.

<div id="function_set_count" style="margin-block-end: 1em;">
 * set_count - Sets the stack size.
 * : Number provider. Specifies the stack size to set.
 * : Optional. If, change will be relative to current count.

<div id="function_set_damage" style="margin-block-end: 1em;">
 * set_damage - Sets the item's damage value (durability) for tools.
 * Number provider. Specifies the damage fraction to set (1.0 is undamaged, 0.0 is zero durability left).
 * Optional. If, change will be relative to current damage.

<div id="function_set_enchantments" style="margin-block-end: 1em;">
 * set_enchantments - Modifies the item's enchantments.
 * Enchantments to modify.
 * Key name is the enchantment ID. Value is a number provider specifying the enchantment level. Levels are clamped at a maximum of 255. Decreasing an enchantment level below 1 will remove the enchantment, through a relative negative add or through a direct value assignemnt.
 * Optional. If, change will be relative to current level. A nonexistent enchantment will be presumed to start at 0.

<div id="function_set_loot_table" style="margin-block-end: 1em;">
 * set_loot_table&mdash;Sets the loot table for a container block when placed and opened.
 * : Specifies the resource location of the loot table to be used.
 * : Optional. Specifies the loot table seed. If absent or set to 0, a random seed will be used.
 * : the type to be written in.

<div id="function_set_lore" style="margin-block-end: 1em;">
 * set_lore&mdash;Adds or changes the item's lore.
 * : List of lines to append or replace on the item's lore.
 * A line of item lore, following the Raw JSON text format. Components requiring resolution are resolved only if  successfully targets an entity.
 * : Specifies the entity to act as  when referenced in the JSON text component. Set to   to use the entity that triggered the item modifier,   for the entity that killed the   entity, or   to target the killer only if they are a player.
 * : Set to  to replace the existing item lore with only the lines in . If   or absent, the lines are appended to the list of existing lines of lore.

<div id="function_set_name" style="margin-block-end: 1em;">
 * set_name&mdash;Adds or changes the item's custom name.
 * : A JSON text component, overwriting the previous custom name on the item. Components requiring resolution are resolved only if  successfully targets an entity.
 * : Specifies the entity to act as  when referenced in the JSON text component. Set to   to use the entity that triggered the item modifier,   for the entity that killed the   entity, or   to target the killer only if they are a player.

<div id="function_set_nbt" style="margin-block-end: 1em;">
 * set_nbt&mdash;Adds or changes NBT data of the item.
 * : The NBT to merge onto the item's  tag, within a JSON string. The outer braces   of the NBT must be present within this JSON string. Additional care is required when the NBT contains quotation marks , as they must be escaped from the JSON syntax with a backslash.

<div id="function_set_potion" style="margin-block-end: 1em;">
 * set_potion&mdash;Sets the  tag of an item.
 * : The potion ID.

<div id="function_set_stew_effect">
 * set_stew_effect&mdash;Sets the status effects for suspicious stew. Fails if invoked on an item that is not suspicious stew.
 * : The effects to apply.
 * An effect.
 * : The effect ID.
 * : Number provider. The duration of the effect.

Data packs
Data packs can add item modifiers. This is the folder structure:


 * (data pack name)
 * data
 * (namespace)
 * item_modifiers
 * (item_modifier).json

Each item modifier is defined in its own JSON file (see ). You can apply a modifier to an item using the command.

Issues
Gegenstandsmodifizierer 物品修饰器