diff options
Diffstat (limited to 'api/src')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java | 121 |
1 files changed, 114 insertions, 7 deletions
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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + default <T extends Recipe<?>, D extends Display> void registerRecipesFiller(Class<T> typeClass, RecipeType<? super T> recipeType, Function<? extends T, @Nullable Collection<? extends D>> filler) { + registerRecipesFiller(typeClass, type -> Objects.equals(recipeType, type), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + default <T extends Recipe<?>, D extends Display> void registerRecipesFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Function<? extends T, @Nullable Collection<? extends D>> filler) { + registerRecipesFiller(typeClass, recipeType, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + default <T extends Recipe<?>, D extends Display> void registerRecipesFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Predicate<? extends T> predicate, Function<? extends T, @Nullable Collection<? extends D>> filler) { + registerDisplaysFiller(typeClass, recipe -> recipeType.test((RecipeType<? super T>) recipe.getType()) && ((Predicate<T>) predicate).test(recipe), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + default <T, D extends Display> void registerDisplaysFiller(Class<T> typeClass, Function<? extends T, @Nullable Collection<? extends D>> filler) { + registerDisplaysFiller(typeClass, Predicates.alwaysTrue(), filler); + } + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + <T, D extends Display> void registerDisplaysFiller(Class<T> typeClass, Predicate<? extends T> predicate, Function<? extends T, @Nullable Collection<? extends D>> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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<REIClientPlugin> { * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. * <p> * 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 <T> the type of object + * @param <D> the type of display + */ + @ApiStatus.Experimental + <T, D extends Display> void registerDisplaysFiller(Class<T> typeClass, BiPredicate<? extends T, DisplayAdditionReasons> predicate, Function<? extends T, @Nullable Collection<? extends D>> filler); + + /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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} @@ -310,6 +404,19 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> { <D extends Display> void registerFiller(Predicate<?> predicate, Function<?, @Nullable D> filler); /** + * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}. + * <p> + * 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 <D> the type of display + */ + @ApiStatus.Experimental + <D extends Display> void registerDisplaysFiller(Predicate<?> predicate, Function<?, @Nullable Collection<? extends D>> filler); + + /** * Tries to fill displays from {@code T}. * * @param value the object |
