Search in sources :

Example 21 with Color

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);
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) Color(net.silentchaos512.utils.Color)

Example 22 with 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);
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 23 with Color

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();
}
Also used : MutableComponent(net.minecraft.network.chat.MutableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Color(net.silentchaos512.utils.Color) StatInstance(net.silentchaos512.gear.api.stats.StatInstance)

Example 24 with Color

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);
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) PartType(net.silentchaos512.gear.api.part.PartType) MutableComponent(net.minecraft.network.chat.MutableComponent) Color(net.silentchaos512.utils.Color) MutableComponent(net.minecraft.network.chat.MutableComponent) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent)

Example 25 with Color

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;
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) CompoundMaterialItem(net.silentchaos512.gear.item.CompoundMaterialItem)

Aggregations

Color (net.silentchaos512.lib.util.Color)12 Color (net.silentchaos512.utils.Color)9 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)8 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)7 TextComponent (net.minecraft.network.chat.TextComponent)6 TextFormatting (net.minecraft.util.text.TextFormatting)6 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)6 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)6 MutableComponent (net.minecraft.network.chat.MutableComponent)4 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)4 Random (java.util.Random)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Item (net.minecraft.item.Item)3 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)3 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)3 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)3 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)3 UUID (java.util.UUID)2 Minecraft (net.minecraft.client.Minecraft)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2