-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathWireRecipeHandler.java
More file actions
191 lines (161 loc) · 8.46 KB
/
Copy pathWireRecipeHandler.java
File metadata and controls
191 lines (161 loc) · 8.46 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package gregtech.loaders.recipe.handlers;
import gregtech.api.GTValues;
import gregtech.api.recipes.ModHandler;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.material.properties.WireProperties;
import gregtech.api.unification.ore.OrePrefix;
import gregtech.api.unification.stack.UnificationEntry;
import gregtech.api.util.GTUtility;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import static gregtech.api.GTValues.*;
import static gregtech.api.recipes.RecipeMaps.*;
import static gregtech.api.unification.material.Materials.*;
import static gregtech.api.unification.material.info.MaterialFlags.GENERATE_PLATE;
import static gregtech.api.unification.material.info.MaterialFlags.NO_WORKING;
import static gregtech.api.unification.ore.OrePrefix.*;
import static gregtech.common.items.MetaItems.SHAPE_EXTRUDER_WIRE;
/**
* Guide to the new GregTech CE: Unofficial Cable Processing.
*
* Cable Covering Fluids:
* - Rubber: This can be used for any cable EV-tier or lower. After that it is unavailable.
*
* - Silicone Rubber: This can be used for any cable tier, saving the amount of fluid needed. However, at IV,
* it will require a Foil of the cable material as well, making it undesirable.
*
* - Styrene-Butadiene Rubber (SBR): This can be used for any cable tier, and is the most optimal cable-covering
* fluid available.
*
* Extra Materials for Cable Covering:
* - Polyphenylene Sulfide (PPS): At LuV, this foil is required to cover cables. Lower tiers will not use it.
*
* - Material Foil: At IV, an extra foil of the Material is needed to make the cable with SiR.
*/
public class WireRecipeHandler {
private static final Map<OrePrefix, Integer> INSULATION_AMOUNT = ImmutableMap.of(
cableGtSingle, 1,
cableGtDouble, 1,
cableGtQuadruple, 2,
cableGtOctal, 3,
cableGtHex, 5);
public static void register() {
// Generate 1x Wire creation recipes (Wiremill, Extruder, Wire Cutters)
wireGtSingle.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::processWireSingle);
// Generate Cable Covering Recipes
wireGtSingle.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::generateCableCovering);
wireGtDouble.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::generateCableCovering);
wireGtQuadruple.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::generateCableCovering);
wireGtOctal.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::generateCableCovering);
wireGtHex.addProcessingHandler(PropertyKey.WIRE, WireRecipeHandler::generateCableCovering);
}
private static final OrePrefix[] wireSizes = { wireGtDouble, wireGtQuadruple, wireGtOctal, wireGtHex };
public static void processWireSingle(OrePrefix wirePrefix, Material material, WireProperties property) {
OrePrefix prefix = material.hasProperty(PropertyKey.INGOT) ? ingot :
material.hasProperty(PropertyKey.GEM) ? gem : dust;
int workingTier = material.getWorkingTier();
EXTRUDER_RECIPES.recipeBuilder()
.input(prefix, material)
.notConsumable(SHAPE_EXTRUDER_WIRE)
.output(wireGtSingle, material, 2)
.duration((int) material.getMass() * 2)
.EUt(GTUtility.scaleVoltage(6 * getVoltageMultiplier(material), workingTier))
.buildAndRegister();
WIREMILL_RECIPES.recipeBuilder()
.input(prefix, material)
.circuitMeta(1)
.output(wireGtSingle, material, 2)
.duration((int) material.getMass())
.EUt(GTUtility.scaleVoltage(getVoltageMultiplier(material), workingTier))
.buildAndRegister();
for (OrePrefix wireSize : wireSizes) {
final int multiplier = (int) (wireSize.getMaterialAmount(material) / GTValues.M);
WIREMILL_RECIPES.recipeBuilder()
.input(prefix, material, multiplier)
.circuitMeta(multiplier * 2)
.output(wireSize, material)
.duration((int) (material.getMass() * multiplier))
.EUt(GTUtility.scaleVoltage(getVoltageMultiplier(material), workingTier))
.buildAndRegister();
}
if (!material.hasFlag(NO_WORKING) && material.hasFlag(GENERATE_PLATE) && workingTier <= HV) {
ModHandler.addShapedRecipe(String.format("%s_wire_single", material),
OreDictUnifier.get(wireGtSingle, material), "Xx",
'X', new UnificationEntry(plate, material));
}
}
public static void generateCableCovering(OrePrefix wirePrefix, Material material, WireProperties property) {
// Superconductors have no Cables, so exit early
if (property.isSuperconductor()) return;
int cableAmount = (int) (wirePrefix.getMaterialAmount(material) * 2 / GTValues.M);
OrePrefix cablePrefix = OrePrefix.getPrefix("cable" + wirePrefix.name().substring(4));
int voltageTier = GTUtility.getTierByVoltage(property.getVoltage());
int insulationAmount = INSULATION_AMOUNT.get(cablePrefix);
// Generate hand-crafting recipes for ULV and LV cables
if (voltageTier <= GTValues.LV) {
generateManualRecipe(wirePrefix, material, cablePrefix, cableAmount);
}
// Rubber Recipe (ULV-EV cables)
if (voltageTier <= GTValues.EV) {
var builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
.input(wirePrefix, material)
.output(cablePrefix, material)
.fluidInputs(Rubber.getFluid(GTValues.L * insulationAmount));
if (voltageTier == GTValues.EV) {
builder.input(foil, PolyvinylChloride, insulationAmount);
}
builder.buildAndRegister();
}
// Silicone Rubber Recipe (all cables)
var builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
.input(wirePrefix, material)
.output(cablePrefix, material);
// Apply a Polyphenylene Sulfate Foil if LuV or above.
if (voltageTier >= GTValues.LuV) {
builder.input(foil, PolyphenyleneSulfide, insulationAmount);
}
// Apply a PVC Foil if EV or above.
if (voltageTier >= GTValues.EV) {
builder.input(foil, PolyvinylChloride, insulationAmount);
}
builder.fluidInputs(SiliconeRubber.getFluid(GTValues.L * insulationAmount / 2))
.buildAndRegister();
// Styrene Butadiene Rubber Recipe (all cables)
builder = ASSEMBLER_RECIPES.recipeBuilder().EUt(VA[ULV]).duration(100)
.input(wirePrefix, material)
.output(cablePrefix, material);
// Apply a Polyphenylene Sulfate Foil if LuV or above.
if (voltageTier >= GTValues.LuV) {
builder.input(foil, PolyphenyleneSulfide, insulationAmount);
}
// Apply a PVC Foil if EV or above.
if (voltageTier >= GTValues.EV) {
builder.input(foil, PolyvinylChloride, insulationAmount);
}
builder.fluidInputs(StyreneButadieneRubber.getFluid(GTValues.L * insulationAmount / 4))
.buildAndRegister();
}
private static void generateManualRecipe(OrePrefix wirePrefix, Material material, OrePrefix cablePrefix,
int cableAmount) {
int insulationAmount = INSULATION_AMOUNT.get(cablePrefix);
Object[] ingredients = new Object[insulationAmount + 1];
ingredients[0] = new UnificationEntry(wirePrefix, material);
for (int i = 1; i <= insulationAmount; i++) {
ingredients[i] = OreDictUnifier.get(plate, Rubber);
}
ModHandler.addShapelessRecipe(String.format("%s_cable_%d", material, cableAmount),
OreDictUnifier.get(cablePrefix, material),
ingredients);
PACKER_RECIPES.recipeBuilder()
.input(wirePrefix, material)
.input(plate, Rubber, insulationAmount)
.output(cablePrefix, material)
.duration(100).EUt(VA[ULV])
.buildAndRegister();
}
private static long getVoltageMultiplier(Material material) {
return material.getBlastTemperature() >= 2800 ? VA[LV] : VA[ULV];
}
}