removeAdvancement([
    'lootr:root',
    "betterdungeons:skeleton_dungeon",
    "betterdungeons:small_nether_dungeon",
    "betterdungeons:small_dungeon",
    "betterdungeons:zombie_dungeon",
    "betterdungeons:spider_dungeon",
    "betterdungeons:all_dungeons",
    "betterdungeons:root",
    "betterdeserttemples:root",
    "betterdeserttemples:temple_entry",
    "betterdeserttemples:temple_clear"
]);

/**
 * Borrowed from Mriya, made by mortuusars
 * @param {String | Array} advancement
 */
function removeAdvancement(advancement) {
    let arr = []
    if (typeof (advancement) == 'string') arr = [advancement]
    else if (typeof (advancement) == 'object') arr = advancement
    else console.error(`Invalid type for removeAdvancement(${advancement})`)

    ServerEvents.highPriorityData(e => {
        e.addJson('kubejs:advancements/removed', {
            display: { hidden: true },
        });
        arr.forEach(advancement => {
            let advSplit = advancement.split(':');
            let advModId = advSplit[0];
            let advName = advSplit[1];

            e.addJson(`${advModId}:advancements/${advName}.json`, {
                parent: 'kubejs:advancements/removed',
                display: { hidden: true },
                criteria: {
                    impossible: {
                        trigger: 'minecraft:impossible'
                    }
                },
                requirements: [['impossible']]
            });
        });
    });
};

ServerEvents.lowPriorityData(event => {
    event.addJson('kubejs:advancements/endgame/root.json', {
        "criteria": {
            "enigmatic_item": {
                "conditions": {
                    "items": [
                        {
                            "items": [
                                "enigmaticlegacy:enigmatic_item"
                            ]
                        }
                    ]
                },
                "trigger": "minecraft:inventory_changed"
            }
        },
        "display": {
            "announce_to_chat": true,
            "background": "kubejs:textures/gui/advancements/backgrounds/endgame.png",
            "description": {
                "translate": "advancements.kubejs.endgame.root.description"
            },
            "frame": "goal",
            "hidden": true,
            "icon": {
                "item": "enigmaticlegacy:enigmatic_item"
            },
            "show_toast": true,
            "title": {
                "translate": "advancements.kubejs.endgame.root.title"
            }
        },
        "requirements": [
            [
                "enigmatic_item"
            ]
        ],
        "sends_telemetry_event": true
    });
})