{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/minecraft-loot-table.json",
  "$comment": "https://minecraft.wiki/w/Loot_table",
  "definitions": {
    "numberProvider": {
      "$comment": "https://minecraft.wiki/w/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": {
                "$ref": "#/definitions/numberProvider",
                "title": "Minimum",
                "description": "The minimum value.",
                "type": ["number", "object"]
              },
              "max": {
                "$ref": "#/definitions/numberProvider",
                "title": "Max",
                "description": "The maximum value.",
                "type": ["number", "object"]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "minecraft:binomial"
              }
            }
          },
          "then": {
            "description": "A random number following a binomial distribution.",
            "properties": {
              "n": {
                "$ref": "#/definitions/numberProvider",
                "title": "n",
                "description": "The amount of trials.",
                "type": ["integer", "object"]
              },
              "p": {
                "$ref": "#/definitions/numberProvider",
                "title": "p",
                "description": "The probability of success on an individual trial."
              }
            }
          }
        },
        {
          "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 a loot table for a data pack for Minecraft.",
  "properties": {
    "type": {
      "title": "Type",
      "type": "string",
      "enum": [
        "minecraft:empty",
        "empty",
        "minecraft:entity",
        "entity",
        "minecraft:block",
        "block",
        "minecraft:chest",
        "chest",
        "minecraft:fishing",
        "fishing",
        "minecraft:gift",
        "gift",
        "minecraft:advancement_reward",
        "advancement_reward",
        "minecraft:barter",
        "barter",
        "minecraft:command",
        "command",
        "minecraft:selector",
        "selector",
        "minecraft:advancement_entity",
        "advancement_entity",
        "minecraft:generic",
        "generic"
      ]
    },
    "functions": {
      "title": "Functions",
      "description": " Applies functions to all item stacks produced by this table. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.",
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": {
          "description": "A function.",
          "type": "object",
          "properties": {
            "function": {
              "title": "Function",
              "description": "Namespaced ID of the function to apply.",
              "type": "string"
            },
            "conditions": {
              "title": "Conditions",
              "description": "Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.",
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": {
                  "description": "A function.",
                  "type": "object",
                  "properties": {
                    "condition": {
                      "title": "Condition",
                      "description": "Namespaced ID of condition.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "pools": {
      "title": "Pools",
      "description": "A list of all pools for this loot table. Each pool used generates items from its list of items based on the number of rolls. Pools are applied in order.",
      "type": "array",
      "items": {
        "description": "A pool.",
        "type": "object",
        "properties": {
          "conditions": {
            "title": "Conditions",
            "description": "Determines conditions for this pool to be used. If multiple conditions are specified, all must pass.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "description": "A condition.",
                "properties": {
                  "condition": {
                    "title": "Condition",
                    "description": "Namespaced ID of condition.",
                    "type": "string"
                  }
                }
              }
            }
          },
          "functions": {
            "title": "Functions",
            "description": "Applies functions to all item stacks produced by this pool. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "description": "A function.",
                "properties": {
                  "function": {
                    "title": "Function",
                    "description": "Namespaced ID of the function to apply.",
                    "type": "string"
                  },
                  "conditions": {
                    "title": "Conditions",
                    "description": "Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.",
                    "type": "array",
                    "items": {
                      "description": "A condition.",
                      "type": "object",
                      "properties": {
                        "condition": {
                          "title": "Condition",
                          "description": "Namespaced ID of condition.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "rolls": {
            "$ref": "#/definitions/numberProvider",
            "title": "Rolls",
            "description": "Specifies the number of rolls on the pool.",
            "type": ["integer", "object"]
          },
          "bonus_rolls": {
            "$ref": "#/definitions/numberProvider",
            "title": "Bonus Rolls",
            "description": "Specifies the number of bonus rolls on the pool per point of luck. Rounded down after multiplying.",
            "type": ["number", "object"]
          },
          "entries": {
            "title": "Entries",
            "description": "A list of all things that can be produced by this pool. One entry is chosen per roll as a weighted random selection from all entries without failing conditions.",
            "type": "array",
            "items": {
              "description": "An entry.",
              "type": "object",
              "properties": {
                "conditions": {
                  "title": "Conditions",
                  "description": "Determines conditions for this entry to be used. If multiple conditions are specified, all must pass.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": {
                      "description": "A condition.",
                      "properties": {
                        "condition": {
                          "title": "Condition",
                          "description": "Namespaced ID of condition.",
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "functions": {
                  "title": "Functions",
                  "description": "Applies functions to the item stack or item stacks being produced. Functions are applied in order, so for example looting_enchant must be after set_count to work correctly.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": {
                      "description": "A function.",
                      "properties": {
                        "function": {
                          "title": "Function",
                          "description": "Namespaced ID of the function to apply.",
                          "type": "string"
                        },
                        "conditions": {
                          "title": "Conditions",
                          "description": "Determines conditions for this function to be applied. If multiple conditions are specified, all must pass.",
                          "type": "array",
                          "items": {
                            "description": "A condition.",
                            "type": "object",
                            "properties": {
                              "condition": {
                                "title": "Condition",
                                "description": "Namespaced ID of condition.",
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "type": {
                  "title": "Type",
                  "description": "Namespaced ID type of entry.",
                  "type": "string",
                  "enum": [
                    "minecraft:item",
                    "minecraft:tag",
                    "minecraft:loot_table",
                    "minecraft:group",
                    "minecraft:alternatives",
                    "minecraft:sequence",
                    "minecraft:dynamic",
                    "minecraft:empty"
                  ]
                },
                "name": {
                  "title": "Name",
                  "type": "string"
                },
                "children": {
                  "title": "Children",
                  "type": "array"
                },
                "expand": {
                  "title": "Expand",
                  "description": "For type 'tag', if set to true, it chooses one item of the tag, each with the same weight and quality. If false, it generates one of each of the items in the tag.",
                  "type": "boolean"
                },
                "weight": {
                  "title": "Weight",
                  "description": "Determines how often this entry is chosen out of all the entries in the pool. Entries with higher weights are used more often (chance is this entry's weight⁄total of all considered entries' weights).",
                  "type": "integer"
                },
                "quality": {
                  "title": "Quality",
                  "description": "Modifies the entry's weight based on the killing/opening/fishing player's luck attribute. Formula is floor( weight + (quality * generic.luck)).",
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  },
  "title": "Minecraft Data Pack Loot Table"
}
