const ZombieSlapper = {
    onHitEntity(event) {
        const { attackingEntity, hadEffect, hitEntity, itemStack } = event;
        try {
            const playerPosition = attackingEntity.location;
            const hitEntityPosition = hitEntity.location;

            // Calculate direction vector (normalized)
            const dx = hitEntityPosition.x - playerPosition.x;
            const dz = hitEntityPosition.z - playerPosition.z;
            const magnitude = Math.sqrt(dx * dx + dz * dz);

            if (magnitude === 0) return; // Prevent division by zero

            const knockbackY = 0.4; // Small upward boost for a better effect

            // Apply motion (velocity)
            hitEntity.applyKnockback(dx, dz, 2, knockbackY);
        } catch (error) { }

    }
};

export default ZombieSlapper;
