use of net.silentchaos512.gear.api.part.PartType 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.gear.api.part.PartType 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.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method addJeiSearchTerms.
private static void addJeiSearchTerms(ItemTooltipEvent event, MaterialInstance material) {
// Add search terms to allow advanced filtering in JEI (requires the
// `SearchAdvancedTooltips` JEI config to be set)
StringBuilder b = new StringBuilder();
for (IMaterialCategory category : material.getCategories()) {
b.append(category.getName()).append(" ");
}
Collection<String> traits = new HashSet<>();
for (PartType partType : material.getPartTypes()) {
b.append(partType.getDisplayName(0).getString()).append(" ");
for (TraitInstance trait : material.getTraits(partType)) {
traits.add(trait.getTrait().getDisplayName(0).getString());
}
}
for (String str : traits) {
b.append(str).append(" ");
}
event.getToolTip().add(new TextComponent(b.toString().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.DARK_GRAY).withStyle(ChatFormatting.ITALIC));
}
use of net.silentchaos512.gear.api.part.PartType 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.api.part.PartType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method onMaterialTooltip.
private static void onMaterialTooltip(ItemTooltipEvent event, ItemStack stack, MaterialInstance material) {
boolean keyHeld = KeyTracker.isDisplayStatsDown();
if (event.getFlags().isAdvanced()) {
event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
}
if (!Config.Client.showMaterialTooltips.get()) {
return;
}
if (keyHeld) {
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD));
} else {
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tooltip.material"), Color.GOLD).append(new TextComponent(" ").append(TextUtil.withColor(TextUtil.keyBinding(KeyTracker.DISPLAY_STATS), ChatFormatting.GRAY))));
}
if (event.getFlags().isAdvanced()) {
event.getToolTip().add(new TextComponent("Material ID: " + material.getId()).withStyle(ChatFormatting.DARK_GRAY));
event.getToolTip().add(new TextComponent("Material data pack: " + material.get().getPackName()).withStyle(ChatFormatting.DARK_GRAY));
}
if (keyHeld) {
getMaterialModifierLines(event, material);
getMaterialCategoriesLine(material).ifPresent(t -> event.getToolTip().add(t));
List<PartType> partTypes = new ArrayList<>(material.getPartTypes());
if (!partTypes.isEmpty()) {
int index = KeyTracker.getMaterialCycleIndex(partTypes.size());
PartType partType = partTypes.get(index);
event.getToolTip().add(buildPartTypeHeader(partTypes, partType));
event.getToolTip().add(TextUtil.withColor(TextUtil.misc("tier", material.getTier(partType)), Color.DEEPSKYBLUE));
getMaterialTraitLines(event, partType, material);
event.getToolTip().add(new TranslatableComponent("misc.silentgear.tooltip.stats").withStyle(ChatFormatting.GOLD));
getMaterialStatLines(event, partType, material);
}
} else {
getMaterialModifierLines(event, material);
if (event.getFlags().isAdvanced()) {
addJeiSearchTerms(event, material);
}
}
}
Aggregations