Skip to content

Commit

Permalink
fixed guis re-initializing even though resetOnOpen was false in non-1…
Browse files Browse the repository at this point in the history
….8.9
  • Loading branch information
kurrycat committed Jul 11, 2023
1 parent 5474b87 commit 0c38558
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand All @@ -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)<br>
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c38558

Please sign in to comment.