import { ItemStack } from "@minecraft/server";
import shootProjectile from "modules/class/projectile";
import { createFreezeShockWave, createLightningShockWave, createPoisonShockWave, } from "./shockwave";
import { emitDynamicLight } from "modules/helper/emitDynamicLight";
import { applyEffect } from "modules/class/effects/effectsManager";
import { webbedEffect } from "./effects";
export const shootFreezeArrow = (player) => {
    shootProjectile(player, {
        projectileID: "cc:fire_bolt",
        power: 2,
        gravity: 0.03,
        spawnDistance: {
            x: 0,
            y: 0,
            z: 0.5,
        },
        onHitBlock: {
            particles: ["minecraft:flame"],
            function: (block) => {
                createFreezeShockWave(block.above());
            },
        },
        onHitEntity: {
            particles: ["minecraft:flame"],
            effect: {
                id: "minecraft:slowness",
                duration: 10,
            },
            knockback: 5,
            damage: 3,
            function: (entity) => {
                createFreezeShockWave(entity);
            },
        },
    });
};
export const shootPeanut = (player) => {
    shootProjectile(player, {
        projectileID: "cc:peanut_projectile",
        power: 2,
        gravity: 0.03,
        //ammoItemID: "minecraft:arrow",
        spawnDistance: {
            x: 0,
            y: 0,
            z: 3.5,
        },
    });
};
export const shootCoconut = (player) => {
    shootProjectile(player, {
        projectileID: "cc:coconut_projectile",
        power: 2,
        gravity: 0.03,
        //ammoItemID: "minecraft:arrow",
        spawnDistance: {
            x: 0,
            y: 0,
            z: 2,
        },
        onHitBlock: {
            sound: "break.dripstone_block",
            function: (block) => {
                block.dimension.spawnItem(new ItemStack("cc:cracked_coconut"), block.above().location);
            },
        },
        onHitEntity: {
            sound: "break.dripstone_block",
            function: (entity) => {
                entity.dimension.spawnItem(new ItemStack("cc:cracked_coconut"), entity.location);
            },
        },
    });
};
export const shootFireArrow = (player) => {
    shootProjectile(player, {
        projectileID: "cc:fire_bolt",
        power: 2,
        gravity: 0.03,
        spawnDistance: {
            x: 0,
            y: 0,
            z: 0.5,
        },
        onHitBlock: {
            particles: ["minecraft:flame"],
            function: (block) => {
                createPoisonShockWave(block.above());
                emitDynamicLight(15, block.above(), 8);
            },
        },
        onHitEntity: {
            particles: ["minecraft:flame"],
            effect: {
                id: "minecraft:slowness",
                duration: 10,
            },
            knockback: 5,
            damage: 3,
            function: (entity) => {
                createPoisonShockWave(entity);
                emitDynamicLight(15, entity, 4);
            },
        },
    });
};
export const shootLightningArrow = (player) => {
    shootProjectile(player, {
        projectileID: "cc:siren_bolt",
        power: 2,
        gravity: 0.03,
        spawnDistance: {
            x: 0,
            y: 0,
            z: 0.5,
        },
        onHitBlock: {
            particles: ["minecraft:flame"],
            function: (block) => {
                createLightningShockWave(block.above());
                emitDynamicLight(15, block.above(), 8);
            },
        },
        onHitEntity: {
            particles: ["minecraft:flame"],
            effect: {
                id: "minecraft:slowness",
                duration: 10,
            },
            knockback: 5,
            damage: 3,
            function: (entity) => {
                createLightningShockWave(entity);
                emitDynamicLight(15, entity, 4);
            },
        },
    });
};
export const webProjectile = {
    projectileID: "cc:web_projectile",
    power: 1.0,
    spawnDistance: {
        x: 0,
        y: 0.3,
        z: -0.5,
    },
    shootEffects: {
        sounds: ["cc:web_shoot"],
    },
    onHitEntity: {
        sound: "cc:web_hit",
        particles: ["cc:webbed"],
        function: (entity) => {
            applyEffect(entity, webbedEffect);
        },
    },
    onHitBlock: {
        sound: "cc:web_hit",
        particles: ["cc:webbed"],
    },
};
export const bananaProjectile = {
    projectileID: "cc:thrown_banana",
    power: 0.8,
    spawnDistance: {
        x: 0.0,
        y: 0.0,
        z: 0.0,
    },
};
export const rockProjectile = {
    projectileID: "cc:rock_projectile",
    power: 0.65,
    gravity: 0.02,
    spawnDistance: {
        x: 0,
        y: -0.5,
        z: 1,
    },
    shootEffects: {
        sounds: ["cc:rock_shoot"],
        particles: ["cc:dust_hit"],
    },
    onHitEntity: {
        sound: "cc:rock_hit",
        particles: ["cc:dust_hit", "cc:jungle_golem_rock_hit"],
        // function: (entity) => {
        //   applyEffect(entity, webbedEffect);
        // },
    },
    onHitBlock: {
        sound: "cc:rock_hit",
        particles: ["cc:dust_hit", "cc:jungle_golem_rock_hit"],
    },
};
export const desertPharaohOrbProjectile = {
    projectileID: "cc:pharaoh_orb",
    power: 1,
    spawnDistance: {
        x: 0,
        y: -1,
        z: 0,
    },
};
export const sirenBoltProjectile = {
    projectileID: "cc:siren_bolt",
    power: 2,
    gravity: 0.0,
    spawnDistance: {
        x: 0,
        y: -1,
        z: 0,
    },
    liquidInertia: 1,
    airInertia: 1,
    maxLifetime: 2,
};
export function shootDesertPharaohOrbProjectile(player) {
    shootProjectile(player, {
        projectileID: "cc:pharaoh_orb",
        power: 1.5,
    });
}
