Allow GuiRecipe to back to general GuiScreen (#236)

This commit is contained in:
miozune authored and GitHub committed 2022-04-25 15:31:50 +02:00
1 parent 995ed24056
commit d6a6551561
2 files changed
+19 -5

No files matched your search

@@ -1,8 +1,13 @@
package codechicken.nei.api;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
public interface IGuiContainerOverlay
{
public GuiContainer getFirstScreen();
GuiContainer getFirstScreen();
default GuiScreen getFirstScreenGeneral() {
return getFirstScreen();
}
}
@@ -65,6 +65,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
public int recipetype;
public ContainerRecipe slotcontainer;
public GuiContainer firstGui;
public GuiScreen firstGuiGeneral;
public GuiScreen prevGui;
public GuiButton nextpage;
public GuiButton prevpage;
@@ -89,12 +90,15 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
slotcontainer = (ContainerRecipe) inventorySlots;
this.prevGui = prevgui;
this.firstGuiGeneral = prevgui;
if(prevgui instanceof GuiContainer)
this.firstGui = (GuiContainer)prevgui;
if (prevgui instanceof IGuiContainerOverlay)
if (prevgui instanceof IGuiContainerOverlay) {
this.firstGui = ((IGuiContainerOverlay) prevgui).getFirstScreen();
this.firstGuiGeneral = ((IGuiContainerOverlay) prevgui).getFirstScreenGeneral();
}
}
/**
@@ -311,7 +315,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
public void keyTyped(char c, int i) {
if (i == Keyboard.KEY_ESCAPE) //esc
{
mc.displayGuiScreen(firstGui);
mc.displayGuiScreen(firstGuiGeneral);
return;
}
if (GuiContainerManager.getManager(this).lastKeyTyped(i, c))
@@ -324,7 +328,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
}
if (i == mc.gameSettings.keyBindInventory.getKeyCode())
mc.displayGuiScreen(firstGui);
mc.displayGuiScreen(firstGuiGeneral);
else if (i == NEIClientConfig.getKeyBinding("gui.back"))
mc.displayGuiScreen(prevGui);
else if (i == NEIClientConfig.getKeyBinding("gui.prev_machine"))
@@ -644,6 +648,11 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
return firstGui;
}
@Override
public GuiScreen getFirstScreenGeneral() {
return firstGuiGeneral;
}
public boolean isMouseOver(PositionedStack stack, int recipe) {
Slot stackSlot = slotcontainer.getSlotWithStack(stack, getRecipePosition(recipe).x, getRecipePosition(recipe).y);
Point mousepos = GuiDraw.getMousePosition();