onEvent('server.datapack.high_priority', (event) => {

    const pools = [
        {
            rolls: 2,
            entries: [
                {item: 'atum:coin_dirty', weight: 45, count: [1,3]},
                {item: 'atum:relic_dirty_ring', weight: 20},
                {item: 'atum:relic_dirty_necklace', weight: 15},
                {item: 'atum:relic_dirty_brooch', weight: 10},
                {item: 'atum:relic_dirty_bracelet', weight: 5},
                {item: 'atum:relic_dirty_idol', weight: 1},
                {item: 'atum:date', weight: 45, count: [1,2]},
                {item: 'atum:golden_date', weight: 1}
            ]
        },
        {
            rolls: [1,2],
            entries: [
                {item: 'atum:nebu_drop', weight: 10, count: [2,4]},
                {item: 'emendatusenigmatica:bronze_nugget', weight: 20, count: [2,4]},
                {item: 'emendatusenigmatica:brass_nugget', weight: 20, count: [2,4]},
                {item: 'emendatusenigmatica:constantan_nugget', weight: 20, count: [2,4]},
                {item: 'kubejs:holy_nugget', weight: 10, count: [2,4]}
            ]
        },
        {
            rolls: [1,2],
            entries: [
                {item: 'minecraft:rabbit_hide', weight: 20, count: [1,3]},
                {item: 'atum:wolf_pelt', weight: 20, count: [1,3]},
                {item: 'atum:mandibles', weight: 20, count: [1,2]},
                {item: 'atum:quail_egg', weight: 20, count: [1,2]},
                {item: 'atum:crunchy_scarab', weight: 20, count: [1,3]},
                {item: 'atum:crunchy_golden_scarab', weight: 1},
                {item: 'shrink:mob_bottle', nbt: '{entity:\"alexsmobs:komodo_dragon\"}', weight: 5}
            ]
        },
        {
            rolls: [0,1],
            entries: [
                {item: 'atum:iron_dagger', enchant: [30,60], weight: 10},
                {item: 'atum:dagger_poison', enchant: [30,60], weight: 10},
                {item: 'atum:iron_greatsword', enchant: [30,60], weight: 10},
                {item: 'atum:iron_club', enchant: [30,60], weight: 10},
                {item: 'atum:iron_khopesh', enchant: [30,60], weight: 10},
                {item: 'atum:desert_helmet_iron', enchant: [30,60], weight: 10},
                {item: 'atum:desert_chest_iron', enchant: [30,60], weight: 10},
                {item: 'atum:desert_legs_iron', enchant: [30,60], weight: 10},
                {item: 'atum:desert_boots_iron', enchant: [30,60], weight: 10},
                {item: 'atum:desert_wolf_iron_armor', weight: 5},
                {item: 'atum:camel_iron_armor', weight: 5},
                {item: 'minecraft:diamond_sword', enchant: [10,30], weight: 2},
                {item: 'minecraft:diamond_axe', enchant: [10,30], weight: 2},
                {item: 'naturesaura:sky_sword', enchant: [10,30], weight: 2},
                {item: 'naturesaura:sky_axe', enchant: [10,30], weight: 2},
                {item: 'atum:desert_helmet_diamond', enchant: [10,30], weight: 2},
                {item: 'atum:desert_chest_diamond', enchant: [10,30], weight: 2},
                {item: 'atum:desert_legs_diamond', enchant: [10,30], weight: 2},
                {item: 'atum:desert_boots_diamond', enchant: [10,30], weight: 2},
                {item: 'atum:desert_wolf_diamond_armor', weight: 1},
                {item: 'atum:camel_diamond_armor', weight: 1}
            ]
        },
        {
            rolls: 1,
            entries: [
                {item: 'atum:sand', weight: 1, count: [1,8]}
            ]
        }
    ];

    let loot_table = {
        type: 'minecraft:chest',
        pools: []
    };

    pools.forEach(pool => {
        let poolJson = {};
        poolJson.rolls = typeof pool.rolls === 'number'? pool.rolls : {min:pool.rolls[0],max:pool.rolls[1],type:'minecraft:uniform'};
        let entriesJson = [];
        pool.entries.forEach(entry => {
            let entryJson = {};
            entryJson.type = entry.type? entry.type : 'minecraft:item';
            entryJson.weight = entry.weight;
            entryJson.functions = [];
            if(entry.count){
                entryJson.functions.push({function:'minecraft:set_count',count:{min:entry.count[0],max:entry.count[1],type:'minecraft:uniform'}});
            }
            if(entry.enchant){
                entryJson.functions.push({function:'minecraft:enchant_with_levels',levels:{min:entry.enchant[0],max:entry.enchant[1]}});
            }
            if(entry.nbt){
                entryJson.functions.push({function:'minecraft:set_nbt',tag:entry.nbt});
            }
            entryJson.name = entry.item;
            entriesJson.push(entryJson);
        });
        poolJson.entries = entriesJson;
        loot_table.pools.push(poolJson);
    });

    event.addJson('atum:loot_tables/chests/pyramid_chest.json', loot_table);
});