-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathLogisticsCraftingTable.java
More file actions
69 lines (52 loc) · 1.96 KB
/
LogisticsCraftingTable.java
File metadata and controls
69 lines (52 loc) · 1.96 KB
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
package logisticspipes.proxy.recipeproviders;
import logisticspipes.utils.tuples.Pair;
import net.minecraft.tileentity.TileEntity;
import logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity;
import logisticspipes.proxy.interfaces.IFuzzyRecipeProvider;
import logisticspipes.utils.item.ItemIdentifierStack;
import network.rs485.logisticspipes.inventory.FuzzySlotAccess;
import network.rs485.logisticspipes.inventory.IItemIdentifierInventory;
import network.rs485.logisticspipes.inventory.SlotAccess;
import network.rs485.logisticspipes.property.BitSetProperty;
public class LogisticsCraftingTable implements IFuzzyRecipeProvider {
@Override
public boolean canOpenGui(TileEntity tile) {
return (tile instanceof LogisticsCraftingTableTileEntity);
}
@Override
public boolean importRecipe(TileEntity tile, IItemIdentifierInventory inventory) {
if (!(tile instanceof LogisticsCraftingTableTileEntity)) {
return false;
}
LogisticsCraftingTableTileEntity bench = (LogisticsCraftingTableTileEntity) tile;
ItemIdentifierStack result = bench.resultInv.getIDStackInSlot(0);
if (result == null) {
return false;
}
// Craft result is slot 9
inventory.setInventorySlotContents(9, result);
// Import (Slots [0, 8])
for (Pair<ItemIdentifierStack, Integer> slot : bench.matrix) {
final int i = slot.getValue2();
if (i <= inventory.getSizeInventory() - 2) {
inventory.setInventorySlotContents(i, slot.getValue1().makeNormalStack());
}
}
if (!bench.isFuzzy()) {
inventory.getSlotAccess().compactFirst(9);
}
return true;
}
@Override
public void importFuzzyFlags(TileEntity tile, SlotAccess slotAccess, BitSetProperty fuzzyFlags) {
if (!(tile instanceof LogisticsCraftingTableTileEntity)) {
return;
}
LogisticsCraftingTableTileEntity bench = (LogisticsCraftingTableTileEntity) tile;
if (!bench.isFuzzy()) {
return;
}
fuzzyFlags.replaceWith(bench.fuzzyFlags);
new FuzzySlotAccess(slotAccess, fuzzyFlags).compactFirst(9);
}
}