/
Focus.java
106 lines (87 loc) · 2.46 KB
/
Focus.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package mezz.jei.gui;
import com.google.common.collect.ImmutableList;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import mezz.jei.api.JEIManager;
import mezz.jei.api.recipe.IRecipeCategory;
public class Focus {
private final ItemStack stack;
private final Fluid fluid;
public Focus() {
this.stack = null;
this.fluid = null;
}
public Focus(Object focus) {
if (focus instanceof ItemStack) {
this.stack = (ItemStack) focus;
this.fluid = null;
} else if (focus instanceof Fluid) {
this.stack = null;
this.fluid = (Fluid) focus;
} else {
this.stack = null;
this.fluid = null;
}
}
public Focus(ItemStack stack) {
this.stack = stack;
this.fluid = null;
}
public Focus(Fluid fluid) {
this.stack = null;
this.fluid = fluid;
}
public Fluid getFluid() {
return fluid;
}
public ItemStack getStack() {
return stack;
}
public boolean isBlank() {
return stack == null && fluid == null;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Focus)) {
return false;
}
Focus other = (Focus) obj;
return ItemStack.areItemStacksEqual(this.stack, other.getStack()) && fluid == other.fluid;
}
@Nonnull
public ImmutableList<IRecipeCategory> getCategoriesWithInput() {
if (stack != null) {
return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(stack);
} else {
return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(fluid);
}
}
@Nonnull
public ImmutableList<IRecipeCategory> getCategoriesWithOutput() {
if (stack != null) {
return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(stack);
} else {
return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(fluid);
}
}
@Nonnull
public ImmutableList<Object> getRecipesWithInput(IRecipeCategory recipeCategory) {
if (stack != null) {
return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, stack);
} else {
return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, fluid);
}
}
@Nonnull
public ImmutableList<Object> getRecipesWithOutput(IRecipeCategory recipeCategory) {
if (stack != null) {
return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, stack);
} else {
return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, fluid);
}
}
public enum Mode {
INPUT, OUTPUT, NONE
}
}