From abfcdbb3f25a883b5094bdd4b29b4e010be2dcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Lindstr=C3=B6m?= Date: Thu, 3 Sep 2020 03:39:30 +0200 Subject: [PATCH] Highly experimental support for backing to BQ when coming from there This is a highly exprimental solution to backing out of NEI's recipe view back to whatever opened it, such as BetterQuesting. It seems highly likely that this will break something somewhere, but extremely quick testing did not find any such case. --- src/codechicken/nei/recipe/GuiCraftingRecipe.java | 5 +++-- src/codechicken/nei/recipe/GuiRecipe.java | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/codechicken/nei/recipe/GuiCraftingRecipe.java b/src/codechicken/nei/recipe/GuiCraftingRecipe.java index fc26ce9d..0a775035 100644 --- a/src/codechicken/nei/recipe/GuiCraftingRecipe.java +++ b/src/codechicken/nei/recipe/GuiCraftingRecipe.java @@ -4,6 +4,7 @@ import codechicken.core.TaskProfiler; import codechicken.nei.ItemList; import codechicken.nei.NEIClientUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import java.util.ArrayList; @@ -14,7 +15,7 @@ public class GuiCraftingRecipe extends GuiRecipe { public static boolean openRecipeGui(String outputId, Object... results) { Minecraft mc = NEIClientUtils.mc(); - GuiContainer prevscreen = mc.currentScreen instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null; + GuiScreen prevscreen = mc.currentScreen;// instanceof GuiContainer ? (GuiContainer) mc.currentScreen : null; ArrayList handlers; TaskProfiler profiler = ProfilerRecipeHandler.getProfiler(); @@ -38,7 +39,7 @@ public class GuiCraftingRecipe extends GuiRecipe return true; } - private GuiCraftingRecipe(GuiContainer prevgui, ArrayList handlers) { + private GuiCraftingRecipe(GuiScreen prevgui, ArrayList handlers) { super(prevgui); currenthandlers = handlers; } diff --git a/src/codechicken/nei/recipe/GuiRecipe.java b/src/codechicken/nei/recipe/GuiRecipe.java index 13b71b6a..a7635878 100644 --- a/src/codechicken/nei/recipe/GuiRecipe.java +++ b/src/codechicken/nei/recipe/GuiRecipe.java @@ -15,6 +15,7 @@ import codechicken.nei.guihook.IContainerTooltipHandler; import codechicken.nei.guihook.IGuiClientSide; import codechicken.nei.guihook.IGuiHandleMouseWheel; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -34,18 +35,20 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve public int recipetype; public ContainerRecipe slotcontainer; public GuiContainer firstGui; - public GuiContainer prevGui; + public GuiScreen prevGui; public GuiButton nextpage; public GuiButton prevpage; public GuiButton overlay1; public GuiButton overlay2; - protected GuiRecipe(GuiContainer prevgui) { + protected GuiRecipe(GuiScreen prevgui) { super(new ContainerRecipe()); slotcontainer = (ContainerRecipe) inventorySlots; this.prevGui = prevgui; - this.firstGui = prevgui; + if(prevgui instanceof GuiContainer) + this.firstGui = (GuiContainer)prevgui; + if (prevgui instanceof IGuiContainerOverlay) this.firstGui = ((IGuiContainerOverlay) prevgui).getFirstScreen(); }