-
Notifications
You must be signed in to change notification settings - Fork 497
/
AssemblyRecipe.java
48 lines (35 loc) · 1009 Bytes
/
AssemblyRecipe.java
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
package buildcraft.api.recipes;
import java.util.LinkedList;
import net.minecraft.item.ItemStack;
public class AssemblyRecipe {
public static LinkedList<AssemblyRecipe> assemblyRecipes = new LinkedList<AssemblyRecipe>();
public final ItemStack[] input;
public final ItemStack output;
public final float energy;
public AssemblyRecipe(ItemStack[] input, int energy, ItemStack output) {
this.input = input;
this.output = output;
this.energy = energy;
}
public boolean canBeDone(ItemStack[] items) {
for (ItemStack in : input) {
if (in == null) {
continue;
}
int found = 0; // Amount of ingredient found in inventory
for (ItemStack item : items) {
if (item == null) {
continue;
}
if (item.isItemEqual(in)) {
found += item.stackSize; // Adds quantity of stack to amount
// found
}
}
if (found < in.stackSize)
return false; // Return false if the amount of ingredient found
// is not enough
}
return true;
}
}