package net.halbear.supernova.registry.util;

import net.halbear.supernova.SuperNova;
//import dev.halbear1.supernova.custom.particle.StarSparkle;
import net.halbear.supernova.entity.EntityRenderers.SpaceshipRenderer;
import net.halbear.supernova.entity.Spaceship;
import net.halbear.supernova.registry.ModEntities;
import net.halbear.supernova.registry.blocks.ModBlocks;
import net.halbear.supernova.registry.blocks.ModFluids;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraft.block.Block;

@Mod.EventBusSubscriber(modid = SuperNova.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventHandler {

    @SafeVarargs
    public static void SetCollectionRenderType(RenderType type, RegistryObject<Block>... blocks_list) { //hal
        for (RegistryObject<Block> blockRegistryObject : blocks_list) {
            RenderTypeLookup.setRenderLayer(blockRegistryObject.get(), type);
        }
    }
    @SubscribeEvent
    public static void init(final FMLClientSetupEvent event) { // block render types, examples for paladin and chef to see
        // pal: drying up your code
        SetCollectionRenderType(RenderType.getSolid(), // Cutout: Texture pixels with a transparency element are discarded, fastest method, prevents re-ordering at render.
                ModBlocks.ARC_FURNACE
                //blocks here
        );
        SetCollectionRenderType(RenderType.getCutout(), // Cutout: Texture pixels with a transparency element are discarded, fastest method, prevents re-ordering at render.
                ModBlocks.BAUXITE_ORE, //hal
                ModBlocks.RUTILE_ORE, // pal: rutile, generator
                ModBlocks.COPPER_ORE,
                ModBlocks.ANATASE_ORE,
                ModBlocks.STEEL_PIPE
                //blocks here
        );
        RenderTypeLookup.setRenderLayer(ModFluids.SALT_WATER_FLUID.get(), RenderType.getTranslucent());
        RenderTypeLookup.setRenderLayer(ModFluids.SALT_WATER_FLOWING.get(), RenderType.getTranslucent());
        RenderTypeLookup.setRenderLayer(ModFluids.SALT_WATER_BLOCK.get(), RenderType.getTranslucent());
        RenderTypeLookup.setRenderLayer(ModFluids.KEROSENE_FLUID.get(), RenderType.getTranslucent());
        RenderTypeLookup.setRenderLayer(ModFluids.KEROSENE_FLOWING.get(), RenderType.getTranslucent());
        RenderTypeLookup.setRenderLayer(ModFluids.KEROSENE_BLOCK.get(), RenderType.getTranslucent());

        RenderingRegistry.registerEntityRenderingHandler(ModEntities.SPACESHIP.get(), SpaceshipRenderer::new);
        /*SetCollectionRenderType(RenderType.getCutoutMipped(), // Cutout Mipped: Cutout but with mipmapping. Textures from far away are simplified for performance.
                //blocks here
        );


        SetCollectionRenderType(RenderType.getTranslucent(), // Translucent: Texture pixels with a transparency element are mixed, slowest method.
            //blocks here
        );*/

    }

    /*@SubscribeEvent
    public static void registerFactory(final ParticleFactoryRegisterEvent event){
        //register particles here, an example would be:
        //Minecraft.GetInstance().particleEngine.register(ModParticleTypes.ExampleParticle.get(), ExampleParticle.Factory::new);
        Minecraft.getInstance().particles.registerFactory(ModParticles.STAR_SPARKLE.get(), StarSparkle.Factory::new);
    }*/
}
