private static int getBlendedColour(byte[] alphas, HaloContext context) {
        // Find the total alpha
        int aTotal = 0;
        int aMax = 0;
        for (int i = 0; i < 16; i++) {
            aTotal += alphas[i] & 0xFF;
            aMax = Math.max(aMax, alphas[i] & 0xFF);
        }

        if (aTotal == 0) {
            return 0;
        }

        // Normalize alpha values
        float[] aNorm = new float[16];
        for (int i = 0; i < 16; i++) {
            aNorm[i] = (alphas[i] & 0xFF) / (float) aTotal * aMax / 255f;
        }

        float r = 0, g = 0, b = 0, a = 0;
        for (int i = 0; i < 16; i++) {
            if (alphas[i] == 0) continue;

            int colour = getBaseColour(i, context);
            float rsrc = ((colour >> 24) & 0xFF) / 255f;
            float gsrc = ((colour >> 16) & 0xFF) / 255f;
            float bsrc = ((colour >> 8) & 0xFF) / 255f;
            float asrc = aNorm[i];

            r = rsrc * asrc + r * (1 - asrc);
            g = gsrc * asrc + g * (1 - asrc);
            b = bsrc * asrc + b * (1 - asrc);
            a = asrc * asrc + a * (1 - asrc);
        }

        // Note: Below alpha controls how halo renderer blends it into the render target, not alpha used to blend colours together
        return (int) (r * 255) << 24 | (int) (g * 255) << 16 | (int) (b * 255) << 8 | 0xA0;
    }
Mix all 16 colours given input array of alpha values. Colours are additively blended
using same calculations as GL_SRC_ALPHA/GL_ONE_MINUS_SRC_ALPHA blending.

@param alphas 16-element array of alpha values
@return Blended colour (rgba)
core/src/main/java/mrtjp/projectred/core/client/HaloRenderer.java