{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "title": "Loot Table",
    "description": "Schema for loot tables in Minecraf Add-Ons",
    "definitions": {
        "conditions": {
            "type": "array",
            "title": "Conditions",
            "description": "Types of conditions that cause loot tables to activate",
            "items": {
                "type": "object",
                "properties": {
                    "condition": {
                        "type": "string",
                        "title": "Condition",
                        "description": "Condition that triggers loot"
                    },
                    "default_chance": {
                        "type": "number",
                        "title": "Default Chance",
                        "description": "Chance of loot in default difficulty"
                    },
                    "peaceful": {
                        "type": "number",
                        "title": "Peaceful Chance",
                        "description": "Chance of loot in peaceful difficulty"
                    },
                    "hard": {
                        "type": "number",
                        "title": "Hard Chance",
                        "description": "Chance of loot in hard difficulty"
                    }
                },
                "required": [
                    "condition",
                    "default_chance",
                    "peaceful",
                    "hard"
                ]
            }
        },
        "rolls": {
            "type": [
                "array",
                "integer"
            ],
            "title": "Rolls",
            "description": "Unkown/either one number or array of 'min' and 'max'"
        },
        "pools": {
            "type": "array",
            "title": "Pools",
            "items": {
                "type": "object",
                "properties": {
                    "rolls": {
                        "$ref": "#/definitions/rolls"
                    },
                    "entries": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "type": {
                                    "type": "string",
                                    "title": "Type",
                                    "description": "Type of loot"
                                },
                                "name": {
                                    "type": "string",
                                    "title": "Name",
                                    "description": "Name of loot in 'minecraft:x' format"
                                },
                                "weight": {
                                    "type": "integer",
                                    "title": "Weight",
                                    "description": "Weight of loot"
                                },
                                "pools": {
                                    "$ref": "#/definitions/pools"
                                },
                                "functions": {
                                    "type": "array",
                                    "title": "Functions",
                                    "description": "Holds functions for loot",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "function": {
                                                "type": "string",
                                                "title": "Function",
                                                "description": "Name of function used"
                                            },
                                            "count": {
                                                "type": "object",
                                                "title": "Count",
                                                "properties": {
                                                    "min": {
                                                        "type": "integer",
                                                        "title": "Minimum"
                                                    },
                                                    "max": {
                                                        "type": "integer",
                                                        "title": "Maximum"
                                                    }
                                                },
                                                "required": [
                                                    "min",
                                                    "max"
                                                ]
                                            }
                                        },
                                        "required": [
                                            "function",
                                            "count"
                                        ]
                                    }
                                }
                            },
                            "required": [
                                "type",
                                "name"
                            ]
                        }
                    }
                },
                "conditions": {
                    "$ref": "#/definitions/conditions"
                },
                "required": [
                    "rolls"
                ]
            }
        }
    },
    "properties": {
        "pools": {
            "$ref": "#/definitions/pools"
        }
    }
}