(ItemStack aStack)
| 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 */ |
no test coverage detected