import { TicksPerSecond } from "@minecraft/server";
import * as Vector3Utils from "../U/Vector3Utils";
import { griffinArmorConfig } from "../DATA/ArmorConfig";
let playerWasJumping = new Map();
let playerWasOnGround = new Map();
export async function doubleJump(player) {
    if (player.isJumping && playerWasJumping.get(player.id) === false) {
        triggerJump(player, playerWasOnGround.get(player.id));
    }
    if (player.isOnGround && playerWasOnGround.get(player.id) === false) {
        landingReset(player);
    }
    playerWasJumping.set(player.id, player.isJumping);
    playerWasOnGround.set(player.id, player.isOnGround);
}
function triggerJump(source, wasOnGround) {
    try {
        const hasDoubleJumped = source.getDynamicProperty(`kicu_mmad:doubleJumpCount`) ?? false;
        if (hasDoubleJumped === false) {
            if (!wasOnGround && !source.isOnGround) {
                source.dimension.spawnParticle("kicu_mmad:double_jump_particle", source.location);
                source.playSound(griffinArmorConfig.soundEffect.sound);
                source.setDynamicProperty(`kicu_mmad:doubleJumpCount`, true);
                const velocity = source.getVelocity();
                const horizontalVelocity = Vector3Utils.magnitude({ x: velocity.x, y: 0, z: velocity.z });
                source.applyKnockback(velocity.x, velocity.z, horizontalVelocity * griffinArmorConfig.horizontalStrengthModifier, griffinArmorConfig.verticalStrength);
                source.addEffect("slow_falling", griffinArmorConfig.slowFallDuration * TicksPerSecond, {
                    showParticles: false,
                });
            }
        }
    }
    catch { }
}
function landingReset(source) {
    source.setDynamicProperty(`kicu_mmad:doubleJumpCount`, false);
}

//# sourceMappingURL=../../../../../_KiCuMountsBPDebug/kicu/mmad/A/GriffinArmour.js.map
