Skip to content

Commit

Permalink
add convenience version of createClickableIngredient that doesn't req…
Browse files Browse the repository at this point in the history
…uire a type
  • Loading branch information
mezz committed Sep 19, 2024
1 parent 05ef020 commit b5ba8ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,24 @@ default <V> Optional<ITypedIngredient<V>> createTypedIngredient(V ingredient) {
*/
<V> Optional<IClickableIngredient<V>> createClickableIngredient(IIngredientType<V> ingredientType, V ingredient, Rect2i area, boolean normalize);

/**
* Create a clickable ingredient.
*
* @see IClickableIngredient
*
* @param ingredient the ingredient being clicked
* @param area the area that this clickable ingredient is drawn in, in absolute screen coordinates.
* @param normalize set true to normalize the ingredient (see {@link IIngredientHelper#normalizeIngredient}
*
* @return a clickable ingredient, or {@link Optional#empty()} if the ingredient is invalid (see {@link IIngredientHelper#isValidIngredient}
*
* @since 19.18.6
*/
default <V> Optional<IClickableIngredient<V>> createClickableIngredient(V ingredient, Rect2i area, boolean normalize) {
return getIngredientTypeChecked(ingredient)
.flatMap(type -> createClickableIngredient(type, ingredient, area, normalize));
}

/**
* Get an ingredient by the given unique id.
* This uses the uids from {@link IIngredientHelper#getUniqueId(Object, UidContext)}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ modrinthId=u6dRKJwZ
jUnitVersion=5.8.2

# Version
specificationVersion=19.18.5
specificationVersion=19.18.6

0 comments on commit b5ba8ce

Please sign in to comment.