diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index dbcee3e6a8b..040683891df 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -45,6 +45,7 @@ import crafttweaker.annotations.ZenRegister; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Range; import stanhebben.zenscript.annotations.OperatorType; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenGetter; @@ -868,6 +869,20 @@ public Builder color(int color) { return this; } + /** + * Set the color of this Material. + * Defaults to 0xFFFFFF unless {@link Builder#colorAverage()} was called, where it will be a weighted average of + * the components of the Material. + * + * @param r the red component of the color + * @param g the green component of the color + * @param b the blue component of the color + */ + public Builder color(@Range(from = 0, to = 255) int r, @Range(from = 0, to = 255) int g, + @Range(from = 0, to = 255) int b) { + return color(GTUtility.combineRGB(r, g, b)); + } + public Builder colorAverage() { this.averageRGB = true; return this; diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index 42da3a04836..12e3688d7a8 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -61,6 +61,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Range; import java.util.AbstractList; import java.util.ArrayList; @@ -959,4 +960,9 @@ public static long scaleVoltage(long voltage, int workingTier) { // Sanity check to make sure we don't accidentally create full-amp recipes. return Math.min(voltage, GTValues.VA[workingTier]); } + + public static int combineRGB(@Range(from = 0, to = 255) int r, @Range(from = 0, to = 255) int g, + @Range(from = 0, to = 255) int b) { + return (r << 16) | (g << 8) | b; + } }