Skip to content

Commit 35f90d5

Browse files
committed
add convenience version of createClickableIngredient that doesn't require a type
1 parent 07e0f52 commit 35f90d5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ default <V> Optional<ITypedIngredient<V>> createTypedIngredient(V ingredient) {
168168
*/
169169
<V> Optional<IClickableIngredient<V>> createClickableIngredient(IIngredientType<V> ingredientType, V ingredient, Rect2i area, boolean normalize);
170170

171+
/**
172+
* Create a clickable ingredient.
173+
*
174+
* @see IClickableIngredient
175+
*
176+
* @param ingredient the ingredient being clicked
177+
* @param area the area that this clickable ingredient is drawn in, in absolute screen coordinates.
178+
* @param normalize set true to normalize the ingredient (see {@link IIngredientHelper#normalizeIngredient}
179+
*
180+
* @return a clickable ingredient, or {@link Optional#empty()} if the ingredient is invalid (see {@link IIngredientHelper#isValidIngredient}
181+
*
182+
* @since 15.19.3
183+
*/
184+
default <V> Optional<IClickableIngredient<V>> createClickableIngredient(V ingredient, Rect2i area, boolean normalize) {
185+
return getIngredientTypeChecked(ingredient)
186+
.flatMap(type -> createClickableIngredient(type, ingredient, area, normalize));
187+
}
188+
171189
/**
172190
* Get an ingredient by the given unique id.
173191
* This uses the uids from {@link IIngredientHelper#getUniqueId(Object, UidContext)}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ modrinthId=u6dRKJwZ
5757
jUnitVersion=5.8.2
5858

5959
# Version
60-
specificationVersion=15.19.2
60+
specificationVersion=15.19.3

0 commit comments

Comments
 (0)