use of net.silentchaos512.gear.item.CompoundMaterialItem in project Silent-Gear by SilentChaos512.
the class CompoundMaterialDisplay method getLayerColor.
@Override
public int getLayerColor(GearType gearType, IPartData part, IMaterialInstance materialIn, int layer) {
List<MaterialLayer> layers = getLayerList(gearType, part, materialIn).getLayers();
if (layer < layers.size()) {
ItemStack stack = materialIn.getItem();
if (stack.getItem() instanceof CompoundMaterialItem) {
List<IMaterialInstance> subMaterials = CompoundMaterialItem.getSubMaterials(stack);
int color = ColorUtils.getBlendedColor((CompoundMaterialItem) stack.getItem(), subMaterials, layer);
// return layers.get(layer).getColor();
return color;
}
}
return Color.VALUE_WHITE;
}
use of net.silentchaos512.gear.item.CompoundMaterialItem in project Silent-Gear by SilentChaos512.
the class ColorUtils method getBlendedColor.
public static int getBlendedColor(CompoundMaterialItem item, Collection<? extends IMaterialInstance> materials, int layer) {
int[] componentSums = new int[3];
int maxColorSum = 0;
int colorCount = 0;
int i = 0;
for (IMaterialInstance mat : materials) {
IMaterialDisplay model = mat.getDisplayProperties();
List<MaterialLayer> layers = model.getLayerList(GearType.ALL, PartType.MAIN, mat).getLayers();
if (layers.size() > layer) {
int color = layers.get(layer).getColor();
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
int colorWeight = item.getColorWeight(i, materials.size());
for (int j = 0; j < colorWeight; ++j) {
maxColorSum += Math.max(r, Math.max(g, b));
componentSums[0] += r;
componentSums[1] += g;
componentSums[2] += b;
++colorCount;
}
++i;
}
}
return blendColors(componentSums, maxColorSum, colorCount);
}
Aggregations