aboutsummaryrefslogtreecommitdiff
path: root/api/src
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-12-18 20:50:56 +0800
committershedaniel <daniel@shedaniel.me>2024-04-16 00:38:17 +0900
commitffe21652b40a93a00f33a27a5ecf41479b48bcd9 (patch)
tree2861df1f563c35c78a1eda7477f6c201eed7ce56 /api/src
parente6687c01b254bf903d4895aa0bb631b1679d465c (diff)
downloadRoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.tar.gz
RoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.tar.bz2
RoughlyEnoughItems-ffe21652b40a93a00f33a27a5ecf41479b48bcd9.zip
Close #1131
Diffstat (limited to 'api/src')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java121
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