7171
7272import java .util .Arrays ;
7373import java .util .List ;
74+ import java .util .Objects ;
7475import java .util .function .Function ;
7576
7677import static gregtech .api .capability .GregtechDataCodes .*;
@@ -498,7 +499,7 @@ public boolean usesMui2() {
498499
499500 @ Override
500501 public ModularPanel buildUI (PosGuiData guiData , PanelSyncManager guiSyncManager ) {
501- RecipeMap <?> workableRecipeMap = workable .getRecipeMap ();
502+ RecipeMap <?> workableRecipeMap = Objects . requireNonNull ( workable .getRecipeMap (), "recipe map is null" );
502503 int yOffset = 0 ;
503504 if (workableRecipeMap .getMaxInputs () >= 6 || workableRecipeMap .getMaxFluidInputs () >= 6 ||
504505 workableRecipeMap .getMaxOutputs () >= 6 || workableRecipeMap .getMaxFluidOutputs () >= 6 ) {
@@ -509,53 +510,47 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
509510 Widget <?> widget = workableRecipeMap .getRecipeMapUI ().buildWidget (workable ::getProgressPercent , importItems ,
510511 exportItems , importFluids , exportFluids , yOffset , guiSyncManager );
511512
513+ BooleanSyncValue hasEnergy = new BooleanSyncValue (workable ::isHasNotEnoughEnergy );
514+
512515 panel .child (widget )
513516 .child (IKey .lang (getMetaFullName ()).asWidget ().pos (5 , 5 ))
514517 .child (new ItemSlot ()
515518 .slot (SyncHandlers .itemSlot (chargerInventory , 0 ))
516519 .pos (79 , 62 + yOffset )
517520 .background (GTGuiTextures .SLOT , GTGuiTextures .CHARGER_OVERLAY )
518- .tooltip ( t -> t . addLine ( IKey .lang ("gregtech.gui.charger_slot.tooltip" , GTValues . VNF [ getTier ()] ,
519- GTValues .VNF [getTier ()]) )))
521+ .addTooltipLine ( IKey .lang ("gregtech.gui.charger_slot.tooltip" ,
522+ GTValues .VNF [getTier ()], GTValues . VNF [ getTier ()] )))
520523 .child (new Widget <>()
521524 .size (18 , 18 )
522525 .pos (79 , 42 + yOffset )
523526 .background (GTGuiTextures .INDICATOR_NO_ENERGY )
524- // todo this isnt synced, and flicker appears on ui open even when it has enough energy
525- .setEnabledIf ($ -> workable .isHasNotEnoughEnergy ()))
527+ // todo flicker appears on ui open even when it has enough energy
528+ // will need to test this
529+ .setEnabledIf ($ -> hasEnergy .getBoolValue ()))
526530 .bindPlayerInventory ();
527531
528532 int leftButtonStartX = 7 ;
529533
530534 if (exportItems .getSlots () > 0 ) {
531- BooleanSyncValue outputValue = new BooleanSyncValue (() -> autoOutputItems , val -> autoOutputItems = val );
532- guiSyncManager .syncValue ("item_auto_output" , outputValue );
533535
534536 panel .child (new ToggleButton ()
535537 .pos (leftButtonStartX , 62 + yOffset )
536- .value (new BoolValue .Dynamic (outputValue ::getBoolValue , outputValue ::setBoolValue ))
537538 .overlay (GTGuiTextures .BUTTON_ITEM_OUTPUT )
538- .tooltipBuilder (t -> t
539- .setAutoUpdate (true )
540- .addLine (outputValue .getBoolValue () ?
541- IKey .lang ("gregtech.gui.item_auto_output.tooltip.enabled" ) :
542- IKey .lang ("gregtech.gui.item_auto_output.tooltip.disabled" ))));
539+ .value (new BooleanSyncValue (() -> autoOutputItems , val -> autoOutputItems = val ))
540+ .addTooltip (true , IKey .lang ("gregtech.gui.item_auto_output.tooltip.enabled" ))
541+ .addTooltip (false , IKey .lang ("gregtech.gui.item_auto_output.tooltip.disabled" )));
542+
543543 leftButtonStartX += 18 ;
544544 }
545545
546546 if (exportFluids .getTanks () > 0 ) {
547- BooleanSyncValue outputValue = new BooleanSyncValue (() -> autoOutputFluids , val -> autoOutputFluids = val );
548- guiSyncManager .syncValue ("fluid_auto_output" , outputValue );
549547
550548 panel .child (new ToggleButton ()
551549 .pos (leftButtonStartX , 62 + yOffset )
552- .value (new BoolValue .Dynamic (outputValue ::getBoolValue , outputValue ::setBoolValue ))
553550 .overlay (GTGuiTextures .BUTTON_FLUID_OUTPUT )
554- .tooltipBuilder (t -> t
555- .setAutoUpdate (true )
556- .addLine (outputValue .getBoolValue () ?
557- IKey .lang ("gregtech.gui.fluid_auto_output.tooltip.enabled" ) :
558- IKey .lang ("gregtech.gui.fluid_auto_output.tooltip.disabled" ))));
551+ .value (new BooleanSyncValue (() -> autoOutputFluids , val -> autoOutputFluids = val ))
552+ .addTooltip (true , IKey .lang ("gregtech.gui.fluid_auto_output.tooltip.enabled" ))
553+ .addTooltip (false , IKey .lang ("gregtech.gui.fluid_auto_output.tooltip.disabled" )));
559554 }
560555
561556 if (exportItems .getSlots () + exportFluids .getTanks () <= 9 ) {
0 commit comments