import { Entity } from "@minecraft/server";
import { namespace } from "../../namespace";

/**
 * 
 * @param {Entity} target
 */
export function frogSword(target) {
    if (target?.typeId == "minecraft:player" || target?.typeId == "minecraft:frog") return
    if (!target?.typeId.startsWith("minecraft:")) {
        if (target.typeId != `${namespace}:brain` && target.typeId != `${namespace}:dino` && target.typeId != `${namespace}:droid` && target.typeId != `${namespace}:spider`) return
    }
    const targetLoc = target?.location
    target.dimension.spawnEntity("minecraft:frog", targetLoc)
    target.dimension.playSound(`${namespace}:frog_sword`, targetLoc)
    target.remove()
}