Search in sources :

Example 1 with AbilityTooltip

use of it.hurts.sskirillss.relics.client.tooltip.base.AbilityTooltip 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)

Aggregations

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