From 73bd2d0b37cb29f2b080955228a0559ce5f0fd62 Mon Sep 17 00:00:00 2001 From: Hubry Date: Wed, 3 Oct 2018 06:13:54 +0200 Subject: [PATCH] Add a hook for getting the hovered ingredient in the recipe gui (#1374) --- gradle.properties | 2 +- src/api/java/mezz/jei/api/IRecipesGui.java | 12 ++++++++++-- src/main/java/mezz/jei/gui/recipes/RecipesGui.java | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index fd4c40e43..6e8e5c2d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ curse_project_id=238222 version_major=4 version_minor=13 -version_patch=0 +version_patch=1 diff --git a/src/api/java/mezz/jei/api/IRecipesGui.java b/src/api/java/mezz/jei/api/IRecipesGui.java index b71152b91..1f1056ae5 100644 --- a/src/api/java/mezz/jei/api/IRecipesGui.java +++ b/src/api/java/mezz/jei/api/IRecipesGui.java @@ -1,9 +1,10 @@ package mezz.jei.api; -import java.util.List; - import mezz.jei.api.recipe.IFocus; +import javax.annotation.Nullable; +import java.util.List; + /** * JEI's gui for displaying recipes. Use this interface to open recipes. * Get the instance from {@link IJeiRuntime#getRecipesGui()}. @@ -26,4 +27,11 @@ public interface IRecipesGui { * @param recipeCategoryUids a list of categories to display, in order. Must not be empty. */ void showCategories(List recipeCategoryUids); + + /** + * @return the ingredient that's currently under the mouse in this gui, or null if there is none. + * @since JEI 4.13.1 + */ + @Nullable + Object getIngredientUnderMouse(); } diff --git a/src/main/java/mezz/jei/gui/recipes/RecipesGui.java b/src/main/java/mezz/jei/gui/recipes/RecipesGui.java index d336de067..0ff9e9be9 100644 --- a/src/main/java/mezz/jei/gui/recipes/RecipesGui.java +++ b/src/main/java/mezz/jei/gui/recipes/RecipesGui.java @@ -399,6 +399,16 @@ public void showCategories(List recipeCategoryUids) { } } + @Nullable + @Override + public Object getIngredientUnderMouse() { + IClickedIngredient ingredient = getIngredientUnderMouse(MouseHelper.getX(), MouseHelper.getY()); + if (ingredient != null) { + return ingredient.getValue(); + } + return null; + } + public void back() { logic.back(); }