// All enchantment handeling

onEvent("player.chest.opened", event => {
    let chestSize = event.inventory.getSize();
    console.info(`chest opened with size: ${chestSize}`);

    for (let slotIndex = 0; slotIndex < chestSize; slotIndex++){
        let currentItem = event.inventory.get(slotIndex);
        let currentItemEnchs = currentItem.getEnchantments();
        if (currentItem != "item.empty" && "forbidden_arcanus:indestructible" in currentItemEnchs) {
                console.info(`Found indestructible on ${currentItem}`);
                currentItem.enchant("forbidden_arcanus:indestructible", 0);
        }
    }   
})

onEvent("player.inventory.opened", event => {
    let chestSize = event.player.inventory.getSize();
    console.info(`chest opened with size: ${chestSize}`);

    for (let slotIndex = 0; slotIndex < chestSize; slotIndex++){
        let currentItem = event.player.inventory.get(slotIndex);
        let currentItemEnchs = currentItem.getEnchantments();
        if (currentItem != "item.empty" && "forbidden_arcanus:indestructible" in currentItemEnchs) {
                console.info(`Found indestructible on ${currentItem}`);
                currentItem.enchant("forbidden_arcanus:indestructible", 0);
        }
    }   
})
