Skip to content

Commit 1767e2b

Browse files
committed
refactor(gui): enhance view mode handling in ResearchTableScreen
1 parent 2103f02 commit 1767e2b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/main/java/com/researchcube/client/screen/ResearchTableScreen.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ private void onWipeTank() {
249249
}
250250

251251
private void onSwitchToTreeView() {
252-
preferredView = ViewMode.TREE;
253-
updateViewMode();
252+
Minecraft mc = Minecraft.getInstance();
253+
if (mc.player == null) return;
254+
mc.setScreen(new ResearchTreeScreen(menu, mc.player.getInventory(), this.title));
254255
}
255256

256257
private void onSwitchToListView() {
@@ -260,12 +261,19 @@ private void onSwitchToListView() {
260261

261262
/**
262263
* Updates the view mode based on research state and user preference.
263-
* When researching: always show PROGRESS view
264+
* When researching AND definition is available: show PROGRESS view
264265
* When not researching: show user's preferred view (LIST or TREE)
265266
*/
266267
private void updateViewMode() {
267268
if (menu.isResearching()) {
268-
currentView = ViewMode.PROGRESS;
269+
// Only show PROGRESS view if the active definition is synced to client
270+
ResearchDefinition activeDef = menu.getBlockEntity().getActiveDefinition();
271+
if (activeDef != null) {
272+
currentView = ViewMode.PROGRESS;
273+
} else {
274+
// Stay in current view until definition is synced
275+
currentView = preferredView;
276+
}
269277
} else {
270278
currentView = preferredView;
271279
}

0 commit comments

Comments
 (0)