aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java
blob: dd563f01a39c08eaccf6c17390a79c1fe781dab4 (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
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
107
108
109
110
111
112
/*
 * Roughly Enough Items by Danielshe.
 * Licensed under the MIT License.
 */

package me.shedaniel.rei.api;

import me.shedaniel.rei.api.annotations.ToBeRemoved;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public interface RecipeDisplay {
    
    /**
     * @return a list of items
     * @see RecipeDisplay#getInputStacks()
     */
    @ToBeRemoved
    @Deprecated
    default List<List<ItemStack>> getInput() {
        return Collections.emptyList();
    }
    
    /**
     * @return a list of inputs
     */
    default List<List<EntryStack>> getInputEntries() {
        List<List<ItemStack>> input = getInput();
        if (input.isEmpty())
            return Collections.emptyList();
        List<List<EntryStack>> list = new ArrayList<>();
        for (List<ItemStack> stacks : input) {
            List<EntryStack> entries = new ArrayList<>();
            for (ItemStack stack : stacks) {
                entries.add(EntryStack.create(stack));
            }
            list.add(entries);
        }
        return list;
    }
    
    /**
     * @return a list of outputs
     */
    @ToBeRemoved
    @Deprecated
    default List<ItemStack> getOutput() {
        return Collections.emptyList();
    }
    
    /**
     * @return a list of outputs
     */
    default List<EntryStack> getOutputEntries() {
        List<ItemStack> input = getOutput();
        if (input.isEmpty())
            return Collections.emptyList();
        List<EntryStack> entries = new ArrayList<>();
        for (ItemStack stack : input) {
            entries.add(EntryStack.create(stack));
        }
        return entries;
    }
    
    /**
     * Gets the required items used in craftable filters
     *
     * @return the list of required items
     */
    default List<List<EntryStack>> getRequiredEntries() {
        List<List<ItemStack>> input = getRequiredItems();
        if (input.isEmpty())
            return Collections.emptyList();
        List<List<EntryStack>> list = new ArrayList<>();
        for (List<ItemStack> stacks : input) {
            List<EntryStack> entries = new ArrayList<>();
            for (ItemStack stack : stacks) {
                entries.add(EntryStack.create(stack));
            }
            list.add(entries);
        }
        return list;
    }
    
    @ToBeRemoved
    @Deprecated
    default List<List<ItemStack>> getRequiredItems() {
        return Collections.emptyList();
    }
    
    /**
     * Gets the recipe display category identifier
     *
     * @return the identifier of the category
     */
    Identifier getRecipeCategory();
    
    /**
     * Gets the recipe location from datapack
     *
     * @return the recipe location
     */
    default Optional<Identifier> getRecipeLocation() {
        return Optional.empty();
    }
    
}