From 4715ea0df8d287a792facf57502c6030c45e919b Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 18 Nov 2022 21:29:30 +0100 Subject: [PATCH] [Feature] Allow nbt-Tag for Input Slot in Infusion Recipe .json-Files (#83) --- .../betterend/recipe/builders/InfusionRecipe.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 4f96a5b7..5f23e9c0 100644 --- a/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java +++ b/src/main/java/org/betterx/betterend/recipe/builders/InfusionRecipe.java @@ -216,7 +216,18 @@ public class InfusionRecipe implements Recipe, UnknownReceipBook @Override public InfusionRecipe fromJson(ResourceLocation id, JsonObject json) { InfusionRecipe recipe = new InfusionRecipe(id); - recipe.input = Ingredient.fromJson(json.get("input")); + JsonObject inputObject = GsonHelper.getAsJsonObject(json, "input"); + recipe.input = Ingredient.fromJson(inputObject); + if (inputObject.has("nbt") && !recipe.input.isEmpty()) { + try { + String nbtData = GsonHelper.getAsString(inputObject, "nbt"); + CompoundTag nbt = TagParser.parseTag(nbtData); + recipe.input.getItems()[0].setTag(nbt); + } catch (CommandSyntaxException ex) { + BetterEnd.LOGGER.warning("Error parse nbt data for input.", ex); + } + } + JsonObject result = GsonHelper.getAsJsonObject(json, "result"); recipe.output = ItemUtil.fromJsonRecipe(result); if (recipe.output == null) {