(This article is one of a series of commentary articles)
First article: Introduction Previous article: 5. Adding Armor Next article: 7. Add progress
By the way, 1. Add item, 2. Add block, 4 Add tools, 5. Add armor and add various items. However, there is no recipe to craft these yet. This time we will add recipes for some patterns. In 1.14.4, adding recipes does not require writing code and can be added based on json.
For example, let's add a sword recipe.
\src\main\resources
├ assets
└ data
└ example_mod
├ loot_tables
└ recipes
└ example_sword.json
Create a \ src \ main \ resources \ data \ recipes
folder and place the recipe files in it.
example_sword.json
{
"type": "minecraft:crafting_shaped",
"pattern": [
"#",
"#",
"X"
],
"key": {
"#": {
"item": "example_mod:example_ingot"
},
"X": {
"item": "minecraft:stick"
}
},
"result": {
"item": "example_mod:example_sword"
}
}
You can make a standard recipe by giving minecraft: crafting_shaped
to type
. A standard recipe is a craft recipe in which the arrangement of ingredients is fixed.
Use key
to determine an arbitrary token (# and X here, but anything is fine) and the corresponding item, and use this token to place it in pattern
in the form of a matrix of 3x3 or less. To decide.
Specify the item obtained as a result of crafting in result
.
You can now make swords.
In this example, only one row is used to arrange the materials, so you can make it vertically at any position as shown in the figure.
Since "nothing" is indicated by a half-width space, you can explicitly do the following, but even in this case, it seems that you can also make one vertical column on the left or right.
python
"pattern": [
" # ",
" # ",
" X "
]
Next, let's add an amorphous recipe that does not specify the arrangement of ingredients. A little unsuitable as an example, but consider a recipe that breaks down two blocks into 18 ingots.
\src\main\resources
├ assets
└ data
└ example_mod
├ loot_tables
└ recipes
└ example_ingot.json
example_ingot.json
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "example_mod:example_block"
},
{
"item": "example_mod:example_block"
}
],
"result": {
"item": "example_mod:example_ingot",
"count": 18
}
}
By giving minecraft: crafting_shapeless
to type
, you can create an atypical recipe.
ʻIngredientsis an array of materials, which lists the items used for crafting.
resultis the same as the standard recipe. You can specify the number with
count` (default 1 was omitted in the previous section).
The ingot was obtained from any arrangement.
Next, add a recipe for refining with a kamado. For example, let's refine a diamond so that we can get an ingot.
\src\main\resources
├ assets
└ data
└ example_mod
├ loot_tables
└ recipes
└ furnace
└ example_ingot.json
(It seems that all the files under recipes
will be registered, so maybe the folder structure and file name are free.)
example_ingot.json
{
"type": "minecraft:smelting",
"ingredient": {
"item": "minecraft:diamond"
},
"result": {
"item": "example_mod:example_ingot"
},
"experience": 3.0,
"cookingtime": 200
}
Add a refining recipe by specifying minecraft: smelting
for type
.
ʻIngredient(** Note because it is singular **) is the material, and
result is the item after refining. ʻExperience
is the experience value gained by refining, and cooking time
is the refining time. By the way, vanilla iron is 0.7 and 200, respectively.
I was able to refine it.
Q. Isn't it in the recipe book? ** A. Once made, it will be listed. If you want to put it first, you need to modify the part related to advancements **, but I have not learned it yet, so I hope to add it later.
Q. I want to make the same item from multiple materials
** A. There are three solutions. ** **
The first is to simply create as many json files as the recipe. Not recommended.
The second is to pass multiple items to key
or ʻingradient`.
X position is stick or oak_Either wood
{
"type": "minecraft:crafting_shaped",
"pattern": [
"#",
"#",
"X"
],
"key": {
"#": {
"item": "example_mod:example_ingot"
},
"X": [
{
"item": "minecraft:stick"
},
{
"item": "minecraft:oak_wood"
}
]
},
"result": {
"item": "example_mod:example_sword"
}
}
The material is diamond or gold_Either ingot
{
"type": "minecraft:smelting",
"ingredient": [
{
"item": "minecraft:diamond"
},
{
"item": "minecraft:gold_ingot"
}
],
"result": {
"item": "example_mod:example_ingot"
},
"experience": 3.0,
"cookingtime": 200
}
(I wasn't sure if this method could be used for shapeless
recipes. Doesn't it seem to work?)
The third method is to use tag
. For example, vanilla charcoal crafts one item from all kinds of logs. The code is shown below.
charcoal.json
{
"type": "minecraft:smelting",
"ingredient": {
"tag": "minecraft:logs"
},
"result": "minecraft:charcoal",
"experience": 0.15,
"cookingtime": 200
}
This tag is declared in net \ minecraft \ tags \ BlockTags.java
. Of course, you can define new tags yourself, so it's a good idea to create a tag that summarizes alternative materials and use it to define recipes.
Q. I want to modify the vanilla recipe ** A. Easy to add. Difficult to change. ** ** In other words, it is easy to add C → B to A → B craft, but it is difficult to change to A → D craft. The former coexists with vanilla's if you simply add a new recipe, but the latter seems to give priority to vanilla even if you add a recipe with the same ingredients. Therefore, it seems that it is necessary to go back to the code that registers the recipe.
Q. I want to make a brewing recipe Probably, you can't add json base like above for brewing recipes. (Reference)
Recipes - Forge Documentation Minecraft 1.14.4 Forge Mod Creation Part 9 [Add Recipe]