Implement tags !
This commit is contained in:
@@ -68,15 +68,23 @@ recipes with the same tool, material and addition are an error.
|
||||
|
||||
## Choices
|
||||
|
||||
Anywhere a recipe takes an item (`key` values, `input`, `item`), a list of ids means any of them fits:
|
||||
Anywhere a recipe takes an item (`key` values, `input`, `item`), an item [tag](tags.md) means anything in it fits, and
|
||||
so does a list of ids and tags:
|
||||
|
||||
```json
|
||||
"key": { "P": ["bworld:planks", "bworld:birch_planks", "bworld:spruce_planks"] }
|
||||
"key": { "P": "#bworld:planks" }
|
||||
```
|
||||
|
||||
```json
|
||||
"item": ["bworld:coal", "#bworld:logs"]
|
||||
```
|
||||
|
||||
In the crafting grid, each slot can hold a different one of them, so a stick can be made from oak and birch planks
|
||||
together. The recipe viewer takes turns showing them.
|
||||
|
||||
Use a tag rather than listing ids when other mods might have more of the same thing: a mod that adds planks to
|
||||
`#bworld:planks` makes them work in every recipe that takes it.
|
||||
|
||||
## Custom Recipe Types
|
||||
|
||||
Any `type` with a namespace is a mod's own, like `farmersdelight:cooking` for the cooking pot. The engine only stores
|
||||
@@ -101,8 +109,8 @@ const recipes = ctx.recipes.list("farmersdelight:cooking").map((json, i) => {
|
||||
if (!Array.isArray(json.ingredients) || json.ingredients.length > 6) {
|
||||
throw new Error(`cooking recipe ${i + 1}: ingredients must be 1 to 6 items`);
|
||||
}
|
||||
// ...check the rest, and turn it into whatever the machine needs
|
||||
return json;
|
||||
// ...check the rest, and turn it into whatever the machine needs. expand turns #tags into their items
|
||||
return { ingredients: json.ingredients.map((choice) => ctx.tags.expand(choice)) };
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user