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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
|
package gtPlusPlus.core.material;
import static gregtech.api.enums.GT_Values.M;
import java.util.*;
import gregtech.api.enums.*;
import gtPlusPlus.core.item.base.cell.BaseItemCell;
import gtPlusPlus.core.material.state.MaterialState;
import gtPlusPlus.core.util.StringUtils;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.fluid.FluidUtils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.materials.MaterialUtils;
import gtPlusPlus.core.util.math.MathUtils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
public class Material {
private final String unlocalizedName;
private final String localizedName;
private final MaterialState materialState;
private final Fluid vMoltenFluid;
private final Fluid vPlasma;
private final boolean vGenerateCells;
protected Object dataVar = MathUtils.generateSingularRandomHexValue();
private ArrayList<MaterialStack> vMaterialInput = new ArrayList<>();
public final long[] vSmallestRatio;
public final short vComponentCount;
private final short[] RGBA;
private final boolean usesBlastFurnace;
public final boolean isRadioactive;
public final byte vRadiationLevel;
private final int meltingPointK;
private final int boilingPointK;
private final int meltingPointC;
private final int boilingPointC;
private final long vProtons;
private final long vNeutrons;
private final long vMass;
public final int smallestStackSizeWhenProcessing; //Add a check for <=0 || > 64
public final int vTier;
public final int vVoltageMultiplier;
public final String vChemicalFormula;
public final String vChemicalSymbol;
public final long vDurability;
public final int vToolQuality;
public final int vHarvestLevel;
public static Map<Integer, Materials> invalidMaterials = new HashMap<Integer, Materials>();
public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final MaterialStack... inputs){
this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", 0, inputs);
}
public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, boolean generateCells, final MaterialStack... inputs){
this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", 0, generateCells, inputs);
}
public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final int radiationLevel, final MaterialStack... inputs){
this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", radiationLevel, inputs);
}
public Material(final String materialName, final MaterialState defaultState,final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final int radiationLevel, final MaterialStack... inputs){
this(materialName, defaultState, durability, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, "", radiationLevel, inputs);
}
public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, final MaterialStack... inputs){
this(materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, inputs);
}
public Material(final String materialName, final MaterialState defaultState,final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean addCells,final MaterialStack... inputs) {
this (materialName, defaultState, 0, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, addCells, inputs);
}
public Material(final String materialName, final MaterialState defaultState, final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, final MaterialStack... inputs){
this (materialName, defaultState, durability, rgba, meltingPoint, boilingPoint, protons, neutrons, blastFurnace, chemicalSymbol, radiationLevel, true, inputs);
}
public Material(final String materialName, final MaterialState defaultState, final long durability, final short[] rgba, final int meltingPoint, final int boilingPoint, final long protons, final long neutrons, final boolean blastFurnace, final String chemicalSymbol, final int radiationLevel, boolean generateCells, final MaterialStack... inputs){
this.unlocalizedName = Utils.sanitizeString(materialName);
this.localizedName = materialName;
this.materialState = defaultState;
this.RGBA = rgba;
this.vGenerateCells = generateCells;
//Add Components to an array.
if (inputs == null){
this.vMaterialInput = null;
}
else {
if (inputs.length != 0){
for (int i=0; i < inputs.length; i++){
if (inputs[i] != null){
this.vMaterialInput.add(i, inputs[i]);
}
}
}
}
//Set Melting/Boiling point, if value is -1 calculate it from compound inputs.
if (meltingPoint != -1){
this.meltingPointC = meltingPoint;
}
else {
this.meltingPointC = this.calculateMeltingPoint();
}
if (boilingPoint != -1){
if (boilingPoint != 0){
this.boilingPointC = boilingPoint;
}
else {
this.boilingPointC = meltingPoint*4;
}
}
else {
this.boilingPointC = this.calculateMeltingPoint();
}
this.meltingPointK = (int) MathUtils.celsiusToKelvin(this.meltingPointC);
this.boilingPointK = (int) MathUtils.celsiusToKelvin(this.boilingPointC);
//Set Proton/Neutron count, if value is -1 calculate it from compound inputs.
if (protons != -1){
this.vProtons = protons;
}
else {
this.vProtons = this.calculateProtons();
}
if (boilingPoint != -1){
this.vNeutrons = neutrons;
}
else {
this.vNeutrons = this.calculateNeutrons();
}
this.vMass = this.getMass();
//Sets tool Durability
if (durability != 0){
this.vDurability = durability;
}
else {
if (inputs != null){
long durabilityTemp = 0;
int counterTemp = 0;
for (final MaterialStack m : inputs){
if (m.getStackMaterial() != null){
if (m.getStackMaterial().vDurability != 0){
durabilityTemp = (durabilityTemp+m.getStackMaterial().vDurability);
counterTemp++;
}
}
}
if ((durabilityTemp != 0) && (counterTemp != 0)){
this.vDurability = (durabilityTemp/counterTemp);
}
else {
this.vDurability = 8196;
}
}
else {
this.vDurability = 0;
}
}
if ((this.vDurability >= 0) && (this.vDurability < 64000)){
this.vToolQuality = 1;
this.vHarvestLevel = 2;
}
else if ((this.vDurability >= 64000) && (this.vDurability < 128000)){
this.vToolQuality = 2;
this.vHarvestLevel = 2;
}
else if ((this.vDurability >= 128000) && (this.vDurability < 256000)){
this.vToolQuality = 3;
this.vHarvestLevel = 2;
}
else if ((this.vDurability >= 256000) && (this.vDurability < 512000)){
this.vToolQuality = 3;
this.vHarvestLevel = 3;
}
else if ((this.vDurability >= 512000) && (this.vDurability <= Integer.MAX_VALUE)){
this.vToolQuality = 4;
this.vHarvestLevel = 4;
}
else {
this.vToolQuality = 0;
this.vHarvestLevel = 0;
}
//Sets the Rad level
if (radiationLevel != 0){
this.isRadioactive = true;
this.vRadiationLevel = (byte) radiationLevel;
}
else {
this.isRadioactive = false;
this.vRadiationLevel = (byte) radiationLevel;
}
//Sets the materials 'tier'. Will probably replace this logic.
this.vTier = MaterialUtils.getTierOfMaterial((int) MathUtils.celsiusToKelvin(meltingPoint));
this.usesBlastFurnace = blastFurnace;
this.vVoltageMultiplier = this.getMeltingPointK() >= 2800 ? 60 : 15;
this.vComponentCount = this.getComponentCount(inputs);
this.vSmallestRatio = this.getSmallestRatio(this.vMaterialInput);
int tempSmallestSize = 0;
if (this.vSmallestRatio != null){
for (int v=0;v<this.vSmallestRatio.length;v++){
tempSmallestSize=(int) (tempSmallestSize+this.vSmallestRatio[v]);
}
this.smallestStackSizeWhenProcessing = tempSmallestSize; //Valid stacksizes
}
else {
this.smallestStackSizeWhenProcessing = 1; //Valid stacksizes
}
//Makes a Fancy Chemical Tooltip
this.vChemicalSymbol = chemicalSymbol;
if (this.vMaterialInput != null){
this.vChemicalFormula = this.getToolTip(chemicalSymbol, OrePrefixes.dust.mMaterialAmount / M, true);
}
else if (!this.vChemicalSymbol.equals("")){
Utils.LOG_WARNING("materialInput is null, using a valid chemical symbol.");
this.vChemicalFormula = this.vChemicalSymbol;
}
else{
Utils.LOG_WARNING("MaterialInput == null && chemicalSymbol probably equals nothing");
this.vChemicalFormula = "??";
}
final Materials isValid = Materials.get(this.getLocalizedName());
if (FluidUtils.getFluidStack(localizedName, 1) != null){
this.vMoltenFluid = FluidUtils.getFluidStack(localizedName, 1).getFluid();
}
else if (isValid == null || isValid == Materials._NULL){
this.vMoltenFluid = this.generateFluid();
}
else {
if (isValid.mFluid != null){
this.vMoltenFluid = isValid.mFluid;
}
else if (isValid.mGas != null){
this.vMoltenFluid = isValid.mGas;
}
else {
this.vMoltenFluid = this.generateFluid();
}
}
this.vPlasma = this.generatePlasma();
String ratio = "";
if (this.vSmallestRatio != null) {
for (int hu=0;hu<this.vSmallestRatio.length;hu++){
if (ratio.equals("")){
ratio = String.valueOf(this.vSmallestRatio[hu]);
}
else {
ratio = ratio + ":" +this.vSmallestRatio[hu];
}
}
}
Utils.LOG_WARNING("Creating a Material instance for "+materialName);
Utils.LOG_WARNING("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio);
Utils.LOG_WARNING("Protons: "+this.vProtons);
Utils.LOG_WARNING("Neutrons: "+this.vNeutrons);
Utils.LOG_WARNING("Mass: "+this.vMass+"/units");
Utils.LOG_WARNING("Melting Point: "+this.meltingPointC+"C.");
Utils.LOG_WARNING("Boiling Point: "+this.boilingPointC+"C.");
}
public final String getLocalizedName(){
if (this.localizedName != null) {
return this.localizedName;
}
return "ERROR BAD LOCALIZED NAME";
}
public final String getUnlocalizedName(){
if (this.unlocalizedName != null) {
return this.unlocalizedName;
}
return "ERROR.BAD.UNLOCALIZED.NAME";
}
final public MaterialState getState(){
return this.materialState;
}
final public short[] getRGBA(){
if (this.RGBA != null) {
return this.RGBA;
}
return new short[] {255,0,0};
}
final public int getRgbAsHex(){
final int returnValue = Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]);
if (returnValue == 0){
return (int) this.dataVar;
}
return Utils.rgbtoHexValue(this.RGBA[0], this.RGBA[1], this.RGBA[2]);
}
final public long getProtons() {
return this.vProtons;
}
public final long getNeutrons() {
return this.vNeutrons;
}
final public long getMass() {
return this.vProtons + this.vNeutrons;
}
public final int getMeltingPointC() {
return this.meltingPointC;
}
public final int getBoilingPointC() {
return this.boilingPointC;
}
public final int getMeltingPointK() {
return this.meltingPointK;
}
public final int getBoilingPointK() {
return this.boilingPointK;
}
public final boolean requiresBlastFurnace(){
return this.usesBlastFurnace;
}
final public Block getBlock(){
return Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("block"+this.unlocalizedName, 1).getItem());
}
public final ItemStack getBlock(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("block"+this.unlocalizedName, stacksize);
}
public final ItemStack getDust(final int stacksize){
return ItemUtils.getGregtechDust("dust"+this.unlocalizedName, stacksize);
}
public final ItemStack getSmallDust(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSmall"+this.unlocalizedName, stacksize);
}
public final ItemStack getTinyDust(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustTiny"+this.unlocalizedName, stacksize);
}
public final ItemStack[] getValidInputStacks(){
return ItemUtils.validItemsForOreDict(this.unlocalizedName);
}
public final ItemStack getIngot(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingot"+this.unlocalizedName, stacksize);
}
public final ItemStack getPlate(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plate"+this.unlocalizedName, stacksize);
}
public final ItemStack getPlateDouble(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDouble"+this.unlocalizedName, stacksize);
}
public final ItemStack getGear(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("gear"+this.unlocalizedName, stacksize);
}
public final ItemStack getRod(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("stick"+this.unlocalizedName, stacksize);
}
public final ItemStack getLongRod(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("stickLong"+this.unlocalizedName, stacksize);
}
public final ItemStack getBolt(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("bolt"+this.unlocalizedName, stacksize);
}
public final ItemStack getScrew(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("screw"+this.unlocalizedName, stacksize);
}
public final ItemStack getRing(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ring"+this.unlocalizedName, stacksize);
}
public final ItemStack getRotor(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("rotor"+this.unlocalizedName, stacksize);
}
public final ItemStack getFrameBox(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("frameGt"+this.unlocalizedName, stacksize);
}
public final ItemStack getCell(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.unlocalizedName, stacksize);
}
public final ItemStack getPlasmaCell(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellPlasma"+this.unlocalizedName, stacksize);
}
public final ItemStack getNugget(final int stacksize){
return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nugget"+this.unlocalizedName, stacksize);
}
final public ItemStack[] getMaterialComposites(){
if (this.vMaterialInput != null){
if (!this.vMaterialInput.isEmpty()){
final ItemStack[] temp = new ItemStack[this.vMaterialInput.size()];
for (int i=0;i<this.vMaterialInput.size();i++){
//Utils.LOG_WARNING("i:"+i);
ItemStack testNull = null;
try {
testNull = this.vMaterialInput.get(i).getValidStack();
} catch (final Throwable r){
Utils.LOG_WARNING("Failed gathering material stack for "+this.localizedName+".");
Utils.LOG_WARNING("What Failed: Length:"+this.vMaterialInput.size()+" current:"+i);
}
try {
if (testNull != null){
//Utils.LOG_WARNING("not null");
temp[i] = this.vMaterialInput.get(i).getValidStack();
}
} catch (final Throwable r){
Utils.LOG_WARNING("Failed setting slot "+i+", using "+this.localizedName);
}
}
return temp;
}
}
return new ItemStack[]{};
}
public final ArrayList<MaterialStack> getComposites(){
return this.vMaterialInput;
}
final public int[] getMaterialCompositeStackSizes(){
if (!this.vMaterialInput.isEmpty()){
final int[] temp = new int[this.vMaterialInput.size()];
for (int i=0;i<this.vMaterialInput.size();i++){
if (this.vMaterialInput.get(i) != null) {
temp[i] = this.vMaterialInput.get(i).getDustStack().stackSize;
} else {
temp[i]=0;
}
}
return temp;
}
return new int[]{};
}
private final short getComponentCount(final MaterialStack[] inputs){
int counterTemp = 0;
for (final MaterialStack m : inputs){
if (m.getStackMaterial() != null){
counterTemp++;
}
}
if (counterTemp != 0){
return (short) counterTemp;
}
else {
return 1;
}
}
@SuppressWarnings("static-method")
public final long[] getSmallestRatio(final ArrayList<MaterialStack> tempInput){
if (tempInput != null){
if (!tempInput.isEmpty()){
Utils.LOG_WARNING("length: "+tempInput.size());
Utils.LOG_WARNING("(inputs != null): "+(tempInput != null));
//Utils.LOG_WARNING("length: "+inputs.length);
final long[] tempRatio = new long[tempInput.size()];
for (int x=0;x<tempInput.size();x++){
//tempPercentage = tempPercentage+inputs[x].percentageToUse;
//this.mMaterialList.add(inputs[x]);
if (tempInput.get(x) != null){
tempRatio[x] = tempInput.get(x).getPartsPerOneHundred();
}
}
final long[] smallestRatio = MathUtils.simplifyNumbersToSmallestForm(tempRatio);
if (smallestRatio.length > 0){
String tempRatioStringThing1 = "";
for (int r=0;r<tempRatio.length;r++){
tempRatioStringThing1 = tempRatioStringThing1 + tempRatio[r] +" : ";
}
Utils.LOG_WARNING("Default Ratio: "+tempRatioStringThing1);
String tempRatioStringThing = "";
int tempSmallestCraftingUseSize = 0;
for (int r=0;r<smallestRatio.length;r++){
tempRatioStringThing = tempRatioStringThing + smallestRatio[r] +" : ";
tempSmallestCraftingUseSize = (int) (tempSmallestCraftingUseSize + smallestRatio[r]);
}
//this.smallestStackSizeWhenProcessing = tempSmallestCraftingUseSize;
Utils.LOG_WARNING("Smallest Ratio: "+tempRatioStringThing);
return smallestRatio;
}
}
}
return null;
}
public final String getToolTip(final String chemSymbol, final long aMultiplier, final boolean aShowQuestionMarks) {
if (!aShowQuestionMarks && (this.vChemicalFormula.equals("?")||this.vChemicalFormula.equals("??"))) {
return "";
}
Utils.LOG_WARNING("===============| Calculating Atomic Formula for "+this.localizedName+" |===============");
if (!chemSymbol.equals("")) {
return chemSymbol;
}
final ArrayList<MaterialStack> tempInput = this.vMaterialInput;
if (tempInput != null){
if (!tempInput.isEmpty()){
String dummyFormula = "";
final long[] dummyFormulaArray = this.getSmallestRatio(tempInput);
if (dummyFormulaArray != null){
if (dummyFormulaArray.length >= 1){
for (int e=0;e<tempInput.size();e++){
if (tempInput.get(e) != null){
if (tempInput.get(e).getStackMaterial() != null){
if (!tempInput.get(e).getStackMaterial().vChemicalSymbol.equals("??")){
if (dummyFormulaArray[e] > 1){
if (tempInput.get(e).getStackMaterial().vChemicalFormula.length() > 3){
dummyFormula = dummyFormula + "(" + tempInput.get(e).getStackMaterial().vChemicalFormula + ")" + dummyFormulaArray[e];
}
else {
dummyFormula = dummyFormula + tempInput.get(e).getStackMaterial().vChemicalFormula + dummyFormulaArray[e];
}
}
else if (dummyFormulaArray[e] == 1){
if (tempInput.get(e).getStackMaterial().vChemicalFormula.length() > 3){
dummyFormula = dummyFormula + "(" +tempInput.get(e).getStackMaterial().vChemicalFormula + ")";
}
else {
dummyFormula = dummyFormula +tempInput.get(e).getStackMaterial().vChemicalFormula;
}
}
} else {
dummyFormula = dummyFormula + "??";
}
} else {
dummyFormula = dummyFormula + "▓▓";
}
}
}
return StringUtils.subscript(dummyFormula);
//return dummyFormula;
}
Utils.LOG_WARNING("dummyFormulaArray <= 0");
}
Utils.LOG_WARNING("dummyFormulaArray == null");
}
Utils.LOG_WARNING("tempInput.length <= 0");
}
Utils.LOG_WARNING("tempInput == null");
return "??";
}
public final Fluid generateFluid(){
final Materials isValid = Materials.get(this.getLocalizedName());
Utils.LOG_WARNING("Is "+this.getLocalizedName()+" a Gregtech material? "+(isValid != null && isValid != Materials._NULL)+" | Found "+isValid.mDefaultLocalName);
if (isValid != Materials._NULL){
for (Materials m : invalidMaterials.values()){
if (isValid == m){
Utils.LOG_WARNING("Trying to generate a fluid for blacklisted material: "+m.mDefaultLocalName);
FluidStack a1 = m.getFluid(1);
FluidStack a2 = m.getGas(1);
FluidStack a3 = m.getMolten(1);
FluidStack a4 = m.getSolid(1);
FluidStack a5 = m.getPlasma(1);
if (a1 != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. Fluid.");
return a1.getFluid();
}
if (a2 != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. Gas.");
return a2.getFluid();
}
if (a3 != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. Molten.");
return a3.getFluid();
}
if (a4 != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. Solid.");
return a4.getFluid();
}
if (a5 != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. Plasma.");
return a5.getFluid();
}
Utils.LOG_WARNING("Using null.");
return null;
}
}
}
if (this.materialState == MaterialState.SOLID){
if (isValid.mFluid != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mFluid.");
return isValid.mFluid;
}
else if (isValid.mStandardMoltenFluid != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mStandardMoltenFluid.");
return isValid.mStandardMoltenFluid;
}
}
else if (this.materialState == MaterialState.GAS){
if (isValid.mGas != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mGas.");
return isValid.mGas;
}
}
else if (this.materialState == MaterialState.LIQUID || this.materialState == MaterialState.PURE_LIQUID){
if (isValid.mFluid != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mFluid.");
return isValid.mFluid;
}
else if (isValid.mGas != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mGas.");
return isValid.mGas;
}
else if (isValid.mStandardMoltenFluid != null){
Utils.LOG_WARNING("Using a pre-defined Fluid from GT. mStandardMoltenFluid.");
return isValid.mStandardMoltenFluid;
}
}
Utils.LOG_WARNING("Generating our own fluid.");
//Generate a Cell if we need to
if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1) == null){
if (this.vGenerateCells){
final Item temp = new BaseItemCell(this);
Utils.LOG_WARNING("Generated a cell for "+this.getUnlocalizedName());
}
else {
Utils.LOG_WARNING("Did not generate a cell for "+this.getUnlocalizedName());
}
}
if (this.materialState == MaterialState.SOLID){
return FluidUtils.addGTFluid(
this.getUnlocalizedName(),
"Molten "+this.getLocalizedName(),
this.RGBA,
this.materialState.ID(),
this.getMeltingPointK(),
ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1),
ItemList.Cell_Empty.get(1L, new Object[0]),
1000);
}
else if (this.materialState == MaterialState.LIQUID){
return FluidUtils.addGTFluid(
this.getUnlocalizedName(),
this.getLocalizedName(),
this.RGBA,
this.materialState.ID(),
this.getMeltingPointK(),
ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1),
ItemList.Cell_Empty.get(1L, new Object[0]),
1000);
}
else if (this.materialState == MaterialState.GAS){
return FluidUtils.addGTFluid(
this.getUnlocalizedName(),
this.getLocalizedName()+" Gas",
this.RGBA,
this.materialState.ID(),
this.getMeltingPointK(),
ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1),
ItemList.Cell_Empty.get(1L, new Object[0]),
1000);
}
else { //Plasma
return this.generatePlasma();
}
}
public final Fluid generatePlasma(){
final Materials isValid = Materials.get(this.getLocalizedName());
if (!this.vGenerateCells){
return null;
}
for (Materials m : invalidMaterials.values()){
if (isValid == m){
return (m.mPlasma != null ? m.mPlasma : null);
}
}
if (isValid.mPlasma != null){
Utils.LOG_WARNING("Using a pre-defined Plasma from GT.");
return isValid.mPlasma;
}
Utils.LOG_WARNING("Generating our own Plasma.");
return FluidUtils.addGTPlasma(this);
}
final public FluidStack getFluid(final int fluidAmount) {
if (this.vMoltenFluid == null){
return null;
}
final FluidStack moltenFluid = new FluidStack(this.vMoltenFluid, fluidAmount);
return moltenFluid;
}
final public int calculateMeltingPoint(){
int meltingPoint = 0;
for (MaterialStack part : this.vMaterialInput){
int incrementor = part.getStackMaterial().getMeltingPointC();
meltingPoint += incrementor;
Utils.LOG_WARNING("Melting Point for "+this.getLocalizedName()+" increased to "+ incrementor);
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
Utils.LOG_WARNING("Dividing "+meltingPoint+" / "+divisor+" to get average melting point.");
meltingPoint = (meltingPoint/divisor);
return meltingPoint;
}
final public int calculateBoilingPoint(){
int boilingPoint = 0;
for (MaterialStack part : this.vMaterialInput){
boilingPoint += part.getStackMaterial().getBoilingPointC();
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
boilingPoint = (boilingPoint/divisor);
return boilingPoint;
}
final public long calculateProtons(){
long protonCount = 0;
for (MaterialStack part : this.vMaterialInput){
protonCount += (part.getStackMaterial().getProtons());
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
protonCount = (protonCount/divisor);
return protonCount;
}
final public long calculateNeutrons(){
long neutronCount = 0;
for (MaterialStack part : this.vMaterialInput){
neutronCount += (part.getStackMaterial().getNeutrons());
}
int divisor = (this.vMaterialInput.size()>0 ? this.vMaterialInput.size() : 1);
neutronCount = (neutronCount/divisor);
return neutronCount;
}
}
|