aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/plugin/crafting/VanillaShapedCraftingRecipe.java
blob: 3f830f3818e5cf3f389962dcdeb56b40b7b3e4e8 (plain)
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
package me.shedaniel.plugin.crafting;

import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.crafting.ShapedRecipe;

import java.util.LinkedList;
import java.util.List;

public class VanillaShapedCraftingRecipe extends VanillaCraftingRecipe {
    
    private final ShapedRecipe recipe;
    
    public VanillaShapedCraftingRecipe(ShapedRecipe recipe) {
        
        this.recipe = recipe;
    }
    
    @Override
    public int getWidth() {
        return recipe.getWidth();
    }
    
    @Override
    public int getHeight() {
        return recipe.getHeight();
    }
    
    @Override
    public String getId() {
        return "vanilla";
    }
    
    @Override
    public List<ItemStack> getOutput() {
        List<ItemStack> output = new LinkedList<>();
        output.add(recipe.getOutput());
        return output;
    }
    
    @Override
    public List<List<ItemStack>> getInput() {
        List<List<ItemStack>> input = new LinkedList<>();
        int count = 0;
        for(Ingredient ingredient : recipe.getPreviewInputs()) {
            List<ItemStack> ingList = new LinkedList<>();
            for(ItemStack matchingStack : ingredient.getStackArray()) {
                ingList.add(matchingStack);
            }
            input.add(ingList);
            count++;
        }
        return input;
    }
}