Better support for opening EMI screens from non-handled screens#946
Better support for opening EMI screens from non-handled screens#946Abbie5 wants to merge 2 commits intoemilyploszaj:1.21from
Conversation
emilyploszaj
left a comment
There was a problem hiding this comment.
This likely works to fix this issue, but does it cause other issues? for instance, if you open from another GUI, it'll show no recipes as craftable, even if they may be craftable via the currently open screen handler? maybe getHandledScreen should default to that so we can support both use cases.
This fixes the behaviour where, upon closing the recipe screen that was opened from the FTB Quests screen, the client is returned to the inventory screen instead of the original quest screen.
a157a64 to
12e249c
Compare
|
Hi, coming back to this PR after a while so I'm a bit rusty.
Is there a way to test this behaviour so I can make sure my implementation is correct? And, I don't see a way to get a HandledScreen from the currently open screen handler exposed in PlayerEntity#currentScreenHandler, so please clarify what you're referring to by "that". |
| return rs.old; | ||
| } else if (s instanceof BoMScreen bs) { | ||
| return bs.old; | ||
| } else if (s instanceof RecipeScreen rs && rs.old instanceof HandledScreen<?> hs) { |
There was a problem hiding this comment.
Here's what I mean in my previous comment, both RecipeScreen and BoMScreen can now have an old screen that is not a HandledScreen, such as a quest UI, and then no recipes would show up as craftable. Maybe this behavior should default to the player's inventory when nothing else is valid, since that is always accessible. WDYT?
There was a problem hiding this comment.
like this?
Index: xplat/src/main/java/dev/emi/emi/api/EmiApi.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/xplat/src/main/java/dev/emi/emi/api/EmiApi.java b/xplat/src/main/java/dev/emi/emi/api/EmiApi.java
--- a/xplat/src/main/java/dev/emi/emi/api/EmiApi.java (revision 12e249c067862fd4233bfb86ca8c92865f52fc8e)
+++ b/xplat/src/main/java/dev/emi/emi/api/EmiApi.java (date 1771852166073)
@@ -111,6 +111,8 @@
return hs;
} else if (s instanceof BoMScreen bs && bs.old instanceof HandledScreen<?> hs) {
return hs;
+ } else if (client.player != null) {
+ return new InventoryScreen(client.player);
}
return null;
}
This fixes the behaviour where, upon closing the recipe screen that was opened from the FTB Quests screen, the client is returned to the inventory screen instead of the original quest screen.