{
  "$comment": "https://minecraft.fandom.com/wiki/Item_modifier#JSON_structure",
  "$id": "https://json.schemastore.org/minecraft-item-modifier.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "slotEnum": {
      "enum": ["mainhand", "offhand", "feet", "legs", "chest", "head"]
    },
    "numberProvider": {
      "$comment": "https://minecraft.fandom.com/wiki/Loot_table#Number_Providers",
      "properties": {
        "type": {
          "title": "Type",
          "description": "The number provider type.",
          "type": "string",
          "enum": [
            "minecraft:constant",
            "minecraft:uniform",
            "minecraft:binomial",
            "minecraft:score"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "minecraft:constant"
              }
            }
          },
          "then": {
            "description": "A constant value.",
            "properties": {
              "value": {
                "title": "Value",
                "description": "The exact value.",
                "type": "number"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "minecraft:uniform"
              }
            }
          },
          "then": {
            "description": "A random number following a uniform distribution between two values (inclusive).",
            "properties": {
              "min": {
                "title": "Minimum",
                "description": "The minimum value.",
                "type": ["number", "object"],
                "$ref": "#/definitions/numberProvider"
              },
              "max": {
                "title": "Max",
                "description": "The maximum value.",
                "type": ["number", "object"],
                "$ref": "#/definitions/numberProvider"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "minecraft:binomial"
              }
            }
          },
          "then": {
            "description": "A random number following a binomial distribution.",
            "properties": {
              "n": {
                "title": "n",
                "description": "The amount of trials.",
                "type": ["integer", "object"],
                "$ref": "#/definitions/numberProvider"
              },
              "p": {
                "title": "p",
                "description": "The probability of success on an individual trial.",
                "$ref": "#/definitions/numberProvider"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "minecraft:score"
              }
            }
          },
          "then": {
            "description": "A scoreboard value.",
            "properties": {
              "target": {
                "title": "Target",
                "description": "Scoreboard name provider.",
                "type": ["string", "object"],
                "enum": ["this", "killer", "direct_killer", "player_killer"],
                "properties": {
                  "type": {
                    "title": "Type",
                    "description": "Resource location.",
                    "type": "string",
                    "enum": ["fixed", "context"]
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "type": {
                          "const": "fixed"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "name": {
                          "title": "Name",
                          "description": "A UUID or player name.",
                          "type": "string"
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "type": {
                          "const": "context"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "target": {
                          "title": "Target",
                          "type": "string",
                          "enum": [
                            "this",
                            "killer",
                            "direct_killer",
                            "player_killer"
                          ]
                        }
                      }
                    }
                  }
                ]
              },
              "score": {
                "title": "Score",
                "description": "The scoreboard objective.",
                "type": "string"
              },
              "scale": {
                "title": "Scale",
                "description": "Scale to multiply the score before returning it.",
                "type": "number"
              }
            }
          }
        }
      ]
    }
  },
  "description": "Configuration file defining an item modifier for a data pack for Minecraft.",
  "items": {
    "properties": {
      "function": {
        "title": "Function",
        "description": "Namespaced ID of the function to apply.",
        "type": "string",
        "enum": [
          "minecraft:apply_bonus",
          "minecraft:copy_name",
          "minecraft:copy_nbt",
          "minecraft:copy_state",
          "minecraft:enchant_randomly",
          "minecraft:enchant_with_levels",
          "minecraft:exploration_map",
          "minecraft:explosion_decay",
          "minecraft:furnace_smelt",
          "minecraft:fill_player_head",
          "minecraft:limit_count",
          "minecraft:looting_enchant",
          "minecraft:set_attributes",
          "minecraft:set_banner_pattern",
          "minecraft:set_contents",
          "minecraft:set_count",
          "minecraft:set_damage",
          "minecraft:set_enchantments",
          "minecraft:set_loot_table",
          "minecraft:set_lore",
          "minecraft:set_name",
          "minecraft:set_nbt",
          "minecraft:set_stew_effect"
        ]
      }
    },
    "allOf": [
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:apply_bonus"
            }
          }
        },
        "then": {
          "description": "Applies a predefined bonus formula.",
          "type": "object",
          "properties": {
            "enchantment": {
              "title": "Enchantment",
              "description": "Enchantment ID used for level calculation.",
              "type": "string"
            },
            "formula": {
              "title": "Forumla",
              "type": "string",
              "enum": [
                "binomial_with_bonus_count",
                "uniform_bonus_count",
                "ore_drops"
              ]
            },
            "parameters": {
              "title": "Parameters",
              "description": "Values required for the formula.",
              "type": "object",
              "properties": {
                "extra": {
                  "title": "Extra",
                  "description": "For formula 'binomial_with_bonus_count', the extra value.",
                  "type": "integer"
                },
                "probability": {
                  "title": "Probability",
                  "description": "For formula 'binomial_with_bonus_count', the probability.",
                  "type": "number"
                },
                "bonusMultiplier": {
                  "title": "Bonus Multiplier",
                  "description": "For formula 'uniform_bonus_count', the bonus multiplier.",
                  "type": "number"
                }
              }
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:copy_name"
            }
          }
        },
        "then": {
          "description": "For loot table type 'block', copies a block entity's CustomName tag into the item's display.",
          "type": "object",
          "properties": {
            "source": {
              "title": "Source",
              "type": "string",
              "enum": ["block_entity"],
              "default": "block_entity"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:copy_nbt"
            }
          }
        },
        "then": {
          "description": "Copies NBT to the item.",
          "type": "object",
          "properties": {
            "source": {
              "title": "Source",
              "anyOf": [
                {
                  "type": "string",
                  "enum": ["block_entity", "this", "killer", "killer_player"]
                },
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "title": "Type",
                      "description": "NBT provider type.",
                      "type": "string",
                      "enum": ["minecraft:context", "minecraft:storage"]
                    }
                  },
                  "allOf": [
                    {
                      "if": {
                        "properties": {
                          "type": {
                            "const": "minecraft:context"
                          }
                        }
                      },
                      "then": {
                        "properties": {
                          "target": {
                            "title": "Target",
                            "description": "Same as source above.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    {
                      "if": {
                        "properties": {
                          "type": {
                            "const": "minecraft:storage"
                          }
                        }
                      },
                      "then": {
                        "properties": {
                          "target": {
                            "title": "Source",
                            "description": "A resource location specifying the storage ID.",
                            "type": "string"
                          }
                        }
                      }
                    }
                  ]
                }
              ]
            },
            "ops": {
              "title": "Operations",
              "description": "A list of copy operations.",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "source": {
                    "title": "Source",
                    "description": "The NBT path to copy from.",
                    "type": "string"
                  },
                  "target": {
                    "title": "Target",
                    "description": "The NBT path to copy to, starting from the item's tag tag.",
                    "type": "string"
                  },
                  "op": {
                    "title": "Operation",
                    "description": "Can be replace to replace any existing contents of the target, append to append to a list, or merge to merge into a compound tag.",
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:copy_state"
            }
          }
        },
        "then": {
          "description": "Copies state properties from dropped block to the item's BlockStateTag tag.",
          "properties": {
            "block": {
              "title": "Block",
              "description": "A block ID. Function fails if the block doesn't match.",
              "type": "string"
            },
            "properties": {
              "title": "Properties",
              "description": "A list of property names to copy.",
              "type": "array",
              "items": {
                "title": "Property",
                "description": "A block state name to copy.",
                "type": "string"
              }
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:enchant_randomly"
            }
          }
        },
        "then": {
          "description": "Enchants the item with one randomly-selected enchantment. The level of the enchantment, if applicable, is random.",
          "properties": {
            "enchantments": {
              "title": "Enchantments",
              "description": "List of enchantment IDs to choose from.",
              "type": "array"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:enchant_with_levels"
            }
          }
        },
        "then": {
          "description": "Enchants the item, with the specified enchantment level (roughly equivalent to using an enchantment table at that level).",
          "properties": {
            "treasure": {
              "title": "Treasure",
              "description": "Determines whether treasure enchantments are allowed on this item.",
              "type": "boolean"
            },
            "levels": {
              "title": "Levels",
              "description": "Specifies the exact enchantment level to use.",
              "type": ["integer", "object"],
              "$ref": "#/definitions/numberProvider"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:exploration_map"
            }
          }
        },
        "then": {
          "description": "Converts an empty map into an explorer map leading to a nearby generated structure.",
          "properties": {
            "destination": {
              "title": "Destination",
              "description": "The type of generated structure to locate. Accepts any of the StructureTypes used by the /locate command (case insensitive).",
              "type": "string"
            },
            "decoration": {
              "title": "Decoration",
              "description": "The icon used to mark the destination on the map. Accepts any of the map icon text IDs (case insensitive).",
              "type": "string"
            },
            "zoom": {
              "title": "Zoom",
              "description": "The zoom level of the resulting map.",
              "type": "integer",
              "default": 2
            },
            "search_radius": {
              "title": "Search Radius",
              "description": "The size, in chunks, of the area to search for structures. The area checked is square, not circular.",
              "type": "integer",
              "default": 50
            },
            "skip_existing_chunks": {
              "title": "Skip Existing Chunks",
              "description": "Don't search in chunks that have already been generated.",
              "type": "boolean",
              "default": true
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:explosion_decay"
            }
          }
        },
        "then": {
          "description": "For loot tables of type 'block', removes some items from a stack, if there was an explosion. Each item has a chance of 1/explosion radius to be lost."
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:furnace_smelt"
            }
          }
        },
        "then": {
          "description": "Smelts the item as it would be in a furnace. Used in combination with the entity_properties condition to cook food from animals on death."
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:fill_player_head"
            }
          }
        },
        "then": {
          "description": "Adds required item tags of a player head.",
          "properties": {
            "entity": {
              "title": "Entity",
              "description": "Specifies an entity to be used for the player head.",
              "type": "string"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:limit_count"
            }
          }
        },
        "then": {
          "description": "Limits the count of every item stack.",
          "properties": {
            "limit": {
              "title": "Limit",
              "description": "Specifies the exact limit to use.",
              "type": ["integer", "object"],
              "$ref": "#/definitions/numberProvider",
              "properties": {
                "min": {
                  "title": "Minimum",
                  "description": "Minimum limit to use.",
                  "type": ["integer", "object"],
                  "$ref": "#/definitions/numberProvider"
                },
                "max": {
                  "title": "Max",
                  "description": "Max limit to use.",
                  "type": ["integer", "object"],
                  "$ref": "#/definitions/numberProvider"
                }
              }
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:looting_enchant"
            }
          }
        },
        "then": {
          "description": "Adjusts the stack size based on the level of the Looting enchantment on the killer entity.",
          "properties": {
            "count": {
              "title": "Count",
              "description": "Specifies the number of additional items per level of looting.",
              "type": ["integer", "object"],
              "$ref": "#/definitions/numberProvider"
            },
            "limit": {
              "title": "Limit",
              "description": "Specifies the maximum amount of items in the stack after the looting calculation. If the value is 0, no limit is applied.",
              "type": "integer"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_attributes"
            }
          }
        },
        "then": {
          "description": "Add attribute modifiers to the item.",
          "properties": {
            "modifiers": {
              "title": "Modifiers",
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "properties": {
                    "name": {
                      "title": "Name",
                      "description": "Name of the modifer.",
                      "type": "string"
                    },
                    "attribute": {
                      "title": "Attribute",
                      "description": "The name of the attribute this modifer is to act upon.",
                      "type": "string"
                    },
                    "operation": {
                      "title": "Operation",
                      "type": "string",
                      "enum": ["addition", "multiply_base", "multiply_total"]
                    },
                    "amount": {
                      "title": "Amount",
                      "description": "Specifies the amount of the modifier.",
                      "type": ["number", "object"],
                      "$ref": "#/definitions/numberProvider"
                    },
                    "id": {
                      "title": "ID",
                      "description": "UUID of the modifier following.",
                      "type": "string"
                    },
                    "slot": {
                      "title": "Slot",
                      "description": "Slots the item must be in for the modifier to take effect.",
                      "type": ["string", "array"],
                      "$ref": "#/definitions/slotEnum",
                      "items": {
                        "type": "string",
                        "$ref": "#/definitions/slotEnum"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_banner_pattern"
            }
          }
        },
        "then": {
          "description": "Sets tags needed for banner patterns.",
          "properties": {
            "patterns": {
              "title": "Patterns",
              "description": "List of patterns.",
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "pattern": {
                      "title": "Pattern",
                      "description": "The pattern type.",
                      "type": "string"
                    },
                    "color": {
                      "title": "Color",
                      "description": "The color for this pattern.",
                      "type": "string",
                      "enum": [
                        "white",
                        "orange",
                        "magenta",
                        "light_blue",
                        "yellow",
                        "lime",
                        "pink",
                        "gray",
                        "light_gray",
                        "cyan",
                        "purple",
                        "blue",
                        "brown",
                        "green",
                        "red",
                        "black"
                      ]
                    }
                  }
                }
              }
            },
            "append": {
              "title": "Append",
              "description": "If true, new patterns will be appended to existing ones.",
              "type": "boolean"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_contents"
            }
          }
        },
        "then": {
          "description": "For loot tables of type 'block', sets the contents of a container block item to a list of entries.",
          "properties": {
            "entries": {
              "title": "Entries",
              "description": "The entries to use as contents.",
              "type": "array"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_count"
            }
          }
        },
        "then": {
          "description": "Sets the stack size.",
          "properties": {
            "count": {
              "title": "Count",
              "description": "Specifies the stack size to set.",
              "type": ["integer", "object"],
              "$ref": "#/definitions/numberProvider"
            },
            "add": {
              "title": "Add",
              "description": "If true, change will be relative to the current count.",
              "type": "boolean"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_damage"
            }
          }
        },
        "then": {
          "description": "Sets the item's damage value (durability) for tools.",
          "properties": {
            "damage": {
              "title": "Damage",
              "description": "Specifies the damage fraction to set (1.0 is undamaged, 0.0 is zero durability left).",
              "type": ["number", "object"],
              "$ref": "#/definitions/numberProvider"
            },
            "add": {
              "title": "Add",
              "description": "If true, change will be relative to current damage.",
              "type": "boolean"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_enchantments"
            }
          }
        },
        "then": {
          "description": "Sets the item's enchantments.",
          "properties": {
            "enchantments": {
              "title": "Enchantments",
              "description": "Enchantments to add.",
              "type": "object",
              "additionalProperties": {
                "description": "Key name is the enchantment ID.",
                "type": ["integer", "object"],
                "$ref": "#/definitions/numberProvider"
              }
            },
            "add": {
              "title": "Add",
              "description": "If true, change will be relative to current level.",
              "type": "boolean"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_loot_table"
            }
          }
        },
        "then": {
          "description": "Sets the loot table for a container (chest etc.).",
          "properties": {
            "name": {
              "title": "Name",
              "description": "Specifies the resource location of the loot table to be used.",
              "type": "string"
            },
            "seed": {
              "title": "Seed",
              "description": "Specifies the loot table seed. If absent or set to 0, a random seed will be used.",
              "type": "integer"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_lore"
            }
          }
        },
        "then": {
          "description": "Adds lore to the item.",
          "properties": {
            "lore": {
              "title": "Lore",
              "description": "List of JSON text components. Each list entry represents one line of the lore. Advanced components are resolved only if entity successfully targets an entity.",
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            "entity": {
              "title": "Entity",
              "description": "Specifies the entity to act as the source @s in the JSON text component.",
              "type": "string"
            },
            "replace": {
              "title": "Replace",
              "description": "If true, replaces all existing lines of lore, if false appends the list.",
              "type": "boolean"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_name"
            }
          }
        },
        "then": {
          "description": "Adds display name of the item.",
          "properties": {
            "name": {
              "title": "Name",
              "description": "A JSON text component name, allowing color, translations, etc. Advanced components are resolved only if entity successfully targets an entity.",
              "type": ["array", "object", "string"]
            },
            "entity": {
              "title": "Entity",
              "description": "Specifies an entity to act as source @s in the JSON text component.",
              "type": "string"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_nbt"
            }
          }
        },
        "then": {
          "description": "Adds NBT data to the item.",
          "properties": {
            "tag": {
              "title": "Tag",
              "description": "Tag string to add, similar to those used by commands. Note that the first bracket is required and quotation marks need to be escaped using a backslash (\\).",
              "type": "string"
            }
          }
        }
      },
      {
        "if": {
          "properties": {
            "function": {
              "const": "minecraft:set_stew_effect"
            }
          }
        },
        "then": {
          "description": "Sets the status effects for suspicious stew.",
          "properties": {
            "effects": {
              "title": "Effects",
              "description": "The effects to apply.",
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "title": "Type",
                      "description": "The effect ID.",
                      "type": "string"
                    },
                    "duration": {
                      "title": "Duration",
                      "description": "The duration of the effect.",
                      "type": ["integer", "object"],
                      "$ref": "#/definitions/numberProvider"
                    }
                  }
                }
              }
            }
          }
        }
      }
    ]
  },
  "title": "Minecraft Data Pack Item Modifier",
  "type": "array"
}