diff --git a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java index 48d1e9e8..250bf1da 100644 --- a/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/LevitatingItemRenderer.java @@ -64,7 +64,7 @@ public class LevitatingItemRenderer { } private void setColor(int glowColor) { - GL14.glBlendColor(Color.r(glowColor), Color.g(glowColor), Color.b(glowColor), 0.2F); + Color.glBlendColour(glowColor, 0.2F); } private void unsetColor() { diff --git a/src/main/java/com/minelittlepony/client/util/render/Color.java b/src/main/java/com/minelittlepony/client/util/render/Color.java index 92b1d43e..1e671e7a 100644 --- a/src/main/java/com/minelittlepony/client/util/render/Color.java +++ b/src/main/java/com/minelittlepony/client/util/render/Color.java @@ -1,53 +1,98 @@ package com.minelittlepony.client.util.render; +import org.lwjgl.opengl.GL14; + import com.mojang.blaze3d.platform.GlStateManager; /** * Colouration Utilities */ public interface Color { + /** - * Returns the RED channel for the given colour integer. + * Returns the ALPHA channel for the given colour hex code. */ - static float r(int color) { - return (color >> 16 & 255) / 255F; + static float a(int hex) { + return (hex >> 24 & 255) / 255F; } /** - * Returns the GREEN channel for the given colour integer. + * Returns the RED channel for the given colour hex code. */ - static float g(int color) { - return (color >> 8 & 255) / 255F; + static float r(int hex) { + return (hex >> 16 & 255) / 255F; } /** - * Returns the BLUE channel for the given colour integer. + * Returns the GREEN channel for the given colour hex code. */ - static float b(int color) { - return (color & 255) / 255F; + static float g(int hex) { + return (hex >> 8 & 255) / 255F; } /** - * Converts the given rgb floats on a range of 0-1 into a minecraft colour integer. + * Returns the BLUE channel for the given colour hex code. */ - static int colorInteger(float r, float g, float b) { - return colorInteger((int) (r * 255), (int) (g * 255), (int) (b * 255)); + static float b(int hex) { + return (hex & 255) / 255F; } /** - * Converts the given rbg int on a range of 0-255 into a minecraft colour integer. + * Converts the given rgb floats on a range of 0-1 into a colour hex code. */ - static int colorInteger(int r, int g, int b) { - return (r << 16) | (g << 8) | (b); + static int argbToHex(float a, float r, float g, float b) { + return argbToHex((int)(a * 255), (int) (r * 255), (int) (g * 255), (int) (b * 255)); } /** - * Applies a GLTint based on the given colour integer. + * Converts the given rbg int on a range of 0-255 into a colour hex code. + */ + static int argbToHex(int a, int r, int g, int b) { + return (a << 24) | (r << 16) | (g << 8) | (b); + } + + /** + * Converts a colour hex code from BGR to RGB (and back). + */ + static int abgrToArgb(int color) { + return argbToHex(a(color), b(color), g(color), r(color)); + } + + /** + * Applies a GLTint based on the given colour hex code. * - * @param color The colour to apply + * @param hex The colour to apply + */ + static void glColor(int hex) { + glColor(hex, a(hex)); + } + + /** + * Applies a GLTint based on the given colour hex code. + * + * @param hex The colour to apply * @param alpha The opacity to use */ - static void glColor(int color, float alpha) { - GlStateManager.color4f(r(color), g(color), b(color), alpha); + static void glColor(int hex, float alpha) { + GlStateManager.color4f(r(hex), g(hex), b(hex), alpha); + } + + /** + * Applies a GLBlendTint based on the given colour hex code. + * + * @param hex The colour to apply + */ + static void glBlendColour(int hex) { + glBlendColour(hex, a(hex)); + } + + /** + * Applies a GLBlendTint based on the given colour hex code. + * + * @param hex The colour to apply + * @param alpha The opacity to use + */ + static void glBlendColour(int hex, float alpha) { + GL14.glBlendColor(r(hex), g(hex), b(hex), alpha); } } diff --git a/src/main/java/com/minelittlepony/pony/meta/Race.java b/src/main/java/com/minelittlepony/pony/meta/Race.java index feeca3d3..a6823c36 100644 --- a/src/main/java/com/minelittlepony/pony/meta/Race.java +++ b/src/main/java/com/minelittlepony/pony/meta/Race.java @@ -9,18 +9,18 @@ import javax.annotation.Nonnull; public enum Race implements ITriggerPixelMapped { HUMAN (0x000000, false, false), - EARTH (0x31b1f9, false, false), - PEGASUS (0xf0ca88, true, false), - UNICORN (0xe49fd1, false, true), - ALICORN (0xfcf9fe, true, true), - CHANGELING (0x292b28, true, true), - ZEBRA (0xcfccd0, false, false), - CHANGEDLING (0x5aedca, CHANGELING), - GRIFFIN (0x4591ae, PEGASUS), - HIPPOGRIFF (0xacddd6, PEGASUS), - KIRIN (0xaf88fa, UNICORN), + EARTH (0xf9b131, false, false), + PEGASUS (0x88caf0, true, false), + UNICORN (0xd19fe4, false, true), + ALICORN (0xfef9fc, true, true), + CHANGELING (0x282b29, true, true), + ZEBRA (0xd0cccf, false, false), + CHANGEDLING (0xcaed5a, CHANGELING), + GRIFFIN (0xae9145, PEGASUS), + HIPPOGRIFF (0xd6ddac, PEGASUS), + KIRIN (0xfa88af, UNICORN), BATPONY (0xeeeeee, true, false), - SEAPONY (0xdd5536, false, true); + SEAPONY (0x3655dd, false, true); private boolean wings; private boolean horn; diff --git a/src/main/java/com/minelittlepony/pony/meta/Size.java b/src/main/java/com/minelittlepony/pony/meta/Size.java index b41d928a..5f72b0c5 100644 --- a/src/main/java/com/minelittlepony/pony/meta/Size.java +++ b/src/main/java/com/minelittlepony/pony/meta/Size.java @@ -4,12 +4,12 @@ import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.pony.ITriggerPixelMapped; public enum Size implements ITriggerPixelMapped { - TALL (0x764b53, 0.45f, 1.1F, 1.15F), - BULKY (0x5432ce, 0.5f, 1, 1.05F), - LANKY (0xce5432, 0.45F, 0.85F, 0.9F), + TALL (0x534b76, 0.45f, 1.1F, 1.15F), + BULKY (0xce3254, 0.5f, 1, 1.05F), + LANKY (0x3254ce, 0.45F, 0.85F, 0.9F), NORMAL (0x000000, 0.4f, 0.8F, 0.8F), - YEARLING(0xffbe53, 0.4F, 0.6F, 0.65F), - FOAL (0x53beff, 0.25f, 0.6F, 0.5F), + YEARLING(0x53beff, 0.4F, 0.6F, 0.65F), + FOAL (0xffbe53, 0.25f, 0.6F, 0.5F), UNSET (0x000000, 1, 1, 1); public static final Size[] REGISTRY = values(); diff --git a/src/main/java/com/minelittlepony/pony/meta/TailLength.java b/src/main/java/com/minelittlepony/pony/meta/TailLength.java index 7f28247d..a1c8a283 100644 --- a/src/main/java/com/minelittlepony/pony/meta/TailLength.java +++ b/src/main/java/com/minelittlepony/pony/meta/TailLength.java @@ -4,10 +4,10 @@ import com.minelittlepony.pony.ITriggerPixelMapped; public enum TailLength implements ITriggerPixelMapped { - STUB (0x445842), - QUARTER (0xe49fd1), - HALF (0x764b53), - THREE_QUARTERS (0x7f6b8a), + STUB (0x425844), + QUARTER (0xd19fe4), + HALF (0x534b76), + THREE_QUARTERS (0x8a6b7f), FULL (0x000000); private int triggerValue; diff --git a/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java b/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java index 78f85f4e..8f23c9f3 100644 --- a/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java +++ b/src/main/java/com/minelittlepony/pony/meta/TriggerPixels.java @@ -2,6 +2,7 @@ package com.minelittlepony.pony.meta; import net.minecraft.client.texture.NativeImage; +import com.minelittlepony.client.util.render.Color; import com.minelittlepony.pony.ITriggerPixelMapped; /** @@ -93,8 +94,8 @@ public enum TriggerPixels { } public int readValue(int x, int y, NativeImage image) { - /*getPixelABGR*/ - return (image.getPixelRGBA(x, y) >> offset) & mask; + /*getPixelABGR*/ + return Color.abgrToArgb((image.getPixelRGBA(x, y) >> offset) & mask); } } }