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.
This commit is contained in:
David Lindström committed 2020-09-03 03:39:30 +02:00
1 parent 2fae9f0968
commit abfcdbb3f2
2 files changed
+9 -5

No files matched your search

@@ -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<ICraftingHandler> handlers;
TaskProfiler profiler = ProfilerRecipeHandler.getProfiler();
@@ -38,7 +39,7 @@ public class GuiCraftingRecipe extends GuiRecipe
return true;
}
private GuiCraftingRecipe(GuiContainer prevgui, ArrayList<ICraftingHandler> handlers) {
private GuiCraftingRecipe(GuiScreen prevgui, ArrayList<ICraftingHandler> handlers) {
super(prevgui);
currenthandlers = handlers;
}
+6 -3
View File
@@ -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();
}