Skip to content

Commit b5ba8ce

Browse files
committed
add convenience version of createClickableIngredient that doesn't require a type
1 parent 05ef020 commit b5ba8ce

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
@@ -177,6 +177,24 @@ default <V> Optional<ITypedIngredient<V>> createTypedIngredient(V ingredient) {
177177
*/
178178
<V> Optional<IClickableIngredient<V>> createClickableIngredient(IIngredientType<V> ingredientType, V ingredient, Rect2i area, boolean normalize);
179179

180+
/**
181+
* Create a clickable ingredient.
182+
*
183+
* @see IClickableIngredient
184+
*
185+
* @param ingredient the ingredient being clicked
186+
* @param area the area that this clickable ingredient is drawn in, in absolute screen coordinates.
187+
* @param normalize set true to normalize the ingredient (see {@link IIngredientHelper#normalizeIngredient}
188+
*
189+
* @return a clickable ingredient, or {@link Optional#empty()} if the ingredient is invalid (see {@link IIngredientHelper#isValidIngredient}
190+
*
191+
* @since 19.18.6
192+
*/
193+
default <V> Optional<IClickableIngredient<V>> createClickableIngredient(V ingredient, Rect2i area, boolean normalize) {
194+
return getIngredientTypeChecked(ingredient)
195+
.flatMap(type -> createClickableIngredient(type, ingredient, area, normalize));
196+
}
197+
180198
/**
181199
* Get an ingredient by the given unique id.
182200
* 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
@@ -74,4 +74,4 @@ modrinthId=u6dRKJwZ
7474
jUnitVersion=5.8.2
7575

7676
# Version
77-
specificationVersion=19.18.5
77+
specificationVersion=19.18.6

0 commit comments

Comments
 (0)