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);
});
}
}
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;
}
Aggregations