Skip to content

Commit c3bc7ba

Browse files
committed
Add access for the IRecipesGui's parent screen
1 parent b8a0253 commit c3bc7ba

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CommonApi/src/main/java/mezz/jei/api/runtime/IRecipesGui.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import mezz.jei.api.recipe.IFocus;
1313
import mezz.jei.api.recipe.category.IRecipeCategory;
14+
import net.minecraft.client.gui.screens.Screen;
1415

1516
/**
1617
* JEI's gui for displaying recipes. Use this interface to open recipes.
@@ -58,4 +59,14 @@ default <V> void show(IFocus<V> focus) {
5859
* @return the ingredient that's currently under the mouse in this gui
5960
*/
6061
<T> Optional<T> getIngredientUnderMouse(IIngredientType<T> ingredientType);
62+
63+
/**
64+
* Get the screen that the {@link IRecipesGui} was opened from.
65+
* When the {@link IRecipesGui} is closed, it will re-open the parent screen.
66+
*
67+
* If the {@link IRecipesGui} is not open, this will return {@link Optional#empty()}.
68+
*
69+
* @since 19.20.0
70+
*/
71+
Optional<Screen> getParentScreen();
6172
}

Gui/src/main/java/mezz/jei/gui/recipes/RecipesGui.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import mezz.jei.api.recipe.RecipeType;
1717
import mezz.jei.api.recipe.category.IRecipeCategory;
1818
import mezz.jei.api.recipe.transfer.IRecipeTransferManager;
19-
import mezz.jei.api.runtime.IIngredientManager;
2019
import mezz.jei.api.runtime.IRecipesGui;
2120
import mezz.jei.common.Internal;
2221
import mezz.jei.common.config.DebugConfig;
@@ -67,7 +66,6 @@ public class RecipesGui extends Screen implements IRecipesGui, IRecipeFocusSourc
6766
private final IInternalKeyMappings keyBindings;
6867
private final BookmarkList bookmarks;
6968
private final IFocusFactory focusFactory;
70-
private final IIngredientManager ingredientManager;
7169

7270
private int headerHeight;
7371

@@ -111,15 +109,13 @@ public class RecipesGui extends Screen implements IRecipesGui, IRecipeFocusSourc
111109
public RecipesGui(
112110
IRecipeManager recipeManager,
113111
IRecipeTransferManager recipeTransferManager,
114-
IIngredientManager ingredientManager,
115112
IInternalKeyMappings keyBindings,
116113
IFocusFactory focusFactory,
117114
BookmarkList bookmarks,
118115
IGuiHelper guiHelper
119116
) {
120117
super(Component.literal("Recipes"));
121118
this.bookmarks = bookmarks;
122-
this.ingredientManager = ingredientManager;
123119
this.keyBindings = keyBindings;
124120
this.logic = new RecipeGuiLogic(
125121
recipeManager,
@@ -567,6 +563,11 @@ public AbstractContainerMenu getParentContainerMenu() {
567563
return null;
568564
}
569565

566+
@Override
567+
public Optional<Screen> getParentScreen() {
568+
return Optional.ofNullable(parentScreen);
569+
}
570+
570571
@Nullable
571572
public IGuiProperties getProperties() {
572573
if (width <= 0 || height <= 0) {

Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ public static JeiEventHandlers start(IRuntimeRegistration registration) {
182182
RecipesGui recipesGui = new RecipesGui(
183183
recipeManager,
184184
recipeTransferManager,
185-
ingredientManager,
186185
keyMappings,
187186
focusFactory,
188187
bookmarkList,

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ modrinthId=u6dRKJwZ
7474
jUnitVersion=5.8.2
7575

7676
# Version
77-
specificationVersion=19.19.6
77+
specificationVersion=19.20.0

0 commit comments

Comments
 (0)