

PalladiumEvents.registerGuiOverlays((event) => {
    event.register(
        // ID for the overlay
        'arrzenhanced:speedster_speed',
        // Function for rendering
        (minecraft, gui, poseStack, partialTick, screenWidth, screenHeight) => {
            if (abilityUtil.hasPower(minecraft.player, 'arrzenhanced:speedster')) {        
                
                    let username = minecraft.player.getGameProfile().getName();
                    let value = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("arrz.speedburst.speed")).getScore();
                    let value_max = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("arrz.speedburst.speed_max")).getScore();
                    

                // Drawing text. Parameters: PoseStack, Text (as text component), X, Y, Color
                guiUtil.drawString(poseStack, Component.string("speed: " + value + "/" + ((value_max + 1))), 10, 20, 0xffdc00);

            }
        });
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/summon_lightning1', 1, (builder) => {
        
    if (abilityUtil.isEnabled(builder.getPlayer(), "arrzenhanced:speedster", "summon_sword")) {

        const progress_sum1 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:speedster', 'summon_sword', builder.getPartialTicks(), 1, 6);
        if (progress_sum1 > 0 && !builder.isFirstPerson()) {

        builder.get('right_arm')
            .setXRotDegrees(-90)
            .setYRotDegrees(-30.5)
            .setZRotDegrees(85)
            .animate('InOutCubic', progress_sum1);

        builder.get('left_arm')
            .setXRotDegrees(-90)
            .setYRotDegrees(30.5)
            .setZRotDegrees(-85)
            .animate('InOutCubic', progress_sum1);
    }
    if (progress_sum1 > 0.0 && builder.isFirstPerson()) {
                builder.get('right_arm')
                .setZRotDegrees(-45)
                .animate('InOutCubic', progress_sum1);

                builder.get('left_arm')
                .setZRotDegrees(45)
                .animate('InOutCubic', progress_sum1);
            }


        }
    });
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/summon_lightning2', 1, (builder) => {

        const progress_sum2 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:speedster', 'summon_sword', builder.getPartialTicks(), 5, 16);
        if (progress_sum2 > 0 && !builder.isFirstPerson()) {

            builder.get('right_arm')
            .setXRotDegrees(-90)
            .setYRotDegrees(40.5)
            .setZRotDegrees(-16.5)
            .animate('InOutCubic', progress_sum2);

        builder.get('left_arm')
            .setXRotDegrees(-90)
            .setYRotDegrees(-40.5)
            .setZRotDegrees(16.5)
            .animate('InOutCubic', progress_sum2);
    }


    });
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/tachyon_frontflip1', 1, (builder) => {
        
    if (abilityUtil.isEnabled(builder.getPlayer(), "arrzenhanced:tachyon_speedburst_armor", "frontflip_anim")) {

        const progress_frontflip1 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:tachyon_speedburst_armor', 'frontflip_anim', builder.getPartialTicks(), 1, 2);
        if (progress_frontflip1 > 0 && !builder.isFirstPerson()) {
            builder.get('body')
            .setXRotDegrees(-55)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .setY(10)
            .setZ(15)
            .animate('Linear', progress_frontflip1);
            
            builder.get('left_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(5)
            .setYRotDegrees(20)
            .animate('Linear', progress_frontflip1);

            builder.get('right_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(-5)
            .setYRotDegrees(-20)
            .animate('Linear', progress_frontflip1);

            builder.get('left_leg')
            .setXRotDegrees(-70)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip1);

            builder.get('right_leg')
            .setXRotDegrees(-80)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip1);
    }
    if (progress_frontflip1 > 0.0 && builder.isFirstPerson()) {
            }
        }
    });
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/tachyon_frontflip2', 1, (builder) => {
        
    if (abilityUtil.isEnabled(builder.getPlayer(), "arrzenhanced:tachyon_speedburst_armor", "frontflip_anim")) {

        const progress_frontflip2 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:tachyon_speedburst_armor', 'frontflip_anim', builder.getPartialTicks(), 2, 4);
        if (progress_frontflip2 > 0 && !builder.isFirstPerson()) {
            builder.get('body')
            .setXRotDegrees(-125)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .setY(25)
            .setZ(15)
            .animate('Linear', progress_frontflip2);
            
            builder.get('left_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(5)
            .setYRotDegrees(20)
            .animate('Linear', progress_frontflip2);

            builder.get('right_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(-5)
            .setYRotDegrees(-20)
            .animate('Linear', progress_frontflip2);

            builder.get('left_leg')
            .setXRotDegrees(-70)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip2);

            builder.get('right_leg')
            .setXRotDegrees(-80)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip2);

         }
         if (progress_frontflip2 > 0.0 && builder.isFirstPerson()) {
            }
    }});
});
                 
PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/tachyon_frontflip3', 1, (builder) => {
        
    if (abilityUtil.isEnabled(builder.getPlayer(), "arrzenhanced:tachyon_speedburst_armor", "frontflip_anim")) {

        const progress_frontflip3 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:tachyon_speedburst_armor', 'frontflip_anim', builder.getPartialTicks(), 4, 6);
        if (progress_frontflip3 > 0 && !builder.isFirstPerson()) {
            builder.get('body')
            .setXRotDegrees(-205)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .setY(30)
            .setZ(-5)
            .animate('Linear', progress_frontflip3);
            
            builder.get('left_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(5)
            .setYRotDegrees(20)
            .animate('Linear', progress_frontflip3);

            builder.get('right_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(-5)
            .setYRotDegrees(-20)
            .animate('Linear', progress_frontflip3);

            builder.get('left_leg')
            .setXRotDegrees(-70)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip3);

            builder.get('right_leg')
            .setXRotDegrees(-80)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip3);

         }
         if (progress_frontflip3 > 0.0 && builder.isFirstPerson()) {
        }
    }});
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/tachyon_frontflip4', 1, (builder) => {

        const progress_frontflip4 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:tachyon_speedburst_armor', 'frontflip_anim', builder.getPartialTicks(), 6, 9);
        if (progress_frontflip4 > 0 && !builder.isFirstPerson()) {
            builder.get('body')
            .setXRotDegrees(-275)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .setY(10)
            .setZ(-15)
            .animate('Linear', progress_frontflip4);
            
            builder.get('left_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(5)
            .setYRotDegrees(20)
            .animate('Linear', progress_frontflip4);

            builder.get('right_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(-5)
            .setYRotDegrees(-20)
            .animate('Linear', progress_frontflip4);

            builder.get('left_leg')
            .setXRotDegrees(-70)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip4);

            builder.get('right_leg')
            .setXRotDegrees(-80)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip4);

         }
         if (progress_frontflip4 > 0.0 && builder.isFirstPerson()) {
    }});
});

PalladiumEvents.registerAnimations((event) => {
    event.register('arrzee/tachyon_frontflip5', 1, (builder) => {

        const progress_frontflip5 = animationUtil.getAnimationTimerAbilityValue(builder.getPlayer(), 'arrzenhanced:tachyon_speedburst_armor', 'frontflip_anim', builder.getPartialTicks(), 9, 12);
        if (progress_frontflip5 > 0 && !builder.isFirstPerson()) {
            builder.get('body')
            .setXRotDegrees(-360)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .setY(-5)
            .setZ(0)
            .animate('Linear', progress_frontflip5);
            
            builder.get('left_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(5)
            .setYRotDegrees(20)
            .animate('Linear', progress_frontflip5);

            builder.get('right_arm')
            .setXRotDegrees(-50)
            .setZRotDegrees(-5)
            .setYRotDegrees(-20)
            .animate('Linear', progress_frontflip5);

            builder.get('left_leg')
            .setXRotDegrees(-70)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip5);

            builder.get('right_leg')
            .setXRotDegrees(-80)
            .setZRotDegrees(0)
            .setYRotDegrees(0)
            .animate('Linear', progress_frontflip5);

         }
         if (progress_frontflip5 > 0.0 && builder.isFirstPerson()) {
        }});
});