Skip to content

Commit

Permalink
Add slot index to FluidGrouBuilder#widgetCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
tth05 committed Oct 14, 2023
1 parent d753255 commit d09c78e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

Expand Down Expand Up @@ -233,7 +234,7 @@ public static class FluidGroupBuilder {
private Boolean controlsAmount;
private IDrawable[] background;
private Function<IFluidTank, IFluidTanksHandler> tankHandlerCreator;
private Function<IFluidTanksHandler, FluidSlotWidget> widgetCreator;
private BiFunction<Integer, IFluidTanksHandler, FluidSlotWidget> widgetCreator;

private FluidGroupBuilder(List<IFluidTank> fluidTanks, int slotsPerRow) {
this.fluidTanks = fluidTanks;
Expand All @@ -257,7 +258,7 @@ public SlotGroup build() {
tankHandlerCreator = tank -> new FluidTanksHandler(new FluidTankLongDelegate(tank));
}
if (widgetCreator == null) {
widgetCreator = h -> new FluidSlotWidget(h, 0);
widgetCreator = (i, h) -> new FluidSlotWidget(h);
}

SlotGroup slotGroup = new SlotGroup();
Expand All @@ -266,7 +267,7 @@ public SlotGroup build() {
}
int x = 0, y = 0;
for (int i = startFromSlot; i < endAtSlot + 1; i++) {
FluidSlotWidget toAdd = widgetCreator.apply(tankHandlerCreator.apply(fluidTanks.get(i)));
FluidSlotWidget toAdd = widgetCreator.apply(i, tankHandlerCreator.apply(fluidTanks.get(i)));
toAdd.setPhantom(phantom);
toAdd.setControlsAmount(controlsAmount, false);
toAdd.setBackground(background).setPos(new Pos2d(x * 18, y * 18));
Expand Down Expand Up @@ -309,7 +310,7 @@ public FluidGroupBuilder tankHandlerCreator(Function<IFluidTank, IFluidTanksHand
return this;
}

public FluidGroupBuilder widgetCreator(Function<IFluidTanksHandler, FluidSlotWidget> widgetCreator) {
public FluidGroupBuilder widgetCreator(BiFunction<Integer, IFluidTanksHandler, FluidSlotWidget> widgetCreator) {
this.widgetCreator = widgetCreator;
return this;
}
Expand Down

0 comments on commit d09c78e

Please sign in to comment.