loadTextures({
    "base": "gowhp:odin/gungnir_closed",
    "open": "gowhp:odin/gungnir_open"
});

var utils = implement("fisktag:external/utils");
var gungnir_open = implement("gowhp:external/gungnir_open");
var gungnir_bifrost = implement("gowhp:external/gungnir_bifrost");

var model;
var lines;

function init(renderer) {
    model = utils.createModel(renderer, "gowhp:gungnir_open", "base");
    renderer.setModel(model);
    utils.addPlayerAnimationWithData(renderer, "fisktag:dual_hand", "fiskheroes:aiming_timer");

    utils.addPlayerAnimation(renderer, "gowhp:sprint_kratos")
        .setData((entity, data) => data.load(1.0))
        .setCondition(entity => (entity.isSprinting()));

    lines = gungnir_bifrost.create(renderer, "gowhp:bifrost", 0x651adf, [
        {"start": [-1.0, 8.3, -34.0], "end": [-1.0, 9.0, -46.6], "size": [15.0, 15.0]},
        {"start": [-1.0, 9.7, -34.0], "end": [-1.0, 9.0, -46.6], "size": [15.0, 15.0]}
    ]);
    lines.effect.setOffset(0, 11, -9);
}

function render(renderer, entity, glProxy, renderType, isLeftSide) {
    if (renderType === "EQUIPPED_FIRST_PERSON") {
        glProxy.translate(0.0, 1.5, 0.0);
    }
    if (renderType === "ENTITY") {
        glProxy.translate(0.0, -2.7, 0.00);
        glProxy.scale(1.0);
    }
    if (renderType === "INVENTORY") {
        glProxy.translate(0.0, 0.0, -0.05);
        glProxy.scale(0.5);
    }
    glProxy.translate(0.0, -0.6, -0.1);
    glProxy.rotate(90.0, 0.0, 1.0, 0.0);
    glProxy.scale(1.0);
    gungnir_open.setGungnirOpenTexture(entity, model.texture, true);

    if (renderType === "EQUIPPED" || renderType === "EQUIPPED_FIRST_PERSON") {
        lines.render(entity.getData("gowhp:dyn/gungnirblade"));
    }
}
