function init(hero) {

    hero.setName("Yellow Lantern");

    hero.setTier(8);

    

    hero.setChestplate("Fear Ring");

    

    hero.addPowers("ahhp:fear");

    hero.addAttribute("PUNCH_DAMAGE", 9.0, 0);

    hero.addAttribute("JUMP_HEIGHT", 1.0, 0);

    hero.addAttribute("FALL_RESISTANCE", 50.0, 1);

    hero.addAttribute("SPRINT_SPEED", 1.25, 1);

    hero.addAttribute("IMPACT_DAMAGE", 0.3, 1);

    

    hero.addKeyBind("AIM", "key.aim", 1);

    hero.addKeyBind("LANTERN_HAMMER", "Light Construct", 2);

    hero.addKeyBind("SHIELD", "Light Forcefield", 3);

    hero.addKeyBind("TELEKINESIS", "Light Grab", 4);

    hero.addKeyBindFunc("func_AURA_TOGGLE", auraToggle, "Toggle Aura", 5);

    hero.addKeyBind("LANTERN_TRANSFORM", "Suit Manifestation", 5);

    

    hero.setModifierEnabled(isModifierEnabled);

    hero.addAttributeProfile("INACTIVE", inactiveProfile);

    hero.addAttributeProfile("LANTERNHAMMER", lanternhammerProfile);

    hero.addAttributeProfile("SHIELD", shieldProfile);

    hero.setAttributeProfile(getAttributeProfile);

    hero.setTierOverride(getTierOverride);

    hero.setKeyBindEnabled(isKeyBindEnabled);

    hero.setHasProperty(hasProperty);

    hero.supplyFunction("canAim", canAim);

    hero.setTickHandler((entity, manager) => {

        if (entity.motionY() < -0.6 && !entity.isSneaking() && !entity.isOnGround() && !entity.world().blockAt(entity.pos().add(0, -3, 0)).isSolid()) {

            manager.setData(entity, "fiskheroes:flying", true);

        };

        var t = entity.getData("fiskheroes:dyn/superhero_landing_ticks");

    if (t == 0 && !entity.isSprinting() && !entity.isOnGround() && entity.motionY() < -1.25 && entity.getData("fiskheroes:flight_boost_timer") > 0 && entity.world().blockAt(entity.pos().add(0, -2, 0)).isSolid()) {
        manager.setDataWithNotify(entity, "fiskheroes:dyn/superhero_landing_ticks", t = 12);
        entity.playSound("ahhp:suit.groundsmash", 1, 1.15 - Math.random() * 0.3);
    }
    else if (t > 0) {
        manager.setData(entity, "fiskheroes:dyn/superhero_landing_ticks", --t);
    }

    manager.incrementData(entity, "fiskheroes:dyn/superhero_landing_timer", 2, 8, t > 0);
        
    });

    hero.addSoundEvent("AIM_START", "ahhp:lantern_blast");

}



function auraToggle(player, manager) {

    manager.setData(player, "ahhp:dyn/lantern_aura", player.getData("ahhp:dyn/lantern_aura") + 1);

    if (player.getData("ahhp:dyn/lantern_aura") > 1) {

        manager.setData(player, "ahhp:dyn/lantern_aura", 0);

    }

    return true;

}



function hasProperty(entity, property) {

    switch (property) {

    case "BREATHE_SPACE":

        return entity.getData("ahhp:dyn/lantern") && !entity.getData("fiskheroes:mask_open");

    case "MASK_TOGGLE":

        return entity.getData("ahhp:dyn/lantern");

    default:

        return false;

    }

}



function canAim(entity) {

    return entity.getHeldItem().isEmpty() && !entity.getData("ahhp:dyn/lanternhammer");

}



function getTierOverride(entity) {

    return entity.getData("ahhp:dyn/lantern") ? 8 : 0;

}



function inactiveProfile(profile) {
}



function lanternhammerProfile(profile) {

    profile.addAttribute("PUNCH_DAMAGE", 11.0, 0);

    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);

    profile.addAttribute("FALL_RESISTANCE", 8.5, 0);

    profile.addAttribute("SPRINT_SPEED", 0.25, 1);

    profile.addAttribute("IMPACT_DAMAGE", 0.5, 1);

}



function shieldProfile(profile) {

    profile.inheritDefaults();

    profile.addAttribute("SPRINT_SPEED", -1.5, 1);

    profile.addAttribute("JUMP_HEIGHT", -10.0, 1);

}



function getAttributeProfile(entity) {

    if (entity.getData("fiskheroes:shield_blocking")) {

        return "SHIELD";

    }

    if (entity.getData("ahhp:dyn/lanternhammer")) {

        return "LANTERNHAMMER";

    }

    return entity.getData("ahhp:dyn/lantern") ? null : "INACTIVE";

}



function isModifierEnabled(entity, modifier) {

    if (modifier.name() != "fiskheroes:transformation" && modifier.name() != "fiskheroes:cooldown" && (!entity.getData("ahhp:dyn/lantern") || modifier.name() == "fiskheroes:controlled_flight" && entity.getData("ahhp:dyn/lantern_timer") < 1)) {

        return false;

    }

    switch (modifier.name()) {

    case "fiskheroes:energy_bolt":

        return entity.getData("fiskheroes:aimed_timer") >= 1;

    case "ahhp:dyn/lanternhammer":

        return entity.getData("ahhp:dyn/lantern") && !entity.getData("fiskheroes:aiming") && !entity.getData("fiskheroes:shield") && entity.getData("fiskheroes:flight_boost_timer") == 0;

    case "fiskheroes:shield":

        return !entity.getData("fiskheroes:aiming") && !entity.getData("ahhp:dyn/lanternhammer") && entity.getData("fiskheroes:flight_boost_timer") == 0;

    case "fiskheroes:regeneration":

        return !entity.getData("ahhp:dyn/lanternhammer");

    case "fiskheroes:telekinesis":

        return entity.getData("ahhp:dyn/lantern") && !entity.getData("fiskheroes:aiming") && !entity.getData("fiskheroes:shield") && entity.getData("fiskheroes:flight_boost_timer") == 0;

    default:

        return true;

    }

}



function isKeyBindEnabled(entity, keyBind) {

    switch (keyBind) {

        case "LANTERN_HAMMER":

            return (entity.getData("ahhp:dyn/lantern")) && (entity.getData("fiskheroes:flight_boost_timer") == 0) && (!entity.getData("fiskheroes:telekinesis")) && (!entity.getData("fiskheroes:shield")) && !entity.getData("fiskheroes:aiming");

        case "SHIELD":

            return (entity.getData("ahhp:dyn/lantern")) && (!entity.getData("ahhp:dyn/lanternhammer")) && (entity.getData("fiskheroes:flight_boost_timer") == 0) && !entity.getData("fiskheroes:aiming") && (!entity.getData("fiskheroes:telekinesis"));

        case "TELEKINESIS":

            return (entity.getData("ahhp:dyn/lantern")) && (!entity.getData("fiskheroes:shield")) && (!entity.getData("ahhp:dyn/lanternhammer")) && (entity.getData("fiskheroes:flight_boost_timer") == 0) && !entity.getData("fiskheroes:aiming");

        case "AIM":

            return (entity.getData("ahhp:dyn/lantern")) && (!entity.getData("fiskheroes:shield")) && (!entity.getData("ahhp:dyn/lanternhammer")) && (entity.getData("fiskheroes:flight_boost_timer") == 0) && (!entity.getData("fiskheroes:telekinesis"));
        
        case "LANTERN_TRANSFORM":

            return (entity.getData("ahhp:dyn/lantern") && entity.isSneaking()) || !entity.getData("ahhp:dyn/lantern");
        
        case "func_AURA_TOGGLE":

            return entity.getData("ahhp:dyn/lantern") && !entity.isSneaking();
        
        default:

            return true;

    }

}