diff --git a/CommonApi/src/main/java/mezz/jei/api/runtime/IRecipesGui.java b/CommonApi/src/main/java/mezz/jei/api/runtime/IRecipesGui.java index f0966b8da..9bd5176b9 100644 --- a/CommonApi/src/main/java/mezz/jei/api/runtime/IRecipesGui.java +++ b/CommonApi/src/main/java/mezz/jei/api/runtime/IRecipesGui.java @@ -11,6 +11,7 @@ import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.gui.screens.Screen; /** * JEI's gui for displaying recipes. Use this interface to open recipes. @@ -58,4 +59,14 @@ default void show(IFocus focus) { * @return the ingredient that's currently under the mouse in this gui */ Optional getIngredientUnderMouse(IIngredientType ingredientType); + + /** + * Get the screen that the {@link IRecipesGui} was opened from. + * When the {@link IRecipesGui} is closed, it will re-open the parent screen. + * + * If the {@link IRecipesGui} is not open, this will return {@link Optional#empty()}. + * + * @since 19.20.0 + */ + Optional getParentScreen(); } diff --git a/Gui/src/main/java/mezz/jei/gui/recipes/RecipesGui.java b/Gui/src/main/java/mezz/jei/gui/recipes/RecipesGui.java index c4c6b19c8..35c7b14a8 100644 --- a/Gui/src/main/java/mezz/jei/gui/recipes/RecipesGui.java +++ b/Gui/src/main/java/mezz/jei/gui/recipes/RecipesGui.java @@ -16,7 +16,6 @@ import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.transfer.IRecipeTransferManager; -import mezz.jei.api.runtime.IIngredientManager; import mezz.jei.api.runtime.IRecipesGui; import mezz.jei.common.Internal; import mezz.jei.common.config.DebugConfig; @@ -67,7 +66,6 @@ public class RecipesGui extends Screen implements IRecipesGui, IRecipeFocusSourc private final IInternalKeyMappings keyBindings; private final BookmarkList bookmarks; private final IFocusFactory focusFactory; - private final IIngredientManager ingredientManager; private int headerHeight; @@ -111,7 +109,6 @@ public class RecipesGui extends Screen implements IRecipesGui, IRecipeFocusSourc public RecipesGui( IRecipeManager recipeManager, IRecipeTransferManager recipeTransferManager, - IIngredientManager ingredientManager, IInternalKeyMappings keyBindings, IFocusFactory focusFactory, BookmarkList bookmarks, @@ -119,7 +116,6 @@ public RecipesGui( ) { super(Component.literal("Recipes")); this.bookmarks = bookmarks; - this.ingredientManager = ingredientManager; this.keyBindings = keyBindings; this.logic = new RecipeGuiLogic( recipeManager, @@ -567,6 +563,11 @@ public AbstractContainerMenu getParentContainerMenu() { return null; } + @Override + public Optional getParentScreen() { + return Optional.ofNullable(parentScreen); + } + @Nullable public IGuiProperties getProperties() { if (width <= 0 || height <= 0) { diff --git a/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java b/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java index 5a51491d4..18b90ce6b 100644 --- a/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java +++ b/Gui/src/main/java/mezz/jei/gui/startup/JeiGuiStarter.java @@ -182,7 +182,6 @@ public static JeiEventHandlers start(IRuntimeRegistration registration) { RecipesGui recipesGui = new RecipesGui( recipeManager, recipeTransferManager, - ingredientManager, keyMappings, focusFactory, bookmarkList, diff --git a/gradle.properties b/gradle.properties index d2c192d80..28b3b7877 100644 --- a/gradle.properties +++ b/gradle.properties @@ -74,4 +74,4 @@ modrinthId=u6dRKJwZ jUnitVersion=5.8.2 # Version -specificationVersion=19.19.6 +specificationVersion=19.20.0