Skip to content

Commit 85d27da

Browse files
Create recipes.md
1 parent afc6165 commit 85d27da

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/recipes.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Recipes
2+
3+
## Making each recipe
4+
First, get started by making a new class for your recipe, and implementing all the methods:
5+
```java
6+
public class MyFirstRecipe extends CaramelRecipe {
7+
public ItemStack getResult() {return ...;};
8+
public CaramelRecipeDetail getDetails() {return ...;};
9+
public NamespacedKey getKey() {return ...;};
10+
}
11+
```
12+
13+
Result needs to be an ItemStack to return as the output.
14+
15+
Key needs to be a NamespacedKey with your Plugin/Identifier and the recipe's identifier.
16+
17+
The details are where we define the actual recipe:
18+
```
19+
CaramelRecipeDetail.of(
20+
new CaramelRecipeValue[] {},
21+
new String[] {
22+
" ",
23+
" ",
24+
" "
25+
}
26+
);
27+
```
28+
29+
The array of values are your mappings for your pattern. See the values section below.
30+
31+
The array of strings is your pattern, and should be 3x tripple-letter strings.
32+
33+
34+
<br/><br/>
35+
36+
37+
## Recipe Values
38+
A recipe value is a mapping of character <--> an itemstack or material to be used in the crafting grid.
39+
40+
You can create these by the `CaramelRecipeValueItem` and `CaramelRecipeValueMaterial` constructors:
41+
42+
```java
43+
// A material value is only the material.
44+
new CaramelRecipeValueMaterial('D', Material.DIAMOND)
45+
46+
// A item value is for more specific recipe values.
47+
new CaramelRecipeValueItem('D', new ItemStack(Material.DIAMOND))
48+
```
49+
50+
51+
<br/><br/>
52+
53+
54+
## Registering your recipes
55+
Recipes are registered through RecipeLists. You can create these directly from the instance of Caramel:
56+
57+
```java
58+
// Define your list in your class:
59+
CaramelRecipeList myRecipes;
60+
61+
// Inside your onEnable:
62+
recipeList = Caramel.createRecipeList(
63+
myFirstRecipe,
64+
mySecondRecipe
65+
);
66+
recipeList.registerAll();
67+
68+
// Inside your onDisable:
69+
recipeList.cleanup();
70+
```

0 commit comments

Comments
 (0)