use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class GearClientHelper method addStatsInfo.
public static void addStatsInfo(ItemStack stack, List<Component> tooltip, GearTooltipFlag flag, ICoreItem item) {
if (KeyTracker.isDisplayStatsDown() && flag.showStats) {
tooltip.add(TextUtil.withColor(misc("tooltip.stats"), Color.GOLD));
tooltip.add(TextUtil.withColor(misc("tier", GearData.getTier(stack)), Color.DEEPSKYBLUE));
// Display only stats relevant to the item class
Collection<ItemStat> relevantStats = item.getRelevantStats(stack);
Collection<ItemStat> displayStats = flag.isAdvanced() && SilentGear.isDevBuild() ? ItemStats.allStatsOrdered() : relevantStats;
TextListBuilder builder = new TextListBuilder();
for (ItemStat stat : displayStats) {
if (stat == ItemStats.ENCHANTABILITY && !Config.Common.allowEnchanting.get()) {
// Enchanting not allowed, so hide the stat
continue;
}
float statValue = GearData.getStat(stack, stat);
StatInstance inst = StatInstance.of(statValue, StatInstance.Operation.AVG, StatInstance.DEFAULT_KEY);
Color nameColor = relevantStats.contains(stat) ? stat.getNameColor() : TooltipHandler.MC_DARK_GRAY;
Component textName = TextUtil.withColor(stat.getDisplayName(), nameColor);
MutableComponent textStat = inst.getFormattedText(stat, stat.isDisplayAsInt() ? 0 : 2, false);
// TODO: The stats should probably handle this instead
if (stat == ItemStats.DURABILITY) {
int durabilityLeft = stack.getMaxDamage() - stack.getDamageValue();
int durabilityMax = stack.getMaxDamage();
textStat = statText("durabilityFormat", durabilityLeft, durabilityMax);
} else if (stat == ItemStats.HARVEST_LEVEL) {
textStat = TooltipHandler.harvestLevelWithHint(textStat, statValue);
}
builder.add(statText("displayFormat", textName, textStat));
}
tooltip.addAll(builder.build());
} else if (flag.showStats) {
tooltip.add(TextUtil.withColor(TextUtil.misc("tooltip.stats"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY))));
}
}
use of net.silentchaos512.gear.client.util.TextListBuilder 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.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatLines.
private static void getMaterialStatLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
TextListBuilder builder = new TextListBuilder();
for (ItemStat stat : ItemStats.allStatsOrdered()) {
if (stat.isVisible()) {
getMaterialStatModLines(event, partType, material, builder, stat);
}
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatModLines.
private static void getMaterialStatModLines(ItemTooltipEvent event, PartType partType, MaterialInstance material, TextListBuilder builder, ItemStat stat) {
Collection<StatInstance> modsAll = material.getStatModifiers(partType, StatGearKey.of(stat, GearType.ALL));
Optional<MutableComponent> head = getStatTooltipLine(event, partType, stat, modsAll);
builder.add(head.orElseGet(() -> TextUtil.withColor(stat.getDisplayName(), stat.getNameColor())));
builder.indent();
int subCount = 0;
List<StatGearKey> keysForStat = material.get().getStatKeys(material, partType).stream().filter(key -> key.getStat().equals(stat)).collect(Collectors.toList());
for (StatGearKey key : keysForStat) {
if (key.getGearType() != GearType.ALL) {
ItemStat stat1 = ItemStats.get(key.getStat());
if (stat1 != null) {
Collection<StatInstance> mods = material.getStatModifiers(partType, key);
Optional<MutableComponent> line = getSubStatTooltipLine(event, partType, stat1, key.getGearType(), mods);
if (line.isPresent()) {
builder.add(line.get());
++subCount;
}
}
}
}
if (subCount == 0 && !head.isPresent()) {
builder.removeLast();
}
builder.unindent();
}
Aggregations