/
ShapedOreRecipeHandler.java
50 lines (42 loc) · 1.14 KB
/
ShapedOreRecipeHandler.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
package mezz.jei.plugins.vanilla.crafting;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraftforge.oredict.ShapedOreRecipe;
import mezz.jei.api.recipe.IRecipeHandler;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
public class ShapedOreRecipeHandler implements IRecipeHandler<ShapedOreRecipe> {
@Override
@Nonnull
public Class<ShapedOreRecipe> getRecipeClass() {
return ShapedOreRecipe.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
return VanillaRecipeCategoryUid.CRAFTING;
}
@Override
@Nonnull
public IRecipeWrapper getRecipeWrapper(@Nonnull ShapedOreRecipe recipe) {
return new ShapedOreRecipeWrapper(recipe);
}
@Override
public boolean isRecipeValid(@Nonnull ShapedOreRecipe recipe) {
if (recipe.getRecipeOutput() == null) {
return false;
}
int inputCount = 0;
for (Object input : recipe.getInput()) {
if (input instanceof List) {
if (((List) input).size() == 0) {
return false;
}
}
if (input != null) {
inputCount++;
}
}
return inputCount > 0;
}
}