aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-06-06 20:13:29 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-06-06 20:13:29 +0800
commit23698d1218bb325596ead0736a7a0636c7796ad7 (patch)
tree8283f7bd34518b17560dab9bd8c84d68529c2892 /src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
parentdb368a5149b38934e2585ca4ddd75b427d84b8b4 (diff)
downloadRoughlyEnoughItems-23698d1218bb325596ead0736a7a0636c7796ad7.tar.gz
RoughlyEnoughItems-23698d1218bb325596ead0736a7a0636c7796ad7.tar.bz2
RoughlyEnoughItems-23698d1218bb325596ead0736a7a0636c7796ad7.zip
better api for whatever reason
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java')
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
index 00155ba65..7f4a0ee80 100644
--- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
+++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
@@ -271,7 +271,7 @@ public class RecipeHelperImpl implements RecipeHelper {
Collections.reverse(allSortedRecipes);
recipeFunctions.forEach(recipeFunction -> {
try {
- allSortedRecipes.stream().filter(recipe -> recipeFunction.recipeClass.isAssignableFrom(recipe.getClass())).forEach(t -> registerDisplay(recipeFunction.category, (RecipeDisplay) recipeFunction.mappingFunction.apply(t), 0));
+ allSortedRecipes.stream().filter(recipe -> recipeFunction.recipeFilter.apply(recipe)).forEach(t -> registerDisplay(recipeFunction.category, (RecipeDisplay) recipeFunction.mappingFunction.apply(t), 0));
} catch (Exception e) {
RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to add recipes!", e);
}
@@ -356,7 +356,12 @@ public class RecipeHelperImpl implements RecipeHelper {
@Override
public <T extends Recipe<?>> void registerRecipes(Identifier category, Class<T> recipeClass, Function<T, RecipeDisplay> mappingFunction) {
- recipeFunctions.add(new RecipeFunction(category, recipeClass, mappingFunction));
+ recipeFunctions.add(new RecipeFunction(category, recipe -> recipeClass.isAssignableFrom(recipe.getClass()), mappingFunction));
+ }
+
+ @Override
+ public <T extends Recipe<?>> void registerRecipes(Identifier category, Function<Recipe, Boolean> recipeFilter, Function<T, RecipeDisplay> mappingFunction) {
+ recipeFunctions.add(new RecipeFunction(category, recipeFilter, mappingFunction));
}
@Override
@@ -371,12 +376,12 @@ public class RecipeHelperImpl implements RecipeHelper {
private class RecipeFunction {
Identifier category;
- Class recipeClass;
+ Function<Recipe, Boolean> recipeFilter;
Function mappingFunction;
- public RecipeFunction(Identifier category, Class<?> recipeClass, Function<?, RecipeDisplay> mappingFunction) {
+ public RecipeFunction(Identifier category, Function<Recipe, Boolean> recipeFilter, Function<?, RecipeDisplay> mappingFunction) {
this.category = category;
- this.recipeClass = recipeClass;
+ this.recipeFilter = recipeFilter;
this.mappingFunction = mappingFunction;
}
}