/
FillCanteenRecipe.java
76 lines (62 loc) · 1.89 KB
/
FillCanteenRecipe.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package knightminer.inspirations.plugins.tan.recipes;
import java.util.List;
import com.google.common.collect.ImmutableList;
import knightminer.inspirations.library.recipe.cauldron.ISimpleCauldronRecipe;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
public class FillCanteenRecipe implements ISimpleCauldronRecipe {
private Item canteen;
private int meta, current, type;
private CauldronState fluid;
// JEI data
private List<ItemStack> input;
private ItemStack result;
public FillCanteenRecipe(Item canteen, int current, int type, Fluid fluid) {
this.canteen = canteen;
// canteen level
this.current = current;
// meta offset for canteen
this.type = type;
// detemine the metadata for the input, easier than calculating it two places
this.meta = current == 0 ? 0 : (3 - current) * 4 + type;
this.fluid = CauldronState.fluid(fluid);
// JEI data
this.input = ImmutableList.of(new ItemStack(canteen, 1, meta));
this.result = new ItemStack(canteen, 1, type);
}
@Override
public boolean matches(ItemStack stack, boolean boiling, int level, CauldronState state) {
return level >= 1 && fluid.matches(state)
&& stack.getItem() == canteen && stack.getMetadata() == meta;
}
@Override
public ItemStack getResult(ItemStack stack, boolean boiling, int level, CauldronState state) {
if(level + current >= 3) {
return new ItemStack(canteen, 1, type);
}
return new ItemStack(canteen, 1, ((3 - (level + current)) * 4) + type);
}
@Override
public int getInputLevel() {
return 3 - current;
}
@Override
public int getLevel(int level) {
int total = level + current;
return total <= 3 ? 0 : total - 3;
}
/* JEI */
@Override
public List<ItemStack> getInput() {
return input;
}
@Override
public ItemStack getResult() {
return result;
}
@Override
public Object getInputState() {
return fluid.getFluid();
}
}