function init(hero) {
    hero.addKeyBind("HEAT_VISION_HEATBLAST1", "Heat Blast", 1);

    hero.addKeyBind("AIM", "Aim", 1);
    hero.addKeyBind("HEAT_VISION", "Aim", 1); 

    hero.addDamageProfile("FLAME_PUNCH", {
        "types": {
            "BLUNT": 1.0,
            "FIRE": 0.6
        },
        "properties": {
            "HEAT_TRANSFER": 40,
            "IGNITE": 2
        }
    });

    hero.addAttributeProfile("HEATBLAST", profile => {
        profile.addAttribute("PUNCH_DAMAGE", 6.5, 0);
        profile.addAttribute("SPRINT_SPEED", 0.15, 1);
        profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
        profile.addAttribute("FALL_RESISTANCE", 0.65, 1);
    });

    hero.addAttributeProfile("HEATBLAST_STANDING", profile => {
        profile.addAttribute("PUNCH_DAMAGE", 3.5, 0);
        profile.addAttribute("BASE_SPEED", -2.0, 1);
        profile.addAttribute("JUMP_HEIGHT", -1.0, 0);
        profile.addAttribute("FALL_RESISTANCE", 0.65, 1);
    });
}

function tick(entity, manager, isCurrent) {
    if (!isCurrent) {
        return;
    }

    var nbt = entity.getWornChestplate().nbt();	
    var SL = nbt.getByte("heatblast");
    var PC1 = entity.getData('tmf:dyn/pc_1');
    var flight = entity.getData("fiskheroes:flying");

    if (PC1 == 1) {
        manager.setData(entity, 'tmf:dyn/pc_1', 0);
    }
    if (PC1 >= 0.85 && PC1 <= 0.9) {
        manager.setData(entity, 'fiskheroes:heat_vision', true);
    }
    if (PC1 >= 0.9) {
        manager.setData(entity, 'fiskheroes:heat_vision', false);
    }

    if (SL >= 15 && SL < 60 && PC1 >= 0.6) {
        manager.setData(entity, 'tmf:dyn/pc_1', 0);
    }

    if (flight) {
        if (PC1 >= 0.3) {
            manager.setData(entity, 'tmf:dyn/p_2', true);
        }
        if (entity.getData('tmf:dyn/p_2')) {
            manager.incrementData(entity, "tmf:dyn/pt_1", 7, Math.sqrt(Math.pow(entity.motionX(),2) + Math.pow(entity.motionZ(), 2)) > 0.35 ? 1 : 0 );
        }
    }
    if (!flight) {
        manager.setData(entity, 'tmf:dyn/p_2', false);
    }

    manager.incrementData(entity, "tmf:dyn/pt_3", 10, entity.isInWater() ? 1 : 0);
}

function getAttributeProfile(entity) {
    return entity.getData('tmf:dyn/pc_1') >= 0.6 ? "HEATBLAST_STANDING" : "HEATBLAST";
}

function getDamageProfile(entity) {
    return entity.getHeldItem().isEmpty() ? "FLAME_PUNCH" : null;
}

function isModifierEnabled(entity, modifier) {
    var nbt = entity.getWornChestplate().nbt();	
    var SL = nbt.getByte("heatblast");
    var PC1 = entity.getData('tmf:dyn/pc_1');
    var P2 = entity.getData('tmf:dyn/p_2');

    if (modifier.id() == "heatblast_1") {
        return  SL >= 0 && entity.getHeldItem().isEmpty() && !entity.getData("fiskheroes:flying");
    }
    if (modifier.id() == "heatblast_2") {
        return  SL >= 0 && PC1 == 0 && (entity.getHeldItem().isEmpty() && !entity.getData("fiskheroes:flying")) || (P2 == true && entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:flying"));
    }

    if (modifier.id() == "heatblast_3") {
        return  SL >= 15 && P2 == true;
    }

    if (modifier.id() == "heatblast_4") {
        return  (SL == 60 || PC1 >= 0.3) && P2 == false;
    }

    if (modifier.id() == "heatblast_5") {
        return  SL >= 15 && entity.getHeldItem().isEmpty();
    }
    if (modifier.id() == "heatblast_6") {
        return  SL == 60 && PC1 >= 0.85;
    }

    return true;
}

function isKeyBindEnabled(entity, keyBind) {
    var nbt = entity.getWornChestplate().nbt();	
    var SL = nbt.getByte("heatblast");
    var PC1 = entity.getData('tmf:dyn/pc_1');
    var P2 = entity.getData('tmf:dyn/p_2');
    var flight = entity.getData("fiskheroes:flying");

    if (keyBind == "HEAT_VISION_HEATBLAST1") {
        return SL >= 0 && PC1 == 0 && !flight;
    }
    
    if (keyBind == "AIM") {
        return SL >= 0 && PC1 == 0 && !flight;
    }
    if (keyBind == "HEAT_VISION") {
        return SL >= 0 && PC1 == 0 && (!flight) || (P2 == true && entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:flying"));
    }

    return false;
}

function hasProperty(entity, property) {
    return false;
}

function canAim(entity) {
    var PC1 = entity.getData('tmf:dyn/pc_1');
    var P2 = entity.getData('tmf:dyn/p_2');
    return (entity.getHeldItem().isEmpty() && !entity.getData("fiskheroes:flying") && entity.getData('tmf:dyn/pc_1') == 0) || (P2 == true && entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:flying") && PC1 == 0);
}

function getDefaultScale(entity) {
    return 0.96;
}

function getTierOverride(entity) {
    return 6;
}
