use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class ColorUtils method getBlendedColor.
public static int getBlendedColor(CompoundPartItem 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(item.getGearType(), item.getPartType(), mat).getLayers();
if (layers.size() > layer) {
int color = model.getLayerColor(item.getGearType(), item.getPartType(), mat, layer);
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);
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class GearClientHelper method tooltipListParts.
public static void tooltipListParts(ItemStack gear, List<Component> tooltip, Collection<PartData> parts, GearTooltipFlag flag) {
TextListBuilder builder = new TextListBuilder();
for (PartData part : parts) {
if (part.get().isVisible()) {
int partNameColor = Color.blend(part.getColor(gear), Color.VALUE_WHITE, 0.25f) & 0xFFFFFF;
MutableComponent partNameText = TextUtil.withColor(part.getDisplayName(gear).copy(), partNameColor);
builder.add(flag.isAdvanced() ? partNameText.append(TextUtil.misc("spaceBrackets", part.getType().getName()).withStyle(ChatFormatting.DARK_GRAY)) : partNameText);
// List materials for compound parts
if (part.get() instanceof CompoundPart) {
builder.indent();
for (IMaterialInstance material : CompoundPartItem.getMaterials(part.getItem())) {
int nameColor = material.getNameColor(part.getType(), GearType.ALL);
builder.add(TextUtil.withColor(material.getDisplayNameWithModifiers(part.getType(), ItemStack.EMPTY), nameColor));
}
builder.unindent();
}
}
}
tooltip.addAll(builder.build());
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class FragmentModelOverrideList method getOverrideModel.
private BakedModel getOverrideModel(ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn) {
List<MaterialLayer> layers = new ArrayList<>();
IMaterialInstance material = FragmentItem.getMaterial(stack);
if (material != null) {
IMaterialDisplay model = material.getDisplayProperties();
int layerLevel = 0;
for (MaterialLayer layer : model.getLayerList(GearType.FRAGMENT, PartType.MAIN, material)) {
int blendedColor = model.getLayerColor(GearType.FRAGMENT, PartType.MAIN, material, layerLevel);
layers.add(new MaterialLayer(layer.getTextureId(), blendedColor));
++layerLevel;
}
}
return model.bake(layers, owner, bakery, spriteGetter, modelTransform, this, modelLocation);
}
Aggregations