diff --git a/src/client/java/com/bawnorton/allthetrims/AllTheTrimsClient.java b/src/client/java/com/bawnorton/allthetrims/AllTheTrimsClient.java index e5a4597..b32fb47 100644 --- a/src/client/java/com/bawnorton/allthetrims/AllTheTrimsClient.java +++ b/src/client/java/com/bawnorton/allthetrims/AllTheTrimsClient.java @@ -2,6 +2,7 @@ import com.bawnorton.allthetrims.compat.Compat; import com.bawnorton.allthetrims.compat.client.YACLImpl; +import com.bawnorton.allthetrims.util.ImageUtil; import com.bawnorton.allthetrims.util.PaletteHelper; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; @@ -69,7 +70,12 @@ public void onInitializeClient() { return -1; } - return tintIndex >= 1 ? palette.get(MathHelper.clamp(5 - tintIndex, 0, palette.size() - 1)).getRGB() : -1; + if(tintIndex < 1) return -1; + Color color = palette.get(MathHelper.clamp(6 - tintIndex, 0, palette.size() - 1)); + if(tintIndex == 1) return ImageUtil.changeBrightness(color, 0.6f).getRGB(); + if(tintIndex == 2) return ImageUtil.changeBrightness(color, 0.75f).getRGB(); + if(tintIndex == 3) return ImageUtil.changeBrightness(color, 0.9f).getRGB(); + return color.getRGB(); }, Registries.ITEM.stream().filter(item -> item instanceof Equipment).toArray(Item[]::new)); } diff --git a/src/client/java/com/bawnorton/allthetrims/util/ImageUtil.java b/src/client/java/com/bawnorton/allthetrims/util/ImageUtil.java index 4a672a5..e61609a 100644 --- a/src/client/java/com/bawnorton/allthetrims/util/ImageUtil.java +++ b/src/client/java/com/bawnorton/allthetrims/util/ImageUtil.java @@ -1,5 +1,7 @@ package com.bawnorton.allthetrims.util; +import net.minecraft.util.math.MathHelper; + import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; @@ -74,4 +76,10 @@ public static BufferedImage removeOtherColours(BufferedImage bufferedImage, Colo } return maskedImage; } + + public static Color changeBrightness(Color color, float percent) { + float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); + float brightness = MathHelper.clamp(hsb[2] * percent, 0, 1); + return Color.getHSBColor(hsb[0], hsb[1], brightness); + } } diff --git a/src/client/java/com/bawnorton/allthetrims/util/PaletteHelper.java b/src/client/java/com/bawnorton/allthetrims/util/PaletteHelper.java index b7af673..ab5a1f6 100644 --- a/src/client/java/com/bawnorton/allthetrims/util/PaletteHelper.java +++ b/src/client/java/com/bawnorton/allthetrims/util/PaletteHelper.java @@ -127,22 +127,12 @@ private static List coloursToPalette(List colours) { return hsb[1]; }))); Color darkest = colours.get(0); - darkest = darken(darkest); + darkest = ImageUtil.changeBrightness(darkest, 0.95f); Color lightest = colours.get(colours.size() - 1); - lightest = lighten(lightest); + lightest = ImageUtil.changeBrightness(lightest, 1.05f); return stretchColors(darkest, lightest); } - private static Color darken(Color colour) { - float[] hsb = Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), null); - return Color.getHSBColor(hsb[0], hsb[1], MathHelper.clamp(hsb[2] - 0.05f, 0.0f, 1.0f)); - } - - private static Color lighten(Color colour) { - float[] hsb = Color.RGBtoHSB(colour.getRed(), colour.getGreen(), colour.getBlue(), null); - return Color.getHSBColor(hsb[0], hsb[1], MathHelper.clamp(hsb[2] + 0.05f, 0.0f, 1.0f)); - } - private static List stretchColors(Color... originalColors) { List stretchedColors = new ArrayList<>();