diff --git a/common/src/main/java/io/github/kurrycat/mpkmod/gui/MPKGuiScreen.java b/common/src/main/java/io/github/kurrycat/mpkmod/gui/MPKGuiScreen.java index d7369fb..ff7ea27 100644 --- a/common/src/main/java/io/github/kurrycat/mpkmod/gui/MPKGuiScreen.java +++ b/common/src/main/java/io/github/kurrycat/mpkmod/gui/MPKGuiScreen.java @@ -27,15 +27,24 @@ public Vector2D getScreenSize() { } public final void onInit() { - initialized = true; setSize(Renderer2D.getScaledSize()); setRoot(this); - onGuiInit(); + if (!initialized || resetOnOpen()) + onGuiInit(); + initialized = true; + } + + public boolean resetOnOpen() { + return true; } public void onGuiInit() { } + public boolean isInitialized() { + return initialized; + } + public void onGuiClosed() { } @@ -59,7 +68,6 @@ public void onMouseClickMove(Vector2D mouse, int mouseButton, long timeSinceLast public void onMouseReleased(Vector2D mouse, int mouseButton) { } - /** * @param mousePos Mouse position when scrolled * @param delta number of lines to scroll (one scroll tick = 3 per default)
@@ -84,14 +92,6 @@ public boolean shouldCreateKeyBind() { return false; } - public boolean resetOnOpen() { - return true; - } - - public boolean isInitialized() { - return initialized; - } - public final void close() { Minecraft.displayGuiScreen(null); } diff --git a/forge-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/forge_1_8/MPKGuiScreen.java b/forge-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/forge_1_8/MPKGuiScreen.java index dd730cd..729cb67 100644 --- a/forge-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/forge_1_8/MPKGuiScreen.java +++ b/forge-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/forge_1_8/MPKGuiScreen.java @@ -37,8 +37,7 @@ public void initGui() { repeatEventsEnabled = Keyboard.areRepeatEventsEnabled(); Keyboard.enableRepeatEvents(true); super.initGui(); - if (!eventReceiver.isInitialized() || eventReceiver.resetOnOpen()) - eventReceiver.onInit(); + eventReceiver.onInit(); } @Override