-
Notifications
You must be signed in to change notification settings - Fork 497
/
AdvancedFacadeRecipe.java
109 lines (94 loc) · 3.27 KB
/
AdvancedFacadeRecipe.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
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
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.recipes;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.JavaTools;
import buildcraft.api.facades.FacadeType;
import buildcraft.api.facades.IFacadeItem;
import buildcraft.api.transport.PipeWire;
import buildcraft.core.recipes.IntegrationRecipeBC;
import buildcraft.transport.ItemFacade;
import buildcraft.transport.ItemPipeWire;
public class AdvancedFacadeRecipe extends IntegrationRecipeBC {
public AdvancedFacadeRecipe() {
super(25000, 2);
}
@Override
public List<ItemStack> generateExampleInput() {
return ItemFacade.allFacades;
}
@Override
public List<ItemStack> generateExampleOutput() {
return ItemFacade.allFacades;
}
@Override
public List<List<ItemStack>> generateExampleExpansions() {
List<List<ItemStack>> list = new ArrayList<List<ItemStack>>();
list.add(ItemFacade.allFacades);
List<ItemStack> pipeWires = new ArrayList<ItemStack>();
for (PipeWire wire : PipeWire.values()) {
pipeWires.add(wire.getStack());
}
list.add(pipeWires);
return list;
}
@Override
public boolean isValidInput(ItemStack input) {
return input.getItem() instanceof ItemFacade;
}
@Override
public boolean isValidExpansion(ItemStack input, ItemStack expansion) {
return (expansion.getItem() instanceof ItemFacade &&
((IFacadeItem) expansion.getItem()).getFacadeType(expansion) == FacadeType.Basic) ||
expansion.getItem() == BuildCraftTransport.plugItem ||
expansion.getItem() == BuildCraftTransport.pipeWire;
}
@Override
public ItemStack craft(ItemStack input, List<ItemStack> expansions, boolean preview) {
PipeWire wire = null;
ItemStack facade = null;
for (ItemStack stack : expansions) {
if (wire == null && stack.getItem() instanceof ItemPipeWire) {
wire = PipeWire.fromOrdinal(stack.getItemDamage());
if (!preview) {
stack.stackSize--;
}
} else if (facade == null && (stack.getItem() instanceof ItemFacade || stack.getItem() == BuildCraftTransport.pipeWire)) {
facade = stack;
if (!preview) {
stack.stackSize--;
}
}
}
if (wire != null && facade != null) {
ItemFacade.FacadeState[] states = ItemFacade.getFacadeStates(input);
ItemFacade.FacadeState additionalState;
if (facade.getItem() == BuildCraftTransport.plugItem) {
additionalState = ItemFacade.FacadeState.createTransparent(wire);
} else {
additionalState = ItemFacade.getFacadeStates(facade)[0];
additionalState = new ItemFacade.FacadeState(additionalState.block, additionalState.metadata, wire, additionalState.hollow);
}
// if in states array exists state with the same wire just override it
for (int i = 0; i < states.length; i++) {
if (states[i].wire == wire) {
states[i] = additionalState;
return ItemFacade.getFacade(states);
}
}
return ItemFacade.getFacade(JavaTools.concat(states,
new ItemFacade.FacadeState[]{additionalState}));
} else {
return null;
}
}
}