Search in sources :

Example 1 with IRepairableItem

use of it.hurts.sskirillss.relics.api.durability.IRepairableItem in project relics by SSKirillSS.

the class TooltipDescriptionHandler method renderState.

private static void renderState(ItemStack stack, List<ITextComponent> tooltip, PlayerEntity player) {
    if (player == null || stack == null)
        return;
    Item item = stack.getItem();
    if (item instanceof IRepairableItem) {
        if (DurabilityUtils.isBroken(stack))
            tooltip.add((new StringTextComponent("▶ ").withStyle(TextFormatting.GOLD)).append((new TranslationTextComponent("tooltip.relics.relic.broken")).withStyle(TextFormatting.YELLOW)));
        else if (stack.getDamageValue() >= stack.getMaxDamage() * 0.1F)
            tooltip.add((new StringTextComponent("▶ ").withStyle(TextFormatting.GOLD)).append((new TranslationTextComponent("tooltip.relics.relic.damaged")).withStyle(TextFormatting.YELLOW)));
    }
    for (String tag : CuriosApi.getCuriosHelper().getCurioTags(item)) {
        CuriosApi.getCuriosHelper().getCuriosHandler(player).ifPresent(handler -> {
            Map<String, ICurioStacksHandler> curios = handler.getCurios();
            if (curios.size() == 0)
                return;
            List<ITextComponent> list = new ArrayList<>();
            if (curios.get(tag) == null || curios.get(tag).getSlots() > 0)
                return;
            for (Item curio : ItemRegistry.getSlotModifiers()) {
                RelicItem<?> relic = (RelicItem<?>) curio;
                for (Pair<String, Integer> pair : relic.getSlotModifiers(stack).getModifiers()) {
                    String identifier = pair.getLeft();
                    int amount = pair.getRight();
                    if (identifier.equals(tag) && amount > 0)
                        list.add((new StringTextComponent("   ◆ ").withStyle(TextFormatting.YELLOW)).append(new StringTextComponent(new ItemStack(curio).getHoverName().getString()).withStyle(TextFormatting.GREEN)).append((new StringTextComponent(String.format(" [+%d]", amount)).withStyle(TextFormatting.WHITE))));
                }
            }
            StringTextComponent info = new StringTextComponent("");
            info.append((new StringTextComponent("▶ ").withStyle(TextFormatting.GOLD)).append((new TranslationTextComponent("tooltip.relics.relic.requires_slot")).withStyle(TextFormatting.YELLOW)).append(" ").append((new TranslationTextComponent("curios.identifier." + tag).withStyle(TextFormatting.GREEN))));
            if (!list.isEmpty())
                info.append(". ").withStyle(TextFormatting.YELLOW).append(new TranslationTextComponent("tooltip.relics.relic.allowed_modifiers").withStyle(TextFormatting.YELLOW));
            tooltip.add(info);
            if (!list.isEmpty())
                tooltip.addAll(list);
        });
    }
}
Also used : RelicItem(it.hurts.sskirillss.relics.items.relics.base.RelicItem) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) ICurioStacksHandler(top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler) IRepairableItem(it.hurts.sskirillss.relics.api.durability.IRepairableItem) Item(net.minecraft.item.Item) ILeveledItem(it.hurts.sskirillss.relics.api.leveling.ILeveledItem) ICurioItem(top.theillusivec4.curios.api.type.capability.ICurioItem) RelicItem(it.hurts.sskirillss.relics.items.relics.base.RelicItem) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) IRepairableItem(it.hurts.sskirillss.relics.api.durability.IRepairableItem) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IRepairableItem

use of it.hurts.sskirillss.relics.api.durability.IRepairableItem in project relics by SSKirillSS.

the class TooltipDescriptionHandler method getDurabilityTooltip.

private static List<ITextComponent> getDurabilityTooltip(ItemStack stack) {
    List<ITextComponent> tooltip = new ArrayList<>();
    if (!(stack.getItem() instanceof IRepairableItem) || DurabilityUtils.isBroken(stack))
        return tooltip;
    tooltip.add((new StringTextComponent("   ◆ ").withStyle(TextFormatting.GREEN)).append((new TranslationTextComponent("tooltip.relics.shift.stats.durability")).withStyle(TextFormatting.YELLOW)).append((new StringTextComponent(String.format(" %d/%d", DurabilityUtils.getDurability(stack), stack.getMaxDamage()))).withStyle(TextFormatting.WHITE)));
    return tooltip;
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) IRepairableItem(it.hurts.sskirillss.relics.api.durability.IRepairableItem)

Aggregations

IRepairableItem (it.hurts.sskirillss.relics.api.durability.IRepairableItem)2 ArrayList (java.util.ArrayList)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 ILeveledItem (it.hurts.sskirillss.relics.api.leveling.ILeveledItem)1 RelicItem (it.hurts.sskirillss.relics.items.relics.base.RelicItem)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ICurioItem (top.theillusivec4.curios.api.type.capability.ICurioItem)1 ICurioStacksHandler (top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler)1