-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCraftingManagerInfuserTransmutation.java
More file actions
79 lines (60 loc) · 2.36 KB
/
CraftingManagerInfuserTransmutation.java
File metadata and controls
79 lines (60 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package betterwithaddons.crafting.manager;
import betterwithaddons.crafting.recipes.infuser.TransmutationRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class CraftingManagerInfuserTransmutation {
private static final CraftingManagerInfuserTransmutation instance = new CraftingManagerInfuserTransmutation();
public static CraftingManagerInfuserTransmutation getInstance() {
return instance;
}
private final ArrayList<TransmutationRecipe> recipes = new ArrayList<>();
private CraftingManagerInfuserTransmutation() {
}
public void addRecipe(TransmutationRecipe recipe)
{
this.recipes.add(recipe);
}
public void addRecipe(Ingredient input, int spirits, ItemStack output) {
this.recipes.add(createRecipe(input, spirits, output));
}
public void addRecipe(Ingredient input, int spirits, ItemStack[] outputs) {
this.recipes.add(createRecipe(input, spirits, outputs));
}
public void removeRecipe(TransmutationRecipe recipe) {
this.recipes.remove(recipe);
}
public void clearRecipes() {
this.recipes.clear();
}
protected TransmutationRecipe createRecipe(Ingredient input, int spirits, ItemStack output)
{
return createRecipe(input, spirits, new ItemStack[]{output});
}
protected TransmutationRecipe createRecipe(Ingredient input, int spirits, ItemStack[] outputs)
{
return new TransmutationRecipe(input, spirits, outputs);
}
public List<TransmutationRecipe> findRecipeForRemoval(@Nonnull ItemStack output) {
return recipes.stream().filter(recipe -> recipe.getRecipeOutputs().contains(output)).collect(Collectors.toList());
}
public TransmutationRecipe getSmeltingRecipe(ItemStack input, int spirits) {
Iterator<TransmutationRecipe> var2 = this.recipes.iterator();
TransmutationRecipe entry;
do {
if(!var2.hasNext()) {
return null;
}
entry = var2.next();
} while(!entry.matchesInput(input, spirits));
return entry;
}
public List<TransmutationRecipe> getRecipes() {
return this.recipes;
}
}