blob: e818b153cdef46e8af2f5da8f577dcd2b0b6ee10 (
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
|
/*
* Roughly Enough Items by Danielshe.
* Licensed under the MIT License.
*/
package me.shedaniel.rei.plugin;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class DefaultCustomDisplay implements DefaultCraftingDisplay {
private List<List<ItemStack>> input;
private List<ItemStack> output;
private Recipe possibleRecipe;
private int width, height;
public DefaultCustomDisplay(List<List<ItemStack>> input, List<ItemStack> output, Recipe possibleRecipe) {
this.input = input;
this.output = output;
this.possibleRecipe = possibleRecipe;
List<Boolean> row = Lists.newArrayList(false, false, false);
List<Boolean> column = Lists.newArrayList(false, false, false);
for(int i = 0; i < 9; i++)
if (i < input.size()) {
List<ItemStack> stacks = input.get(i);
if (stacks.stream().filter(stack -> !stack.isEmpty()).count() > 0) {
row.set((i - (i % 3)) / 3, true);
column.set(i % 3, true);
}
}
width = (int) column.stream().filter(b -> b).count();
height = (int) row.stream().filter(b -> b).count();
}
public DefaultCustomDisplay(List<List<ItemStack>> input, List<ItemStack> output) {
this(input, output, null);
}
@Override
public Optional<Recipe> getRecipe() {
return Optional.ofNullable(possibleRecipe);
}
@Override
public List<List<ItemStack>> getInput() {
return Collections.unmodifiableList(input);
}
@Override
public List<ItemStack> getOutput() {
return Collections.unmodifiableList(output);
}
@Override
public List<List<ItemStack>> getRequiredItems() {
return Collections.unmodifiableList(input);
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
}
|