MCPcopy Index your code
hub / github.com/GregTech6/gregtech6 / color

Method color

src/main/java/gregapi/util/UT.java:1605–1619  ·  view source on GitHub ↗
(ItemStack aStack)

Source from the content-addressed store, hash-verified

1603 public static short getA(int aColors) {return (short)((aColors >>> 24) & 255);}
1604
1605 @SideOnly(Side.CLIENT)
1606 /** estebes helped with the code for this one, and yes that cast down there is fucking necessary... */
1607 public static short[] color(ItemStack aStack) {
1608 if (ST.invalid(aStack)) return UNCOLOURED;
1609 IIcon tIcon = null;
1610 try {tIcon = aStack.getIconIndex();} catch(Throwable e) {return UNCOLOURED;} // And ofcourse some Mod needs to crash here...
1611 if (tIcon == null) return UNCOLOURED;
1612 String tResourceLocation = tIcon.getIconName();
1613 if (stringInvalid(tResourceLocation)) return UNCOLOURED;
1614 short[] rColor = color(tResourceLocation);
1615 if (rColor == null) return UNCOLOURED;
1616 short[] rModulation = getRGBaArray(aStack.getItem().getColorFromItemStack(aStack, 0));
1617 for (byte i = 0; i < 3; i++) rColor[i] = (short)((rColor[i] * rModulation[i]) / 255);
1618 return rColor;
1619 }
1620
1621 @SideOnly(Side.CLIENT)
1622 /** estebes helped with the code for this one */

Callers 1

onModServerStarting2Method · 0.80

Calls 8

invalidMethod · 0.95
stringInvalidMethod · 0.95
getRGBaArrayMethod · 0.95
getResourceMethod · 0.80
getItemMethod · 0.65
containsMethod · 0.65
getIconIndexMethod · 0.45
getColorFromItemStackMethod · 0.45

Tested by

no test coverage detected