use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class StatInstance method formatAdd.
// region Private formatted text methods
private MutableComponent formatAdd(ItemStat stat, @Nonnegative int decimalPlaces, boolean addColor) {
String format = "%s" + ("%." + decimalPlaces + "f");
Color color = getFormattedColor(this.value, 0f, addColor);
String text = trimNumber(String.format(format, this.value < 0 ? "" : "+", this.value));
return TextUtil.withColor(new TextComponent(text), color);
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class MaterialLayer method read.
public static MaterialLayer read(FriendlyByteBuf buffer) {
ResourceLocation texture = buffer.readResourceLocation();
int color = buffer.readVarInt();
PartType partType = PartType.getNonNull(buffer.readResourceLocation());
return new MaterialLayer(texture, partType, color, true);
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getStatTooltipLine.
private static Optional<MutableComponent> getStatTooltipLine(ItemTooltipEvent event, PartType partType, ItemStat stat, Collection<StatInstance> modifiers) {
if (!modifiers.isEmpty()) {
StatInstance inst = stat.computeForDisplay(0, GearType.ALL, modifiers);
if (inst.shouldList(partType, stat, event.getFlags().isAdvanced())) {
boolean isZero = inst.getValue() == 0;
Color nameColor = isZero ? MC_DARK_GRAY : stat.getNameColor();
Color statColor = isZero ? MC_DARK_GRAY : Color.WHITE;
MutableComponent nameStr = TextUtil.withColor(stat.getDisplayName(), nameColor);
int decimalPlaces = stat.isDisplayAsInt() && inst.getOp() != StatInstance.Operation.MUL1 && inst.getOp() != StatInstance.Operation.MUL2 ? 0 : 2;
MutableComponent statListText = TextUtil.withColor(StatModifierMap.formatText(modifiers, stat, decimalPlaces), statColor);
// Harvest level hints
MutableComponent textWithAdditions = stat == ItemStats.HARVEST_LEVEL && modifiers.size() == 1 ? harvestLevelWithHint(statListText, inst.getValue()) : statListText;
return Optional.of(new TranslatableComponent("stat.silentgear.displayFormat", nameStr, textWithAdditions));
}
}
return Optional.empty();
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class TooltipHandler method buildPartTypeHeader.
private static Component buildPartTypeHeader(Collection<PartType> types, PartType selectedType) {
MutableComponent ret = new TextComponent("| ").withStyle(ChatFormatting.GRAY);
for (PartType type : types) {
Color color = type == selectedType ? Color.AQUAMARINE : MC_DARK_GRAY;
Component text = TextUtil.withColor(type.getDisplayName(-1), color);
ret.append(text).append(" | ");
}
Component keyHint = TextUtil.misc("tooltip.material.keyHint", TextUtil.withColor(TextUtil.keyBinding(KeyTracker.CYCLE_BACK), Color.AQUAMARINE), TextUtil.withColor(TextUtil.keyBinding(KeyTracker.CYCLE_NEXT), Color.AQUAMARINE));
return ret.append(keyHint);
}
use of net.silentchaos512.utils.Color 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;
}
Aggregations