package top.r3944realms.lib39.client.shader;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraftforge.client.event.RegisterShadersEvent;
import top.r3944realms.lib39.Lib39;

/**
 * The type Lib 39 shaders.
 */
public class Lib39Shaders {
    /**
     * The Minecraft.
     */
    static final Minecraft MINECRAFT = Minecraft.getInstance();

    /**
     * Gets ring shader.
     *
     * @return the ring shader
     */
    public static ShaderInstance getRingShader() {
        return ringShader;
    }

    /**
     * The Ring shader.
     */
    static ShaderInstance ringShader;

    /**
     * Gets selection shader.
     *
     * @return the selection shader
     */
    public static ShaderInstance getSelectionShader() {
        return selectionShader;
    }

    /**
     * The Selection shader.
     */
    static ShaderInstance selectionShader;

    /**
     * Register.
     *
     * @param event the event
     */
    public static void register(RegisterShadersEvent event) {
         try {
            event.registerShader(
                    new ShaderInstance(
                            event.getResourceProvider(),
                            Lib39.rl("ring"),
                            DefaultVertexFormat.POSITION_COLOR
                    ),
                    it -> ringShader = it
            );
             event.registerShader(
                     new ShaderInstance(
                             event.getResourceProvider(),
                             Lib39.rl("selection"),
                             DefaultVertexFormat.POSITION_COLOR
                     ),
                     it -> selectionShader = it
             );
        } catch (Exception e) {
             Lib39.LOGGER.error("Failed to register shader", e);
         }
    }
}
