Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,26 @@ public class ClientScreenHandler {
private static long ticks = 0L;

private static IMuiScreen lastMui;

public static boolean guiIsClosing;

// we need to know the actual gui and not some fake bs some other mod overwrites
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onGuiOpen(GuiOpenEvent event) {
GuiScreen newGui = event.getGui();
guiIsClosing = newGui == null;

defaultContext.reset();
if (lastMui != null && event.getGui() == null) {
if (lastMui != null && newGui == null) {
if (lastMui.getScreen().getPanelManager().isOpen()) {
lastMui.getScreen().getPanelManager().closeAll();
}
lastMui.getScreen().getPanelManager().dispose();
lastMui = null;
} else if (event.getGui() instanceof IMuiScreen screenWrapper) {
} else if (newGui instanceof IMuiScreen screenWrapper) {
if (lastMui == null) {
lastMui = screenWrapper;
} else if (lastMui == event.getGui()) {
} else if (lastMui == newGui) {
lastMui.getScreen().getPanelManager().reopen();
} else {
if (lastMui.getScreen().getPanelManager().isOpen()) {
Expand All @@ -103,7 +108,7 @@ public static void onGuiOpen(GuiOpenEvent event) {
}
}

if (event.getGui() instanceof IMuiScreen muiScreen) {
if (newGui instanceof IMuiScreen muiScreen) {
Objects.requireNonNull(muiScreen.getScreen(), "ModularScreen must not be null!");
if (currentScreen != muiScreen.getScreen()) {
if (hasScreen()) {
Expand All @@ -114,7 +119,7 @@ public static void onGuiOpen(GuiOpenEvent event) {
currentScreen = muiScreen.getScreen();
fpsCounter.reset();
}
} else if (hasScreen() && getMCScreen() != null && event.getGui() != getMCScreen()) {
} else if (hasScreen() && getMCScreen() != null && newGui != getMCScreen()) {
currentScreen.onCloseParent();
currentScreen = null;
lastChar = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cleanroommc.modularui.value.sync;

import com.cleanroommc.modularui.ModularUI;
import com.cleanroommc.modularui.screen.ClientScreenHandler;
import com.cleanroommc.modularui.screen.ModularContainer;
import com.cleanroommc.modularui.widgets.slot.SlotGroup;
import com.cleanroommc.bogosorter.api.ISortingContextBuilder;
Expand Down Expand Up @@ -61,7 +62,9 @@ public void detectAndSendChanges(boolean init) {
}

public void onClose() {
this.panelSyncManagerMap.values().forEach(PanelSyncManager::onClose);
if (ClientScreenHandler.guiIsClosing) {
this.panelSyncManagerMap.values().forEach(PanelSyncManager::onClose);
}
}

public void onOpen() {
Expand Down