From e64108cf1b6cd147bece207453ad0ede8c4b5bd7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 4 Jan 2019 21:47:38 +0800 Subject: fixes esc and crashes --- src/main/java/me/shedaniel/ClientListener.java | 6 +++--- src/main/java/me/shedaniel/gui/GuiItemList.java | 7 ++----- .../java/me/shedaniel/gui/REIRenderHelper.java | 22 +++++++++++++--------- src/main/java/me/shedaniel/gui/RecipeGui.java | 2 +- src/main/java/me/shedaniel/gui/widget/REISlot.java | 5 ++++- 5 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/me/shedaniel/ClientListener.java b/src/main/java/me/shedaniel/ClientListener.java index 18fb26130..ec1061e2f 100755 --- a/src/main/java/me/shedaniel/ClientListener.java +++ b/src/main/java/me/shedaniel/ClientListener.java @@ -47,7 +47,7 @@ public class ClientListener implements DoneLoading, RecipeLoadListener { @Override public boolean apply(int key) { if (key == this.getKey()) - REIRenderHelper.recipeKeybind(); + REIRenderHelper.recipeKeyBind(); return key == this.getKey(); } }; @@ -55,7 +55,7 @@ public class ClientListener implements DoneLoading, RecipeLoadListener { @Override public boolean apply(int key) { if (key == this.getKey()) - REIRenderHelper.hideKeybind(); + REIRenderHelper.hideKeyBind(); return key == this.getKey(); } }; @@ -63,7 +63,7 @@ public class ClientListener implements DoneLoading, RecipeLoadListener { @Override public boolean apply(int key) { if (key == this.getKey()) - REIRenderHelper.useKeybind(); + REIRenderHelper.useKeyBind(); return key == this.getKey(); } }; diff --git a/src/main/java/me/shedaniel/gui/GuiItemList.java b/src/main/java/me/shedaniel/gui/GuiItemList.java index f0c8ce3aa..defdd6643 100755 --- a/src/main/java/me/shedaniel/gui/GuiItemList.java +++ b/src/main/java/me/shedaniel/gui/GuiItemList.java @@ -35,11 +35,8 @@ public class GuiItemList extends Drawable { private ArrayList displaySlots; protected ArrayList controls; private boolean needsResize = false; - Button buttonLeft; - Button buttonRight; - Button buttonCheating; - Button buttonConfig; - TextBox searchBox; + Button buttonLeft, buttonRight, buttonCheating, buttonConfig; + private TextBox searchBox; private ArrayList view; private Control lastHovered; protected boolean visible = true; diff --git a/src/main/java/me/shedaniel/gui/REIRenderHelper.java b/src/main/java/me/shedaniel/gui/REIRenderHelper.java index cd68534f3..985eb721f 100755 --- a/src/main/java/me/shedaniel/gui/REIRenderHelper.java +++ b/src/main/java/me/shedaniel/gui/REIRenderHelper.java @@ -238,41 +238,45 @@ public class REIRenderHelper { reiGui.tick(); } - public static void recipeKeybind() { + public static boolean recipeKeyBind() { if (!(MinecraftClient.getInstance().currentGui instanceof ContainerGui)) - return; + return false; Control control = reiGui.getLastHovered(); if (control != null && control.isHighlighted() && control instanceof REISlot) { REISlot slot = (REISlot) control; REIRecipeManager.instance().displayRecipesFor(slot.getStack()); - return; + return true; } if (((IMixinContainerGui) overlayedGui).getHoveredSlot() != null) { ItemStack stack = ((IMixinContainerGui) overlayedGui).getHoveredSlot().getStack(); REIRecipeManager.instance().displayRecipesFor(stack); + return true; } - + return false; } - public static void useKeybind() { + public static boolean useKeyBind() { if (!(MinecraftClient.getInstance().currentGui instanceof ContainerGui)) - return; + return false; Control control = reiGui.getLastHovered(); if (control != null && control.isHighlighted() && control instanceof REISlot) { REISlot slot = (REISlot) control; REIRecipeManager.instance().displayUsesFor(slot.getStack()); - return; + return true; } if (((IMixinContainerGui) overlayedGui).getHoveredSlot() != null) { ItemStack stack = ((IMixinContainerGui) overlayedGui).getHoveredSlot().getStack(); REIRecipeManager.instance().displayUsesFor(stack); + return true; } - + return false; } - public static void hideKeybind() { + public static boolean hideKeyBind() { if (MinecraftClient.getInstance().currentGui == overlayedGui && reiGui != null) { reiGui.visible = !reiGui.visible; + return true; } + return false; } } diff --git a/src/main/java/me/shedaniel/gui/RecipeGui.java b/src/main/java/me/shedaniel/gui/RecipeGui.java index bee43415b..cf2c87572 100755 --- a/src/main/java/me/shedaniel/gui/RecipeGui.java +++ b/src/main/java/me/shedaniel/gui/RecipeGui.java @@ -220,7 +220,7 @@ public class RecipeGui extends ContainerGui { @Override public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) { - if (p_keyPressed_1_ == 259 && prevScreen != null && REIRenderHelper.focusedControl == null) { + if (p_keyPressed_1_ == 256 && prevScreen != null) { this.client.openGui(prevScreen); return true; } diff --git a/src/main/java/me/shedaniel/gui/widget/REISlot.java b/src/main/java/me/shedaniel/gui/widget/REISlot.java index 73faa85c4..d1a41ac59 100755 --- a/src/main/java/me/shedaniel/gui/widget/REISlot.java +++ b/src/main/java/me/shedaniel/gui/widget/REISlot.java @@ -127,7 +127,10 @@ public class REISlot extends Control { return true; } } else { - REIRenderHelper.recipeKeybind(); + if (button == 0) + return REIRenderHelper.recipeKeyBind(); + else if (button == 1) + return REIRenderHelper.useKeyBind(); } return false; } -- cgit