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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
package gregtech.common.tileentities.machines.multi.purification;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static gregtech.api.enums.GTValues.AuthorNotAPenguin;
import static gregtech.api.enums.HatchElement.InputHatch;
import static gregtech.api.enums.HatchElement.OutputHatch;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW;
import static gregtech.api.recipe.RecipeMaps.purificationPlasmaHeatingRecipes;
import static gregtech.api.util.GTRecipeBuilder.SECONDS;
import static gregtech.api.util.GTStructureUtility.ofFrame;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import com.google.common.collect.ImmutableList;
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 cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Materials;
import gregtech.api.enums.Mods;
import gregtech.api.enums.SoundResource;
import gregtech.api.enums.Textures;
import gregtech.api.enums.TierEU;
import gregtech.api.interfaces.IHatchElement;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchInput;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTStructureUtility;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
public class MTEPurificationUnitPlasmaHeater extends MTEPurificationUnitBase<MTEPurificationUnitPlasmaHeater>
implements ISurvivalConstructable {
private static final int CASING_INDEX_HEATER = getTextureIndex(GregTechAPI.sBlockCasings9, 11);
private static final int CASING_INDEX_TOWER = getTextureIndex(GregTechAPI.sBlockCasings9, 5);
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final int STRUCTURE_X_OFFSET = 2;
private static final int STRUCTURE_Y_OFFSET = 14;
private static final int STRUCTURE_Z_OFFSET = 5;
/**
* Fluid is consumed every CONSUME_INTERVAL ticks
*/
private static final long CONSUME_INTERVAL = 1 * SECONDS;
/**
* Current internal temperature of the multiblock
*/
private long currentTemperature = 0;
/**
* Amount of successful heating cycles completed
*/
private int cyclesCompleted = 0;
/**
* Whether this recipe is ruined due to high temperature
*/
private boolean ruinedCycle = false;
private enum CycleState {
// Was previously at 0K, currently waiting to heat to 10000K
Heating,
// Was previously at 10000K, currently waiting to cool down to 0K
Cooling
}
private CycleState state = CycleState.Heating;
// A cycle is 30s at shortest, a purification plant cycle is 120s. 33% chance per heating cycle
// will give you plenty of room for delay and still get to 99% chance.
public static final long SUCCESS_PER_CYCLE = 33;
// Consumption rates in liters/second
public static final long MAX_PLASMA_PER_SEC = 10;
public static final long MAX_COOLANT_PER_SEC = 100;
// Change in temperature per consumed liter of plasma
public static final long PLASMA_TEMP_PER_LITER = 100;
// Change in temperature per consumed liter of coolant
public static final long COOLANT_TEMP_PER_LITER = -5;
// Temperature at which the batch is ruined
public static final long MAX_TEMP = 12500;
// Point at which the heating point of the cycle is reached
public static final long HEATING_POINT = 10000;
private static final Materials plasmaMaterial = Materials.Helium;
private static final Materials coolantMaterial = Materials.SuperCoolant;
private MTEHatchInput plasmaInputHatch;
private MTEHatchInput coolantInputHatch;
private static final String[][] structure = new String[][] {
// spotless:off
{ " DDDDD ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " DDDDD ", " DDDDD ", " DDDDD ", " DDKDD " },
{ " DD DD ", " DDDDD ", " ", " ", " ", " ", " ", " ", " DDDDD ", " DDDDD ", " DDDDD ", " DD DD ", " DD DD ", " DD DD ", " DDDDDDDDD " },
{ " D D ", " DD DD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DD DD ", " DD DD ", " DD DD ", " D D ", " D D ", " D D ", " DDDDDDDDDDD " },
{ " D D ", " D D ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " DDDDDDDDDDDDD " },
{ " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " DDDDDDDDDDDDD " },
{ " D D", " D D ", " D D ", " D D ", " D D ", "GBBBG D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D", "G G D D", "G G D D", "GB~BG DDDDDDDDDDDDDDD" },
{ " D D", " D D ", " D D ", " D D ", " BBB D D ", "BBBBB D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D", " EEE D D", " EEEBBBBD D", "BAAAB DDDDDDDDDDDDDDD" },
{ " D D", " D D ", " D D ", " D D ", " BBB D D ", "BBBBB D D ", " EFE D D ", " EFE D D ", " EFE D D ", " EFE D D ", " EFE D D ", " EFE D D", " EFEBBBBD D", " EFE D D", "PAAABBBBDDDDDDDDDDDDDDD" },
{ " D D", " D D ", " D D ", " D D ", " BBB D D ", "BBBBB D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D ", " EEE D D", " EEE D D", " EEEBBBBD D", "BAAAB DDDDDDDDDDDDDDD" },
{ " D D", " D D ", " D D ", " D D ", " D D ", "GBBBG D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D ", "G G D D", "G G D D", "G G D D", "GBBBG DDDDDDDDDDDDDDD" },
{ " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " DDDDDDDDDDDDD " },
{ " D D ", " D D ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " DD DD ", " D D ", " D D ", " D D ", " D D ", " D D ", " D D ", " DDDDDDDDDDDDD " },
{ " D D ", " DD DD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD ", " DD DD ", " DD DD ", " DD DD ", " D D ", " D D ", " D D ", " DDDDDDDDDDD " },
{ " DD DD ", " DDDDD ", " ", " ", " ", " ", " ", " ", " DDDDD ", " DDDDD ", " DDDDD ", " DD DD ", " DD DD ", " DD DD ", " DDDDDDDDD " },
{ " DDDDD ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " DDDDD ", " DDDDD ", " DDDDD ", " DDDDD " } };
// spotless:on
private int casingCount = 0;
private static final int MIN_CASING = 50;
private static final IStructureDefinition<MTEPurificationUnitPlasmaHeater> STRUCTURE_DEFINITION = StructureDefinition
.<MTEPurificationUnitPlasmaHeater>builder()
.addShape(STRUCTURE_PIECE_MAIN, structure)
// Superconducting coil block
.addElement('A', ofBlock(GregTechAPI.sBlockCasings1, 15))
// Plasma Heating Casing
.addElement(
'B',
ofChain(
lazy(
t -> GTStructureUtility.<MTEPurificationUnitPlasmaHeater>buildHatchAdder()
.atLeastList(t.getAllowedHatches())
.dot(1)
.casingIndex(CASING_INDEX_HEATER)
.build()),
onElementPass(t -> t.casingCount++, ofBlock(GregTechAPI.sBlockCasings9, 11))))
// Reinforced Sterile Water Plant Casing
.addElement('D', ofBlock(GregTechAPI.sBlockCasings9, 5))
// Any Tinted Glass
.addElement('E', ofBlockAnyMeta(GregTechAPI.sBlockTintedGlass, 0))
// Neonite, with fallback to air
.addElement('F', lazy(t -> {
if (Mods.Chisel.isModLoaded()) {
Block neonite = GameRegistry.findBlock(Mods.Chisel.ID, "neonite");
return ofBlockAnyMeta(neonite, 7);
} else {
return ofBlockAnyMeta(Blocks.air);
}
}))
// Superconductor Base ZPM frame box
.addElement('G', ofFrame(Materials.Tetranaquadahdiindiumhexaplatiumosminid))
// Coolant input hatch
.addElement(
'K',
lazy(
t -> GTStructureUtility.<MTEPurificationUnitPlasmaHeater>buildHatchAdder()
.hatchClass(MTEHatchInput.class)
.dot(2)
.adder(MTEPurificationUnitPlasmaHeater::addCoolantHatchToMachineList)
.cacheHint(() -> "Input Hatch (Coolant)")
.casingIndex(CASING_INDEX_TOWER)
.buildAndChain(ofBlock(GregTechAPI.sBlockCasings9, 5))))
// Plasma input hatch
.addElement(
'P',
lazy(
t -> GTStructureUtility.<MTEPurificationUnitPlasmaHeater>buildHatchAdder()
.hatchClass(MTEHatchInput.class)
.dot(3)
.adder(MTEPurificationUnitPlasmaHeater::addPlasmaHatchToMachineList)
.cacheHint(() -> "Input Hatch (Plasma)")
.casingIndex(CASING_INDEX_HEATER)
.buildAndChain(ofBlock(GregTechAPI.sBlockCasings9, 11))))
.build();
private List<IHatchElement<? super MTEPurificationUnitPlasmaHeater>> getAllowedHatches() {
return ImmutableList.of(InputHatch, OutputHatch);
}
public MTEPurificationUnitPlasmaHeater(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public MTEPurificationUnitPlasmaHeater(String aName) {
super(aName);
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTEPurificationUnitPlasmaHeater(this.mName);
}
@Override
public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection facing,
int colorIndex, boolean active, boolean redstoneLevel) {
if (side == facing) {
if (active) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX_HEATER),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW)
.extFacing()
.glow()
.build() };
return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX_HEATER),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW)
.extFacing()
.glow()
.build() };
}
return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX_HEATER) };
}
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
buildPiece(
STRUCTURE_PIECE_MAIN,
stackSize,
hintsOnly,
STRUCTURE_X_OFFSET,
STRUCTURE_Y_OFFSET,
STRUCTURE_Z_OFFSET);
}
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
return survivialBuildPiece(
STRUCTURE_PIECE_MAIN,
stackSize,
STRUCTURE_X_OFFSET,
STRUCTURE_Y_OFFSET,
STRUCTURE_Z_OFFSET,
elementBudget,
env,
true);
}
@Override
public IStructureDefinition<MTEPurificationUnitPlasmaHeater> getStructureDefinition() {
return STRUCTURE_DEFINITION;
}
@Override
public RecipeMap<?> getRecipeMap() {
return purificationPlasmaHeatingRecipes;
}
@Override
protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Purification Unit")
.addInfo(
EnumChatFormatting.AQUA + ""
+ EnumChatFormatting.BOLD
+ "Water Tier: "
+ EnumChatFormatting.WHITE
+ GTUtility.formatNumbers(getWaterTier())
+ EnumChatFormatting.RESET)
.addInfo("Must be linked to a Purification Plant using a data stick to work.")
.addSeparator()
.addInfo(
"Complete heating cycles by first heating the water to " + EnumChatFormatting.RED
+ HEATING_POINT
+ "K"
+ EnumChatFormatting.GRAY
+ ",")
.addInfo(
"and then cooling it back down to " + EnumChatFormatting.RED + "0K" + EnumChatFormatting.GRAY + ".")
.addInfo(
"Initial temperature is reset to " + EnumChatFormatting.RED
+ "0K"
+ EnumChatFormatting.GRAY
+ " on recipe start.")
.addInfo(
// TODO: Refer to heating cycles in another way to avoid confusion
"Each completed heating cycle boosts success chance by " + EnumChatFormatting.RED
+ SUCCESS_PER_CYCLE
+ "%"
+ EnumChatFormatting.GRAY
+ ".")
.addInfo(
"If the temperature ever reaches " + EnumChatFormatting.RED
+ MAX_TEMP
+ "K"
+ EnumChatFormatting.GRAY
+ " the recipe will fail and output steam.")
.addSeparator()
.addInfo(
"Consumes up to " + EnumChatFormatting.RED
+ MAX_PLASMA_PER_SEC
+ "L/s "
+ EnumChatFormatting.WHITE
+ plasmaMaterial.getPlasma(1)
.getLocalizedName()
+ EnumChatFormatting.GRAY
+ " and up to "
+ EnumChatFormatting.RED
+ MAX_COOLANT_PER_SEC
+ "L/s "
+ EnumChatFormatting.WHITE
+ coolantMaterial.getFluid(1)
.getLocalizedName()
+ EnumChatFormatting.GRAY
+ ".")
.addInfo(
EnumChatFormatting.RED + "Raises "
+ EnumChatFormatting.GRAY
+ "the temperature by "
+ EnumChatFormatting.RED
+ PLASMA_TEMP_PER_LITER
+ "K"
+ EnumChatFormatting.GRAY
+ " per liter of plasma consumed.")
.addInfo(
EnumChatFormatting.RED + "Lowers "
+ EnumChatFormatting.GRAY
+ "the temperature by "
+ EnumChatFormatting.RED
+ -COOLANT_TEMP_PER_LITER
+ "K"
+ EnumChatFormatting.GRAY
+ " per liter of coolant consumed.")
.addSeparator()
.addInfo(
EnumChatFormatting.AQUA + ""
+ EnumChatFormatting.ITALIC
+ "Step five of water purification is to evaporate complex organic polymers and extremophile organisms")
.addInfo(
EnumChatFormatting.AQUA + ""
+ EnumChatFormatting.ITALIC
+ "that might be resistant to simple acids, clarifying agents, and filters. Using an ultra high")
.addInfo(
EnumChatFormatting.AQUA + ""
+ EnumChatFormatting.ITALIC
+ "pressure chamber in combination with extreme temperature fluctuations allows the water to remain")
.addInfo(
EnumChatFormatting.AQUA + ""
+ EnumChatFormatting.ITALIC
+ "supercritical while evaporating any remaining contaminants, ready for filtration.")
.beginStructureBlock(23, 15, 15, false)
.addCasingInfoExactlyColored(
"Reinforced Sterile Water Plant Casing",
EnumChatFormatting.GRAY,
669,
EnumChatFormatting.GOLD,
false)
.addCasingInfoExactlyColored(
"Heat-Resistant Trinium Plated Casing",
EnumChatFormatting.GRAY,
54,
EnumChatFormatting.GOLD,
false)
.addCasingInfoExactlyColored(
"Any Tinted Industrial Glass",
EnumChatFormatting.GRAY,
64,
EnumChatFormatting.GOLD,
false)
.addCasingInfoExactlyColored(
"Superconductor Base ZPM Frame Box",
EnumChatFormatting.GRAY,
40,
EnumChatFormatting.GOLD,
false)
.addCasingInfoExactlyColored("Any Neonite", EnumChatFormatting.GRAY, 8, EnumChatFormatting.GOLD, false)
.addCasingInfoExactlyColored(
"Superconducting Coil Block",
EnumChatFormatting.GRAY,
9,
EnumChatFormatting.GOLD,
false)
.addController("Front center")
.addOtherStructurePart("Input Hatch (Water)", EnumChatFormatting.GOLD + "1+", 1)
.addOtherStructurePart("Output Hatch", EnumChatFormatting.GOLD + "1", 1)
.addOtherStructurePart("Input Hatch (Coolant)", EnumChatFormatting.GOLD + "1", 2)
.addOtherStructurePart("Input Hatch (Plasma)", EnumChatFormatting.GOLD + "1", 3)
.toolTipFinisher(AuthorNotAPenguin);
return tt;
}
@Override
public void startCycle(int cycleTime, int progressTime) {
super.startCycle(cycleTime, progressTime);
// Reset internal state
this.cyclesCompleted = 0;
this.currentTemperature = 0;
this.ruinedCycle = false;
this.state = CycleState.Heating;
}
// Drains up to maxAmount of a fluid if it is the same fluid as given, returns the amount drained
private long drainFluidLimited(MTEHatchInput inputHatch, FluidStack fluid, long maxAmount) {
FluidStack hatchStack = inputHatch.getDrainableStack();
if (hatchStack == null) return 0;
if (hatchStack.isFluidEqual(fluid)) {
long amountToDrain = Math.min(maxAmount, hatchStack.amount);
if (amountToDrain > 0) {
inputHatch.drain((int) amountToDrain, true);
}
return amountToDrain;
} else {
return 0;
}
}
@Override
public void addRecipeOutputs() {
super.addRecipeOutputs();
// If the cycle was ruined, output steam
if (this.ruinedCycle) {
FluidStack insertedWater = currentRecipe.mFluidInputs[0];
// Multiply by 60 since that's the water:steam ratio in GTNH
long steamAmount = insertedWater.amount * 60L;
addOutput(GTModHandler.getSteam(steamAmount));
}
}
@Override
protected void runMachine(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.runMachine(aBaseMetaTileEntity, aTick);
if (mMaxProgresstime > 0 && aTick % CONSUME_INTERVAL == 0) {
// Drain plasma and coolant up to limited amount per second
long plasmaDrained = drainFluidLimited(plasmaInputHatch, plasmaMaterial.getPlasma(1L), MAX_PLASMA_PER_SEC);
long coolantDrained = drainFluidLimited(
coolantInputHatch,
coolantMaterial.getFluid(1L),
MAX_COOLANT_PER_SEC);
// Calculate temperature change
long tempChance = plasmaDrained * PLASMA_TEMP_PER_LITER + coolantDrained * COOLANT_TEMP_PER_LITER;
currentTemperature = Math.max(0, currentTemperature + tempChance);
// Check if batch was ruined
if (currentTemperature > MAX_TEMP) {
ruinedCycle = true;
}
// Update cycle state.
switch (state) {
case Heating -> {
// Heating state can change to cooling when temperature exceeds 10000K
if (currentTemperature >= HEATING_POINT) {
state = CycleState.Cooling;
}
}
case Cooling -> {
if (currentTemperature == 0) {
state = CycleState.Heating;
cyclesCompleted += 1;
}
}
}
}
}
public boolean addCoolantHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatchInput) {
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
((MTEHatchInput) aMetaTileEntity).mRecipeMap = null;
coolantInputHatch = (MTEHatchInput) aMetaTileEntity;
return true;
}
return false;
}
public boolean addPlasmaHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatchInput) {
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
((MTEHatchInput) aMetaTileEntity).mRecipeMap = null;
plasmaInputHatch = (MTEHatchInput) aMetaTileEntity;
return true;
}
return false;
}
@Override
public float calculateFinalSuccessChance() {
if (ruinedCycle) return 0.0f;
// Success chance directly depends on number of cycles completed.
return cyclesCompleted * SUCCESS_PER_CYCLE + currentRecipeChance;
}
@Override
public String[] getInfoData() {
ArrayList<String> infoData = new ArrayList<>(Arrays.asList(super.getInfoData()));
infoData.add("Current temperature: " + EnumChatFormatting.YELLOW + currentTemperature + "K");
infoData.add("Heating cycles completed this run: " + EnumChatFormatting.YELLOW + cyclesCompleted);
return infoData.toArray(new String[] {});
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setLong("mCurrentTemperature", currentTemperature);
aNBT.setInteger("mCyclesCompleted", cyclesCompleted);
aNBT.setBoolean("mRuinedCycle", ruinedCycle);
aNBT.setString("mCycleState", state.toString());
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
currentTemperature = aNBT.getLong("mCurrentTemperature");
cyclesCompleted = aNBT.getInteger("mCyclesCompleted");
ruinedCycle = aNBT.getBoolean("mRuinedCycle");
state = CycleState.valueOf(aNBT.getString("mCycleState"));
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public int getWaterTier() {
return 5;
}
@Override
public long getBasePowerUsage() {
return TierEU.RECIPE_UV;
}
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
casingCount = 0;
if (!checkPiece(STRUCTURE_PIECE_MAIN, STRUCTURE_X_OFFSET, STRUCTURE_Y_OFFSET, STRUCTURE_Z_OFFSET)) return false;
if (casingCount < MIN_CASING) return false;
// Do not form without positioned hatches
if (plasmaInputHatch == null || coolantInputHatch == null) return false;
return super.checkMachine(aBaseMetaTileEntity, aStack);
}
@Override
protected SoundResource getActivitySoundLoop() {
return SoundResource.GT_MACHINES_PURIFICATION_PLASMA_LOOP;
}
}
|