From 4bea4730254f5b5e152ab089d71e7687f580c403 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 22 Nov 2018 19:40:12 -0800 Subject: [PATCH] Fix #1405 Center search bar not centered after toggling overlay --- src/main/java/mezz/jei/gui/GuiEventHandler.java | 10 +++++----- src/main/java/mezz/jei/gui/overlay/ConfigButton.java | 2 +- .../mezz/jei/gui/overlay/IngredientListOverlay.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/mezz/jei/gui/GuiEventHandler.java b/src/main/java/mezz/jei/gui/GuiEventHandler.java index fc00e10b6..caaa6d106 100644 --- a/src/main/java/mezz/jei/gui/GuiEventHandler.java +++ b/src/main/java/mezz/jei/gui/GuiEventHandler.java @@ -27,25 +27,25 @@ public GuiEventHandler(IngredientListOverlay ingredientListOverlay, RecipeRegist @SubscribeEvent public void onOverlayToggle(OverlayToggleEvent event) { GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; - ingredientListOverlay.updateScreen(currentScreen); + ingredientListOverlay.updateScreen(currentScreen, true); } @SubscribeEvent public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) { GuiScreen gui = event.getGui(); - ingredientListOverlay.updateScreen(gui); + ingredientListOverlay.updateScreen(gui, false); } @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { GuiScreen gui = event.getGui(); - ingredientListOverlay.updateScreen(gui); + ingredientListOverlay.updateScreen(gui, false); } @SubscribeEvent public void onDrawBackgroundEventPost(GuiScreenEvent.BackgroundDrawnEvent event) { GuiScreen gui = event.getGui(); - ingredientListOverlay.updateScreen(gui); + ingredientListOverlay.updateScreen(gui, false); drawnOnBackground = true; ingredientListOverlay.drawScreen(gui.mc, event.getMouseX(), event.getMouseY(), gui.mc.getRenderPartialTicks()); @@ -64,7 +64,7 @@ public void onDrawForegroundEvent(GuiContainerEvent.DrawForeground event) { public void onDrawScreenEventPost(GuiScreenEvent.DrawScreenEvent.Post event) { GuiScreen gui = event.getGui(); - ingredientListOverlay.updateScreen(gui); + ingredientListOverlay.updateScreen(gui, false); if (!drawnOnBackground) { ingredientListOverlay.drawScreen(gui.mc, event.getMouseX(), event.getMouseY(), gui.mc.getRenderPartialTicks()); diff --git a/src/main/java/mezz/jei/gui/overlay/ConfigButton.java b/src/main/java/mezz/jei/gui/overlay/ConfigButton.java index 7cb986d1f..9f4dcebb9 100644 --- a/src/main/java/mezz/jei/gui/overlay/ConfigButton.java +++ b/src/main/java/mezz/jei/gui/overlay/ConfigButton.java @@ -90,7 +90,7 @@ public boolean handleMouseClick(int mouseX, int mouseY) { } else { if (minecraft.currentScreen != null) { GuiScreen configScreen = new JEIModConfigGui(minecraft.currentScreen); - parent.updateScreen(configScreen); + parent.updateScreen(configScreen, false); minecraft.displayGuiScreen(configScreen); } } diff --git a/src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java b/src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java index 94efe42f5..03ca67d5e 100644 --- a/src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java +++ b/src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java @@ -99,7 +99,7 @@ private static Rectangle getDisplayArea(IGuiProperties guiProperties) { return new Rectangle(x, y, width, height); } - public void updateScreen(@Nullable GuiScreen guiScreen) { + public void updateScreen(@Nullable GuiScreen guiScreen, boolean forceUpdate) { JeiRuntime runtime = Internal.getRuntime(); if (runtime == null) { return; @@ -112,7 +112,7 @@ public void updateScreen(@Nullable GuiScreen guiScreen) { setKeyboardFocus(false); this.ghostIngredientDragManager.stopDrag(); } - } else if (this.guiProperties == null || !areGuiPropertiesEqual(this.guiProperties, guiProperties)) { + } else if (this.guiProperties == null || !areGuiPropertiesEqual(this.guiProperties, guiProperties) || forceUpdate) { this.guiProperties = guiProperties; this.displayArea = getDisplayArea(guiProperties);