Skip to content

Commit

Permalink
Sort of fixed smithing
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarWind22 committed Dec 1, 2023
1 parent 0459098 commit b94c5a9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,96 @@ public static JsonObject createShapedRecipe(ArrayList<Character> 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"

Expand Down

0 comments on commit b94c5a9

Please sign in to comment.