use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getPartStatLines.
private static void getPartStatLines(ItemTooltipEvent event, ItemStack stack, PartData part) {
GearType gearType = getPartGearType(part);
TextListBuilder builder = new TextListBuilder();
List<ItemStat> relevantStats = new ArrayList<>(part.getGearType().getRelevantStats());
if (part.getGearType().isArmor() && relevantStats.contains(ItemStats.DURABILITY)) {
int index = relevantStats.indexOf(ItemStats.DURABILITY);
relevantStats.remove(ItemStats.DURABILITY);
relevantStats.add(index, ItemStats.ARMOR_DURABILITY);
}
for (ItemStat stat : relevantStats) {
Collection<StatInstance> modifiers = new ArrayList<>();
for (StatInstance mod : part.getStatModifiers(StatGearKey.of(stat, gearType), ItemStack.EMPTY)) {
if (mod.getOp() == StatInstance.Operation.AVG) {
float computed = stat.compute(Collections.singleton(mod));
modifiers.add(StatInstance.of(computed, StatInstance.Operation.AVG, mod.getKey()));
} else {
modifiers.add(mod);
}
}
getStatTooltipLine(event, part.getType(), stat, modifiers).ifPresent(builder::add);
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialTraitLines.
private static void getMaterialTraitLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
Collection<TraitInstance> traits = material.getTraits(partType);
if (traits.isEmpty())
return;
MutableComponent header = TextUtil.misc("tooltip.traits").withStyle(ChatFormatting.GOLD);
if (!KeyTracker.isDisplayTraitsDown()) {
MutableComponent keyHint = TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_TRAITS), Color.AQUAMARINE);
header.append(" ").append(keyHint);
}
event.getToolTip().add(header);
TextListBuilder builder = new TextListBuilder();
for (TraitInstance trait : traits) {
builder.add(trait.getDisplayName());
// Trait description and conditions
if (event.getFlags().isAdvanced() || KeyTracker.isDisplayTraitsDown()) {
builder.indent();
builder.add(trait.getTrait().getDescription(trait.getLevel()).withStyle(ChatFormatting.DARK_GRAY));
if (!trait.getConditions().isEmpty()) {
builder.add(TextUtil.withColor(trait.getConditionsText(), ChatFormatting.DARK_GRAY));
}
builder.unindent();
}
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class GearBlueprintItem method appendSupportedTypesText.
private void appendSupportedTypesText(Collection<Component> list) {
if (KeyTracker.isDisplayStatsDown()) {
Optional<ICoreItem> itemOptional = this.gearType.getItem();
if (itemOptional.isPresent()) {
TextListBuilder builder = new TextListBuilder();
ICoreItem item = itemOptional.get();
ItemStack gear = new ItemStack(item);
for (PartType type : PartType.getValues()) {
if (type != PartType.MAIN) {
List<IGearPart> partsOfType = PartManager.getPartsOfType(type);
if (!partsOfType.isEmpty() && item.supportsPart(gear, PartData.of(partsOfType.get(0)))) {
builder.add(type.getDisplayName(0));
}
}
}
List<Component> lines = builder.build();
if (!lines.isEmpty()) {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD));
list.addAll(lines);
}
}
} else {
list.add(TextUtil.withColor(TextUtil.misc("supportedPartTypes"), Color.GOLD).append(" ").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 CompoundMaterialItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
if (Config.Client.showMaterialTooltips.get()) {
Collection<IMaterialInstance> materials = getSubMaterials(stack);
TextListBuilder statsBuilder = new TextListBuilder();
for (IMaterialInstance material : materials) {
int nameColor = material.getNameColor(PartType.MAIN, GearType.ALL);
statsBuilder.add(TextUtil.withColor(material.getDisplayName(PartType.MAIN).copy(), nameColor));
}
tooltip.addAll(statsBuilder.build());
}
}
use of net.silentchaos512.gear.client.util.TextListBuilder in project Silent-Gear by SilentChaos512.
the class CompoundPartItem method appendHoverText.
@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip, TooltipFlag flagIn) {
PartData part = PartData.from(stack);
if (part != null && Config.Client.showPartTooltips.get()) {
float synergy = SynergyUtils.getSynergy(this.partType, getMaterials(stack), part.getTraits());
tooltip.add(SynergyUtils.getDisplayText(synergy));
TextListBuilder matsBuilder = new TextListBuilder();
getMaterials(stack).forEach(material -> {
int nameColor = material.getNameColor(part.getType(), this.getGearType());
matsBuilder.add(TextUtil.withColor(material.getDisplayNameWithModifiers(part.getType(), ItemStack.EMPTY), nameColor));
});
tooltip.addAll(matsBuilder.build());
}
}
Aggregations