From ffe21652b40a93a00f33a27a5ecf41479b48bcd9 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 18 Dec 2022 20:50:56 +0800 Subject: Close #1131 --- .../client/registry/display/DisplayRegistry.java | 121 +++++++++++++++++++-- 1 file changed, 114 insertions(+), 7 deletions(-) (limited to 'api/src/main/java') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java index fd34e4e84..b708a2e31 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java @@ -212,7 +212,7 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -227,7 +227,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, RecipeType recipeType, Function> filler) { + registerRecipesFiller(typeClass, type -> Objects.equals(recipeType, type), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -242,7 +258,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Function> filler) { + registerRecipesFiller(typeClass, recipeType, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -257,7 +289,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default , D extends Display> void registerRecipesFiller(Class typeClass, Predicate> recipeType, Predicate predicate, Function> filler) { + registerDisplaysFiller(typeClass, recipe -> recipeType.test((RecipeType) recipe.getType()) && ((Predicate) predicate).test(recipe), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param filler the filler, taking a {@code T} and returning a {@code D} @@ -272,7 +320,23 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + default void registerDisplaysFiller(Class typeClass, Function> filler) { + registerDisplaysFiller(typeClass, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param predicate the predicate of {@code T} @@ -286,7 +350,22 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param predicate the predicate of {@code T} + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Class typeClass, Predicate predicate, Function> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param typeClass the type of {@code T} * @param predicate the predicate of {@code T} and reason @@ -301,7 +380,22 @@ public interface DisplayRegistry extends RecipeManagerContext { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. *

* Vanilla {@link Recipe} are by default filled, display filters - * can be used to automatically generate displaies for vanilla {@link Recipe}. + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param typeClass the type of {@code T} + * @param predicate the predicate of {@code T} and reason + * @param filler the filler, taking a {@code T} and returning a {@code D} + * @param the type of object + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Class typeClass, BiPredicate predicate, Function> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. * * @param predicate the predicate of the object * @param filler the filler, taking an object and returning a {@code D} @@ -309,6 +403,19 @@ public interface DisplayRegistry extends RecipeManagerContext { */ void registerFiller(Predicate predicate, Function filler); + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + *

+ * Vanilla {@link Recipe} are by default filled, display filters + * can be used to automatically generate displays for vanilla {@link Recipe}. + * + * @param predicate the predicate of the object + * @param filler the filler, taking an object and returning a {@code D} + * @param the type of display + */ + @ApiStatus.Experimental + void registerDisplaysFiller(Predicate predicate, Function> filler); + /** * Tries to fill displays from {@code T}. * -- cgit