From b94c5a95e5f80663700e4e43874e887919cd2c74 Mon Sep 17 00:00:00 2001 From: StellarWind22 Date: Fri, 1 Dec 2023 08:57:08 -0600 Subject: [PATCH] Sort of fixed smithing --- .../basicshields/module/AdabraniumModule.java | 2 +- .../basicshields/module/GobberModule.java | 2 +- .../basicshields/module/VanillaModule.java | 2 +- .../basicshields/util/ModRecipe.java | 88 ++++++++++++++++++- 4 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/crimsondawn45/basicshields/module/AdabraniumModule.java b/src/main/java/com/github/crimsondawn45/basicshields/module/AdabraniumModule.java index a44a476..f0209ee 100644 --- a/src/main/java/com/github/crimsondawn45/basicshields/module/AdabraniumModule.java +++ b/src/main/java/com/github/crimsondawn45/basicshields/module/AdabraniumModule.java @@ -45,7 +45,7 @@ public void registerContent() { "entity/nether_shield_base"); //Recipe - this.addRecipe(nether_shield, ModRecipe.createSmithingRecipe(new Identifier("minecraft", "shield"), false, new Identifier("minecraft", "nether_brick"), false, nether_shield.getIdentifier())); + this.addRecipe(nether_shield, ModRecipe.createSmithingRecipeNoTemplate(new Identifier("minecraft", "shield"), false, new Identifier("minecraft", "nether_brick"), false, nether_shield.getIdentifier())); //Vibranium vibranium_shield = new ModShieldItem(this, "vibranium_shield", diff --git a/src/main/java/com/github/crimsondawn45/basicshields/module/GobberModule.java b/src/main/java/com/github/crimsondawn45/basicshields/module/GobberModule.java index a8f0738..15ebace 100644 --- a/src/main/java/com/github/crimsondawn45/basicshields/module/GobberModule.java +++ b/src/main/java/com/github/crimsondawn45/basicshields/module/GobberModule.java @@ -119,6 +119,6 @@ public void registerContent() { "entity/gobber_dragon_shield_base"); //Recipe - this.addRecipe(gobber_dragon_shield, ModRecipe.createSmithingRecipe(gobber_end_shield.getIdentifier(), false, gobber_dragon_tag.id(), true, gobber_dragon_shield.getIdentifier())); + this.addRecipe(gobber_dragon_shield, ModRecipe.createSmithingRecipeNoTemplate(gobber_end_shield.getIdentifier(), false, gobber_dragon_tag.id(), true, gobber_dragon_shield.getIdentifier())); } } \ No newline at end of file diff --git a/src/main/java/com/github/crimsondawn45/basicshields/module/VanillaModule.java b/src/main/java/com/github/crimsondawn45/basicshields/module/VanillaModule.java index afa1f51..920f3d3 100644 --- a/src/main/java/com/github/crimsondawn45/basicshields/module/VanillaModule.java +++ b/src/main/java/com/github/crimsondawn45/basicshields/module/VanillaModule.java @@ -77,6 +77,6 @@ public void registerContent() { "entity/netherite_shield_base"); //Recipe - this.addRecipe(netherite_shield, ModRecipe.createSmithingRecipe(diamond_shield.getIdentifier(), false, netherite_tag.id(), true, netherite_shield.getIdentifier())); + this.addRecipe(netherite_shield, ModRecipe.createSmithingRecipe(new Identifier("minecraft", "netherite_upgrade_smithing_template"), false, diamond_shield.getIdentifier(), false, netherite_tag.id(), true, netherite_shield.getIdentifier())); } } \ No newline at end of file diff --git a/src/main/java/com/github/crimsondawn45/basicshields/util/ModRecipe.java b/src/main/java/com/github/crimsondawn45/basicshields/util/ModRecipe.java index d2b5077..9444951 100644 --- a/src/main/java/com/github/crimsondawn45/basicshields/util/ModRecipe.java +++ b/src/main/java/com/github/crimsondawn45/basicshields/util/ModRecipe.java @@ -206,12 +206,96 @@ public static JsonObject createShapedRecipe(ArrayList keys, ArrayList * * @return Smithing Recipe in JsonObject Form */ - public static JsonObject createSmithingRecipe(Identifier inputId, boolean isInputTag, Identifier additionId, boolean isAdditionTag, Identifier outputId) { + public static JsonObject createSmithingRecipe(Identifier templateId, boolean isTemplateTag, Identifier inputId, boolean isInputTag, Identifier additionId, boolean isAdditionTag, Identifier outputId) { //Creating a new json object, where we will store our recipe. JsonObject json = new JsonObject(); //The "type" of the recipe we are creating. In this case, a smithing recipe. - json.addProperty("type", "minecraft:smithing"); + json.addProperty("type", "minecraft:smithing_transform"); + //This creates + //"type":"minecraft:smithing" + + /** + * * Create "template" object contains original item + */ + JsonObject template = new JsonObject(); + + if(isTemplateTag) { + template.addProperty("tag", templateId.toString()); + } else { + template.addProperty("item", templateId.toString()); + } + //Add "base" object + json.add("template", template); + //This creates + //"base":{ + // "item": "minecraft:stick" + //} + + /** + * * Create "base" object contains original item + */ + JsonObject base = new JsonObject(); + + if(isInputTag) { + base.addProperty("tag", inputId.toString()); + } else { + base.addProperty("item", inputId.toString()); + } + //Add "base" object + json.add("base", base); + //This creates + //"base":{ + // "item": "minecraft:stick" + //} + + /** + * *Create "addition" object contains additive + */ + JsonObject addition = new JsonObject(); + + if(isAdditionTag) { + addition.addProperty("tag", additionId.toString()); + } else { + addition.addProperty("item", additionId.toString()); + } + //Add "addition" object + json.add("addition", addition); + //This creates + //"base":{ + // "item": "minecraft:stick" + //} + + + /** + * *Create "result" object contains result + */ + JsonObject result = new JsonObject(); + result.addProperty("item", outputId.toString()); + + //Add "result" object + json.add("result", result); + + return json; + } + + /** + * * generates a JsonObject for a new smithing recipe + * + * @param inputId Identifier of the input + * @param isInputTag Is input a tag? + * @param additionId Identifier of the addition + * @param isAdditionTag Is addition a tag? + * @param outputId Output item Identifier + * + * @return Smithing Recipe in JsonObject Form + */ + public static JsonObject createSmithingRecipeNoTemplate(Identifier inputId, boolean isInputTag, Identifier additionId, boolean isAdditionTag, Identifier outputId) { + //Creating a new json object, where we will store our recipe. + JsonObject json = new JsonObject(); + + //The "type" of the recipe we are creating. In this case, a smithing recipe. + json.addProperty("type", "minecraft:smithing_transform"); //This creates //"type":"minecraft:smithing"