15
15
import gregtech .api .mui .sync .BigIntegerSyncValue ;
16
16
import gregtech .api .pattern .*;
17
17
import gregtech .api .util .BlockInfo ;
18
- import gregtech .api .util .TextComponentUtil ;
18
+ import gregtech .api .util .KeyUtil ;
19
19
import gregtech .api .util .TextFormattingUtil ;
20
20
import gregtech .client .renderer .ICubeRenderer ;
21
21
import gregtech .client .renderer .texture .Textures ;
34
34
import net .minecraft .network .PacketBuffer ;
35
35
import net .minecraft .util .EnumFacing ;
36
36
import net .minecraft .util .ResourceLocation ;
37
- import net .minecraft .util .text .ITextComponent ;
38
- import net .minecraft .util .text .TextComponentTranslation ;
39
37
import net .minecraft .util .text .TextFormatting ;
40
38
import net .minecraft .world .World ;
41
39
import net .minecraftforge .common .capabilities .Capability ;
@@ -332,112 +330,83 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation,
332
330
}
333
331
334
332
@ Override
335
- protected void addDisplayText (List <ITextComponent > textList ) {
336
- MultiblockDisplayText .builder (textList , isStructureFormed ())
337
- .setWorkingStatus (true , isActive () && isWorkingEnabled ()) // transform into two-state system for display
338
- .setWorkingStatusKeys (
339
- "gregtech.multiblock.idling" ,
340
- "gregtech.multiblock.idling" ,
341
- "gregtech.machine.active_transformer.routing" )
342
- .addCustom (tl -> {
343
- if (isStructureFormed () && energyBank != null ) {
344
- BigInteger energyStored = energyBank .getStored ();
345
- BigInteger energyCapacity = energyBank .getCapacity ();
346
-
347
- // Stored EU line
348
- ITextComponent storedFormatted = TextComponentUtil .stringWithColor (
349
- TextFormatting .GOLD ,
350
- TextFormattingUtil .formatNumbers (energyStored ) + " EU" );
351
- tl .add (TextComponentUtil .translationWithColor (
352
- TextFormatting .GRAY ,
353
- "gregtech.multiblock.power_substation.stored" ,
354
- storedFormatted ));
355
-
356
- // EU Capacity line
357
- ITextComponent capacityFormatted = TextComponentUtil .stringWithColor (
358
- TextFormatting .GOLD ,
359
- TextFormattingUtil .formatNumbers (energyCapacity ) + " EU" );
360
- tl .add (TextComponentUtil .translationWithColor (
361
- TextFormatting .GRAY ,
362
- "gregtech.multiblock.power_substation.capacity" ,
363
- capacityFormatted ));
364
-
365
- // Passive Drain line
366
- ITextComponent passiveDrain = TextComponentUtil .stringWithColor (
367
- TextFormatting .DARK_RED ,
368
- TextFormattingUtil .formatNumbers (getPassiveDrain ()) + " EU/t" );
369
- tl .add (TextComponentUtil .translationWithColor (
370
- TextFormatting .GRAY ,
371
- "gregtech.multiblock.power_substation.passive_drain" ,
372
- passiveDrain ));
373
-
374
- // Average EU IN line
375
- ITextComponent avgValue = TextComponentUtil .stringWithColor (
376
- TextFormatting .GREEN ,
377
- TextFormattingUtil .formatNumbers (averageInLastSec ) + " EU/t" );
378
- ITextComponent base = TextComponentUtil .translationWithColor (
379
- TextFormatting .GRAY ,
380
- "gregtech.multiblock.power_substation.average_in" ,
381
- avgValue );
382
- ITextComponent hover = TextComponentUtil .translationWithColor (
383
- TextFormatting .GRAY ,
384
- "gregtech.multiblock.power_substation.average_in_hover" );
385
- tl .add (TextComponentUtil .setHover (base , hover ));
386
-
387
- // Average EU OUT line
388
- avgValue = TextComponentUtil .stringWithColor (
389
- TextFormatting .RED ,
390
- TextFormattingUtil .formatNumbers (averageOutLastSec ) + " EU/t" );
391
- base = TextComponentUtil .translationWithColor (
392
- TextFormatting .GRAY ,
393
- "gregtech.multiblock.power_substation.average_out" ,
394
- avgValue );
395
- hover = TextComponentUtil .translationWithColor (
396
- TextFormatting .GRAY ,
397
- "gregtech.multiblock.power_substation.average_out_hover" );
398
- tl .add (TextComponentUtil .setHover (base , hover ));
399
-
400
- // Time to fill/drain line
401
- if (averageInLastSec > averageOutLastSec ) {
402
- ITextComponent timeToFill = getTimeToFillDrainText (energyCapacity .subtract (energyStored )
403
- .divide (BigInteger .valueOf ((averageInLastSec - averageOutLastSec ) * 20 )));
404
- TextComponentUtil .setColor (timeToFill , TextFormatting .GREEN );
405
- tl .add (TextComponentUtil .translationWithColor (
406
- TextFormatting .GRAY ,
407
- "gregtech.multiblock.power_substation.time_to_fill" ,
408
- timeToFill ));
409
- } else if (averageInLastSec < averageOutLastSec ) {
410
- ITextComponent timeToDrain = getTimeToFillDrainText (
411
- energyStored .divide (BigInteger .valueOf (
412
- (averageOutLastSec - averageInLastSec ) * 20 )));
413
- TextComponentUtil .setColor (timeToDrain , TextFormatting .RED );
414
- tl .add (TextComponentUtil .translationWithColor (
415
- TextFormatting .GRAY ,
416
- "gregtech.multiblock.power_substation.time_to_drain" ,
417
- timeToDrain ));
418
- }
419
- }
420
- })
421
- .addWorkingStatusLine ();
333
+ protected void configureDisplayText (MultiblockUIFactory .Builder builder ) {
334
+ builder .structureFormed (isStructureFormed ());
335
+ builder .setWorkingStatus (true , isActive () && isWorkingEnabled ()); // transform into two-state system for display
336
+ builder .setWorkingStatusKeys ("gregtech.multiblock.idling" , "gregtech.multiblock.idling" ,
337
+ "gregtech.machine.active_transformer.routing" );
338
+ builder .addCustom (list -> {
339
+ if (isStructureFormed () && energyBank != null ) {
340
+ BigInteger energyStored = energyBank .getStored ();
341
+ BigInteger energyCapacity = energyBank .getCapacity ();
342
+
343
+ // Stored EU line
344
+ IKey storedFormatted = KeyUtil .string (TextFormatting .GOLD ,
345
+ TextFormattingUtil .formatNumbers (energyStored ) + " EU" );
346
+ list .add (KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.stored" ,
347
+ storedFormatted ));
348
+
349
+ // EU Capacity line
350
+ IKey capacityFormatted = KeyUtil .string (TextFormatting .GOLD ,
351
+ TextFormattingUtil .formatNumbers (energyCapacity ) + " EU" );
352
+ list .add (KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.capacity" ,
353
+ capacityFormatted ));
354
+
355
+ // Passive Drain line
356
+ IKey passiveDrain = KeyUtil .string (TextFormatting .DARK_RED ,
357
+ TextFormattingUtil .formatNumbers (getPassiveDrain ()) + " EU/t" );
358
+ list .add (KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.passive_drain" ,
359
+ passiveDrain ));
360
+
361
+ // Average EU IN line
362
+ IKey avgValue = KeyUtil .string (TextFormatting .GREEN ,
363
+ TextFormattingUtil .formatNumbers (averageInLastSec ) + " EU/t" );
364
+ IKey base = KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.average_in" ,
365
+ avgValue );
366
+ IKey hover = KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.average_in_hover" );
367
+ list .add (KeyUtil .setHover (base , hover ));
368
+
369
+ // Average EU OUT line
370
+ avgValue = KeyUtil .string (TextFormatting .RED ,
371
+ TextFormattingUtil .formatNumbers (averageOutLastSec ) + " EU/t" );
372
+ base = KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.average_out" , avgValue );
373
+ hover = KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.average_out_hover" );
374
+ list .add (KeyUtil .setHover (base , hover ));
375
+
376
+ // Time to fill/drain line
377
+ if (averageInLastSec > averageOutLastSec ) {
378
+ IKey timeToFill = getTimeToFillDrainText (energyCapacity .subtract (energyStored )
379
+ .divide (BigInteger .valueOf ((averageInLastSec - averageOutLastSec ) * 20 )));
380
+ timeToFill .format (TextFormatting .GREEN );
381
+ list .add (KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.time_to_fill" ,
382
+ timeToFill ));
383
+ } else if (averageInLastSec < averageOutLastSec ) {
384
+ IKey timeToDrain = getTimeToFillDrainText (
385
+ energyStored .divide (BigInteger .valueOf ((averageOutLastSec - averageInLastSec ) * 20 )));
386
+ timeToDrain .format (TextFormatting .RED );
387
+ list .add (KeyUtil .lang (TextFormatting .GRAY , "gregtech.multiblock.power_substation.time_to_drain" ,
388
+ timeToDrain ));
389
+ }
390
+ }
391
+ });
392
+ builder .addWorkingStatusLine ();
422
393
}
423
394
424
395
@ Override
425
- protected void addWarningText (List <ITextComponent > textList ) {
426
- super .addWarningText (textList );
427
- if (isStructureFormed ()) {
428
- if (averageInLastSec < averageOutLastSec ) { // decreasing
396
+ protected void configureWarningText (MultiblockUIFactory .Builder builder ) {
397
+ builder .addCustom (list -> {
398
+ if (isStructureFormed () && averageInLastSec < averageOutLastSec ) {
429
399
BigInteger timeToDrainSeconds = energyBank .getStored ()
430
400
.divide (BigInteger .valueOf ((averageOutLastSec - averageInLastSec ) * 20 ));
431
401
if (timeToDrainSeconds .compareTo (BigInteger .valueOf (60 * 60 )) < 0 ) { // less than 1 hour left
432
- textList .add (TextComponentUtil .translationWithColor (
433
- TextFormatting .YELLOW ,
402
+ list .add (KeyUtil .lang (TextFormatting .YELLOW ,
434
403
"gregtech.multiblock.power_substation.under_one_hour_left" ));
435
404
}
436
405
}
437
- }
406
+ });
438
407
}
439
408
440
- private static ITextComponent getTimeToFillDrainText (BigInteger timeToFillSeconds ) {
409
+ private static IKey getTimeToFillDrainText (BigInteger timeToFillSeconds ) {
441
410
if (timeToFillSeconds .compareTo (BIG_INTEGER_MAX_LONG ) > 0 ) {
442
411
// too large to represent in a java Duration
443
412
timeToFillSeconds = BIG_INTEGER_MAX_LONG ;
@@ -462,10 +431,10 @@ private static ITextComponent getTimeToFillDrainText(BigInteger timeToFillSecond
462
431
fillTime = duration .toDays () / 365 ;
463
432
key = "gregtech.multiblock.power_substation.time_years" ;
464
433
} else {
465
- return new TextComponentTranslation ("gregtech.multiblock.power_substation.time_forever" );
434
+ return KeyUtil . lang ("gregtech.multiblock.power_substation.time_forever" );
466
435
}
467
436
468
- return new TextComponentTranslation (key , TextFormattingUtil .formatNumbers (fillTime ));
437
+ return KeyUtil . lang (key , TextFormattingUtil .formatNumbers (fillTime ));
469
438
}
470
439
471
440
@ Override
0 commit comments