package codechicken.lib.colour;

import codechicken.lib.math.MathHelper;
import codechicken.lib.render.TextureUtils;
import net.minecraft.util.ResourceLocation;

import java.awt.image.BufferedImage;

public class CustomGradient
{
    public int[] gradient;
    
    public CustomGradient(ResourceLocation textureFile)
    {
        BufferedImage img = TextureUtils.loadBufferedImage(textureFile);
        int[] data = new int[img.getWidth()];
        img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth());
        gradient = new int[img.getWidth()];
        for(int i = 0; i < data.length; i++)
            gradient[i] = (data[i]<<8)|(((data[i])>>24)&0xFF);
    }
    
    public ColourRGBA getColour(double position)
    {
        return new ColourRGBA(getColourI(position));
    }
    
    public int getColourI(double position)
    {
        int off = (int)MathHelper.clip(gradient.length*position, 0, gradient.length-1);
        return gradient[off];
    }
}

@@ -390,16 +390,124 @@
 eFile);%0A
+        if(img == null)%0A            throw new RuntimeException(%22File not found: %22+textureFile.toString());%0A%0A
         

Add meaningful exception text to CustomGradient when resource not found