Fixed swapped components in horn colours

This commit is contained in:
Sollace 2019-07-16 09:12:38 +02:00
parent 49f394e367
commit cba4fac039
6 changed files with 88 additions and 42 deletions

View file

@ -64,7 +64,7 @@ public class LevitatingItemRenderer {
} }
private void setColor(int glowColor) { 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() { private void unsetColor() {

View file

@ -1,53 +1,98 @@
package com.minelittlepony.client.util.render; package com.minelittlepony.client.util.render;
import org.lwjgl.opengl.GL14;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
/** /**
* Colouration Utilities * Colouration Utilities
*/ */
public interface Color { 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) { static float a(int hex) {
return (color >> 16 & 255) / 255F; 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) { static float r(int hex) {
return (color >> 8 & 255) / 255F; 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) { static float g(int hex) {
return (color & 255) / 255F; 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) { static float b(int hex) {
return colorInteger((int) (r * 255), (int) (g * 255), (int) (b * 255)); 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) { static int argbToHex(float a, float r, float g, float b) {
return (r << 16) | (g << 8) | (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 * @param alpha The opacity to use
*/ */
static void glColor(int color, float alpha) { static void glColor(int hex, float alpha) {
GlStateManager.color4f(r(color), g(color), b(color), 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);
} }
} }

View file

@ -9,18 +9,18 @@ import javax.annotation.Nonnull;
public enum Race implements ITriggerPixelMapped<Race> { public enum Race implements ITriggerPixelMapped<Race> {
HUMAN (0x000000, false, false), HUMAN (0x000000, false, false),
EARTH (0x31b1f9, false, false), EARTH (0xf9b131, false, false),
PEGASUS (0xf0ca88, true, false), PEGASUS (0x88caf0, true, false),
UNICORN (0xe49fd1, false, true), UNICORN (0xd19fe4, false, true),
ALICORN (0xfcf9fe, true, true), ALICORN (0xfef9fc, true, true),
CHANGELING (0x292b28, true, true), CHANGELING (0x282b29, true, true),
ZEBRA (0xcfccd0, false, false), ZEBRA (0xd0cccf, false, false),
CHANGEDLING (0x5aedca, CHANGELING), CHANGEDLING (0xcaed5a, CHANGELING),
GRIFFIN (0x4591ae, PEGASUS), GRIFFIN (0xae9145, PEGASUS),
HIPPOGRIFF (0xacddd6, PEGASUS), HIPPOGRIFF (0xd6ddac, PEGASUS),
KIRIN (0xaf88fa, UNICORN), KIRIN (0xfa88af, UNICORN),
BATPONY (0xeeeeee, true, false), BATPONY (0xeeeeee, true, false),
SEAPONY (0xdd5536, false, true); SEAPONY (0x3655dd, false, true);
private boolean wings; private boolean wings;
private boolean horn; private boolean horn;

View file

@ -4,12 +4,12 @@ import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.pony.ITriggerPixelMapped; import com.minelittlepony.pony.ITriggerPixelMapped;
public enum Size implements ITriggerPixelMapped<Size> { public enum Size implements ITriggerPixelMapped<Size> {
TALL (0x764b53, 0.45f, 1.1F, 1.15F), TALL (0x534b76, 0.45f, 1.1F, 1.15F),
BULKY (0x5432ce, 0.5f, 1, 1.05F), BULKY (0xce3254, 0.5f, 1, 1.05F),
LANKY (0xce5432, 0.45F, 0.85F, 0.9F), LANKY (0x3254ce, 0.45F, 0.85F, 0.9F),
NORMAL (0x000000, 0.4f, 0.8F, 0.8F), NORMAL (0x000000, 0.4f, 0.8F, 0.8F),
YEARLING(0xffbe53, 0.4F, 0.6F, 0.65F), YEARLING(0x53beff, 0.4F, 0.6F, 0.65F),
FOAL (0x53beff, 0.25f, 0.6F, 0.5F), FOAL (0xffbe53, 0.25f, 0.6F, 0.5F),
UNSET (0x000000, 1, 1, 1); UNSET (0x000000, 1, 1, 1);
public static final Size[] REGISTRY = values(); public static final Size[] REGISTRY = values();

View file

@ -4,10 +4,10 @@ import com.minelittlepony.pony.ITriggerPixelMapped;
public enum TailLength implements ITriggerPixelMapped<TailLength> { public enum TailLength implements ITriggerPixelMapped<TailLength> {
STUB (0x445842), STUB (0x425844),
QUARTER (0xe49fd1), QUARTER (0xd19fe4),
HALF (0x764b53), HALF (0x534b76),
THREE_QUARTERS (0x7f6b8a), THREE_QUARTERS (0x8a6b7f),
FULL (0x000000); FULL (0x000000);
private int triggerValue; private int triggerValue;

View file

@ -2,6 +2,7 @@ package com.minelittlepony.pony.meta;
import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImage;
import com.minelittlepony.client.util.render.Color;
import com.minelittlepony.pony.ITriggerPixelMapped; import com.minelittlepony.pony.ITriggerPixelMapped;
/** /**
@ -93,8 +94,8 @@ public enum TriggerPixels {
} }
public int readValue(int x, int y, NativeImage image) { public int readValue(int x, int y, NativeImage image) {
/*getPixelABGR*/ /*getPixelABGR*/
return (image.getPixelRGBA(x, y) >> offset) & mask; return Color.abgrToArgb((image.getPixelRGBA(x, y) >> offset) & mask);
} }
} }
} }