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