ForgeEvents.onEvent(
    "net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent",
    (event) => {
        global.equipmentChangeEvent(event);
    }
);

global.equipmentChangeEvent = (event) => {
    try {
        let player = event.getEntity(); // First we get the entity as a variable
        if (!player.isPlayer()) return; // if its not a player, we return

        let pE = player.potionEffects; // get the player's potion effects
        let armorSlot = event.getSlot(); // This only returns ARMOR for some reason

        let helmet = player.getArmorSlots().get(3); // get the helmet slot

        if (armorSlot.type == "ARMOR") {
            if (helmet.id == "seadwellers:depth_helmet") {
                // player add(effect, duration, amplifier, ambient, particles)
                pE.add("alexscaves:deepsight", -1, 0, true, false);
            } else {
                if (pE.isActive("alexscaves:deepsight")) {
                    let deepSight = pE.getActive("alexscaves:deepsight");
                    if (deepSight) {
                        player.removeEffect("alexscaves:deepsight");
                    }
                }
            }
        }
    } catch (e) {
        console.log(e);
    }
};
