aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java
blob: dab072e0a9fd1ce5bad0066fbc2d5cce3162eea0 (plain)
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
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
package tectech.thing.metaTileEntity.multi.base;

import static gregtech.api.enums.GTValues.V;
import static gregtech.api.enums.GTValues.VN;
import static gregtech.api.enums.HatchElement.InputBus;
import static gregtech.api.enums.HatchElement.InputHatch;
import static gregtech.api.enums.HatchElement.Maintenance;
import static gregtech.api.enums.HatchElement.Muffler;
import static gregtech.api.enums.HatchElement.OutputBus;
import static gregtech.api.enums.HatchElement.OutputHatch;
import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY;
import static gregtech.api.util.GTUtility.filterValidMTEs;
import static java.lang.Math.min;
import static tectech.thing.casing.BlockGTCasingsTT.texturePage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;
import org.lwjgl.opengl.GL11;

import com.google.common.collect.Iterables;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.alignment.IAlignment;
import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.util.Vec3Impl;
import com.gtnewhorizons.modularui.api.NumberFormatMUI;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
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.api.widget.Widget;
import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot;
import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn;
import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget;
import com.gtnewhorizons.modularui.common.widget.Scrollable;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import com.gtnewhorizons.modularui.common.widget.TextWidget;
import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.Textures;
import gregtech.api.gui.modularui.GTUITextures;
import gregtech.api.interfaces.IHatchElement;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.modularui.IBindPlayerInventoryUI;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchDynamo;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.metatileentity.implementations.MTEHatchInput;
import gregtech.api.metatileentity.implementations.MTEHatchInputBus;
import gregtech.api.metatileentity.implementations.MTEHatchMaintenance;
import gregtech.api.metatileentity.implementations.MTEHatchMuffler;
import gregtech.api.metatileentity.implementations.MTEHatchOutput;
import gregtech.api.metatileentity.implementations.MTEHatchOutputBus;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.util.GTUtility;
import gregtech.api.util.HatchElementBuilder;
import gregtech.api.util.IGTHatchAdder;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.shutdown.ShutDownReason;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.api.util.shutdown.SimpleShutDownReason;
import gregtech.common.Pollution;
import gregtech.common.tileentities.machines.IDualInputHatch;
import tectech.Reference;
import tectech.TecTech;
import tectech.loader.TecTechConfig;
import tectech.thing.gui.TecTechUITextures;
import tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector;
import tectech.thing.metaTileEntity.hatch.MTEHatchDataInput;
import tectech.thing.metaTileEntity.hatch.MTEHatchDataOutput;
import tectech.thing.metaTileEntity.hatch.MTEHatchDynamoMulti;
import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyMulti;
import tectech.thing.metaTileEntity.hatch.MTEHatchParam;
import tectech.thing.metaTileEntity.hatch.MTEHatchUncertainty;
import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture;
import tectech.util.CommonValues;
import tectech.util.TTUtility;

/**
 * Created by danie_000 on 27.10.2016.
 */
public abstract class TTMultiblockBase extends MTEExtendedPowerMultiBlockBase<TTMultiblockBase>
    implements IAlignment, IBindPlayerInventoryUI {
    // region Client side variables (static - one per class)

    // Front icon holders - static so it is default one for my blocks
    // just add new static ones in your class and and override getTexture
    protected static Textures.BlockIcons.CustomIcon ScreenOFF;
    protected static Textures.BlockIcons.CustomIcon ScreenON;

    /** Base ID for the LED window popup. LED 1 I0 will have ID 100, LED 1 I1 101... */
    protected static int LED_WINDOW_BASE_ID = 100;

    // Sound resource - same as with screen but override getActivitySound
    public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_lo_freq");

    @SideOnly(Side.CLIENT)
    private SoundLoop activitySoundLoop;
    // endregion

    // region HATCHES ARRAYS - they hold info about found hatches, add hatches to them... (auto structure magic does it
    // tho)

    // HATCHES!!!, should be added and removed in check machine
    protected ArrayList<MTEHatchParam> eParamHatches = new ArrayList<>();
    protected ArrayList<MTEHatchUncertainty> eUncertainHatches = new ArrayList<>();
    // multi amp hatches in/out
    protected ArrayList<MTEHatchEnergyMulti> eEnergyMulti = new ArrayList<>();
    protected ArrayList<MTEHatchDynamoMulti> eDynamoMulti = new ArrayList<>();
    // data hatches
    protected ArrayList<MTEHatchDataInput> eInputData = new ArrayList<>();
    protected ArrayList<MTEHatchDataOutput> eOutputData = new ArrayList<>();

    // endregion

    // region parameters
    public final Parameters parametrization;
    // endregion

    // region Control variables

    // should explode on dismatle?, set it in constructor, if true machine will explode if invalidated structure while
    // active
    protected boolean eDismantleBoom = false;

    // what is the amount of A required
    public long eAmpereFlow = 1; // analogue of EU/t but for amperes used (so eu/t is actually eu*A/t) USE ONLY POSITIVE
                                 // NUMBERS!

    // set to what you need it to be in check recipe
    // data required to operate
    protected long eRequiredData = 0;

    // Counter for the computation timeout. Will be initialized one to the max time and then only decreased.
    protected int eComputationTimeout = MAX_COMPUTATION_TIMEOUT;

    // Max timeout of computation in ticks
    protected static int MAX_COMPUTATION_TIMEOUT = 100;

    // are parameters correct - change in check recipe/output/update params etc. (maintenance status boolean)
    protected boolean eParameters = true;

    // what type of certainty inconvenience is used - can be used as in Computer - more info in uncertainty hatch
    protected byte eCertainMode = 0, eCertainStatus = 0;

    // minimal repair status to make the machine even usable (how much unfixed fixed stuff is needed)
    // if u need to force some things to be fixed - u might need to override doRandomMaintenanceDamage
    protected byte minRepairStatus = 3;

    // whether there is a maintenance hatch in the multi and whether checks are necessary (for now only used in a
    // transformer)
    protected boolean hasMaintenanceChecks = true;

    // is power pass cover present
    public boolean ePowerPassCover = false;

    // functionality toggles - changed by buttons in gui also
    public boolean ePowerPass = false, eSafeVoid = false;

    // endregion

    // region READ ONLY unless u really need to change it

    // max amperes machine can take in after computing it to the lowest tier (exchange packets to min tier count)
    protected long eMaxAmpereFlow = 0, eMaxAmpereGen = 0;

    // What is the max and minimal tier of eu hatches installed
    private long maxEUinputMin = 0, maxEUinputMax = 0, maxEUoutputMin = 0, maxEUoutputMax = 0;

    // read only unless you are making computation generator - read computer class
    protected long eAvailableData = 0; // data being available

    // just some info - private so hidden
    private boolean explodedThisTick = false;

    /** Flag if the new long power variable should be used */
    protected boolean useLongPower = false;

    // Locale-aware formatting of numbers.
    protected static NumberFormatMUI numberFormat;
    static {
        numberFormat = new NumberFormatMUI();
        numberFormat.setMaximumFractionDigits(8);
    }

    // endregion

    protected TTMultiblockBase(int aID, String aName, String aNameRegional) {
        super(aID, aName, aNameRegional);
        parametrization = new Parameters(this);
        parametersInstantiation_EM();
        parametrization.setToDefaults(true, true);
    }

    protected TTMultiblockBase(String aName) {
        super(aName);
        parametrization = new Parameters(this);
        parametersInstantiation_EM();
        parametrization.setToDefaults(true, true);
    }

    // region SUPER STRUCT

    /**
     * Gets structure
     *
     * @return STATIC INSTANCE OF STRUCTURE
     */
    public abstract IStructureDefinition<? extends TTMultiblockBase> getStructure_EM();

    @SuppressWarnings("unchecked")
    private IStructureDefinition<TTMultiblockBase> getStructure_EM_Internal() {
        return (IStructureDefinition<TTMultiblockBase>) getStructure_EM();
    }

    @Override
    public IStructureDefinition<TTMultiblockBase> getStructureDefinition() {
        return getStructure_EM_Internal();
    }

    public final boolean structureCheck_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset) {
        IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity();
        return getStructure_EM_Internal().check(
            this,
            piece,
            baseMetaTileEntity.getWorld(),
            getExtendedFacing(),
            baseMetaTileEntity.getXCoord(),
            baseMetaTileEntity.getYCoord(),
            baseMetaTileEntity.getZCoord(),
            horizontalOffset,
            verticalOffset,
            depthOffset,
            !mMachine);
    }

    public final boolean structureBuild_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset,
        ItemStack trigger, boolean hintsOnly) {
        IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity();
        return getStructure_EM_Internal().buildOrHints(
            this,
            trigger,
            piece,
            baseMetaTileEntity.getWorld(),
            getExtendedFacing(),
            baseMetaTileEntity.getXCoord(),
            baseMetaTileEntity.getYCoord(),
            baseMetaTileEntity.getZCoord(),
            horizontalOffset,
            verticalOffset,
            depthOffset,
            hintsOnly);
    }
    // endregion

    // region METHODS TO OVERRIDE - general functionality, recipe check, output

    /**
     * Check structure here, also add hatches
     *
     * @param iGregTechTileEntity - the tile entity
     * @param itemStack           - what is in the controller input slot
     * @return is structure valid
     */
    protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
        return false;
    }

    /**
     * Checks Recipes (when all machine is complete and can work)
     * <p>
     * can get/set Parameters here also
     *
     * @deprecated Use {@link #createProcessingLogic()} ()} or {@link #checkProcessing_EM()}
     *
     * @param itemStack item in the controller
     * @return is recipe is valid
     */
    @Deprecated
    public boolean checkRecipe_EM(ItemStack itemStack) {
        return false;
    }

    @NotNull
    protected CheckRecipeResult checkProcessing_EM() {
        if (processingLogic == null) {
            return checkRecipe_EM(getControllerSlot()) ? CheckRecipeResultRegistry.SUCCESSFUL
                : CheckRecipeResultRegistry.NO_RECIPE;
        }
        return super.checkProcessing();
    }

    /**
     * Put EM stuff from outputEM into EM output hatches here or do other stuff - it is basically on recipe succeded
     * <p>
     * based on "machine state" do output, this must move to outputEM to EM output hatches and can also modify output
     * items/fluids/EM, remaining EM is NOT overflowed. (Well it can be overflowed if machine didn't finished,
     * soft-hammered/disabled/not enough EU) Setting available data processing
     */
    public void outputAfterRecipe_EM() {}
    // endregion

    // region tooltip and scanner result

    public ArrayList<String> getFullLedDescriptionIn(int hatchNo, int paramID) {
        ArrayList<String> list = new ArrayList<>();
        list.add(
            EnumChatFormatting.WHITE + "ID: "
                + EnumChatFormatting.AQUA
                + hatchNo
                + EnumChatFormatting.YELLOW
                + ":"
                + EnumChatFormatting.AQUA
                + paramID
                + EnumChatFormatting.YELLOW
                + ":"
                + EnumChatFormatting.AQUA
                + "I  "
                + parametrization.getStatusIn(hatchNo, paramID).name.get());
        list.add(
            EnumChatFormatting.WHITE + "Value: "
                + EnumChatFormatting.AQUA
                + numberFormat.format(parametrization.getIn(hatchNo, paramID)));
        try {
            list.add(parametrization.groups[hatchNo].parameterIn[paramID].getBrief());
        } catch (NullPointerException | IndexOutOfBoundsException e) {
            list.add("Unused");
        }
        return list;
    }

    public ArrayList<String> getFullLedDescriptionOut(int hatchNo, int paramID) {
        ArrayList<String> list = new ArrayList<>();
        list.add(
            EnumChatFormatting.WHITE + "ID: "
                + EnumChatFormatting.AQUA
                + hatchNo
                + EnumChatFormatting.YELLOW
                + ":"
                + EnumChatFormatting.AQUA
                + paramID
                + EnumChatFormatting.YELLOW
                + ":"
                + EnumChatFormatting.AQUA
                + "O "
                + parametrization.getStatusOut(hatchNo, paramID).name.get());
        list.add(
            EnumChatFormatting.WHITE + "Value: "
                + EnumChatFormatting.AQUA
                + numberFormat.format(parametrization.getOut(hatchNo, paramID)));
        try {
            list.add(parametrization.groups[hatchNo].parameterOut[paramID].getBrief());
        } catch (NullPointerException | IndexOutOfBoundsException e) {
            list.add("Unused");
        }
        return list;
    }

    @Override
    protected MultiblockTooltipBuilder createTooltip() {
        final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
        tt.addInfo("Nothing special just override me")
            .toolTipFinisher(CommonValues.TEC_MARK_GENERAL);
        return tt;
    }

    /**
     * scanner gives it
     */
    @Override
    public String[] getInfoData() { // TODO Do it
        long storedEnergy = 0;
        long maxEnergy = 0;
        for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) {
            storedEnergy += tHatch.getBaseMetaTileEntity()
                .getStoredEU();
            maxEnergy += tHatch.getBaseMetaTileEntity()
                .getEUCapacity();
        }
        for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) {
            storedEnergy += tHatch.getBaseMetaTileEntity()
                .getStoredEU();
            maxEnergy += tHatch.getBaseMetaTileEntity()
                .getEUCapacity();
        }

        return new String[] { "Progress:",
            EnumChatFormatting.GREEN + GTUtility.formatNumbers(mProgresstime / 20)
                + EnumChatFormatting.RESET
                + " s / "
                + EnumChatFormatting.YELLOW
                + GTUtility.formatNumbers(mMaxProgresstime / 20)
                + EnumChatFormatting.RESET
                + " s",
            "Energy Hatches:",
            EnumChatFormatting.GREEN + GTUtility.formatNumbers(storedEnergy)
                + EnumChatFormatting.RESET
                + " EU / "
                + EnumChatFormatting.YELLOW
                + GTUtility.formatNumbers(maxEnergy)
                + EnumChatFormatting.RESET
                + " EU",
            (getPowerFlow() * eAmpereFlow <= 0 ? "Probably uses: " : "Probably makes: ") + EnumChatFormatting.RED
                + GTUtility.formatNumbers(Math.abs(getPowerFlow()))
                + EnumChatFormatting.RESET
                + " EU/t at "
                + EnumChatFormatting.RED
                + GTUtility.formatNumbers(eAmpereFlow)
                + EnumChatFormatting.RESET
                + " A",
            "Tier Rating: " + EnumChatFormatting.YELLOW
                + VN[getMaxEnergyInputTier_EM()]
                + EnumChatFormatting.RESET
                + " / "
                + EnumChatFormatting.GREEN
                + VN[getMinEnergyInputTier_EM()]
                + EnumChatFormatting.RESET
                + " Amp Rating: "
                + EnumChatFormatting.GREEN
                + GTUtility.formatNumbers(eMaxAmpereFlow)
                + EnumChatFormatting.RESET
                + " A",
            "Problems: " + EnumChatFormatting.RED
                + (getIdealStatus() - getRepairStatus())
                + EnumChatFormatting.RESET
                + " Efficiency: "
                + EnumChatFormatting.YELLOW
                + mEfficiency / 100.0F
                + EnumChatFormatting.RESET
                + " %",
            "PowerPass: " + EnumChatFormatting.BLUE
                + ePowerPass
                + EnumChatFormatting.RESET
                + " SafeVoid: "
                + EnumChatFormatting.BLUE
                + eSafeVoid,
            "Computation: " + EnumChatFormatting.GREEN
                + GTUtility.formatNumbers(eAvailableData)
                + EnumChatFormatting.RESET
                + " / "
                + EnumChatFormatting.YELLOW
                + GTUtility.formatNumbers(eRequiredData)
                + EnumChatFormatting.RESET };
    }

    /**
     * should it work with scanner? HELL YES
     */
    @Override
    public boolean isGivingInformation() {
        return true;
    }

    // endregion

    // region GUI/SOUND/RENDER

    /**
     * add more textures
     */
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister aBlockIconRegister) {
        ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER");
        ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER_ACTIVE");
        super.registerIcons(aBlockIconRegister);
    }

    /**
     * actually use textures
     */
    @Override
    public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing,
        int colorIndex, boolean aActive, boolean aRedstone) {
        if (side == facing) {
            return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4],
                new TTRenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) };
        }
        return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4] };
    }

    /**
     * should return your activity sound
     */
    @SideOnly(Side.CLIENT)
    protected ResourceLocation getActivitySound() {
        return activitySound;
    }

    /**
     * plays the sounds auto magically
     */
    @SideOnly(Side.CLIENT)
    protected void soundMagic(ResourceLocation activitySound) {
        if (getBaseMetaTileEntity().isActive()) {
            if (activitySoundLoop == null) {
                activitySoundLoop = new SoundLoop(activitySound, getBaseMetaTileEntity(), false, true);
                Minecraft.getMinecraft()
                    .getSoundHandler()
                    .playSound(activitySoundLoop);
            }
        } else {
            if (activitySoundLoop != null) {
                activitySoundLoop = null;
            }
        }
    }

    // endregion

    // region Methods to maybe override (if u implement certain stuff)

    /**
     * is the thing inside controller a valid item to make the machine work
     */
    @Override
    public boolean isCorrectMachinePart(ItemStack itemStack) {
        return true;
    }

    /**
     * how much damage to apply to thing in controller - not sure how it does it
     */
    @Override
    public int getDamageToComponent(ItemStack itemStack) {
        return 0;
    }

    /**
     * called when removing from map - not when unloading? //todo check
     */
    @Override
    public void onRemoval() {
        try {
            if (ePowerPass && getEUVar() > V[3]
                || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) {
                explodeMultiblock();
            }
        } catch (Exception e) {
            if (TecTechConfig.DEBUG_MODE) {
                e.printStackTrace();
            }
        }
    }

    /**
     * prevents spontaneous explosions when the chunks unloading would cause them should cover 3 chunks radius
     */
    protected boolean areChunksAroundLoaded_EM() {
        if (this.isValid() && getBaseMetaTileEntity().isServerSide()) {
            IGregTechTileEntity base = getBaseMetaTileEntity();
            return base.getWorld()
                .doChunksNearChunkExist(base.getXCoord(), base.getYCoord(), base.getZCoord(), 3);
            // todo check if it is actually checking if chunks are loaded
        } else {
            return false;
        }
    }

    /**
     * instantiate parameters in CONSTRUCTOR! CALLED ONCE on creation, don't call it in your classes
     */
    protected void parametersInstantiation_EM() {}

    /**
     * It is automatically called OFTEN update status of parameters in guis (and "machine state" if u wish) Called
     * before check recipe, before outputting, and every second the machine is complete
     * <p>
     * good place to update parameter statuses, default implementation handles it well
     *
     * @param machineBusy is machine doing stuff
     */
    protected void parametersStatusesWrite_EM(boolean machineBusy) { // todo unimplement?
        if (!machineBusy) {
            for (Parameters.Group.ParameterIn parameterIn : parametrization.parameterInArrayList) {
                if (parameterIn != null) {
                    parameterIn.updateStatus();
                }
            }
        } else {
            for (Parameters.Group hatch : parametrization.groups) {
                if (hatch != null && hatch.updateWhileRunning) {
                    for (Parameters.Group.ParameterIn in : hatch.parameterIn) {
                        if (in != null) {
                            in.updateStatus();
                        }
                    }
                }
            }
        }
        for (Parameters.Group.ParameterOut parameterOut : parametrization.parameterOutArrayList) {
            if (parameterOut != null) {
                parameterOut.updateStatus();
            }
        }
    }

    /**
     * For extra types of hatches initiation, LOOK HOW IT IS CALLED! in onPostTick
     *
     * @param mMachine was the machine considered complete at that point in onPostTick
     */
    protected void hatchInit_EM(boolean mMachine) {}

    /**
     * called when the multiblock is exploding - if u want to add more EXPLOSIONS, for ex. new types of hatches also
     * have to explode
     */
    protected void extraExplosions_EM() {} // For that extra hatches explosions, and maybe some MOORE EXPLOSIONS

    /**
     * Get Available data, Override only on data outputters should return mAvailableData that is set in check recipe
     *
     * @return available data
     */
    protected long getAvailableData_EM() {
        long result = 0;
        IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity();
        Vec3Impl pos = new Vec3Impl(
            baseMetaTileEntity.getXCoord(),
            baseMetaTileEntity.getYCoord(),
            baseMetaTileEntity.getZCoord());
        for (MTEHatchDataInput in : eInputData) {
            if (in.q != null) {
                Long value = in.q.contentIfNotInTrace(pos);
                if (value != null) {
                    result += value;
                }
            }
        }
        return result;
    }

    protected long getPowerFlow() {
        return useLongPower ? lEUt : mEUt;
    }

    protected void setPowerFlow(long lEUt) {
        if (useLongPower) {
            this.lEUt = lEUt;
        } else {
            mEUt = (int) Math.min(Integer.MAX_VALUE, lEUt);
        }
    }

    @Override
    protected long getActualEnergyUsage() {
        return -(useLongPower ? lEUt : mEUt) * eAmpereFlow * 10_000 / Math.max(1_000, mEfficiency);
    }

    /**
     * Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) BUT NEEDED WHEN - machine
     * blocks are not touching each other or they don't implement IMachineBlockUpdateable (ex. air,stone,weird TE's)
     */
    protected boolean cyclicUpdate_EM() {
        return mUpdate <= -1000; // set to false to disable cyclic update
        // default is once per 50s; mUpdate is decremented every tick
    }

    /**
     * get pollution per tick
     *
     * @param itemStack what is in controller
     * @return how much pollution is produced
     */
    @Override
    public int getPollutionPerTick(ItemStack itemStack) {
        return 0;
    }

    /**
     * EM pollution per tick
     *
     * @param itemStack - item in controller
     * @return how much excess matter is there
     */
    public float getExcessMassPerTick_EM(ItemStack itemStack) {
        return 0f;
    }

    /**
     * triggered if machine is not allowed to work after completing a recipe, override to make it not shutdown for
     * instance (like turbines). bu just replacing it with blank - active transformer is doing it
     * <p>
     * CALLED DIRECTLY when soft hammered to offline state - usually should stop the machine unless some other mechanics
     * should do it
     */
    protected void notAllowedToWork_stopMachine_EM() {
        stopMachine();
    }

    /**
     * store data
     */
    @Override
    public void saveNBTData(NBTTagCompound aNBT) {
        super.saveNBTData(aNBT);
        aNBT.setLong("eMaxGenEUmin", maxEUoutputMin);
        aNBT.setLong("eMaxGenEUmax", maxEUoutputMax);
        aNBT.setLong("eGenRating", eMaxAmpereGen);
        aNBT.setLong("eMaxEUmin", maxEUinputMin);
        aNBT.setLong("eMaxEUmax", maxEUinputMax);
        aNBT.setLong("eRating", eAmpereFlow);
        aNBT.setLong("eMaxA", eMaxAmpereFlow);
        aNBT.setLong("eDataR", eRequiredData);
        aNBT.setLong("eDataA", eAvailableData);
        aNBT.setByte("eCertainM", eCertainMode);
        aNBT.setByte("eCertainS", eCertainStatus);
        aNBT.setByte("eMinRepair", minRepairStatus);
        aNBT.setBoolean("eParam", eParameters);
        aNBT.setBoolean("ePass", ePowerPass);
        aNBT.setBoolean("ePowerPassCover", ePowerPassCover);
        aNBT.setBoolean("eVoid", eSafeVoid);
        aNBT.setBoolean("eBoom", eDismantleBoom);
        aNBT.setBoolean("eOK", mMachine);
        // Ensures compatibility
        if (mOutputItems != null) {
            aNBT.setInteger("mOutputItemsLength", mOutputItems.length);
            for (int i = 0; i < mOutputItems.length; i++) {
                if (mOutputItems[i] != null) {
                    NBTTagCompound tNBT = new NBTTagCompound();
                    mOutputItems[i].writeToNBT(tNBT);
                    aNBT.setTag("mOutputItem" + i, tNBT);
                }
            }
        }

        // Ensures compatibility
        if (mOutputFluids != null) {
            aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length);
            for (int i = 0; i < mOutputFluids.length; i++) {
                if (mOutputFluids[i] != null) {
                    NBTTagCompound tNBT = new NBTTagCompound();
                    mOutputFluids[i].writeToNBT(tNBT);
                    aNBT.setTag("mOutputFluids" + i, tNBT);
                }
            }
        }

        aNBT.setInteger("eOutputStackCount", 0);
        aNBT.removeTag("outputEM");

        NBTTagCompound paramI = new NBTTagCompound();
        for (int i = 0; i < parametrization.iParamsIn.length; i++) {
            paramI.setDouble(Integer.toString(i), parametrization.iParamsIn[i]);
        }
        aNBT.setTag("eParamsInD", paramI);

        NBTTagCompound paramO = new NBTTagCompound();
        for (int i = 0; i < parametrization.iParamsOut.length; i++) {
            paramO.setDouble(Integer.toString(i), parametrization.iParamsOut[i]);
        }
        aNBT.setTag("eParamsOutD", paramO);

        NBTTagCompound paramIs = new NBTTagCompound();
        for (int i = 0; i < parametrization.eParamsInStatus.length; i++) {
            paramIs.setByte(Integer.toString(i), parametrization.eParamsInStatus[i].getOrdinalByte());
        }
        aNBT.setTag("eParamsInS", paramIs);

        NBTTagCompound paramOs = new NBTTagCompound();
        for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) {
            paramOs.setByte(Integer.toString(i), parametrization.eParamsOutStatus[i].getOrdinalByte());
        }
        aNBT.setTag("eParamsOutS", paramOs);
    }

    /**
     * load data
     */
    @Override
    public void loadNBTData(NBTTagCompound aNBT) {
        super.loadNBTData(aNBT);
        maxEUoutputMin = aNBT.getLong("eMaxGenEUmin");
        maxEUoutputMax = aNBT.getLong("eMaxGenEUmax");
        eMaxAmpereGen = aNBT.getLong("eGenRating");
        maxEUinputMin = aNBT.getLong("eMaxEUmin");
        maxEUinputMax = aNBT.getLong("eMaxEUmax");
        eAmpereFlow = aNBT.hasKey("eRating") ? aNBT.getLong("eRating") : 1;
        eMaxAmpereFlow = aNBT.getLong("eMaxA");
        eRequiredData = aNBT.getLong("eDataR");
        eAvailableData = aNBT.getLong("eDataA");
        eCertainMode = aNBT.getByte("eCertainM");
        eCertainStatus = aNBT.getByte("eCertainS");
        minRepairStatus = aNBT.hasKey("eMinRepair") ? aNBT.getByte("eMinRepair") : 3;
        eParameters = !aNBT.hasKey("eParam") || aNBT.getBoolean("eParam");
        ePowerPass = aNBT.getBoolean("ePass");
        ePowerPassCover = aNBT.getBoolean("ePowerPassCover");
        eSafeVoid = aNBT.getBoolean("eVoid");
        eDismantleBoom = aNBT.getBoolean("eBoom");
        mMachine = aNBT.getBoolean("eOK");

        // Ensures compatibility
        int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength");
        if (aOutputItemsLength > 0) {
            mOutputItems = new ItemStack[aOutputItemsLength];
            for (int i = 0; i < mOutputItems.length; i++) {
                mOutputItems[i] = GTUtility.loadItem(aNBT, "mOutputItem" + i);
            }
        }

        // Ensures compatibility
        int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength");
        if (aOutputFluidsLength > 0) {
            mOutputFluids = new FluidStack[aOutputFluidsLength];
            for (int i = 0; i < mOutputFluids.length; i++) {
                mOutputFluids[i] = GTUtility.loadFluid(aNBT, "mOutputFluids" + i);
            }
        }

        if (aNBT.hasKey("eParamsIn") && aNBT.hasKey("eParamsOut") && aNBT.hasKey("eParamsB")) {
            NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn");
            NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut");
            NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB");
            for (int i = 0; i < 10; i++) {
                if (paramB.getBoolean(Integer.toString(i))) {
                    parametrization.iParamsIn[i] = Float.intBitsToFloat(paramI.getInteger(Integer.toString(i)));
                    parametrization.iParamsOut[i] = Float.intBitsToFloat(paramO.getInteger(Integer.toString(i)));
                } else {
                    parametrization.iParamsIn[i] = paramI.getInteger(Integer.toString(i));
                    parametrization.iParamsOut[i] = paramO.getInteger(Integer.toString(i));
                }
            }
        } else {
            NBTTagCompound paramI = aNBT.getCompoundTag("eParamsInD");
            for (int i = 0; i < parametrization.iParamsIn.length; i++) {
                parametrization.iParamsIn[i] = paramI.getDouble(Integer.toString(i));
            }
            NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOutD");
            for (int i = 0; i < parametrization.iParamsOut.length; i++) {
                parametrization.iParamsOut[i] = paramO.getDouble(Integer.toString(i));
            }
        }

        NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS");
        for (int i = 0; i < parametrization.eParamsInStatus.length; i++) {
            parametrization.eParamsInStatus[i] = LedStatus.getStatus(paramIs.getByte(Integer.toString(i)));
        }

        NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS");
        for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) {
            parametrization.eParamsOutStatus[i] = LedStatus.getStatus(paramOs.getByte(Integer.toString(i)));
        }
    }

    /**
     * Override if needed but usually call super method at start! On machine stop - NOT called directly when soft
     * hammered to offline state! - it SHOULD cause a full stop like power failure does
     */
    @Override
    public void stopMachine(@Nonnull ShutDownReason reason) {
        if (!ShutDownReasonRegistry.isRegistered(reason.getID())) {
            throw new RuntimeException(String.format("Reason %s is not registered for registry", reason.getID()));
        }
        for (MTEHatchDataOutput data : eOutputData) {
            data.q = null;
        }

        mOutputItems = null;
        mOutputFluids = null;
        mEfficiency = 0;
        mEfficiencyIncrease = 0;
        mProgresstime = 0;
        mMaxProgresstime = 0;
        eAvailableData = 0;
        hatchesStatusUpdate_EM();
        getBaseMetaTileEntity().disableWorking();
        getBaseMetaTileEntity().setShutDownReason(reason);
        getBaseMetaTileEntity().setShutdownStatus(true);
        if (reason.wasCritical()) {
            sendSound(INTERRUPT_SOUND_INDEX);
        }
    }

    /**
     * After recipe check failed helper method so i don't have to set that params to nothing at all times
     */
    protected void afterRecipeCheckFailed() {

        for (MTEHatchDataOutput data : eOutputData) {
            data.q = null;
        }

        mOutputItems = null;
        mOutputFluids = null;
        mEfficiency = 0;
        mEfficiencyIncrease = 0;
        mProgresstime = 0;
        mMaxProgresstime = 0;
        eAvailableData = 0;
    }

    /**
     * cyclic check even when not working, called LESS frequently
     */
    private boolean cyclicUpdate() {
        if (cyclicUpdate_EM()) {
            mUpdate = 0;
            return true;
        }
        return false;
    }

    /**
     * mining level...
     */
    @Override
    public byte getTileEntityBaseType() {
        return 3;
    }

    // endregion

    // region internal

    /**
     * internal check machine
     */
    @Override
    public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
        return checkMachine_EM(iGregTechTileEntity, itemStack);
    }

    /**
     * internal check recipe
     */
    @Override
    public final boolean checkRecipe(ItemStack itemStack) { // do recipe checks, based on "machine content and state"
        hatchesStatusUpdate_EM();
        startRecipeProcessing();
        boolean result = checkRecipe_EM(itemStack); // if had no - set default params
        endRecipeProcessing();
        hatchesStatusUpdate_EM();
        return result;
    }

    @NotNull
    @Override
    public final CheckRecipeResult checkProcessing() {
        hatchesStatusUpdate_EM();
        CheckRecipeResult result = checkProcessing_EM();
        hatchesStatusUpdate_EM();
        return result;
    }

    /**
     * callback for updating parameters and new hatches
     */
    protected void hatchesStatusUpdate_EM() {
        if (getBaseMetaTileEntity().isClientSide()) {
            return;
        }
        boolean busy = mMaxProgresstime > 0;
        if (busy) { // write from buffer to hatches only
            for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) {
                if (hatch.param < 0) {
                    continue;
                }
                int hatchId = hatch.param;
                if (parametrization.groups[hatchId] != null && parametrization.groups[hatchId].updateWhileRunning) {
                    parametrization.iParamsIn[hatchId] = hatch.value0D;
                    parametrization.iParamsIn[hatchId + 10] = hatch.value1D;
                }
                hatch.input0D = parametrization.iParamsOut[hatchId];
                hatch.input1D = parametrization.iParamsOut[hatchId + 10];
            }
        } else { // if has nothing to do update all
            for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) {
                if (hatch.param < 0) {
                    continue;
                }
                int hatchId = hatch.param;
                parametrization.iParamsIn[hatchId] = hatch.value0D;
                parametrization.iParamsIn[hatchId + 10] = hatch.value1D;
                hatch.input0D = parametrization.iParamsOut[hatchId];
                hatch.input1D = parametrization.iParamsOut[hatchId + 10];
            }
        }
        for (MTEHatchUncertainty uncertainty : eUncertainHatches) {
            eCertainStatus = uncertainty.update(eCertainMode);
        }
        eAvailableData = getAvailableData_EM();
        parametersStatusesWrite_EM(busy);
    }

    @Deprecated
    public final int getAmountOfOutputs() {
        throw new NoSuchMethodError("Deprecated Do not use");
    }
    // endregion

    // region TICKING functions

    public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) {}

    @Override
    public final void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
        isFacingValid(aBaseMetaTileEntity.getFrontFacing());
        if (getBaseMetaTileEntity().isClientSide()) {
            StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity);
        }
        onFirstTick_EM(aBaseMetaTileEntity);
    }

    /**
     * called every tick the machines is active
     */
    @Override
    public boolean onRunningTick(ItemStack aStack) {
        return onRunningTickCheck(aStack);
    }

    public boolean onRunningTickCheck_EM(ItemStack aStack) {
        if (eRequiredData > eAvailableData) {
            if (!checkComputationTimeout()) {
                if (energyFlowOnRunningTick_EM(aStack, false)) {
                    stopMachine(SimpleShutDownReason.ofCritical("computation_loss"));
                }
                return false;
            }
        }
        return energyFlowOnRunningTick_EM(aStack, true);
    }

    public boolean onRunningTickCheck(ItemStack aStack) {
        if (eRequiredData > eAvailableData) {
            if (!checkComputationTimeout()) {
                if (energyFlowOnRunningTick(aStack, false)) {
                    stopMachine(SimpleShutDownReason.ofCritical("computation_loss"));
                }
                return false;
            }
        }
        return energyFlowOnRunningTick(aStack, true);
    }

    /**
     * CAREFUL!!! it calls most of the callbacks, like everything else in here
     */
    @Override
    public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
        if (aBaseMetaTileEntity.isServerSide()) {
            mTotalRunTime++;
            explodedThisTick = false;
            if (mEfficiency < 0) {
                mEfficiency = 0;
            }

            if (--mUpdate == 0 || --mStartUpCheck == 0
                || cyclicUpdate()
                || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) {
                clearHatches_EM();

                if (aBaseMetaTileEntity instanceof BaseTileEntity) {
                    ((BaseTileEntity) aBaseMetaTileEntity).ignoreUnloadedChunks = mMachine;
                }
                mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]);

                if (!mMachine) {
                    if (ePowerPass && getEUVar() > V[3]
                        || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) {
                        explodeMultiblock();
                    }
                }

                if (eUncertainHatches.size() > 1) {
                    mMachine = false;
                }

                if (mMachine) {
                    setupHatches_EM();

                    setupEnergyHatchesVariables_EM();

                    if (getEUVar() > maxEUStore()) {
                        setEUVar(maxEUStore());
                    }
                } else {
                    maxEUinputMin = 0;
                    maxEUinputMax = 0;
                    eMaxAmpereFlow = 0;
                    setEUVar(0);
                }
                hatchInit_EM(mMachine);
            }

            if (mStartUpCheck < 0) { // E
                if (mMachine) { // S
                    byte Tick = (byte) (aTick % 20);
                    if (CommonValues.MULTI_CHECK_AT == Tick) {
                        checkMaintenance();
                    }

                    if (getRepairStatus() >= minRepairStatus) { // S
                        if (CommonValues.MULTI_CHECK_AT == Tick) {
                            hatchesStatusUpdate_EM();
                        }

                        dischargeController_EM(aBaseMetaTileEntity);
                        chargeController_EM(aBaseMetaTileEntity);

                        if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { // Start
                            if (onRunningTick(mInventory[1])) { // Compute EU
                                if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) {
                                    stopMachine(ShutDownReasonRegistry.POLLUTION_FAIL);
                                }

                                if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { // progress increase
                                                                                                   // and done
                                    hatchesStatusUpdate_EM();

                                    outputAfterRecipe_EM();

                                    addClassicOutputs_EM();

                                    updateSlots();
                                    mProgresstime = 0;
                                    mMaxProgresstime = 0;
                                    mEfficiencyIncrease = 0;

                                    if (aBaseMetaTileEntity.isAllowedToWork()) {
                                        if (checkRecipe()) {
                                            mEfficiency = Math.max(
                                                0,
                                                min(
                                                    mEfficiency + mEfficiencyIncrease,
                                                    getMaxEfficiency(mInventory[1])
                                                        - (getIdealStatus() - getRepairStatus()) * 1000));
                                        } else {
                                            afterRecipeCheckFailed();
                                        }
                                        updateSlots();
                                    } else {
                                        notAllowedToWork_stopMachine_EM();
                                    }
                                }
                            } // else {//failed to consume power/resources - inside on running tick
                              // stopMachine();
                              // }
                        } else if (CommonValues.RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) {
                            if (aBaseMetaTileEntity.isAllowedToWork()) {
                                if (checkRecipe()) {
                                    mEfficiency = Math.max(
                                        0,
                                        min(
                                            mEfficiency + mEfficiencyIncrease,
                                            getMaxEfficiency(mInventory[1])
                                                - (getIdealStatus() - getRepairStatus()) * 1000));
                                } else {
                                    afterRecipeCheckFailed();
                                }
                                updateSlots();
                            } // else notAllowedToWork_stopMachine_EM(); //it is already stopped here
                        }
                    } else { // not repaired
                        stopMachine(ShutDownReasonRegistry.NO_REPAIR);
                    }
                } else { // not complete
                    stopMachine(ShutDownReasonRegistry.STRUCTURE_INCOMPLETE);
                }
            }

            aBaseMetaTileEntity.setErrorDisplayID(
                aBaseMetaTileEntity.getErrorDisplayID() & -512 | (mWrench ? 0 : 1)
                    | (mScrewdriver ? 0 : 2)
                    | (mSoftHammer ? 0 : 4)
                    | (mHardHammer ? 0 : 8)
                    | (mSolderingTool ? 0 : 16)
                    | (mCrowbar ? 0 : 32)
                    | (mMachine ? 0 : 64)
                    | (eCertainStatus == 0 ? 0 : 128)
                    | (eParameters ? 0 : 256));
            aBaseMetaTileEntity.setActive(mMaxProgresstime > 0);
            boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0;
            setMufflers(active);
        } else {
            soundMagic(getActivitySound());
        }
    }

    protected void addClassicOutputs_EM() {
        if (mOutputItems != null) {
            for (ItemStack tStack : mOutputItems) {
                if (tStack != null) {
                    addOutput(tStack);
                }
            }
        }
        mOutputItems = null;

        if (mOutputFluids != null) {
            if (mOutputFluids.length == 1) {
                for (FluidStack tStack : mOutputFluids) {
                    if (tStack != null) {
                        addOutput(tStack);
                    }
                }
            } else if (mOutputFluids.length > 1) {
                addFluidOutputs(mOutputFluids);
            }
        }
        mOutputFluids = null;
    }

    protected void clearHatches_EM() {
        mDualInputHatches.clear();
        mInputHatches.clear();
        mInputBusses.clear();
        mOutputHatches.clear();
        mOutputBusses.clear();
        mDynamoHatches.clear();
        mEnergyHatches.clear();
        mMufflerHatches.clear();
        mMaintenanceHatches.clear();

        for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eOutputData)) {
            hatch_data.id = -1;
        }
        for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eInputData)) {
            hatch_data.id = -1;
        }

        for (MTEHatchUncertainty hatch : filterValidMTEs(eUncertainHatches)) {
            hatch.getBaseMetaTileEntity()
                .setActive(false);
        }
        for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) {
            hatch.getBaseMetaTileEntity()
                .setActive(false);
        }

        eUncertainHatches.clear();
        eEnergyMulti.clear();
        eParamHatches.clear();
        eDynamoMulti.clear();
        eOutputData.clear();
        eInputData.clear();
    }

    protected void setupHatches_EM() {
        short id = 1;

        for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eOutputData)) {
            hatch_data.id = id++;
        }
        id = 1;
        for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eInputData)) {
            hatch_data.id = id++;
        }

        for (MTEHatchUncertainty hatch : filterValidMTEs(eUncertainHatches)) {
            hatch.getBaseMetaTileEntity()
                .setActive(true);
        }
        for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) {
            hatch.getBaseMetaTileEntity()
                .setActive(true);
        }
    }

    protected void setupEnergyHatchesVariables_EM() {
        if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty()
            || !mDynamoHatches.isEmpty()
            || !eDynamoMulti.isEmpty()) {
            maxEUinputMin = V[15];
            maxEUinputMax = V[0];
            maxEUoutputMin = V[15];
            maxEUoutputMax = V[0];
            for (MTEHatchEnergy hatch : filterValidMTEs(mEnergyHatches)) {
                if (hatch.maxEUInput() < maxEUinputMin) {
                    maxEUinputMin = hatch.maxEUInput();
                }
                if (hatch.maxEUInput() > maxEUinputMax) {
                    maxEUinputMax = hatch.maxEUInput();
                }
            }
            for (MTEHatchEnergyMulti hatch : filterValidMTEs(eEnergyMulti)) {
                if (hatch.maxEUInput() < maxEUinputMin) {
                    maxEUinputMin = hatch.maxEUInput();
                }
                if (hatch.maxEUInput() > maxEUinputMax) {
                    maxEUinputMax = hatch.maxEUInput();
                }
            }
            for (MTEHatchDynamo hatch : filterValidMTEs(mDynamoHatches)) {
                if (hatch.maxEUOutput() < maxEUoutputMin) {
                    maxEUoutputMin = hatch.maxEUOutput();
                }
                if (hatch.maxEUOutput() > maxEUoutputMax) {
                    maxEUoutputMax = hatch.maxEUOutput();
                }
            }
            for (MTEHatchDynamoMulti hatch : filterValidMTEs(eDynamoMulti)) {
                if (hatch.maxEUOutput() < maxEUoutputMin) {
                    maxEUoutputMin = hatch.maxEUOutput();
                }
                if (hatch.maxEUOutput() > maxEUoutputMax) {
                    maxEUoutputMax = hatch.maxEUOutput();
                }
            }
            eMaxAmpereFlow = 0;
            eMaxAmpereGen = 0;
            // counts only full amps
            for (MTEHatchEnergy hatch : filterValidMTEs(mEnergyHatches)) {
                eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin;
            }
            for (MTEHatchEnergyMulti hatch : filterValidMTEs(eEnergyMulti)) {
                eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes;
            }
            for (MTEHatchDynamo hatch : filterValidMTEs(mDynamoHatches)) {
                eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin;
            }
            for (MTEHatchDynamoMulti hatch : filterValidMTEs(eDynamoMulti)) {
                eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin * hatch.Amperes;
            }
        } else {
            maxEUinputMin = 0;
            maxEUinputMax = 0;
            eMaxAmpereFlow = 0;
            maxEUoutputMin = 0;
            maxEUoutputMax = 0;
            eMaxAmpereGen = 0;
        }
    }

    protected void dischargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) {
        if (ePowerPass && getEUVar() > getMinimumStoredEU()) {
            powerPass(aBaseMetaTileEntity);
        }
    }

    protected final void powerPass(IGregTechTileEntity aBaseMetaTileEntity) {
        long euVar;
        for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) {
            euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut();
            if (tHatch.getBaseMetaTileEntity()
                .getStoredEU() <= tHatch.maxEUStore() - euVar
                && aBaseMetaTileEntity
                    .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) {
                tHatch.setEUVar(
                    tHatch.getBaseMetaTileEntity()
                        .getStoredEU() + euVar);
            }
        }
        for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) {
            euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut();
            if (tHatch.getBaseMetaTileEntity()
                .getStoredEU() <= tHatch.maxEUStore() - euVar
                && aBaseMetaTileEntity
                    .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) {
                tHatch.setEUVar(
                    tHatch.getBaseMetaTileEntity()
                        .getStoredEU() + euVar);
            }
        }
    }

    protected final void powerPass_EM(IGregTechTileEntity aBaseMetaTileEntity) {
        long euVar;
        for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) {
            euVar = tHatch.maxEUOutput();
            if (tHatch.getBaseMetaTileEntity()
                .getStoredEU() <= tHatch.maxEUStore() - euVar
                && aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, 1), false)) {
                tHatch.setEUVar(
                    tHatch.getBaseMetaTileEntity()
                        .getStoredEU() + euVar);
            }
        }
        for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) {
            euVar = tHatch.maxEUOutput() * tHatch.Amperes;
            if (tHatch.getBaseMetaTileEntity()
                .getStoredEU() <= tHatch.maxEUStore() - euVar
                && aBaseMetaTileEntity
                    .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.Amperes), false)) {
                tHatch.setEUVar(
                    tHatch.getBaseMetaTileEntity()
                        .getStoredEU() + euVar);
            }
        }
    }

    protected void chargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) {
        powerInput();
    }

    protected final void powerInput() {
        long euVar;
        for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) {
            if (getEUVar() > getMinimumStoredEU()) {
                break;
            }
            euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar());
            if (tHatch.getBaseMetaTileEntity()
                .decreaseStoredEnergyUnits(euVar, false)) {
                setEUVar(getEUVar() + euVar);
            }
        }
        for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) {
            if (getEUVar() > getMinimumStoredEU()) {
                break;
            }
            euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar());
            if (tHatch.getBaseMetaTileEntity()
                .decreaseStoredEnergyUnits(euVar, false)) {
                setEUVar(getEUVar() + euVar);
            }
        }
    }

    protected final void powerInput_EM() {
        long euVar;
        for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) {
            if (getEUVar() > getMinimumStoredEU()) {
                break;
            }
            euVar = tHatch.maxEUInput();
            if (tHatch.getBaseMetaTileEntity()
                .decreaseStoredEnergyUnits(euVar, false)) {
                setEUVar(getEUVar() + euVar);
            }
        }
        for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) {
            if (getEUVar() > getMinimumStoredEU()) {
                break;
            }
            euVar = tHatch.maxEUInput() * tHatch.Amperes;
            if (tHatch.getBaseMetaTileEntity()
                .decreaseStoredEnergyUnits(euVar, false)) {
                setEUVar(getEUVar() + euVar);
            }
        }
    }

    // endregion

    // region EFFICIENCY AND FIXING LIMITS

    @Override
    public int getMaxEfficiency(ItemStack itemStack) {
        return 10000;
    }

    @Override
    public int getIdealStatus() {
        return super.getIdealStatus() + 2;
    }

    @Override
    public int getRepairStatus() {
        return super.getRepairStatus() + (eCertainStatus == 0 ? 1 : 0) + (eParameters ? 1 : 0);
    }

    // endregion

    // region ENERGY!!!!

    // new method
    public boolean energyFlowOnRunningTick_EM(ItemStack aStack, boolean allowProduction) {
        long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign
        if (allowProduction && euFlow > 0) {
            addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow);
        } else if (euFlow < 0) {
            if (TecTechConfig.POWERLESS_MODE) {
                return true;
            }
            if (!drainEnergyInput_EM(
                getPowerFlow(),
                getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency),
                eAmpereFlow)) {
                criticalStopMachine();
                return false;
            }
        }
        return true;
    }

    public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) {
        long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign
        if (allowProduction && euFlow > 0) {
            addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow);
        } else if (euFlow < 0) {
            if (TecTechConfig.POWERLESS_MODE) {
                return true;
            }
            if (!drainEnergyInput(
                getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency),
                eAmpereFlow)) {
                stopMachine(ShutDownReasonRegistry.POWER_LOSS);
                return false;
            }
        }
        return true;
    }

    @Override
    public long maxEUStore() {
        return Math.max(maxEUinputMin * (eMaxAmpereFlow << 3), maxEUoutputMin * (eMaxAmpereGen << 3));
    }

    @Override
    public final long getMinimumStoredEU() {
        return maxEUStore() >> 1;
    }

    @Override
    public final long maxAmperesIn() {
        return 0L;
    }

    @Override
    public final long maxAmperesOut() {
        return 0L;
    }

    @Deprecated
    @Override
    public final boolean addEnergyOutput(long eu) {
        return addEnergyOutput_EM(eu, 1);
    }

    public boolean addEnergyOutput_EM(long EU, long Amperes) {
        if (EU < 0) {
            EU = -EU;
        }
        if (Amperes < 0) {
            Amperes = -Amperes;
        }
        long euVar = EU * Amperes;
        long diff;
        for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) {
            if (tHatch.maxEUOutput() < EU) {
                explodeMultiblock();
            }
            diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity()
                .getStoredEU();
            if (diff > 0) {
                if (euVar > diff) {
                    tHatch.setEUVar(tHatch.maxEUStore());
                    euVar -= diff;
                } else if (euVar <= diff) {
                    tHatch.setEUVar(
                        tHatch.getBaseMetaTileEntity()
                            .getStoredEU() + euVar);
                    return true;
                }
            }
        }
        for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) {
            if (tHatch.maxEUOutput() < EU) {
                explodeMultiblock();
            }
            diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity()
                .getStoredEU();
            if (diff > 0) {
                if (euVar > diff) {
                    tHatch.setEUVar(tHatch.maxEUStore());
                    euVar -= diff;
                } else if (euVar <= diff) {
                    tHatch.setEUVar(
                        tHatch.getBaseMetaTileEntity()
                            .getStoredEU() + euVar);
                    return true;
                }
            }
        }
        setEUVar(min(getEUVar() + euVar, maxEUStore()));
        return false;
    }

    @Deprecated
    @Override
    public final boolean drainEnergyInput(long eu) {
        return drainEnergyInput_EM(0, eu, 1);
    }

    public boolean drainEnergyInput_EM(long EUtTierVoltage, long EUtEffective, long Amperes) {
        long EUuse = EUtEffective * Amperes;
        if (EUuse == 0) {
            return true;
        }
        if (maxEUinputMin == 0) {
            return false;
        }
        if (EUuse < 0) {
            EUuse = -EUuse;
        }
        if (EUuse > getEUVar() || // not enough power
            (EUtTierVoltage == 0 ? EUuse > getMaxInputEnergy() : (EUtTierVoltage > maxEUinputMax) || // TIER IS
                                                                                                     // BASED ON
                                                                                                     // BEST HATCH!
                                                                                                     // not total
                                                                                                     // EUtEffective
                                                                                                     // input
                (EUtTierVoltage * Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)) { // EUuse==0? --> (EUuse
                                                                                        // - 1) / maxEUinputMin
                                                                                        // + 1 = 1! //if
            // not too much A
            if (TecTechConfig.DEBUG_MODE) {
                TecTech.LOGGER.debug("L1 " + EUuse + ' ' + getEUVar() + ' ' + (EUuse > getEUVar()));
                TecTech.LOGGER.debug("L2 " + EUtEffective + ' ' + maxEUinputMax + ' ' + (EUtEffective > maxEUinputMax));
                TecTech.LOGGER.debug("L3 " + Amperes + ' ' + getMaxInputEnergy());
                TecTech.LOGGER.debug(
                    "L4 " + ((EUuse - 1) / maxEUinputMin + 1)
                        + ' '
                        + eMaxAmpereFlow
                        + ' '
                        + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow));
            }
            return false;
        }
        // sub eu
        setEUVar(getEUVar() - EUuse);
        return true;
    }

    public boolean drainEnergyInput(long EUtEffective, long Amperes) {
        long EUuse = EUtEffective * Amperes;
        if (EUuse == 0) {
            return true;
        }
        if (maxEUinputMin == 0) {
            return false;
        }
        if (EUuse < 0) {
            EUuse = -EUuse;
        }
        // not enough power
        if (EUuse > getEUVar() || EUuse > getMaxInputEnergy()) { // EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1!
                                                                 // //if not too much
            // A
            return false;
        }
        // sub eu
        setEUVar(getEUVar() - EUuse);
        return true;
    }

    // new method
    public final boolean overclockAndPutValuesIn_EM(long EU, int time) { // TODO revise
        if (EU == 0L) {
            setPowerFlow(0);
            mMaxProgresstime = time;
            return true;
        }
        long tempEUt = Math.max(EU, V[1]);
        long tempTier = maxEUinputMax >> 2;
        while (tempEUt < tempTier) {
            tempEUt <<= 2;
            time >>= 1;
            EU = time == 0 ? EU >> 1 : EU << 2; // U know, if the time is less than 1 tick make the machine use less
                                                // power
        }
        if (EU > Integer.MAX_VALUE || EU < Integer.MIN_VALUE) {
            setPowerFlow(Integer.MAX_VALUE - 1);
            mMaxProgresstime = Integer.MAX_VALUE - 1;
            return false;
        }
        setPowerFlow(EU);
        mMaxProgresstime = time == 0 ? 1 : time;
        return true;
    } // Use in EM check recipe return statement if you want overclocking

    /**
     * Use {@link #getMaxInputVoltage()}
     */
    @Deprecated
    public final long getMaxInputVoltageSum() {
        return getMaxInputVoltage();
    }

    /**
     * Use {@link #getMaxInputEu()}
     */
    @Deprecated
    public final long getMaxInputEnergy() {
        return getMaxInputEu();
    }

    /**
     * Use {@link #getMaxInputEu()}
     */
    @Deprecated
    public final long getMaxInputEnergy_EM() {
        return getMaxInputEu();
    }

    // new Method
    public final int getMaxEnergyInputTier_EM() {
        return TTUtility.getTier(maxEUinputMax);
    }

    // new Method
    public final int getMinEnergyInputTier_EM() {
        return TTUtility.getTier(maxEUinputMin);
    }

    public final long getMaxAmpereFlowAtMinTierOfEnergyHatches() {
        return eAmpereFlow;
    }

    @Override
    public List<MTEHatch> getExoticAndNormalEnergyHatchList() {
        List<MTEHatch> list = new ArrayList<>();
        list.addAll(mEnergyHatches);
        list.addAll(eEnergyMulti);
        return list;
    }

    @Override
    public List<MTEHatch> getExoticEnergyHatches() {
        List<MTEHatch> list = new ArrayList<>();
        list.addAll(eEnergyMulti);
        return list;
    }

    @Override
    public boolean explodesOnComponentBreak(ItemStack itemStack) {
        return false;
    }

    @Override
    public final void explodeMultiblock() {
        if (explodedThisTick) {
            return;
        }
        explodedThisTick = true;
        if (!TecTech.configTecTech.BOOM_ENABLE) {
            TecTech.proxy.broadcast(
                "Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord()
                    + ' '
                    + getBaseMetaTileEntity().getYCoord()
                    + ' '
                    + getBaseMetaTileEntity().getZCoord());
            StackTraceElement[] ste = Thread.currentThread()
                .getStackTrace();
            TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString());
            return;
        }
        extraExplosions_EM();
        Pollution.addPollution(getBaseMetaTileEntity(), 600000);
        mInventory[1] = null;
        @SuppressWarnings("unchecked")
        Iterable<MetaTileEntity> allHatches = Iterables.concat(
            mInputBusses,
            mOutputBusses,
            mInputHatches,
            mOutputHatches,
            mDynamoHatches,
            mMufflerHatches,
            mEnergyHatches,
            mMaintenanceHatches,
            eParamHatches,
            eEnergyMulti,
            eUncertainHatches,
            eDynamoMulti,
            eInputData,
            eOutputData);
        for (MetaTileEntity tTileEntity : allHatches) {
            if (tTileEntity != null && tTileEntity.getBaseMetaTileEntity() != null) {
                tTileEntity.getBaseMetaTileEntity()
                    .doExplosion(V[9]);
            }
        }
        getBaseMetaTileEntity().doExplosion(V[15]);
    }

    @Override
    public void doExplosion(long aExplosionPower) {
        if (!TecTech.configTecTech.BOOM_ENABLE) {
            TecTech.proxy.broadcast(
                "Multi DoExplosion BOOM! " + getBaseMetaTileEntity().getXCoord()
                    + ' '
                    + getBaseMetaTileEntity().getYCoord()
                    + ' '
                    + getBaseMetaTileEntity().getZCoord());
            StackTraceElement[] ste = Thread.currentThread()
                .getStackTrace();
            TecTech.proxy.broadcast("Multi DoExplosion BOOM! " + ste[2].toString());
            return;
        }
        explodeMultiblock();
        super.doExplosion(aExplosionPower);
    } // Redirecting to explodemultiblock
      // endregion

    // region adder methods
    @Override
    public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatch) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
        }
        if (aMetaTileEntity instanceof IDualInputHatch) {
            return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInput) {
            return mInputHatches.add((MTEHatchInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInputBus) {
            return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchOutput) {
            return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchOutputBus) {
            return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergy) {
            return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamo) {
            return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchMaintenance) {
            return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchMuffler) {
            return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchParam) {
            return eParamHatches.add((MTEHatchParam) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchUncertainty) {
            return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergyMulti) {
            return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamoMulti) {
            return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDataInput) {
            return eInputData.add((MTEHatchDataInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDataOutput) {
            return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity);
        }
        return false;
    }

    public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatch) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
        }
        if (aMetaTileEntity instanceof IDualInputHatch) {
            return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInput) {
            return mInputHatches.add((MTEHatchInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInputBus) {
            return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchOutput) {
            return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchOutputBus) {
            return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergy) {
            return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamo) {
            return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchMaintenance) {
            return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchMuffler) {
            return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchParam) {
            return eParamHatches.add((MTEHatchParam) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchUncertainty) {
            return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergyMulti) {
            return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamoMulti) {
            return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDataInput) {
            return eInputData.add((MTEHatchDataInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDataOutput) {
            return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity);
        }
        return false;
    }

    public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatch) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
        }

        return false;
    }

    public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }

        return false;
    }

    @Override
    public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchMuffler) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity);
        }

        return false;
    }

    @Override
    public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof IDualInputHatch) {
            ((IDualInputHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInput) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            ((MTEHatchInput) aMetaTileEntity).mRecipeMap = getRecipeMap();
            return mInputHatches.add((MTEHatchInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchInputBus) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            ((MTEHatchInputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
            return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity);
        }

        return false;
    }

    @Override
    public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchOutput) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchOutputBus) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity);
        }

        return false;
    }

    @Deprecated
    @Override
    public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchEnergy) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergyMulti) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity);
        }
        return false;
    }

    @Deprecated
    @Override
    public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchDynamo) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamoMulti) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity);
        }
        return false;
    }

    // New Method
    public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchEnergy) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchEnergyMulti) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamo) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDynamoMulti) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity);
        }
        return false;
    }

    // NEW METHOD
    public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }

        return false;
    }

    // NEW METHOD
    public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }

        return false;
    }

    // NEW METHOD
    public final boolean addParametrizerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchParam) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eParamHatches.add((MTEHatchParam) aMetaTileEntity);
        }
        return false;
    }

    // NEW METHOD
    public final boolean addUncertainToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchUncertainty) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity);
        }
        return false;
    }

    @Override
    public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchMaintenance) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchParam) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eParamHatches.add((MTEHatchParam) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchUncertainty) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity);
        }
        return false;
    }

    // NEW METHOD
    public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchMaintenance) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity);
        }
        return false;
    }

    // NEW METHOD
    public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
        if (aTileEntity == null) {
            return false;
        }
        IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
        if (aMetaTileEntity == null) {
            return false;
        }
        if (aMetaTileEntity instanceof MTEHatchDataInput) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eInputData.add((MTEHatchDataInput) aMetaTileEntity);
        }
        if (aMetaTileEntity instanceof MTEHatchDataOutput) {
            ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
            return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity);
        }
        return false;
    }
    // endregion

    protected static <T extends TTMultiblockBase> IStructureElement<T> classicHatches(int casingIndex, int dot,
        Block casingBlock, int casingMeta) {
        return HatchElementBuilder.<T>builder()
            .atLeast(
                InputBus,
                InputHatch,
                OutputHatch,
                OutputBus,
                Maintenance,
                Muffler,
                HatchElement.EnergyMulti,
                HatchElement.DynamoMulti,
                HatchElement.InputData,
                HatchElement.OutputData,
                HatchElement.Uncertainty)
            .casingIndex(casingIndex)
            .dot(dot)
            .buildAndChain(casingBlock, casingMeta);
    }

    protected static <T extends TTMultiblockBase> IStructureElement<T> allHatches(int casingIndex, int dot,
        Block casingBlock, int casingMeta) {
        return HatchElementBuilder.<T>builder()
            .atLeast(
                InputBus,
                InputHatch,
                OutputHatch,
                OutputBus,
                Maintenance,
                Muffler,
                HatchElement.EnergyMulti,
                HatchElement.DynamoMulti,
                HatchElement.InputData,
                HatchElement.OutputData,
                HatchElement.Uncertainty)
            .casingIndex(casingIndex)
            .dot(dot)
            .buildAndChain(casingBlock, casingMeta);
    }

    public enum HatchElement implements IHatchElement<TTMultiblockBase> {

        Param(TTMultiblockBase::addParametrizerToMachineList, MTEHatchParam.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eParamHatches.size();
            }
        },
        Uncertainty(TTMultiblockBase::addUncertainToMachineList, MTEHatchUncertainty.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eUncertainHatches.size();
            }
        },
        EnergyMulti(TTMultiblockBase::addEnergyInputToMachineList, MTEHatchEnergyMulti.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eEnergyMulti.size();
            }
        },
        DynamoMulti(TTMultiblockBase::addDynamoToMachineList, MTEHatchDynamoMulti.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eDynamoMulti.size();
            }
        },
        InputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataInput.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eInputData.size();
            }
        },
        OutputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataOutput.class) {

            @Override
            public long count(TTMultiblockBase t) {
                return t.eOutputData.size();
            }
        },;

        private final List<Class<? extends IMetaTileEntity>> mteClasses;
        private final IGTHatchAdder<TTMultiblockBase> adder;

        @SafeVarargs
        HatchElement(IGTHatchAdder<TTMultiblockBase> adder, Class<? extends IMetaTileEntity>... mteClasses) {
            this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses));
            this.adder = adder;
        }

        @Override
        public List<? extends Class<? extends IMetaTileEntity>> mteClasses() {
            return mteClasses;
        }

        public IGTHatchAdder<? super TTMultiblockBase> adder() {
            return adder;
        }
    }

    /**
     * Check if the computation timeout is still active
     *
     * @return True if the timeout is still active or false if the machine should fail
     */
    protected boolean checkComputationTimeout() {
        if (eComputationTimeout > 0) {
            return --eComputationTimeout > 0;
        }
        return false;
    }

    // region ModularUI

    @Override
    public int getGUIWidth() {
        return 198;
    }

    @Override
    public int getGUIHeight() {
        return 192;
    }

    @Override
    public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) {
        builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(7, 109), getGUITextureSet().getItemSlot());
    }

    public boolean isPowerPassButtonEnabled() {
        return true;
    }

    public boolean isSafeVoidButtonEnabled() {
        return true;
    }

    public boolean isAllowedToWorkButtonEnabled() {
        return true;
    }

    @Override
    public void addGregTechLogo(ModularWindow.Builder builder) {
        builder.widget(
            new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK)
                .setSize(18, 18)
                .setPos(173, 74));
    }

    private static byte LEDCounter = 0;

    @Override
    public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
        if (doesBindPlayerInventory()) {
            builder.widget(
                new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE)
                    .setPos(4, 4)
                    .setSize(190, 91));
        } else {
            builder.widget(
                new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY)
                    .setPos(4, 4)
                    .setSize(190, 171));
        }
        final SlotWidget inventorySlot = new SlotWidget(new BaseSlot(inventoryHandler, 1) {

            @Override
            public int getSlotStackLimit() {
                return getInventoryStackLimit();
            }
        });
        if (doesBindPlayerInventory()) {
            builder
                .widget(
                    inventorySlot.setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_MESH)
                        .setPos(173, 167))
                .widget(
                    new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL)
                        .setPos(173, 185)
                        .setSize(18, 6));
        }

        final DynamicPositionedColumn screenElements = new DynamicPositionedColumn();
        drawTexts(screenElements, inventorySlot);
        builder.widget(
            new Scrollable().setVerticalScroll()
                .widget(screenElements)
                .setPos(0, 7)
                .setSize(190, doesBindPlayerInventory() ? 79 : 165));

        Widget powerPassButton = createPowerPassButton();
        builder.widget(powerPassButton)
            .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPass, val -> ePowerPass = val))
            .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPassCover, val -> ePowerPassCover = val));
        Widget safeVoidButton = createSafeVoidButton();
        builder.widget(safeVoidButton)
            .widget(new FakeSyncWidget.BooleanSyncer(() -> eSafeVoid, val -> eSafeVoid = val));
        Widget powerSwitchButton = createPowerSwitchButton();
        builder.widget(powerSwitchButton)
            .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> {
                if (val) getBaseMetaTileEntity().enableWorking();
                else getBaseMetaTileEntity().disableWorking();
            }));

        builder.widget(new DrawableWidget() {

            @Override
            public void draw(float partialTicks) {
                super.draw(partialTicks);
                LEDCounter = (byte) ((1 + LEDCounter) % 6);
            }
        }.setDrawable(TecTechUITextures.PICTURE_PARAMETER_BLANK)
            .setPos(5, doesBindPlayerInventory() ? 96 : 176)
            .setSize(166, 12));
        for (int hatch = 0; hatch < 10; hatch++) {
            for (int param = 0; param < 2; param++) {
                int ledID = hatch + param * 10;
                buildContext
                    .addSyncedWindow(LED_WINDOW_BASE_ID + ledID, (player) -> createLEDConfigurationWindow(ledID));
                addParameterLED(builder, hatch, param, true);
                addParameterLED(builder, hatch, param, false);
            }
        }

        if (doesBindPlayerInventory()) {
            builder.widget(
                new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE)
                    .setPos(173, 96)
                    .setSize(18, 18));
            for (int i = 0; i < 9; i++) {
                final int index = i;
                builder.widget(new DrawableWidget().setDrawable(() -> {
                    UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index];
                    UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index];
                    switch (eCertainMode) {
                        case 1: // ooo oxo ooo
                            if (index == 4) return eCertainStatus == 0 ? valid : invalid;
                            break;
                        case 2: // ooo xox ooo
                            if (index == 3) return (eCertainStatus & 1) == 0 ? valid : invalid;
                            if (index == 5) return (eCertainStatus & 2) == 0 ? valid : invalid;
                            break;
                        case 3: // oxo xox oxo
                            if (index == 1) return (eCertainStatus & 1) == 0 ? valid : invalid;
                            if (index == 3) return (eCertainStatus & 2) == 0 ? valid : invalid;
                            if (index == 5) return (eCertainStatus & 4) == 0 ? valid : invalid;
                            if (index == 7) return (eCertainStatus & 8) == 0 ? valid : invalid;
                            break;
                        case 4: // xox ooo xox
                            if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid;
                            if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid;
                            if (index == 6) return (eCertainStatus & 4) == 0 ? valid : invalid;
                            if (index == 8) return (eCertainStatus & 8) == 0 ? valid : invalid;
                            break;
                        case 5: // xox oxo xox
                            if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid;
                            if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid;
                            if (index == 4) return (eCertainStatus & 4) == 0 ? valid : invalid;
                            if (index == 6) return (eCertainStatus & 8) == 0 ? valid : invalid;
                            if (index == 8) return (eCertainStatus & 16) == 0 ? valid : invalid;
                            break;
                    }
                    return null;
                })
                    .setPos(174 + (index % 3) * 6, 97 + (index / 3) * 6)
                    .setSize(4, 4));
            }
            builder.widget(new FakeSyncWidget.ByteSyncer(() -> eCertainMode, val -> eCertainMode = val))
                .widget(new FakeSyncWidget.ByteSyncer(() -> eCertainStatus, val -> eCertainStatus = val));
        }
    }

    protected ButtonWidget createPowerPassButton() {
        Widget button = new ButtonWidget().setOnClick((clickData, widget) -> {
            if (isPowerPassButtonEnabled() || ePowerPassCover) {
                TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click");
                ePowerPass = !ePowerPass;
                if (!isAllowedToWorkButtonEnabled()) { // TRANSFORMER HACK
                    if (ePowerPass) {
                        getBaseMetaTileEntity().enableWorking();
                    } else {
                        getBaseMetaTileEntity().disableWorking();
                    }
                }
            }
        })
            .setPlayClickSound(false)
            .setBackground(() -> {
                List<UITexture> ret = new ArrayList<>();
                ret.add(TecTechUITextures.BUTTON_STANDARD_16x16);
                if (!isPowerPassButtonEnabled() && !ePowerPassCover) {
                    ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_DISABLED);
                } else {
                    if (ePowerPass) {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON);
                    } else {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_OFF);
                    }
                }
                return ret.toArray(new IDrawable[0]);
            })
            .setPos(174, doesBindPlayerInventory() ? 116 : 140)
            .setSize(16, 16);
        if (isPowerPassButtonEnabled()) {
            button.addTooltip("Power Pass")
                .setTooltipShowUpDelay(TOOLTIP_DELAY);
        }
        return (ButtonWidget) button;
    }

    protected ButtonWidget createSafeVoidButton() {
        Widget button = new ButtonWidget().setOnClick((clickData, widget) -> {
            if (isSafeVoidButtonEnabled()) {
                TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click");
                eSafeVoid = !eSafeVoid;
            }
        })
            .setPlayClickSound(false)
            .setBackground(() -> {
                List<UITexture> ret = new ArrayList<>();
                ret.add(TecTechUITextures.BUTTON_STANDARD_16x16);
                if (!isSafeVoidButtonEnabled()) {
                    ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_DISABLED);
                } else {
                    if (eSafeVoid) {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_ON);
                    } else {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_OFF);
                    }
                }
                return ret.toArray(new IDrawable[0]);
            })
            .setPos(174, doesBindPlayerInventory() ? 132 : 156)
            .setSize(16, 16);
        if (isSafeVoidButtonEnabled()) {
            button.addTooltip("Safe Void")
                .setTooltipShowUpDelay(TOOLTIP_DELAY);
        }
        return (ButtonWidget) button;
    }

    protected ButtonWidget createPowerSwitchButton() {
        Widget button = new ButtonWidget().setOnClick((clickData, widget) -> {
            if (isAllowedToWorkButtonEnabled()) {
                TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click");
                if (getBaseMetaTileEntity().isAllowedToWork()) {
                    getBaseMetaTileEntity().disableWorking();
                } else {
                    getBaseMetaTileEntity().enableWorking();
                }
            }
        })
            .setPlayClickSound(false)
            .setBackground(() -> {
                List<UITexture> ret = new ArrayList<>();
                ret.add(TecTechUITextures.BUTTON_STANDARD_16x16);
                if (!isAllowedToWorkButtonEnabled()) {
                    ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED);
                } else {
                    if (getBaseMetaTileEntity().isAllowedToWork()) {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON);
                    } else {
                        ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF);
                    }
                }
                return ret.toArray(new IDrawable[0]);
            })
            .setPos(174, doesBindPlayerInventory() ? 148 : 172)
            .setSize(16, 16);
        if (isAllowedToWorkButtonEnabled()) {
            button.addTooltip("Power Switch")
                .setTooltipShowUpDelay(TOOLTIP_DELAY);
        }
        return (ButtonWidget) button;
    }

    private ModularWindow createLEDConfigurationWindow(int ledID) {
        return ModularWindow.builder(100, 40)
            .setBackground(TecTechUITextures.BACKGROUND_SCREEN_BLUE)
            .setPos(
                (screenSize, mainWindow) -> new Pos2d(
                    (screenSize.width / 2 - mainWindow.getSize().width / 2) - 110,
                    (screenSize.height / 2 - mainWindow.getSize().height / 2)))
            .widget(
                ButtonWidget.closeWindowButton(true)
                    .setPos(85, 3))
            .widget(
                new NumericWidget().setGetter(() -> parametrization.iParamsIn[ledID])
                    .setSetter(val -> parametrization.iParamsIn[ledID] = val)
                    .setIntegerOnly(false)
                    .modifyNumberFormat(format -> format.setMaximumFractionDigits(8))
                    .setTextColor(Color.LIGHT_BLUE.normal)
                    .setTextAlignment(Alignment.CenterLeft)
                    .setFocusOnGuiOpen(true)
                    .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)
                    .setPos(5, 20)
                    .setSize(90, 15))
            .widget(
                new TextWidget((ledID % 10) + ":" + (ledID / 10) + ":I").setDefaultColor(Color.WHITE.normal)
                    .setTextAlignment(Alignment.Center)
                    .setPos(5, 5))
            .build();
    }

    private void addParameterLED(ModularWindow.Builder builder, int hatch, int param, boolean input) {
        final int parameterIndex = hatch + param * 10;
        final int posIndex = hatch * 2 + param;
        ButtonWidget ledWidget = new ButtonWidget() {

            @Override
            public void draw(float partialTicks) {
                IDrawable texture = null;
                final LedStatus status = input ? parametrization.eParamsInStatus[parameterIndex]
                    : parametrization.eParamsOutStatus[parameterIndex];
                switch (status) {
                    case STATUS_WTF: {
                        int c = LEDCounter;
                        if (c > 4) {
                            c = TecTech.RANDOM.nextInt(5);
                        }
                        switch (c) {
                            case 0:
                                texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex];
                                break;
                            case 1:
                                texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex];
                                break;
                            case 2:
                                texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex];
                                break;
                            case 3:
                                texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex];
                                break;
                            case 4:
                                texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex];
                                break;
                        }
                        break;
                    }
                    case STATUS_WRONG: // fallthrough
                        if (LEDCounter < 2) {
                            texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex];
                            break;
                        } else if (LEDCounter < 4) {
                            texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex];
                            break;
                        }
                    case STATUS_OK: // ok
                        texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex];
                        break;
                    case STATUS_TOO_LOW: // too low blink
                        if (LEDCounter < 3) {
                            texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex];
                            break;
                        }
                    case STATUS_LOW: // too low
                        texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex];
                        break;
                    case STATUS_TOO_HIGH: // too high blink
                        if (LEDCounter < 3) {
                            texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex];
                            break;
                        }
                    case STATUS_HIGH: // too high
                        texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex];
                        break;
                    case STATUS_NEUTRAL:
                        if (LEDCounter < 3) {
                            GL11.glColor4f(.85f, .9f, .95f, .5F);
                        } else {
                            GL11.glColor4f(.8f, .9f, 1f, .5F);
                        }
                        texture = TecTechUITextures.PICTURE_PARAMETER_GRAY;
                        break;
                    case STATUS_UNDEFINED:
                        if (LEDCounter < 3) {
                            GL11.glColor4f(.5f, .1f, .15f, .5F);
                        } else {
                            GL11.glColor4f(0f, .1f, .2f, .5F);
                        }
                        texture = TecTechUITextures.PICTURE_PARAMETER_GRAY;
                        break;
                    case STATUS_UNUSED:
                    default:
                        // no-op
                        break;
                }
                setBackground(texture);
                super.draw(partialTicks);
                GL11.glColor4f(1f, 1f, 1f, 1f);
            }
        }.setOnClick((clickData, widget) -> {
            if (!widget.isClient() && input
                && parametrization.eParamsInStatus[parameterIndex] != LedStatus.STATUS_UNUSED) {
                // We don't use CloseAllButMain here in case MB implementation adds their own window
                for (int i = 0; i < parametrization.eParamsInStatus.length; i++) {
                    if (widget.getContext()
                        .isWindowOpen(LED_WINDOW_BASE_ID + i)) {
                        widget.getContext()
                            .closeWindow(LED_WINDOW_BASE_ID + i);
                    }
                }
                widget.getContext()
                    .openSyncedWindow(LED_WINDOW_BASE_ID + parameterIndex);
            }
        });
        builder.widget(ledWidget.dynamicTooltip(() -> {
            if (input) {
                return getFullLedDescriptionIn(hatch, param);
            } else {
                return getFullLedDescriptionOut(hatch, param);
            }
        })
            .setPos(12 + posIndex * 8, (doesBindPlayerInventory() ? 97 : 177) + (input ? 0 : 1) * 6)
            .setSize(6, 4));
        if (input) {
            builder
                .widget(
                    new FakeSyncWidget.ByteSyncer(
                        () -> parametrization.eParamsInStatus[parameterIndex].getOrdinalByte(),
                        val -> parametrization.eParamsInStatus[parameterIndex] = LedStatus.getStatus(val))
                            .setOnClientUpdate(val -> ledWidget.notifyTooltipChange()))
                .widget(
                    new FakeSyncWidget.DoubleSyncer(
                        () -> parametrization.iParamsIn[parameterIndex],
                        val -> parametrization.iParamsIn[parameterIndex] = val)
                            .setOnClientUpdate(val -> ledWidget.notifyTooltipChange()));
        } else {
            builder
                .widget(
                    new FakeSyncWidget.ByteSyncer(
                        () -> parametrization.eParamsOutStatus[parameterIndex].getOrdinalByte(),
                        val -> parametrization.eParamsOutStatus[parameterIndex] = LedStatus.getStatus(val))
                            .setOnClientUpdate(val -> ledWidget.notifyTooltipChange()))
                .widget(
                    new FakeSyncWidget.DoubleSyncer(
                        () -> parametrization.iParamsOut[parameterIndex],
                        val -> parametrization.iParamsOut[parameterIndex] = val)
                            .setOnClientUpdate(val -> ledWidget.notifyTooltipChange()));
        }
    }

    // endregion
}