Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Item modifier

From SAS Gaming Wiki

Template:Exclusive Item modifiers (also known as loot modifiers) can be used to apply modifications to item stacks, such as adjusting the stack size or adding enchantments. They can be defined in Minecraft:datapacks as Minecraft:JSON files, or used in Minecraft:loot tables. The Template:Cmd command also accepts item modifiers in Minecraft:SNBT format.

A single modification in item modifiers is called item function or loot function.

Definition

An item modifier is a single loot function or an array of loot functions to apply to the item. The root element of an item modifier can be either an Template:Nbt, following the structure of a loot function below, or an Template:Nbt, containing multiple loot functions.

Item modifiers are defined using the Minecraft:JSON format in Minecraft:data packs, or the Minecraft:SNBT format in Template:Cmd command.

Item modifiers defined in data packs in the following directory structure, highlighted below: Template:Data pack directory

Usage

Commands

Item modifiers can be invoked with the Template:Cmd command. When doing so, it is required to specify a target slot to invoke the modifier upon, either an item inside a container block's contents, or inside an entity's inventory.

There are two variations of this command: Template:Cmd invokes a modifier alone upon the target slot, Template:Cmd replaces the item in the target slot with another and subsequently invokes a modifier upon it.

Loot tables

In Minecraft:loot tables, item modifiers can be defined without the need for a separate file; however, separate files can also be explicitly referenced using the reference function.

Format

The format of a single item modifier is:

Multiple modifiers may be bundled into one by placing them into a JSON array or an NBT list. In this case, all listed modifiers are applied in sequence, similar to the sequence modifier type.

Function types

The possible resource locations (namespace minecraft: is omitted) for Template:Nbt field and associated extra contents:

  • apply_bonus—Applies a predefined bonus formula to the count of the item stack.
    • Template:Nbt: ID of an enchantment on the tool provided by Minecraft:loot context used for level calculation.
    • Template:Nbt: A Minecraft:resource location. Can be binomial_with_bonus_count for 1 bonus item plus bonus determined by binomial distribution with n=level + extra, p=probability. Can be uniform_bonus_count for uniform distribution (from 0 to level * bonusMultiplier), or ore_drops for a special function used for ore drops in the vanilla game (Count *= (max(1; randomInt(0(inclusive) .. (Level + 2)(exclusive))))).
    • Template:Nbt: Values required for the formula.
      • Template:Nbt: For formula 'binomial_with_bonus_count', the extra value.
      • Template:Nbt: For formula 'binomial_with_bonus_count', the probability.
      • Template:Nbt: For formula 'uniform_bonus_count', the bonus multiplier.
  • discard—Removes the item stack.
  • enchanted_count_increase—Adjusts the stack size based on the level of the specified enchantment on the Template:Cd entity provided by Minecraft:loot context.
    • Template:NbtTemplate:Nbt: A number provider. Specifies the number of additional items per level of the enchantment. Note the number may be fractional, rounded after multiplying by the enchantment level.
    • Template:Nbt: Specifies the maximum amount of items in the stack after the enchantment calculation. If the value is 0, no limit is applied. Defaults to 0.
    • Template:Nbt: Template:Json ref/enchantment. The enchantment whose levels should be used to calculate the count.
  • exploration_map—If the origin is provided by Minecraft:loot context, converts an empty map into an Minecraft:explorer map leading to a nearby generated structure.
    • Template:Nbt: A Minecraft:tag of Minecraft:structure to locate. Defaults to on_treasure_maps.
    • Template:Nbt: The icon used to mark the destination on the map. Accepts any of the map icon text IDs (case insensitive). If mansion or monument is used, the color of the lines on the item texture changes to match the corresponding explorer map. Defaults to mansion.
    • Template:Nbt: The zoom level of the resulting map. Defaults to 2.
    • Template:Nbt: 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.
    • Template:Nbt: Don't search in chunks that have already been generated. Defaults to true.
  • explosion_decay—Removes some items from a stack, if the explosion radius is provided by Minecraft:loot context. Each item in the item stack has a chance of 1/explosion radius to be lost.
  • furnace_smelt—Smelts the item as it would be in a furnace without changing its count.
  • modify_contents—Applies a function to every item inside an inventory component. If such a component does not exist, it is not added.
    • Template:Nbt: A target component. Allowed values are bundle_contents, charged_projectiles, container}}.
    • Template:NbtTemplate:Nbt: Function or list of functions to be applied to every item inside the container.

Template:Bug</ref>

    • Template:Nbt: Location of function to call.
      • Template:Nbt An item modifier. The same JSON structure as described on this page.
  • set_banner_pattern - Adds or replaces banner patterns of a banner. Function successfully adds patterns into NBT tag even if invoked on a non-banner.
    • Template:Nbt: List of patterns to add or replace with.
      • Template:Nbt: A pattern.
        • Template:Nbt: The pattern type. For example, square_bottom_left.
        • Template:Nbt: The color for this pattern. One of white, orange, magenta, light_blue, yellow, lime, pink, gray, light_gray, cyan, purple, blue, brown, green, red, black.
    • Template:Nbt: Required. If true, the patterns are applied on top of the banner's existing patterns.
  • set_book_cover—Sets the cover details of the minecraft:written_book_content component. If present, any pages in the book are left untouched.
    • Template:Nbt: Optional. Sets the author of the book. If omitted, the original author is kept (or an empty string is used if there was no component).
    • Template:Nbt: Optional. Sets the generation value of the book (original, copy, etc.). Allowed values are 0 to 3. If omitted, the original generation is kept (or 0 is used if there was no component).
    • Template:NbtTemplate:NbtTemplate:Nbt: Optional. Sets the title of the book as a Minecraft:raw JSON text component. If omitted, the original title is kept (or an empty string is used if there was no component).
  • set_components—Sets components of an item.
    • Template:Nbt: A map of components ID to component value. Components with a ! prefix (e.g. "!minecraft:damage": {}) causes this component to be removed.
  • set_contents - Sets the contents of a container block item to a list of entries.
    • Template:Nbt: A list of loot table entry producer to provide item stacks.
    • Template:Nbt: The target component to be filled with items. Existing contents are replaced. Allowed values: container, bundle_contents, and charged_projectiles. Both bundle_contents and charged_projectiles ignore empty stacks.<ref>Template:Mcnet</ref>
  • set_custom_data—Sets the minecraft:custom_data component.
    • Template:NbtTemplate:Nbt: The data to merge onto the item's minecraft:custom_data component, either within a JSON string or as unflattened tags. That means that {"tag": "{a:1}"} and {"tag": {"a":1}} are equivalent. When using the string representation, additional care is required: the outer braces { } of the component must still be present and if the NBT contains quotation marks ", they must be escaped with a backslash \.
  • set_damage - Sets the item's damage value (durability).
  • set_enchantments - Modifies the item's enchantments. A book converts to an Minecraft:enchanted book.
    • Template:Nbt: Enchantments to modify.
      • Template:NbtTemplate:Nbt: Key name is the enchantment ID. Value is a number provider specifying the enchantment power. Powers are clamped at a maximum of 255. Decreasing an enchantment power below 1 remove the enchantment, through a relative negative add or through a direct value assignemnt.
    • Template:Nbt: Optional. If true, change is relative to current level. A nonexistent enchantment is presumed to start at 0. Defaults to false.
  • set_fireworks—Sets minecraft:fireworks component.
    • Template:Nbt: Optional. Specifies firework explosions.
      • Template:Nbt: List of firework explosion data.
        • Template:Nbt: The shape of the explosion. Can be Template:Cd.
        • Template:Nbt: The colors of the initial particles of the explosion, randomly selected from.
        • Template:Nbt: The colors of the fading particles of the explosion, randomly selected from.
        • Template:Nbt: Whether or not the explosion has a trail effect (diamond).
        • Template:Nbt: Whether or not the explosion has a twinkle effect (glowstone dust).
      • Template:Nbt: Determines how existing fireworks component should be modified. Allowed values are "append", "insert", "replace_all", "replace_section".
      • Template:Nbt: Used only if Template:Nbt is set to "insert" or "replace_section". Specifies index to insert or replace explosions from. Defaults to 0
      • Template:Nbt: Used only if Template:Nbt is set to "replace_section". Specifies the size of the range to be replaced. If omitted, the size of Template:Nbt field is used.
    • Template:Nbt: Optional, allowed values are 0 to 255. Determines flight duration measured in number of gunpowder. If omitted, the flight duration of the item is left untouched (or set to 0 if the component did not exist before).
  • set_firework_explosion—Sets minecraft:firework_explosion component.
    • Template:Nbt: The shape of the explosion. Can be Template:Cd.
    • Template:Nbt: The colors of the initial particles of the explosion, randomly selected from.
    • Template:Nbt: The colors of the fading particles of the explosion, randomly selected from.
    • Template:Nbt: Whether or not the explosion has a trail effect (diamond).
    • Template:Nbt: Whether or not the explosion has a twinkle effect (glowstone dust).
  • set_instrument - Sets the item tags for instrument items to a random value from a tag.
  • set_item—Replaces item type without changing count or components.
  • set_loot_table - Sets the loot table for a container block when placed and opened.
    • Template:Nbt: Specifies the Minecraft:resource location of the loot table to be used.
    • Template:Nbt: Optional. Specifies the loot table seed. If absent or set to 0, the seed won't be put into the NBT, and a random seed is used when opening the container.
    • Template:Nbt: the block entity type to be written in BlockEntityTag.id.
  • set_ominous_bottle_amplifier—Sets the ominous_bottle_amplifier component of an item.
  • set_potion—Sets the potion_contents component of an item.
  • set_writable_book_pages—Manipulates the pages of the minecraft:writable_book_content component.
    • Template:Nbt: A list of pages as filterable strings.
      • Template:Nbt: A single page.
        Alternatively, a single page can be represented as follows:
      • Template:Nbt: The plain text content of a page.
    • Template:Nbt: Determines how existing pages should be modified. Allowed values are "append", "insert", "replace_all", "replace_section".
    • Template:Nbt: Used only if Template:Nbt is set to "insert" or "replace_section". Specifies index to insert or replace pages from. Defaults to 0
    • Template:Nbt: Used only if Template:Nbt is set to "replace_section". Specifies the size of the range to be replaced. If omitted, the size of Template:Nbt field is used.
  • toggle_tooltips—Toggles which tooltips are visible.
    • Template:Nbt: A map of supported item components to modify. All fields are optional.
      • Template:Nbt: Changes the visibility of the tooltip displaying the item's attribute modifiers.
      • Template:Nbt: Changes the visibility of the tooltip displaying the blocks the item can break in Minecraft:Adventure mode.
      • Template:Nbt: Changes the visibility of the tooltip displaying the blocks the item can placed on in Minecraft:Adventure mode.
      • Template:Nbt: Changes the visibility of the tooltip displaying dyed Minecraft:armor color.
      • Template:Nbt: Changes the visibility of the tooltip displaying the item's enchantments.
      • Template:Nbt: Changes the visibility of the tooltip displaying the item's stored enchantments (for Minecraft:enchanted books).
      • Template:Nbt: Changes the visibility of the tooltip displaying the item's armor trim.
      • Template:Nbt: Changes the visibility of the tooltip displaying the item's unbreakable status. Setting this to any value does not change whether the item is unbreakable.

History

Template:HistoryTable

Issues

Template:Issue list

References

Template:Reflist

External links

Navigation

Template:Navbox Java Edition technical

Minecraft:de:Gegenstandsmodifizierer Minecraft:fr:Modificateur d'objet Minecraft:ja:アイテム修飾子 Minecraft:pt:Modificador de itens Minecraft:zh:物品修饰器