Search in sources :

Example 1 with BookLookupInfo

use of hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo in project AstralSorcery by HellFirePvP.

the class RenderPageRecipeTemplate method addInputInformation.

protected void addInputInformation(ItemStack stack, @Nullable Ingredient stackIngredient, List<ITextProperties> tooltip) {
    try {
        tooltip.addAll(stack.getTooltip(Minecraft.getInstance().player, Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL));
    } catch (Exception exc) {
        tooltip.add(new TranslationTextComponent("astralsorcery.misc.tooltipError").mergeStyle(TextFormatting.RED));
    }
    BookLookupInfo info = BookLookupRegistry.findPage(Minecraft.getInstance().player, LogicalSide.CLIENT, stack);
    if (info != null && info.canSee(ResearchHelper.getProgress(Minecraft.getInstance().player, LogicalSide.CLIENT)) && !info.getResearchNode().equals(this.getResearchNode())) {
        tooltip.add(StringTextComponent.EMPTY);
        tooltip.add(new TranslationTextComponent("astralsorcery.misc.craftInformation").mergeStyle(TextFormatting.GRAY));
    }
    if (stackIngredient != null && Minecraft.getInstance().gameSettings.advancedItemTooltips) {
        ITag<Item> itemTag = IngredientHelper.guessTag(stackIngredient);
        if (itemTag instanceof ITag.INamedTag) {
            tooltip.add(StringTextComponent.EMPTY);
            tooltip.add(new TranslationTextComponent("astralsorcery.misc.input.tag", ((ITag.INamedTag<Item>) itemTag).getName().toString()).mergeStyle(TextFormatting.GRAY));
        }
        if (stackIngredient instanceof FluidIngredient) {
            List<FluidStack> fluids = ((FluidIngredient) stackIngredient).getFluids();
            if (!fluids.isEmpty()) {
                ITextProperties cmp = null;
                for (FluidStack f : fluids) {
                    if (cmp == null) {
                        cmp = f.getFluid().getAttributes().getDisplayName(f);
                    } else {
                        cmp = new TranslationTextComponent("astralsorcery.misc.input.fluid.chain", cmp, f.getFluid().getAttributes().getDisplayName(f)).mergeStyle(TextFormatting.GRAY);
                    }
                }
                tooltip.add(StringTextComponent.EMPTY);
                tooltip.add(new TranslationTextComponent("astralsorcery.misc.input.fluid", cmp).mergeStyle(TextFormatting.GRAY));
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) FluidIngredient(hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) BookLookupInfo(hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 2 with BookLookupInfo

use of hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo in project AstralSorcery by HellFirePvP.

the class RenderPageRecipeTemplate method handleBookLookupClick.

public boolean handleBookLookupClick(double mouseX, double mouseZ) {
    for (Rectangle r : thisFrameInputStacks.keySet()) {
        if (r.contains(mouseX, mouseZ)) {
            ItemStack stack = thisFrameInputStacks.get(r).getA();
            BookLookupInfo info = BookLookupRegistry.findPage(Minecraft.getInstance().player, LogicalSide.CLIENT, stack);
            if (info != null && info.canSee(ResearchHelper.getProgress(Minecraft.getInstance().player, LogicalSide.CLIENT)) && !info.getResearchNode().equals(this.getResearchNode())) {
                info.openGui();
                return true;
            }
        }
    }
    if (this.thisFrameOuputStack != null) {
        if (this.thisFrameOuputStack.getA().contains(mouseX, mouseZ)) {
            ItemStack stack = this.thisFrameOuputStack.getB();
            BookLookupInfo info = BookLookupRegistry.findPage(Minecraft.getInstance().player, LogicalSide.CLIENT, stack);
            if (info != null && info.canSee(ResearchHelper.getProgress(Minecraft.getInstance().player, LogicalSide.CLIENT)) && !info.getResearchNode().equals(this.getResearchNode())) {
                info.openGui();
                return true;
            }
        }
    }
    return false;
}
Also used : BookLookupInfo(hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BookLookupInfo (hellfirepvp.astralsorcery.common.auxiliary.book.BookLookupInfo)2 FluidIngredient (hellfirepvp.astralsorcery.common.crafting.helper.ingredient.FluidIngredient)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ITextProperties (net.minecraft.util.text.ITextProperties)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1 FluidStack (net.minecraftforge.fluids.FluidStack)1