onEvent('block.loot_tables', event => {
    ['iron', 'gold'].forEach(ore => {
        event.addBlock(`cavesandcliffs:deepslate_${ore}_ore`, table => {
            table.addPool(pool => {
                pool.rolls = 1
                pool.addEntry({
                    "type": "minecraft:alternatives",
                    "children": [{
                        "type": "minecraft:item",
                        "conditions": [{
                                "condition": "minecraft:match_tool",
                                "predicate": {
                                      "enchantments": [{
                                          "enchantment": "minecraft:silk_touch",
                                          "levels": {
                                            "min": 1
                                        }
                                    }]
                                }
                                  }],
                            "name": `cavesandcliffs:deepslate_${ore}_ore`
                        }]
                })
                pool.addEntry({
                    "type": "minecraft:item",
                    "functions": [{
                        "function": "minecraft:apply_bonus",
                        "enchantment": "minecraft:fortune",
                        "formula": "minecraft:ore_drops"
                        },
                        {
                            "function": "minecraft:explosion_decay"
                        }],
                    "name": `cavesandcliffs:raw_${ore}`
                })
            })
        })

        event.addBlock(`cavesandcliffs:${ore}_ore`, table => {
            table.addPool(pool => {
                pool.rolls = 1
                pool.addEntry({
                    "type": "minecraft:alternatives",
                    "children": [{
                        "type": "minecraft:item",
                        "conditions": [{
                                "condition": "minecraft:match_tool",
                                "predicate": {
                                      "enchantments": [{
                                          "enchantment": "minecraft:silk_touch",
                                          "levels": {
                                            "min": 1
                                        }
                                    }]
                                }
                                  }],
                            "name": `cavesandcliffs:${ore}_ore`
                        }]
                })
                pool.addEntry({
                    "type": "minecraft:item",
                    "functions": [{
                        "function": "minecraft:apply_bonus",
                        "enchantment": "minecraft:fortune",
                        "formula": "minecraft:ore_drops"
                        },
                        {
                            "function": "minecraft:explosion_decay"
                        }],
                    "name": `cavesandcliffs:raw_${ore}}`
                })
            })
        })
    })
})