@@ -609,34 +609,45 @@ private boolean isSingleRow(int[] grid, int fluidCount) {
609609 return grid [1 ] >= fluidCount && grid [0 ] < 3 ;
610610 }
611611
612- private Widget <?> makeItemGroup (int width , IItemHandlerModifiable handler , boolean isOutputs ) {
613- Flow col = Flow .column ().mainAxisAlignment (Alignment .MainAxis .END )
614- .coverChildren ().debugName ("item.col" );
615- int c = handler .getSlots ();
616- int h = (int ) Math .ceil ((double ) c / width );
617- SlotGroup slotGroup = new SlotGroup (isOutputs ? "output_items" : "input_items" ,
618- width , 1 , !isOutputs );
619- for (int i = 0 ; i < h ; i ++) {
620- Flow row = Flow .row ().mainAxisAlignment (isOutputs ? Alignment .MainAxis .START : Alignment .MainAxis .END )
621- .coverChildren ().debugName ("item.row." + i );
612+ /**
613+ * @param grid [item grid width, item grid height, fluid grid width, fluid grid height]
614+ */
615+ private Widget <?> makeItemGroup (int [] grid , IItemHandlerModifiable handler , boolean isOutputs ) {
616+ Flow col = Flow .column ()
617+ .mainAxisAlignment (Alignment .MainAxis .END )
618+ .coverChildren ()
619+ .debugName ("col:item_grid" );
620+ int width = grid [0 ], height = grid [1 ];
621+ SlotGroup slotGroup = new SlotGroup (isOutputs ? "output_items" : "input_items" , width , 1 , !isOutputs );
622+ for (int i = 0 ; i < height ; i ++) {
623+ Flow row = Flow .row ()
624+ .mainAxisAlignment (isOutputs ? Alignment .MainAxis .START : Alignment .MainAxis .END )
625+ .coverChildren ()
626+ .debugName ("row:item_" + i );
622627 for (int j = 0 ; j < width ; j ++) {
623- row .child (makeItemSlot (slotGroup , (i * h ) + j , handler , isOutputs ));
628+ row .child (makeItemSlot (slotGroup , (i * height ) + j , handler , isOutputs ));
624629 }
625630 col .child (row );
626631 }
627632 return col ;
628633 }
629634
630- private Widget <?> makeFluidGroup (int width , FluidTankList handler , boolean isOutputs ) {
631- Flow col = Flow .column ().mainAxisAlignment (Alignment .MainAxis .START )
632- .coverChildren ().debugName ("fluid.col" );
633- int c = handler .getTanks ();
634- int h = (int ) Math .ceil ((double ) c / width );
635- for (int i = 0 ; i < h ; i ++) {
636- Flow row = Flow .row ().mainAxisAlignment (isOutputs ? Alignment .MainAxis .START : Alignment .MainAxis .END )
637- .coverChildren ().debugName ("fluid.row" );
635+ /**
636+ * @param grid [item grid width, item grid height, fluid grid width, fluid grid height]
637+ */
638+ private Widget <?> makeFluidGroup (int [] grid , FluidTankList handler , boolean isOutputs ) {
639+ Flow col = Flow .column ()
640+ .mainAxisAlignment (Alignment .MainAxis .START )
641+ .coverChildren ()
642+ .debugName ("col:fluid_grid" );
643+ int width = grid [2 ], height = grid [3 ];
644+ for (int i = 0 ; i < height ; i ++) {
645+ Flow row = Flow .row ()
646+ .mainAxisAlignment (isOutputs ? Alignment .MainAxis .START : Alignment .MainAxis .END )
647+ .coverChildren ()
648+ .debugName ("row:fluid_" + i );
638649 for (int j = 0 ; j < width ; j ++) {
639- row .child (makeFluidSlot ((i * h ) + j , handler , isOutputs ));
650+ row .child (makeFluidSlot ((i * height ) + j , handler , isOutputs ));
640651 }
641652 col .child (row );
642653 }
@@ -655,11 +666,9 @@ protected Widget<?> makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH
655666 }
656667
657668 int [] slotGridSizes = determineSlotsGrid (itemInputsCount , fluidInputsCount );
658- int itemGridWidth = slotGridSizes [onlyFluids ? 2 : 0 ];
659669 int itemGridHeight = slotGridSizes [onlyFluids ? 3 : 1 ];
660-
661- int fluidGridWidth = slotGridSizes [2 ];
662670 int fluidGridHeight = slotGridSizes [3 ];
671+
663672 boolean singleRow = isSingleRow (slotGridSizes , fluidInputsCount );
664673
665674 Flow flow = (singleRow ? Flow .row () : Flow .column ())
@@ -678,11 +687,11 @@ protected Widget<?> makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH
678687 }
679688
680689 if (onlyFluids ) {
681- flow .childIf (fluidInputsCount > 0 , () -> makeFluidGroup (fluidGridWidth , fluidHandler , isOutputs ));
690+ flow .childIf (fluidInputsCount > 0 , () -> makeFluidGroup (slotGridSizes , fluidHandler , isOutputs ));
682691 } else {
683- flow .childIf (!singleRow || isOutputs , () -> makeItemGroup (itemGridWidth , itemHandler , isOutputs ));
684- flow .childIf (fluidInputsCount > 0 , () -> makeFluidGroup (fluidGridWidth , fluidHandler , isOutputs ));
685- flow .childIf (singleRow && !isOutputs , () -> makeItemGroup (itemGridWidth , itemHandler , isOutputs ));
692+ flow .childIf (!singleRow || isOutputs , () -> makeItemGroup (slotGridSizes , itemHandler , isOutputs ));
693+ flow .childIf (fluidInputsCount > 0 , () -> makeFluidGroup (slotGridSizes , fluidHandler , isOutputs ));
694+ flow .childIf (singleRow && !isOutputs , () -> makeItemGroup (slotGridSizes , itemHandler , isOutputs ));
686695 }
687696
688697 return flow ;
0 commit comments