From 5480da909e0b8b852cb2599a6bcea8c7abb85b8e Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 29 Apr 2023 15:42:59 +0200 Subject: [PATCH] Fixed loading of InfusionRecipe Categories --- .../recipe/builders/InfusionRecipe.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java b/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java index 6069b186..e63b695d 100644 --- a/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java +++ b/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java @@ -59,8 +59,10 @@ public class InfusionRecipe implements Recipe, UnknownReceipBook this.id = id; this.input = input; this.output = output; - this.catalysts = new Ingredient[8]; - Arrays.fill(catalysts, Ingredient.EMPTY); + this.catalysts = new Ingredient[]{ + Ingredient.EMPTY, Ingredient.EMPTY, Ingredient.EMPTY, Ingredient.EMPTY, + Ingredient.EMPTY, Ingredient.EMPTY, Ingredient.EMPTY, Ingredient.EMPTY + }; } public static Builder create(String id, ItemLike output) { @@ -266,13 +268,19 @@ public class InfusionRecipe implements Recipe, UnknownReceipBook JsonObject o = el.getAsJsonObject(); //directly read as ingredient if (o.has("tag")) { - return ItemUtil.fromJsonIngredientWithNBT(o); + final Ingredient res = ItemUtil.fromJsonIngredientWithNBT(o); + if (res == null) return Ingredient.EMPTY; + return res; } else { - return Ingredient.of(ItemUtil.fromJsonRecipeWithNBT(o)); + final Ingredient res = Ingredient.of(ItemUtil.fromJsonRecipeWithNBT(o)); + if (res == null) return Ingredient.EMPTY; + return res; } } else if (el.isJsonArray()) { //this is an Ingredient-Array, so read as such - return Ingredient.fromJson(el); + final Ingredient res = Ingredient.fromJson(el); + if (res == null) return Ingredient.EMPTY; + return res; } else if (obj.isJsonPrimitive()) { String s = GsonHelper.getAsString(obj, key, ""); ItemStack catalyst = ItemUtil.fromStackString(s); @@ -283,7 +291,7 @@ public class InfusionRecipe implements Recipe, UnknownReceipBook throw new IllegalStateException("Invalid catalyst ingredient for " + key + ": " + el.toString()); } } - return null; + return Ingredient.EMPTY; } @Override