aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me/shedaniel
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2023-09-01 17:37:03 +0800
committershedaniel <daniel@shedaniel.me>2023-09-01 17:37:03 +0800
commit5296049d81a7d201eeb1f535b4223bd0ba21febb (patch)
treedb95b66817c05136ec27f9112103555822740318 /api/src/main/java/me/shedaniel
parent8a68acf83e7c45b381893d1abeb35040c245ace4 (diff)
downloadRoughlyEnoughItems-5296049d81a7d201eeb1f535b4223bd0ba21febb.tar.gz
RoughlyEnoughItems-5296049d81a7d201eeb1f535b4223bd0ba21febb.tar.bz2
RoughlyEnoughItems-5296049d81a7d201eeb1f535b4223bd0ba21febb.zip
Update to 23w35a
Diffstat (limited to 'api/src/main/java/me/shedaniel')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java13
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java11
2 files changed, 16 insertions, 8 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..5a3fb9d30 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
@@ -35,6 +35,7 @@ import me.shedaniel.rei.api.common.registry.RecipeManagerContext;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.item.crafting.Recipe;
+import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
@@ -219,7 +220,7 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* @param <T> the type of object
* @param <D> the type of display
*/
- default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, RecipeType<? super T> recipeType, Function<? extends T, @Nullable D> filler) {
+ default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, RecipeType<? super T> recipeType, Function<? extends RecipeHolder<T>, @Nullable D> filler) {
registerRecipeFiller(typeClass, type -> Objects.equals(recipeType, type), filler);
}
@@ -234,7 +235,7 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* @param <T> the type of object
* @param <D> the type of display
*/
- default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Function<? extends T, @Nullable D> filler) {
+ default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Function<? extends RecipeHolder<T>, @Nullable D> filler) {
registerRecipeFiller(typeClass, recipeType, Predicates.alwaysTrue(), filler);
}
@@ -249,8 +250,12 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* @param <T> the type of object
* @param <D> the type of display
*/
- default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Predicate<? extends T> predicate, Function<? extends T, @Nullable D> filler) {
- registerFiller(typeClass, recipe -> recipeType.test((RecipeType<? super T>) recipe.getType()) && ((Predicate<T>) predicate).test(recipe), filler);
+ default <T extends Recipe<?>, D extends Display> void registerRecipeFiller(Class<T> typeClass, Predicate<RecipeType<? super T>> recipeType, Predicate<? extends RecipeHolder<T>> predicate, Function<? extends RecipeHolder<T>, @Nullable D> filler) {
+ registerFiller(RecipeHolder.class, recipe -> {
+ return typeClass.isInstance(recipe.value())
+ && recipeType.test((RecipeType<? super T>) recipe.value().getType())
+ && ((Predicate<RecipeHolder<T>>) predicate).test(recipe);
+ }, filler);
}
/**
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java b/api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java
index f37e69473..878db7b98 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/registry/RecipeManagerContext.java
@@ -28,8 +28,9 @@ import me.shedaniel.rei.api.common.plugins.REIPlugin;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.item.crafting.Recipe;
+import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeManager;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -44,7 +45,7 @@ public interface RecipeManagerContext<P extends REIPlugin<?>> extends Reloadable
/**
* @return a list of sorted recipes
*/
- List<Recipe<?>> getAllSortedRecipes();
+ List<RecipeHolder<?>> getAllSortedRecipes();
/**
* Returns the vanilla recipe manager
@@ -53,14 +54,16 @@ public interface RecipeManagerContext<P extends REIPlugin<?>> extends Reloadable
*/
RecipeManager getRecipeManager();
- default Recipe<?> byId(CompoundTag tag, String key) {
+ @Nullable
+ default RecipeHolder<?> byId(CompoundTag tag, String key) {
if (tag.contains(key, Tag.TAG_STRING)) {
return getRecipeManager().byKey(new ResourceLocation(tag.getString(key))).orElse(null);
}
return null;
}
- default Recipe<?> byId(ResourceLocation location) {
+ @Nullable
+ default RecipeHolder<?> byId(ResourceLocation location) {
return getRecipeManager().byKey(location).orElse(null);
}
}