How to create an IF statement in the Main Loop for Custom Post Types

You have the right idea.

You can start dividing this up into individual templates in order to prevent repeating yourself or having multiple templates that do the same thing.

You should use get_template_part() to pull in different templates as you need them. This allows you to branch out your templates further without WordPress dictating how it should be done.

In your case, you may have a template for your generic loop that calls a template for individual items in a post list context that calls a template for each different type of item (your custom post type).