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
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
|
package gregtech.common.tileentities.machines.multi;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.GTValues.AuthorBlueWeabo;
import static gregtech.api.enums.GTValues.VN;
import static gregtech.api.enums.HatchElement.Energy;
import static gregtech.api.enums.HatchElement.ExoticEnergy;
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.OutputBus;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.ofFrame;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.NotNull;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
import com.gtnewhorizons.modularui.api.drawable.Text;
import com.gtnewhorizons.modularui.api.drawable.UITexture;
import com.gtnewhorizons.modularui.api.math.Alignment;
import com.gtnewhorizons.modularui.api.math.Color;
import com.gtnewhorizons.modularui.api.math.Pos2d;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn;
import com.gtnewhorizons.modularui.common.widget.DynamicPositionedRow;
import com.gtnewhorizons.modularui.common.widget.MultiChildWidget;
import com.gtnewhorizons.modularui.common.widget.TextWidget;
import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget;
import blockrenderer6343.client.world.ClientFakePlayer;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Materials;
import gregtech.api.enums.Mods;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.SoundResource;
import gregtech.api.enums.Textures.BlockIcons;
import gregtech.api.gui.modularui.GTUITextures;
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.GregTechTileClientEvents;
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchInput;
import gregtech.api.multitileentity.multiblock.casing.Glasses;
import gregtech.api.objects.ItemData;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.recipe.check.SimpleCheckRecipeResult;
import gregtech.api.recipe.metadata.PCBFactoryTierKey;
import gregtech.api.recipe.metadata.PCBFactoryUpgrade;
import gregtech.api.recipe.metadata.PCBFactoryUpgradeKey;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.ParallelHelper;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.common.blocks.BlockCasings8;
@SuppressWarnings("SpellCheckingInspection")
public class MTEPCBFactory extends MTEExtendedPowerMultiBlockBase<MTEPCBFactory> implements ISurvivalConstructable {
private static final String tier1 = "tier1";
private static final String tier2 = "tier2";
private static final String tier3 = "tier3";
private static final String bioUpgrade = "bioUpgrade";
private static final String ocTier1Upgrade = "ocTier1Upgrade";
private static final String ocTier2Upgrade = "ocTier2Upgrade";
private float mRoughnessMultiplier = 1;
private int mTier = 1;
private int mSetTier = 1;
private int mUpgradesInstalled = 0;
private final int mCurrentParallel = 0;
private int mMaxParallel = 0;
private boolean mBioUpgrade = false, mBioRotate = false, mOCTier1 = false, mOCTier2 = false;
private final int[] mBioOffsets = new int[] { -5, -1 };
private final int[] mOCTier1Offsets = new int[] { 2, -11 };
private final int[] mOCTier2Offsets = new int[] { 2, -11 };
private MTEHatchInput mCoolantInputHatch;
private static final int mBioRotateBitMap = 0b1000000;
private static final int mOCTier2BitMap = 0b100000;
private static final int mOCTier1BitMap = 0b10000;
private static final int mBioBitMap = 0b1000;
private static final int mTier3BitMap = 0b100;
private static final int mTier2BitMap = 0b10;
private static final int mTier1BitMap = 0b1;
private static final int COOLANT_CONSUMED_PER_SEC = 10;
private static final IStructureDefinition<MTEPCBFactory> STRUCTURE_DEFINITION = StructureDefinition
.<MTEPCBFactory>builder()
.addShape(
tier1,
transpose(
new String[][] {
// spotless:off
{" ","E E","E E","EEEEEEE","E E","E E"," "},
{"EEEEEEE","CAAAAAC","CAAAAAC","CCCCCCC","CCCCCCC","CCCCCCC","E E"},
{"EAAAAAE","C-----C","C-----C","C-----C","C-----C","C-----C","ECCCCCE"},
{"EAAAAAE","C-----C","B-----B","B-----B","B-----B","C-----C","ECCCCCE"},
{"EAAAAAE","C-----C","B-FFF-B","B-FFF-B","B-FFF-B","C-----C","EPPPPPE"},
{"ECC~CCE","CDDDDDC","CDDDDDC","CDDDDDC","CDDDDDC","CDDDDDC","EPPPPPE"}
//spotless:on
}))
.addShape(
tier2,
transpose(
new String[][] {
// spotless:off
{" "," "," ","HGGH","HGGH","HGGH","HGGH","HGGH"," "," "," "},
{" "," ","HGGH","GGGG","GGGG","GGGG","GGGG","GGGG","HGGH"," "," "},
{" ","HGGH","GGGG","G G","G G","G G","G G","G G","GGGG","HGGH"," "},
{" ","HGGH","G G","G G","G G","G G","G G","G G","G G","HGGH"," "},
{"HGGH","G G","G G","G G","G G","G G","G G","G G","G G","G G","HGGH"},
{"HGGH","G G","G G","G G","G G","G G","G G","G G","G G","G G","HGGH"},
{"HGGH","GGGG","GGGG","GGGG","GGGG","GGGG","GGGG","GGGG","GGGG","GGGG","HGGH"}
//spotless:on
}))
.addShape(
tier3,
transpose(
new String[][] {
// spotless:off
{" "," "," "," "," I "," I "," "," "," "," "},
{" "," "," "," I "," I "," I "," I "," "," "," "},
{" "," "," KKK "," KIK "," K K "," K K "," I "," "," "," "},
{" "," "," KKK "," K K "," K K "," K K "," I "," "," "," "},
{" "," III "," I I "," I I "," I I "," K K "," I "," "," "," "},
{" "," III "," I I "," I I "," I I "," K K "," I "," "," "," "},
{" "," III "," I I "," I I "," I I "," K K "," KIK "," "," "," "},
{" "," I I "," I K I "," I I "," I I "," K K "," KIK "," "," "," "},
{" "," I I "," I K I "," I I "," I I "," K K "," K K "," KKK "," "," "},
{" "," I I "," I K I "," I I "," I I "," K K "," K K "," KKK "," "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," K K "," K K "," K K "," K K "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," "," KKK "," K K "," K K "," I I "," I I "," I I "," III "," "},
{" "," "," KKK "," K K "," K K "," I I "," I I "," I I "," III "," "},
{" "," "," KKK "," K K "," K K "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" "," III "," I I "," I I "," I I "," I I "," I I "," I I "," III "," "},
{" II~II ","IIJJJII","IJJJJJI","IJJJJJI","IJJJJJI","IJJJJJI","IJJJJJI","IJJJJJI","IIJJJII"," IIIII "}
//spotless:on
}))
.addShape(
bioUpgrade,
transpose(
new String[][] {
// spotless:off
{" "," "," LLLLLL "," "," "},
{" "," "," L L "," "," "},
{"E E E E"," LLL LLL "," LLL LLL "," LLL LLL ","E E E E"},
{"EAAAE EAAAE","A A A A","A A A A","A A A A","EAAAE EAAAE"},
{"EAAAE EAAAE","A A A A","A A A A","A A A A","EAAAE EAAAE"},
{"EAAAE EAAAE","A A A A","A A A A","A A A A","EAAAE EAAAE"},
{"ELLLE ELLLE","LLLLL LLLLL","LLLLL LLLLL","LLLLL LLLLL","ELLLE ELLLE"}
//spotless:on
}))
.addShape(
ocTier1Upgrade,
transpose(
new String[][] {
// spotless:off
{"EKKKE","K K","K K","K K","EKKKE"},
{"E E"," KKK "," K K "," KKK ","E E"},
{"E E"," NNN "," N N "," NNN ","E E"},
{"E E"," KKK "," K K "," KKK ","E E"},
{"E E"," KKK "," K K "," KKK ","E E"},
{"EOOOE","OKKKO","OK KO","OKKKO","EOOOE"},
{"E E"," KKK "," K K "," KKK ","E E"},
{"E E"," KKK "," K K "," KKK ","E E"},
{"ENNNE","NKKKN","NK KN","NKKKN","ENNNE"},
{"EGGGE","GGGGG","GGMGG","GGGGG","EGGGE"}
//spotless:on
}))
.addShape(
ocTier2Upgrade,
transpose(
new String[][] {
// spotless:off
{"RGGGR","G G","G G","G G","RGGGR"},
{"R R"," GGG "," GTG "," GGG ","R R"},
{"R R"," NNN "," NTN "," NNN ","R R"},
{"R R"," QQQ "," QTQ "," QQQ ","R R"},
{"R R"," QQQ "," QTQ "," QQQ ","R R"},
{"R R"," QQQ "," QTQ "," QQQ ","R R"},
{"R R"," QQQ "," QTQ "," QQQ ","R R"},
{"R R"," QQQ "," QTQ "," QQQ ","R R"},
{"RNNNR","NQQQN","NQTQN","NQQQN","RNNNR"},
{"RGGGR","GGGGG","GGSGG","GGGGG","RGGGR"}
//spotless:on
}))
.addElement('E', ofFrame(Materials.DamascusSteel))
.addElement('C', ofBlock(GregTechAPI.sBlockCasings8, 11))
.addElement('D', ofBlock(GregTechAPI.sBlockReinforced, 2))
.addElement('A', Glasses.chainAllGlasses())
.addElement('B', ofBlock(GregTechAPI.sBlockCasings3, 10))
.addElement('F', ofFrame(Materials.VibrantAlloy))
.addElement(
'P',
buildHatchAdder(MTEPCBFactory.class)
.atLeast(InputHatch, OutputBus, InputBus, Maintenance, Energy.or(ExoticEnergy))
.dot(1)
.casingIndex(((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(11))
.buildAndChain(GregTechAPI.sBlockCasings8, 11))
.addElement('H', ofFrame(Materials.Duranium))
.addElement('G', ofBlock(GregTechAPI.sBlockCasings8, 12))
.addElement('I', ofBlock(GregTechAPI.sBlockCasings8, 13))
.addElement('K', ofBlock(GregTechAPI.sBlockCasings8, 10))
.addElement(
'J',
buildHatchAdder(MTEPCBFactory.class)
.atLeast(InputHatch, OutputBus, InputBus, Maintenance, Energy.or(ExoticEnergy))
.dot(1)
.casingIndex(((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(13))
.buildAndChain(GregTechAPI.sBlockCasings8, 13))
.addElement('L', ofBlock(GregTechAPI.sBlockCasings4, 1))
.addElement(
'M',
buildHatchAdder(MTEPCBFactory.class).hatchClass(MTEHatchInput.class)
.adder(MTEPCBFactory::addCoolantInputToMachineList)
.casingIndex(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 12))
.dot(2)
.buildAndChain(GregTechAPI.sBlockCasings8, 12))
.addElement('N', ofBlock(GregTechAPI.sBlockCasings2, 15))
.addElement('O', ofBlock(GregTechAPI.sBlockCasings8, 4))
.addElement(
'S',
buildHatchAdder(MTEPCBFactory.class).hatchClass(MTEHatchInput.class)
.adder(MTEPCBFactory::addCoolantInputToMachineList)
.casingIndex(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 12))
.dot(2)
.buildAndChain(GregTechAPI.sBlockCasings8, 12))
.addElement('R', ofFrame(Materials.Americium))
.addElement('Q', ofBlock(GregTechAPI.sBlockCasings8, 14))
.addElement('T', ofBlock(GregTechAPI.sBlockCasings1, 15))
.build();
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
if (mSetTier < 3) {
buildPiece(tier1, stackSize, hintsOnly, 3, 5, 0);
if (mSetTier == 2) {
buildPiece(tier2, stackSize, hintsOnly, 7, 6, 2);
}
} else {
buildPiece(tier3, stackSize, hintsOnly, 3, 21, 0);
}
if (mBioUpgrade) {
if (mBioRotate) {
final IGregTechTileEntity tTile = getBaseMetaTileEntity();
getStructureDefinition().buildOrHints(
this,
stackSize,
bioUpgrade,
tTile.getWorld(),
transformFacing(getExtendedFacing()),
tTile.getXCoord(),
tTile.getYCoord(),
tTile.getZCoord(),
mBioOffsets[1],
6,
mBioOffsets[0],
hintsOnly);
} else {
buildPiece(bioUpgrade, stackSize, hintsOnly, mBioOffsets[0], 6, mBioOffsets[1]);
}
}
if (mOCTier1 && !mOCTier2) {
buildPiece(ocTier1Upgrade, stackSize, hintsOnly, mOCTier1Offsets[0], 9, mOCTier1Offsets[1]);
}
if (!mOCTier1 && mOCTier2) {
buildPiece(ocTier2Upgrade, stackSize, hintsOnly, mOCTier2Offsets[0], 9, mOCTier2Offsets[1]);
}
}
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
int built = 0;
if (Mods.BlockRenderer6343.isModLoaded() && env.getActor() instanceof ClientFakePlayer) {
if (stackSize.stackSize < 3) {
built = survivialBuildPiece(tier1, stackSize, 3, 5, 0, elementBudget, env, false, true);
if (built >= 0) return built;
if (stackSize.stackSize == 2) {
built = survivialBuildPiece(tier2, stackSize, 7, 6, 2, elementBudget, env, false, true);
}
} else {
built = survivialBuildPiece(tier3, stackSize, 3, 21, 0, elementBudget, env, false, true);
}
return built;
}
if (mMachine) return -1;
if (mSetTier < 3) {
built += survivialBuildPiece(tier1, stackSize, 3, 5, 0, elementBudget, env, false, true);
if (mSetTier == 2) {
built += survivialBuildPiece(tier2, stackSize, 7, 6, 2, elementBudget, env, false, true);
}
} else {
built += survivialBuildPiece(tier3, stackSize, 3, 21, 0, elementBudget, env, false, true);
}
if (mBioUpgrade) {
if (mBioRotate) {
final IGregTechTileEntity tTile = getBaseMetaTileEntity();
getStructureDefinition().survivalBuild(
this,
stackSize,
bioUpgrade,
tTile.getWorld(),
transformFacing(getExtendedFacing()),
tTile.getXCoord(),
tTile.getYCoord(),
tTile.getZCoord(),
mBioOffsets[1],
6,
mBioOffsets[0],
elementBudget,
env,
false);
} else {
built += survivialBuildPiece(
bioUpgrade,
stackSize,
mBioOffsets[0],
6,
mBioOffsets[1],
elementBudget,
env,
false,
true);
}
}
if (mOCTier1 && !mOCTier2) {
built += survivialBuildPiece(
ocTier1Upgrade,
stackSize,
mOCTier1Offsets[0],
9,
mOCTier1Offsets[1],
elementBudget,
env,
false,
true);
}
if (!mOCTier1 && mOCTier2) {
built += survivialBuildPiece(
ocTier2Upgrade,
stackSize,
mOCTier2Offsets[0],
9,
mOCTier2Offsets[1],
elementBudget,
env,
false,
true);
}
return built;
}
public MTEPCBFactory(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public MTEPCBFactory(String aName) {
super(aName);
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTEPCBFactory(this.mName);
}
@Override
public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection,
ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) {
if (sideDirection == facingDirection) {
if (active) return new ITexture[] {
BlockIcons.getCasingTextureForId(
getTier() < 3 ? GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 11)
: GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 13)),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW)
.extFacing()
.glow()
.build() };
return new ITexture[] {
BlockIcons.getCasingTextureForId(
getTier() < 3 ? GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 11)
: GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings8, 13)),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW)
.extFacing()
.glow()
.build() };
}
return new ITexture[] { BlockIcons.getCasingTextureForId(
mSetTier < 3 ? ((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(11)
: ((BlockCasings8) GregTechAPI.sBlockCasings8).getTextureIndex(13)) };
}
@Override
public IStructureDefinition<MTEPCBFactory> getStructureDefinition() {
return STRUCTURE_DEFINITION;
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
mTier = 0;
mUpgradesInstalled = 0;
mCoolantInputHatch = null;
if (mSetTier < 3) {
if (!checkPiece(tier1, 3, 5, 0)) {
return false;
}
if (mSetTier == 2) {
if (!checkPiece(tier2, 7, 6, 2)) {
return false;
}
mTier = 2;
} else {
mTier = 1;
}
} else {
if (!checkPiece(tier3, 3, 21, 0)) {
return false;
}
mTier = 3;
}
if (mBioUpgrade) {
if (mBioRotate) {
final IGregTechTileEntity tTile = getBaseMetaTileEntity();
if (!getStructureDefinition().check(
this,
bioUpgrade,
tTile.getWorld(),
transformFacing(getExtendedFacing()),
tTile.getXCoord(),
tTile.getYCoord(),
tTile.getZCoord(),
mBioOffsets[1],
6,
mBioOffsets[0],
!mMachine)) {
return false;
}
} else {
if (!checkPiece(bioUpgrade, mBioOffsets[0], 6, mBioOffsets[1])) {
return false;
}
}
mUpgradesInstalled++;
}
if (mOCTier1 && !mOCTier2) {
if (!checkPiece(ocTier1Upgrade, mOCTier1Offsets[0], 9, mOCTier1Offsets[1])) {
return false;
}
if (mCoolantInputHatch == null) {
return false;
}
mUpgradesInstalled++;
}
if (mOCTier2 && !mOCTier1) {
if (!checkPiece(ocTier2Upgrade, mOCTier2Offsets[0], 9, mOCTier2Offsets[1])) {
return false;
}
if (mCoolantInputHatch == null) {
return false;
}
mUpgradesInstalled++;
}
getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData());
if (mMaintenanceHatches.size() != 1) {
return false;
}
if (!checkExoticAndNormalEnergyHatches()) {
return false;
}
return mTier > 0;
}
@Override
public RecipeMap<?> getRecipeMap() {
return RecipeMaps.pcbFactoryRecipes;
}
@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {
@NotNull
@Override
protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) {
// Here we check the dynamic parallels, which depend on the recipe
int numberOfNanites = 0;
ItemStack aNanite = recipe.getRepresentativeInput(1);
ItemData naniteData = GTOreDictUnificator.getAssociation(aNanite);
if (naniteData != null && naniteData.mPrefix != null && naniteData.mPrefix.equals(OrePrefixes.nanite)) {
for (ItemStack aItem : inputItems) {
if (aItem != null && aItem.isItemEqual(aNanite)) {
numberOfNanites += aItem.stackSize;
}
}
}
maxParallel = (int) Math.max(Math.ceil(Math.log(numberOfNanites) / Math.log(2) + 0.00001), 1);
mMaxParallel = maxParallel;
PCBFactoryUpgrade requiredUpgrade = recipe.getMetadata(PCBFactoryUpgradeKey.INSTANCE);
if (requiredUpgrade == PCBFactoryUpgrade.BIO && !mBioUpgrade)
return SimpleCheckRecipeResult.ofFailure("bio_upgrade_missing");
int requiredPCBTier = recipe.getMetadataOrDefault(PCBFactoryTierKey.INSTANCE, 1);
if (requiredPCBTier > mTier) return CheckRecipeResultRegistry.insufficientMachineTier(requiredPCBTier);
return CheckRecipeResultRegistry.SUCCESSFUL;
}
@Nonnull
@Override
protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) {
return super.createOverclockCalculator(recipe).setNoOverclock(isNoOC())
.setEUtDiscount(Math.sqrt(mUpgradesInstalled == 0 ? 1 : mUpgradesInstalled))
.setSpeedBoost(getDurationMultiplierFromRoughness())
.setDurationDecreasePerOC(mOCTier2 ? 4.0 : 2.0);
}
@Nonnull
@Override
protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) {
return super.createParallelHelper(recipe)
.setEUtModifier((float) Math.sqrt(mUpgradesInstalled == 0 ? 1 : mUpgradesInstalled))
.setChanceMultiplier(mRoughnessMultiplier);
}
};
}
private boolean isNoOC() {
return !mOCTier1 && !mOCTier2;
}
private double getDurationMultiplierFromRoughness() {
return Math.pow(mRoughnessMultiplier, 2);
}
private int ticker = 0;
@Override
public boolean onRunningTick(ItemStack aStack) {
if (!super.onRunningTick(aStack)) {
return false;
}
if (ticker % 20 == 0) {
if (!isNoOC()) {
FluidStack tFluid = mOCTier1 ? GTModHandler.getDistilledWater(COOLANT_CONSUMED_PER_SEC)
: Materials.SuperCoolant.getFluid(COOLANT_CONSUMED_PER_SEC);
if (!drain(mCoolantInputHatch, tFluid, true)) {
stopMachine(ShutDownReasonRegistry.outOfFluid(tFluid));
return false;
}
}
ticker = 0;
}
ticker++;
return true;
}
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isServerSide()) {
// TODO: Look for proper fix
// Updates every 10 sec
if (mUpdate <= -150) mUpdate = 50;
}
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return (int) (10000f * mRoughnessMultiplier);
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
private int getTier() {
return mSetTier;
}
@Override
public void receiveClientEvent(byte aEventID, byte aValue) {
if (aEventID == 1) {
if ((aValue & mTier1BitMap) == mTier1BitMap) {
mSetTier = 1;
}
if ((aValue & mTier2BitMap) == mTier2BitMap) {
mSetTier = 2;
}
if ((aValue & mTier3BitMap) == mTier3BitMap) {
mSetTier = 3;
}
if ((aValue & mBioBitMap) == mBioBitMap) {
mBioUpgrade = true;
}
if ((aValue & mBioRotateBitMap) == mBioRotateBitMap) {
mBioRotate = true;
}
if ((aValue & mOCTier1BitMap) == mOCTier1BitMap) {
mOCTier1 = true;
}
if ((aValue & mOCTier2BitMap) == mOCTier2BitMap) {
mOCTier2 = true;
}
}
}
private ExtendedFacing transformFacing(ExtendedFacing facing) {
ForgeDirection curDirection = facing.getDirection();
Rotation curRotation = facing.getRotation();
Flip curFlip = facing.getFlip();
ForgeDirection newDirection = curDirection;
Rotation newRotation = curRotation;
Flip newFlip = curFlip;
if (curDirection == ForgeDirection.UP || curDirection == ForgeDirection.DOWN) {
switch (curRotation) {
case CLOCKWISE, COUNTER_CLOCKWISE -> {
newFlip = curFlip == Flip.NONE ? Flip.HORIZONTAL : Flip.NONE;
newDirection = curDirection == ForgeDirection.UP ? ForgeDirection.NORTH : ForgeDirection.SOUTH;
}
case NORMAL -> {
newRotation = curDirection == ForgeDirection.UP ? Rotation.CLOCKWISE : Rotation.COUNTER_CLOCKWISE;
newDirection = curDirection == ForgeDirection.UP ? ForgeDirection.EAST : ForgeDirection.WEST;
newFlip = Flip.NONE;
}
case UPSIDE_DOWN -> {
newRotation = curDirection == ForgeDirection.UP ? Rotation.COUNTER_CLOCKWISE : Rotation.CLOCKWISE;
newDirection = curDirection == ForgeDirection.UP ? ForgeDirection.EAST : ForgeDirection.WEST;
newFlip = Flip.NONE;
}
}
} else if (curRotation == Rotation.CLOCKWISE || curRotation == Rotation.COUNTER_CLOCKWISE) {
newFlip = curRotation == Rotation.CLOCKWISE ? curFlip == Flip.NONE ? Flip.NONE : Flip.HORIZONTAL
: curFlip != Flip.NONE ? Flip.NONE : Flip.HORIZONTAL;
newDirection = curRotation == Rotation.CLOCKWISE ? ForgeDirection.UP : ForgeDirection.DOWN;
} else {
newDirection = switch (curDirection) {
case EAST -> ForgeDirection.SOUTH;
case NORTH -> ForgeDirection.EAST;
case WEST -> ForgeDirection.NORTH;
case SOUTH -> ForgeDirection.WEST;
default -> curDirection;
};
}
if (curRotation == Rotation.UPSIDE_DOWN) {
if (curDirection != ForgeDirection.UP && curDirection != ForgeDirection.DOWN) {
newFlip = curFlip == Flip.NONE ? Flip.HORIZONTAL : Flip.NONE;
}
}
return ExtendedFacing.of(newDirection, newRotation, newFlip);
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
public boolean addCoolantInputToMachineList(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;
mCoolantInputHatch = (MTEHatchInput) aMetaTileEntity;
return true;
}
return false;
}
@Override
protected long getActualEnergyUsage() {
return (-this.lEUt * 10000) / Math.min(Math.max(1000, mEfficiency), 10000);
}
@Override
public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {
inputSeparation = !inputSeparation;
GTUtility.sendChatToPlayer(
aPlayer,
StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation);
}
@Override
public String[] getInfoData() {
long storedEnergy = 0;
long maxEnergy = 0;
for (MTEHatch tHatch : getExoticAndNormalEnergyHatchList()) {
storedEnergy += tHatch.getBaseMetaTileEntity()
.getStoredEU();
maxEnergy += tHatch.getBaseMetaTileEntity()
.getEUCapacity();
}
long voltage = getAverageInputVoltage();
long amps = getMaxInputAmps();
return new String[] {
/* 1 */ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": "
+ EnumChatFormatting.GREEN
+ GTUtility.formatNumbers(mProgresstime / 20)
+ EnumChatFormatting.RESET
+ " s / "
+ EnumChatFormatting.YELLOW
+ GTUtility.formatNumbers(mMaxProgresstime / 20)
+ EnumChatFormatting.RESET
+ " s",
/* 2 */ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": "
+ EnumChatFormatting.GREEN
+ GTUtility.formatNumbers(storedEnergy)
+ EnumChatFormatting.RESET
+ " EU / "
+ EnumChatFormatting.YELLOW
+ GTUtility.formatNumbers(maxEnergy)
+ EnumChatFormatting.RESET
+ " EU",
/* 3 */ StatCollector.translateToLocal("GT5U.multiblock.usage") + ": "
+ EnumChatFormatting.RED
+ GTUtility.formatNumbers(getActualEnergyUsage())
+ EnumChatFormatting.RESET
+ " EU/t",
/* 4 */ StatCollector.translateToLocal("GT5U.multiblock.mei") + ": "
+ EnumChatFormatting.YELLOW
+ GTUtility.formatNumbers(voltage)
+ EnumChatFormatting.RESET
+ " EU/t(*"
+ amps
+ " A)"
+ StatCollector.translateToLocal("GT5U.machines.tier")
+ ": "
+ EnumChatFormatting.YELLOW
+ VN[GTUtility.getTier(voltage)]
+ EnumChatFormatting.RESET,
/* 5 */ StatCollector.translateToLocal("GT5U.multiblock.problems") + ": "
+ EnumChatFormatting.RED
+ (getIdealStatus() - getRepairStatus())
+ EnumChatFormatting.RESET
+ " "
+ StatCollector.translateToLocal("GT5U.multiblock.efficiency")
+ ": "
+ EnumChatFormatting.YELLOW
+ mEfficiency / 100.0F
+ EnumChatFormatting.RESET
+ " %",
/* 6 */ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": "
+ EnumChatFormatting.GREEN
+ getAveragePollutionPercentage()
+ EnumChatFormatting.RESET
+ " %",
/* 7 */ StatCollector.translateToLocal("GT5U.multiblock.parallelism") + ": "
+ EnumChatFormatting.GREEN
+ mMaxParallel,
/* 8 */ StatCollector.translateToLocal("GT5U.multiblock.curparallelism") + ": "
+ EnumChatFormatting.GREEN
+ mCurrentParallel };
}
@Override
protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Circuit Board Fabricator")
.addInfo(
EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD
+ "IMPORTANT!"
+ " Check the configuration menu before building.")
.addInfo("Tier of the machine determines the available recipes.")
.addInfo("Machine tier (1-3) is set in the controller GUI.")
.addInfo("The configuration menu can be used to add upgrades.")
.addInfo("Each tier and upgrade requires additional structures.")
.addInfo("Power consumption is multiplied by Sqrt(structures).")
.addInfo("Tier 2 and 3 allow parallel by using extra nanites.")
.addInfo("Every doubling of nanites adds one parallel.")
.addInfo("1x->1, 2x->2, 4x->3, 8x->4 with no limit.")
.addInfo("Recipes require a cooling upgrade to be overclocked.")
.addInfo("Liquid Cooling uses 10 L/s of distilled water and enables default overclocks.")
.addInfo("Thermosink uses 10 L/s of Super Coolant and enables perfect overclocks.")
.addInfo("Trace size can be changed to modify the material usage and machine speed.")
.addTecTechHatchInfo()
.beginStructureBlock(30, 38, 13, false)
.addMaintenanceHatch(EnumChatFormatting.GOLD + "1", 1)
.addEnergyHatch(
EnumChatFormatting.GOLD + "1"
+ EnumChatFormatting.GRAY
+ "-"
+ EnumChatFormatting.GOLD
+ "2"
+ EnumChatFormatting.GRAY
+ " or "
+ EnumChatFormatting.GOLD
+ "1"
+ EnumChatFormatting.GRAY
+ " TT energy hatch.",
1)
.addInputBus(EnumChatFormatting.GOLD + "0" + EnumChatFormatting.GRAY + "+", 1)
.addOutputBus(EnumChatFormatting.GOLD + "0" + EnumChatFormatting.GRAY + "+", 1)
.addInputHatch(EnumChatFormatting.GOLD + "0" + EnumChatFormatting.GRAY + "+", 1)
.addStructureInfo(
"Coolant Hatch (Input Hatch): " + EnumChatFormatting.GOLD
+ "1"
+ EnumChatFormatting.GRAY
+ " Center of the Liquid Cooling/Thermosink")
.addStructureInfo(
EnumChatFormatting.BLUE + "Base Multi (Tier "
+ EnumChatFormatting.DARK_PURPLE
+ 1
+ EnumChatFormatting.BLUE
+ "):")
.addStructureInfo(EnumChatFormatting.GOLD + "40" + EnumChatFormatting.GRAY + " Damascus Steel Frame Box")
.addStructureInfo(EnumChatFormatting.GOLD + "9" + EnumChatFormatting.GRAY + " Vibrant Alloy Frame Box")
.addStructureInfo(EnumChatFormatting.GOLD + "25" + EnumChatFormatting.GRAY + " Reinforced Glass")
.addStructureInfo(
EnumChatFormatting.GOLD + "77" + EnumChatFormatting.GRAY + " Basic Photolithography Framework Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "12" + EnumChatFormatting.GRAY + " Grate Machine Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "25" + EnumChatFormatting.GRAY + " Plascrete Block")
.addStructureInfo(
EnumChatFormatting.BLUE + "Tier "
+ EnumChatFormatting.DARK_PURPLE
+ 2
+ EnumChatFormatting.BLUE
+ " (Adds to Tier "
+ EnumChatFormatting.DARK_PURPLE
+ 1
+ EnumChatFormatting.BLUE
+ "):")
.addStructureInfo(EnumChatFormatting.GOLD + "34" + EnumChatFormatting.GRAY + " Duranium Frame Box")
.addStructureInfo(
EnumChatFormatting.GOLD + "158"
+ EnumChatFormatting.GRAY
+ " Reinforced Photolithography Framework Casing")
.addStructureInfo(
EnumChatFormatting.BLUE + "Tier " + EnumChatFormatting.DARK_PURPLE + 3 + EnumChatFormatting.BLUE + ":")
.addStructureInfo(
EnumChatFormatting.GOLD + "292"
+ EnumChatFormatting.GRAY
+ " Radiation Proof Photolithography Framework Casing")
.addStructureInfo(
EnumChatFormatting.GOLD + "76" + EnumChatFormatting.GRAY + " Radiant Naquadah Alloy Casing")
.addStructureInfo(EnumChatFormatting.BLUE + "Biochamber Upgrade")
.addStructureInfo(
EnumChatFormatting.GOLD + "68" + EnumChatFormatting.GRAY + " Clean Stainless Steel Machine Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "40" + EnumChatFormatting.GRAY + " Damascus Steel Frame Box")
.addStructureInfo(EnumChatFormatting.GOLD + "72" + EnumChatFormatting.GRAY + " Reinforced Glass")
.addStructureInfo(
EnumChatFormatting.BLUE + "Liquid Cooling Tower (Tier "
+ EnumChatFormatting.DARK_PURPLE
+ 1
+ EnumChatFormatting.BLUE
+ "):")
.addStructureInfo(EnumChatFormatting.GOLD + "40" + EnumChatFormatting.GRAY + " Damascus Steel Frame Box")
.addStructureInfo(
EnumChatFormatting.GOLD + "68" + EnumChatFormatting.GRAY + " Radiant Naquadah Alloy Casing")
.addStructureInfo(
EnumChatFormatting.GOLD + "12" + EnumChatFormatting.GRAY + " Extreme Engine Intake Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "20" + EnumChatFormatting.GRAY + " Tungstensteel Pipe Casing")
.addStructureInfo(
EnumChatFormatting.GOLD + "21"
+ EnumChatFormatting.GRAY
+ " Reinforced Photolithography Framework Casing")
.addStructureInfo(
EnumChatFormatting.BLUE + "Thermosink Radiator(Tier "
+ EnumChatFormatting.DARK_PURPLE
+ 2
+ EnumChatFormatting.BLUE
+ "):")
.addStructureInfo(EnumChatFormatting.GOLD + "40" + EnumChatFormatting.GRAY + " Americium Frame Box")
.addStructureInfo(
EnumChatFormatting.GOLD + "41"
+ EnumChatFormatting.GRAY
+ " Reinforced Photolithography Framework Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "8" + EnumChatFormatting.GRAY + " Superconducting Coil Block")
.addStructureInfo(EnumChatFormatting.GOLD + "20" + EnumChatFormatting.GRAY + " Tungstensteel Pipe Casing")
.addStructureInfo(EnumChatFormatting.GOLD + "48" + EnumChatFormatting.GRAY + " Infinity Cooled Casing")
.toolTipFinisher(AuthorBlueWeabo);
return tt;
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("mBioUpgrade", mBioUpgrade);
aNBT.setBoolean("mBioRotate", mBioRotate);
aNBT.setInteger("mBioOffsetX", mBioOffsets[0]);
aNBT.setInteger("mBioOffsetZ", mBioOffsets[1]);
aNBT.setBoolean("mOCTier1Upgrade", mOCTier1);
aNBT.setInteger("mOCTier1OffsetX", mOCTier1Offsets[0]);
aNBT.setInteger("mOCTier1OffsetZ", mOCTier1Offsets[1]);
aNBT.setBoolean("mOCTier2Upgrade", mOCTier2);
aNBT.setInteger("mOCTier2OffsetX", mOCTier2Offsets[0]);
aNBT.setInteger("mOCTier2OffsetZ", mOCTier2Offsets[1]);
aNBT.setFloat("mRoughnessMultiplier", mRoughnessMultiplier);
aNBT.setInteger("mSetTier", mSetTier);
}
@Override
public void loadNBTData(final NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
if (aNBT.hasKey("mSeparate")) {
// backward compatibility
inputSeparation = aNBT.getBoolean("mSeparate");
}
mBioUpgrade = aNBT.getBoolean("mBioUpgrade");
mBioRotate = aNBT.getBoolean("mBioRotate");
mBioOffsets[0] = aNBT.getInteger("mBioOffsetX");
mBioOffsets[1] = aNBT.getInteger("mBioOffsetZ");
mOCTier1 = aNBT.getBoolean("mOCTier1Upgrade");
mOCTier1Offsets[0] = aNBT.getInteger("mOCTier1OffsetX");
mOCTier1Offsets[1] = aNBT.getInteger("mOCTier1OffsetZ");
mOCTier2 = aNBT.getBoolean("mOCTier2Upgrade");
mOCTier2Offsets[0] = aNBT.getInteger("mOCTier2OffsetX");
mOCTier2Offsets[1] = aNBT.getInteger("mOCTier2OffsetZ");
mRoughnessMultiplier = aNBT.getFloat("mRoughnessMultiplier");
mSetTier = aNBT.getInteger("mSetTier");
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
protected SoundResource getProcessStartSound() {
return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP;
}
@Override
public byte getUpdateData() {
byte data = 0;
if (mSetTier == 1) {
data += mTier1BitMap;
} else if (mSetTier == 2) {
data += mTier2BitMap;
} else {
data += mTier3BitMap;
}
if (mBioUpgrade) {
data += mBioBitMap;
}
if (mBioRotate) {
data += mBioRotateBitMap;
}
if (mOCTier1) {
data += mOCTier1BitMap;
}
if (mOCTier2) {
data += mOCTier2BitMap;
}
return data;
}
@Override
public Pos2d getStructureUpdateButtonPos() {
return new Pos2d(80, 91);
}
@Override
public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
super.addUIWidgets(builder, buildContext);
buildContext.addSyncedWindow(10, this::createConfigurationWindow);
builder.widget(
new ButtonWidget().setOnClick(
(clickData, widget) -> {
if (!widget.isClient()) widget.getContext()
.openSyncedWindow(10);
})
.setSize(16, 16)
.setBackground(() -> {
List<UITexture> ret = new ArrayList<>();
ret.add(GTUITextures.BUTTON_STANDARD);
ret.add(GTUITextures.OVERLAY_BUTTON_CYCLIC);
return ret.toArray(new IDrawable[0]);
})
.addTooltip("Configuration Menu")
.setPos(174, 130))
.widget(
new TextWidget(new Text("Tier")).setTextAlignment(Alignment.Center)
.setScale(0.91f)
.setSize(20, 16)
.setPos(173, 98))
.widget(
new NumericWidget().setGetter(() -> mSetTier)
.setSetter(val -> mSetTier = (int) val)
.setBounds(1, 3)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("PCB Factory Tier")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(18, 18)
.setPos(173, 110));
}
protected ModularWindow createConfigurationWindow(final EntityPlayer player) {
ModularWindow.Builder builder = ModularWindow.builder(200, 160);
builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT);
builder.setGuiTint(getGUIColorization());
builder.widget(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CYCLIC)
.setPos(5, 5)
.setSize(16, 16))
.widget(new TextWidget("Configuration Menu").setPos(25, 9))
.widget(
ButtonWidget.closeWindowButton(true)
.setPos(185, 3))
.widget(
new DynamicPositionedColumn().setSynced(false)
.widget(
new MultiChildWidget().addChild(new CycleButtonWidget().setToggle(() -> mBioUpgrade, val -> {
mBioUpgrade = val;
if (!mBioUpgrade) {
GTUtility
.sendChatToPlayer(player, GTUtility.trans("339.1", "Biochamber Upgrade Disabled"));
} else {
GTUtility
.sendChatToPlayer(player, GTUtility.trans("339", "Biochamber Upgrade Enabled"));
}
})
.setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE)
.setSize(90, 18)
.addTooltip(
"Enables nanites to construct organic circuitry. Required for Bioware and Wetware boards."))
.addChild(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CYCLIC)
.setSize(18, 18))
.addChild(
new TextWidget("Biochamber").setTextAlignment(Alignment.Center)
.setPos(23, 5))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(new MultiChildWidget().addChild(new CycleButtonWidget().setToggle(() -> mBioRotate, val -> {
mBioRotate = val;
if (!mBioRotate) {
GTUtility.sendChatToPlayer(player, GTUtility.trans("340.1", "Rotated biochamber disabled"));
} else {
GTUtility.sendChatToPlayer(player, GTUtility.trans("340", "Rotated biochamber enabled"));
}
})
.setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE)
.setSize(90, 18)
.addTooltip("Rotates the biochamber by 90 degrees."))
.addChild(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CYCLIC)
.setSize(18, 18))
.addChild(
new TextWidget("Bio Rotation").setTextAlignment(Alignment.Center)
.setPos(23, 5))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(new MultiChildWidget().addChild(new CycleButtonWidget().setToggle(() -> mOCTier1, val -> {
mOCTier1 = val;
mOCTier2 = false;
if (!mOCTier1) {
GTUtility.sendChatToPlayer(player, GTUtility.trans("341.1", "Tier 1 cooling disabled"));
} else {
GTUtility.sendChatToPlayer(player, GTUtility.trans("341", "Tier 1 cooling enabled"));
}
})
.setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE)
.setSize(90, 18)
.addTooltip(
"Allows for overclocking. Requires 10 L/s of distilled water. Cooling upgrades are mutually exclusive."))
.addChild(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CYCLIC)
.setSize(18, 18))
.addChild(
new TextWidget("Liquid Cooling").setTextAlignment(Alignment.Center)
.setPos(20, 5))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(new MultiChildWidget().addChild(new CycleButtonWidget().setToggle(() -> mOCTier2, val -> {
mOCTier2 = val;
mOCTier1 = false;
if (!mOCTier2) {
GTUtility.sendChatToPlayer(player, GTUtility.trans("342.1", "Tier 2 cooling disabled"));
} else {
GTUtility.sendChatToPlayer(player, GTUtility.trans("342", "Tier 2 cooling enabled"));
}
})
.setVariableBackground(GTUITextures.BUTTON_STANDARD_TOGGLE)
.setSize(90, 18)
.addTooltip(
"Enables perfect overclocking by allowing nanites to work with extreme speed and efficiency. Uses 10 L/s of Super Coolant."))
.addChild(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CYCLIC)
.setSize(18, 18))
.addChild(
new TextWidget("Thermosink").setTextAlignment(Alignment.Center)
.setPos(20, 5))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new TextWidget(new Text("Trace Size")).setSize(90, 18)
.setEnabled(widget -> !getBaseMetaTileEntity().isActive())
.setPos(0, 4))
.widget(
new NumericWidget().setGetter(() -> (int) ((1f / mRoughnessMultiplier) * 100f))
.setSetter(val -> mRoughnessMultiplier = 100f / (int) val)
.setBounds(50, 200)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip(
"Set the trace size. Smaller traces allow material savings but take longer to fabricate. Larger traces waste material but are fast. 50-200 μm.")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(90, 16))
.widget(
new DrawableWidget().setDrawable(GTUITextures.OVERLAY_BUTTON_CROSS)
.setSize(18, 18)
.addTooltip(new Text("Can't change configuration when running !").color(Color.RED.dark(3)))
.setEnabled(widget -> getBaseMetaTileEntity().isActive()))
.setPos(10, 25))
.widget(
new DynamicPositionedColumn().setSynced(false)
.widget(
new TextWidget(new Text("Bio Upgrade Offsets")).setSize(72, 18)
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new DynamicPositionedRow().setSynced(false)
.widget(
new NumericWidget().setGetter(() -> mBioOffsets[0])
.setSetter(val -> mBioOffsets[0] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("X Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.widget(
new NumericWidget().setGetter(() -> mBioOffsets[1])
.setSetter(val -> mBioOffsets[1] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("Z Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new TextWidget(new Text("Cooler Tier 1 Offsets")).setSize(72, 18)
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new DynamicPositionedRow().setSynced(false)
.widget(
new NumericWidget().setGetter(() -> mOCTier1Offsets[0])
.setSetter(val -> mOCTier1Offsets[0] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("X Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.widget(
new NumericWidget().setGetter(() -> mOCTier1Offsets[1])
.setSetter(val -> mOCTier1Offsets[1] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("Z Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new TextWidget(new Text("Cooler Tier 2 Offsets")).setSize(72, 18)
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.widget(
new DynamicPositionedRow().setSynced(false)
.widget(
new NumericWidget().setGetter(() -> mOCTier2Offsets[0])
.setSetter(val -> mOCTier2Offsets[0] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("X Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.widget(
new NumericWidget().setGetter(() -> mOCTier2Offsets[1])
.setSetter(val -> mOCTier2Offsets[1] = (int) val)
.setBounds(-16, 16)
.setTextColor(Color.WHITE.normal)
.setTextAlignment(Alignment.Center)
.addTooltip("Z Offset")
.setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
.setSize(36, 18))
.setEnabled(widget -> !getBaseMetaTileEntity().isActive()))
.setPos(110, 25));
return builder.build();
}
@Override
public boolean supportsVoidProtection() {
return true;
}
@Override
public boolean supportsInputSeparation() {
return true;
}
@Override
public boolean supportsSingleRecipeLocking() {
return true;
}
@Override
public boolean supportsBatchMode() {
return true;
}
}
|