Search in sources :

Example 1 with RelicTooltip

use of it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip in project relics by SSKirillSS.

the class TooltipDescriptionHandler method getAbilitiesTooltip.

private static List<ITextComponent> getAbilitiesTooltip(ItemStack stack) {
    List<ITextComponent> tooltip = new ArrayList<>();
    if (!(stack.getItem() instanceof RelicItem))
        return tooltip;
    RelicItem<?> relic = (RelicItem<?>) stack.getItem();
    RelicTooltip data = relic.getTooltip(stack);
    if (data == null)
        return tooltip;
    List<AbilityTooltip> abilities = data.getAbilities();
    if (abilities.isEmpty())
        return tooltip;
    for (int i = 0; i < abilities.size(); i++) {
        AbilityTooltip ability = abilities.get(i);
        String path = "tooltip." + Reference.MODID + "." + Objects.requireNonNull(relic.getRegistryName()).getPath() + ".ability." + (i + 1) + ".";
        String key = ability.getKeybinding();
        tooltip.add((new StringTextComponent("   ◆ ").withStyle(ability.isNegative() ? TextFormatting.RED : TextFormatting.GREEN)).append((new TranslationTextComponent(path + "name")).withStyle(TextFormatting.YELLOW)).append((new StringTextComponent(key == null ? "" : String.format(" [%s]", key)).withStyle(TextFormatting.DARK_GRAY))).append((new StringTextComponent(" - ").withStyle(TextFormatting.WHITE))).append(new TranslationTextComponent(path + "description", ability.getArgs().toArray(new Object[0])).withStyle(TextFormatting.GRAY)));
    }
    return tooltip;
}
Also used : RelicItem(it.hurts.sskirillss.relics.items.relics.base.RelicItem) RelicTooltip(it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) AbilityTooltip(it.hurts.sskirillss.relics.client.tooltip.base.AbilityTooltip)

Example 2 with RelicTooltip

use of it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip in project relics by SSKirillSS.

the class TooltipBorderHandler method getBorderColors.

@Nullable
private static Pair<String, String> getBorderColors(ItemStack stack) {
    if (!(stack.getItem() instanceof RelicItem))
        return null;
    RelicItem<?> relic = (RelicItem<?>) stack.getItem();
    RelicTooltip tooltip = relic.getTooltip(stack);
    if (tooltip == null)
        return null;
    return tooltip.getBorders();
}
Also used : RelicItem(it.hurts.sskirillss.relics.items.relics.base.RelicItem) RelicTooltip(it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip) Nullable(javax.annotation.Nullable)

Aggregations

RelicTooltip (it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip)2 RelicItem (it.hurts.sskirillss.relics.items.relics.base.RelicItem)2 AbilityTooltip (it.hurts.sskirillss.relics.client.tooltip.base.AbilityTooltip)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 StringTextComponent (net.minecraft.util.text.StringTextComponent)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1