-
Notifications
You must be signed in to change notification settings - Fork 465
Expand file tree
/
Copy pathMTEIndustrialElectrolyzer.java
More file actions
246 lines (219 loc) · 9.23 KB
/
MTEIndustrialElectrolyzer.java
File metadata and controls
246 lines (219 loc) · 9.23 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
package gregtech.common.tileentities.machines.multi;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static gregtech.api.enums.HatchElement.Energy;
import static gregtech.api.enums.HatchElement.InputBus;
import static gregtech.api.enums.HatchElement.InputHatch;
import static gregtech.api.enums.HatchElement.Maintenance;
import static gregtech.api.enums.HatchElement.Muffler;
import static gregtech.api.enums.HatchElement.OutputBus;
import static gregtech.api.enums.HatchElement.OutputHatch;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.ofFrame;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.casing.Casings;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.common.pollution.PollutionConfig;
import gtPlusPlus.api.recipe.GTPPRecipeMaps;
import gtPlusPlus.core.material.MaterialsAlloy;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
public class MTEIndustrialElectrolyzer extends MTEExtendedPowerMultiBlockBase<MTEIndustrialElectrolyzer>
implements ISurvivalConstructable {
private static IStructureDefinition<MTEIndustrialElectrolyzer> STRUCTURE_DEFINITION = null;
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final int OFFSET_X = 2;
private static final int OFFSET_Y = 2;
private static final int OFFSET_Z = 1;
private static final int PARALLEL_PER_TIER = 4;
private static final float SPEED = 2.8f;
private static final float EU_EFFICIENCY = 0.9f;
public MTEIndustrialElectrolyzer(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
}
public MTEIndustrialElectrolyzer(final String aName) {
super(aName);
}
@Override
public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
return new MTEIndustrialElectrolyzer(this.mName);
}
@Override
public IStructureDefinition<MTEIndustrialElectrolyzer> getStructureDefinition() {
if (STRUCTURE_DEFINITION == null) {
STRUCTURE_DEFINITION = StructureDefinition.<MTEIndustrialElectrolyzer>builder()
.addShape(
STRUCTURE_PIECE_MAIN,
// spotless:off
new String[][]{{
" DDD ",
" ",
" ",
" ",
" DDD "
},{
"DDDDD",
" ADA ",
" A~A ",
" ADA ",
"DDDDD"
},{
"DCDBD",
" CDB ",
" CDB ",
" CDB ",
"DDDDD"
},{
"DDDDD",
" ADA ",
" ADA ",
" ADA ",
"DDDDD"
},{
" DDD ",
" ",
" ",
" ",
" DDD "
}})
//spotless:on
.addElement('A', ofFrame(MaterialsAlloy.POTIN))
.addElement('B', Casings.BrassItemPipeCasing.asElement())
.addElement('C', Casings.TinItemPipeCasing.asElement())
.addElement(
'D',
buildHatchAdder(MTEIndustrialElectrolyzer.class)
.atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy, Muffler)
.casingIndex(Casings.ElectrolyzerCasing.textureId)
.hint(1)
.buildAndChain(
onElementPass(
MTEIndustrialElectrolyzer::onCasingAdded,
Casings.ElectrolyzerCasing.asElement())))
.build();
}
return STRUCTURE_DEFINITION;
}
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing,
int colorIndex, boolean aActive, boolean redstoneLevel) {
if (side == aFacing) {
if (aActive) return new ITexture[] { Casings.ElectrolyzerCasing.getCasingTexture(), TextureFactory.builder()
.addIcon(TexturesGtBlock.oMCDIndustrialElectrolyzerActive)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(TexturesGtBlock.oMCDIndustrialElectrolyzerActiveGlow)
.extFacing()
.glow()
.build() };
return new ITexture[] { Casings.ElectrolyzerCasing.getCasingTexture(), TextureFactory.builder()
.addIcon(TexturesGtBlock.oMCDIndustrialElectrolyzer)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(TexturesGtBlock.oMCDIndustrialElectrolyzerGlow)
.extFacing()
.glow()
.build() };
}
return new ITexture[] { Casings.ElectrolyzerCasing.getCasingTexture() };
}
@Override
protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Electrolyzer")
.addBulkMachineInfo(PARALLEL_PER_TIER, SPEED, EU_EFFICIENCY)
.addPollutionAmount(getPollutionPerSecond(null))
.beginStructureBlock(5, 5, 5, false)
.addController("Front Center")
.addCasingInfoMin("Electrolyzer Casings", 6, false)
.addCasingInfoExactly("Potin Frame Box", 12, false)
.addCasingInfoExactly("Tin Item Pipe Casing", 4, false)
.addCasingInfoExactly("Brass Item Pipe Casing", 4, false)
.addInputBus("Any Electrolyzer Casing", 1)
.addOutputBus("Any Electrolyzer Casing", 1)
.addInputHatch("Any Electrolyzer Casing", 1)
.addOutputHatch("Any Electrolyzer Casing", 1)
.addEnergyHatch("Any Electrolyzer Casing", 1)
.addMaintenanceHatch("Any Electrolyzer Casing", 1)
.addMufflerHatch("Any Electrolyzer Casing", 1)
.addStructureAuthors(EnumChatFormatting.BLUE + "Vortex")
.toolTipFinisher();
return tt;
}
@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic().setSpeedBonus(1F / SPEED)
.setEuModifier(EU_EFFICIENCY)
.setMaxParallelSupplier(this::getTrueParallel);
}
@Override
public int getMaxParallelRecipes() {
return (PARALLEL_PER_TIER * GTUtility.getTier(this.getMaxInputVoltage()));
}
private int casingAmount;
private void onCasingAdded() {
casingAmount++;
}
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, OFFSET_X, OFFSET_Y, OFFSET_Z);
}
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
if (mMachine) return -1;
return survivalBuildPiece(
STRUCTURE_PIECE_MAIN,
stackSize,
OFFSET_X,
OFFSET_Y,
OFFSET_Z,
elementBudget,
env,
false,
true);
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
casingAmount = 0;
return checkPiece(STRUCTURE_PIECE_MAIN, OFFSET_X, OFFSET_Y, OFFSET_Z) && casingAmount >= 6
&& !this.mMufflerHatches.isEmpty();
}
@Override
public int getPollutionPerSecond(final ItemStack aStack) {
return PollutionConfig.pollutionPerSecondMultiIndustrialElectrolyzer;
}
@Override
public RecipeMap<?> getRecipeMap() {
return GTPPRecipeMaps.electrolyzerNonCellRecipes;
}
@Override
public boolean supportsInputSeparation() {
return true;
}
@Override
public boolean supportsSingleRecipeLocking() {
return true;
}
@Override
public boolean supportsVoidProtection() {
return true;
}
@Override
public boolean supportsBatchMode() {
return true;
}
}