export class Knockback {
    static magnitude(vector) {
      return Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z);
    }
  
    static knockbackPosition(pusherPosition, entityPosition, forceMagnitude) {
      const direction = {
        x: entityPosition.x - pusherPosition.x,
        y: entityPosition.y - pusherPosition.y,
        z: entityPosition.z - pusherPosition.z
      };
  
      const distance = this.magnitude(direction);
  
      if (distance === 0) {
        return {
          x: 0,
          y: 0,
          z: 0
        };
      }
  
      const scaleFactor = forceMagnitude / distance;
  
      return {
        x: direction.x * scaleFactor,
        y: direction.y * scaleFactor,
        z: direction.z * scaleFactor
      };
    }
  }
  