-
Notifications
You must be signed in to change notification settings - Fork 497
/
IntegrationRecipeBC.java
54 lines (43 loc) · 1.62 KB
/
IntegrationRecipeBC.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
49
50
51
52
53
54
package buildcraft.core.recipes;
import java.lang.ref.SoftReference;
import java.util.List;
import net.minecraft.item.ItemStack;
import buildcraft.api.recipes.IIntegrationRecipe;
public abstract class IntegrationRecipeBC implements IIntegrationRecipe {
private final int energyCost, maxExpansionCount;
private SoftReference<List<ItemStack>> exampleInputs;
private SoftReference<List<List<ItemStack>>> exampleExpansions;
public IntegrationRecipeBC(int energyCost) {
this(energyCost, -1);
}
public IntegrationRecipeBC(int energyCost, int maxExpansionCount) {
this.energyCost = energyCost;
this.maxExpansionCount = maxExpansionCount;
}
public abstract List<ItemStack> generateExampleInput();
public abstract List<List<ItemStack>> generateExampleExpansions();
@Override
public int getEnergyCost() {
return energyCost;
}
@Override
public List<ItemStack> getExampleInput() {
if (exampleInputs != null && exampleInputs.get() != null) {
return exampleInputs.get();
}
exampleInputs = new SoftReference<List<ItemStack>>(generateExampleInput());
return exampleInputs.get();
}
@Override
public List<List<ItemStack>> getExampleExpansions() {
if (exampleExpansions != null && exampleExpansions.get() != null) {
return exampleExpansions.get();
}
exampleExpansions = new SoftReference<List<List<ItemStack>>>(generateExampleExpansions());
return exampleExpansions.get();
}
@Override
public int getMaximumExpansionCount() {
return maxExpansionCount;
}
}