From 003d99a085c0e202af84c4fb658b4b6dbda63f38 Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Fri, 17 Oct 2025 05:56:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E9=80=89=E7=9A=84fa?= =?UTF-8?q?llback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/remainder/RecipeBasedCraftRemainder.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/net/momirealms/craftengine/core/item/recipe/remainder/RecipeBasedCraftRemainder.java b/core/src/main/java/net/momirealms/craftengine/core/item/recipe/remainder/RecipeBasedCraftRemainder.java index d906baee0..afe0b8e17 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/item/recipe/remainder/RecipeBasedCraftRemainder.java +++ b/core/src/main/java/net/momirealms/craftengine/core/item/recipe/remainder/RecipeBasedCraftRemainder.java @@ -4,6 +4,7 @@ import net.momirealms.craftengine.core.item.Item; import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.ResourceConfigUtils; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.List; @@ -12,9 +13,12 @@ import java.util.Map; public class RecipeBasedCraftRemainder implements CraftRemainder { public static final Factory FACTORY = new Factory(); private final Map remainders; + @Nullable + private final CraftRemainder fallback; - public RecipeBasedCraftRemainder(Map remainders) { + public RecipeBasedCraftRemainder(Map remainders, @Nullable CraftRemainder fallback) { this.remainders = remainders; + this.fallback = fallback; } @Override @@ -23,7 +27,7 @@ public class RecipeBasedCraftRemainder implements CraftRemainder { if (remainder != null) { return remainder.remainder(recipeId, item); } - return null; + return this.fallback != null ? this.fallback.remainder(recipeId, item) : null; } public static class Factory implements CraftRemainderFactory { @@ -41,7 +45,7 @@ public class RecipeBasedCraftRemainder implements CraftRemainder { remainders.put(recipeId, remainder.remainder()); } } - return new RecipeBasedCraftRemainder(remainders); + return new RecipeBasedCraftRemainder(remainders, CraftRemainders.fromObject(args.get("fallback"))); } public record GroupedRemainder(List recipes, CraftRemainder remainder) {