Создание рецептов
Прежде чем создавать рецепты, рекомендуем сначала прочитать Основа предмета, чтобы понять это руководство.
Основы
Давайте создадим рецепт для нашей палочки, который мы добавили в руководстве основа предмета.
Шаблон ингредиентов
Давайте начнем с объявления шаблона или макета рецепта, в нашем примере мы хотим, чтобы игрок поместил кирку поверх двух палочек.
which would look like this:
ingredientPattern: "P S S",
width: 1,
height: 3,
P
and S
are identifiers which will be defined later. Every row is separated with a tab, while an empty cell is marked with an underscore _
. The width
of this recipe is 1
and it is 3
rows high. Don't put spaces between the cells for example _ P _
is 5 not 3 cells.
Ingredients
All we need to do now is to define the identifiers we have used before. In our example P
stands for a copper pickaxe and S
for an ordinary stick.
ingredients: {
"P": { type: "item", code: "game:pickaxe-copper"},
"S": { type: "item", code: "game:stick"}
},
Type
is either block
or item
depending whether it's an item or a block.
When recipes have vanilla items they need game:
in front of the item name. When they are from your own mod you can just put the item name.
In order to find out the code
of each item (or block), you can type .edi
into console, which will add the code property to the tooltip:
Furthermore, we could add a required quantity to our ingredients, so instead of one stick per slot we could make it require more:
ingredients: {
"P": { type: "item", code: "game:pickaxe-copper"},
"S": { type: "item", code: "game:stick", quantity: 2}
},
Another thing we could do is instead of consuming the pickaxe, we could use it as a tool:
ingredients: {
"P": { type: "item", code: "game:pickaxe-copper", isTool: true},
"S": { type: "item", code: "game:stick"}
},
This would cause the pickaxe to lose one durability during crafting, instead of consuming the whole pickaxe at once.
Output
We still need to define the output, which is rather similar to defining the ingredients:
output: { type: "item", code: "wand-pickaxe"}
Theoretically, we could add the quantity
property here as well.
Distributing
This is what our final recipe looks like:
{
ingredientPattern: "P S S",
width: 1,
height: 3,
ingredients: {
"P": { type: "item", code: "game:pickaxe-copper"},
"S": { type: "item", code: "game:stick"}
},
output: { type: "item", code: "wand-pickaxe"}
}
In order to add those crafting recipes to your mod, you have to create another folder in your workspace assets/myadvancedwand/recipes/grid/
and copy the files in there.
You can download the full mod including the items here.
Advanced
Type based recipes
There are more complicated things you can do with recipes. This the recipe for wooden planks which are crafted out of logs:
{
ingredientPattern: "L",
ingredients: {
"L": { type: "block", code: "game:log-*-ud", name: "wood" }
},
width: 1,
height: 1,
output: { type: "block", code: "planks-{wood}", quantity: 4 }
}
Instead of having a recipe for every wood type, you can assign a name to an ingredient (in this case it is name: "wood"
) and everything identified by *
will later on replaced be for the output. Meaning {wood}
will be replaced by the type of the giving log.
For example if we would have a birch log block, its code would be log-birch-ud
, so *
would stand for birch
, therefore the output will be converted from code: "planks-{wood}"
to code: "planks-birch"
.
Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.
Modding | |
---|---|
Modding Introduction | Getting Started • Пакет тем |
Content Modding | Content Mods • Developing a Content Mod • Basic Tutorials • Intermediate Tutorials • Advanced Tutorials • Content Mod Concepts |
Code Modding | Code Mods • Setting up your Development Environment |
Property Overview | Item • Entity • Entity Behaviors • Block • Block Behaviors • Block Classes • Block Entities • Block Entity Behaviors • Collectible Behaviors • World properties |
Workflows & Infrastructure | Modding Efficiency Tips • Mod-engine compatibility • Mod Extensibility • VS Engine |
Additional Resources | Community Resources • Modding API Updates • Programming Languages • List of server commands • List of client commands • Client startup parameters • Server startup parameters Example Mods • API Docs • GitHub Repository |