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

/**
 * 
 * @param {Entity} source
 * @param {Entity} target
 */
export function knockbackSword(source, target) {
    const viewDir = source.getViewDirection()
    const impulse = new Vector3(viewDir.x, viewDir.y, viewDir.z).multiply(10)
    target.applyImpulse(impulse)
    target.dimension.playSound(`${namespace}:knockback`, target.location)
}