Skip to content

Commit

Permalink
Add a hook for getting the hovered ingredient in the recipe gui (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubry authored and mezz committed Oct 3, 2018
1 parent 034ec85 commit 73bd2d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=4
version_minor=13
version_patch=0
version_patch=1
12 changes: 10 additions & 2 deletions 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()}.
Expand All @@ -26,4 +27,11 @@ public interface IRecipesGui {
* @param recipeCategoryUids a list of categories to display, in order. Must not be empty.
*/
void showCategories(List<String> 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();
}
10 changes: 10 additions & 0 deletions src/main/java/mezz/jei/gui/recipes/RecipesGui.java
Expand Up @@ -399,6 +399,16 @@ public void showCategories(List<String> 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();
}
Expand Down

0 comments on commit 73bd2d0

Please sign in to comment.