From 7ba0fc903e5d14928d2b894b00a7b7dfc65eee18 Mon Sep 17 00:00:00 2001 From: querns <33518699+querns@users.noreply.github.com> Date: Thu, 19 Sep 2024 08:53:17 -0500 Subject: Infinite Spraycan Additions (#3226) Co-authored-by: Caedis --- src/main/java/gregtech/api/enums/Dyes.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main/java/gregtech/api/enums/Dyes.java') diff --git a/src/main/java/gregtech/api/enums/Dyes.java b/src/main/java/gregtech/api/enums/Dyes.java index 1dedcb6af0..72113b554a 100644 --- a/src/main/java/gregtech/api/enums/Dyes.java +++ b/src/main/java/gregtech/api/enums/Dyes.java @@ -6,6 +6,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.Contract; + import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.objects.GTArrayList; import gregtech.api.util.GTUtility; @@ -123,4 +125,19 @@ public enum Dyes implements IColorModulationContainer { public static Dyes getDyeFromIndex(short index) { return index != -1 ? Dyes.get(index) : Dyes.MACHINE_METAL; } + + /** + * Transforms a dye index between the GT index for this color and the vanilla index for this color. + * + * @param color an integer between 0 and 15 + * @return the transformed color + */ + @Contract(pure = true) + public static int transformDyeIndex(final int color) { + if (color < 0 || color > 15) { + throw new IllegalArgumentException("Color passed to transformColor must be between 0 and 15"); + } + + return (~(byte) color) & 0xF; + } } -- cgit