/
ShapedRecipesWrapper.java
56 lines (45 loc) · 1.44 KB
/
ShapedRecipesWrapper.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
package mezz.jei.plugins.vanilla.crafting;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
public class ShapedRecipesWrapper extends BlankRecipeWrapper implements IShapedCraftingRecipeWrapper {
private final ShapedRecipes recipe;
public ShapedRecipesWrapper(ShapedRecipes recipe) {
this.recipe = recipe;
for (ItemStack itemStack : this.recipe.recipeItems) {
if (itemStack != null && itemStack.stackSize != 1) {
itemStack.stackSize = 1;
}
}
}
@Override
public void getIngredients(IIngredients ingredients) {
List<ItemStack> recipeItems = Arrays.asList(recipe.recipeItems);
ingredients.setInputs(ItemStack.class, recipeItems);
ItemStack recipeOutput = recipe.getRecipeOutput();
if (recipeOutput != null) {
ingredients.setOutput(ItemStack.class, recipeOutput);
}
}
@Override
public List getInputs() {
return Arrays.asList(recipe.recipeItems);
}
@Override
public List<ItemStack> getOutputs() {
return Collections.singletonList(recipe.getRecipeOutput());
}
@Override
public int getWidth() {
return recipe.recipeWidth;
}
@Override
public int getHeight() {
return recipe.recipeHeight;
}
}