Skip to content

Commit

Permalink
remove unneeded method
Browse files Browse the repository at this point in the history
reorder parameters
  • Loading branch information
ghzdude committed Dec 27, 2024
1 parent c553531 commit c84caa7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ protected boolean checkOutputSpaceItems(@NotNull Recipe recipe, @NotNull IItemHa
protected boolean checkOutputSpaceFluids(@NotNull Recipe recipe, @NotNull MultipleTankHandler exportFluids) {
// We have already trimmed fluid outputs at this time
if (!metaTileEntity.canVoidRecipeFluidOutputs() &&
!GTTransferUtils.addFluidsToFluidHandler(exportFluids, true, recipe.getAllFluidOutputs())) {
!GTTransferUtils.addFluidsToFluidHandler(recipe.getAllFluidOutputs(), exportFluids, true)) {
this.isOutputsFull = true;
return false;
}
Expand Down Expand Up @@ -982,7 +982,7 @@ protected void completeRecipe() {
*/
protected void outputRecipeOutputs() {
GTTransferUtils.addItemsToItemHandler(getOutputInventory(), false, itemOutputs);
GTTransferUtils.addFluidsToFluidHandler(getOutputTank(), false, fluidOutputs);
GTTransferUtils.addFluidsToFluidHandler(fluidOutputs, getOutputTank(), false);
}

/**
Expand Down
45 changes: 6 additions & 39 deletions src/main/java/gregtech/api/util/GTTransferUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,40 +134,6 @@ public static boolean addItemsToItemHandler(final IItemHandler handler,
return true;
}

/**
* Simulates the insertion of fluid into a target fluid handler, then optionally performs the insertion.
* <br />
* <br />
* Simulating will not modify any of the input parameters. Insertion will either succeed completely, or fail
* without modifying anything.
* This method should be called with {@code simulate} {@code true} first, then {@code simulate} {@code false},
* only if it returned {@code true}.
*
* @param fluidHandler the target inventory
* @param simulate whether to simulate ({@code true}) or actually perform the insertion ({@code false})
* @param fluidStacks the items to insert into {@code fluidHandler}.
* @return {@code true} if the insertion succeeded, {@code false} otherwise.
*/
public static boolean addFluidsToFluidHandler(MultipleTankHandler fluidHandler,
boolean simulate,
List<FluidStack> fluidStacks) {
if (simulate) {
// OverlayedFluidHandler overlayedFluidHandler = new OverlayedFluidHandler(fluidHandler);
for (FluidStack fluidStack : fluidStacks) {
int inserted = fluidHandler.fill(fluidStack, false);
if (inserted != fluidStack.amount) {
return false;
}
}
return true;
}

for (FluidStack fluidStack : fluidStacks) {
fluidHandler.fill(fluidStack, true);
}
return true;
}

/**
* Simulates the insertion of fluid into a target fluid handler, then optionally performs the insertion. <br />
* <br
Expand All @@ -181,14 +147,15 @@ public static boolean addFluidsToFluidHandler(MultipleTankHandler fluidHandler,
* @param simulate whether to simulate ({@code true}) or actually perform the insertion ({@code false})
* @return {@code true} if the insertion succeeded, {@code false} otherwise.
*/
public static boolean addFluidsToFluidHandler(List<@NotNull FluidStack> fluidStacks,
IFluidHandler fluidHandler,
public static boolean addFluidsToFluidHandler(List<FluidStack> fluidStacks,
MultipleTankHandler fluidHandler,
boolean simulate) {
if (simulate) {
for (FluidStack stack : fluidStacks) {
int filled = fluidHandler.fill(stack, false);
if (filled < stack.amount)
for (FluidStack fluidStack : fluidStacks) {
int inserted = fluidHandler.fill(fluidStack, false);
if (inserted != fluidStack.amount) {
return false;
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ public void setWorkingEnabled(boolean isActivationAllowed) {
}

public boolean fillTanks(FluidStack stack, boolean simulate) {
return GTTransferUtils.addFluidsToFluidHandler(outputFluidInventory, simulate,
Collections.singletonList(stack));
return GTTransferUtils.addFluidsToFluidHandler(Collections.singletonList(stack), outputFluidInventory,
simulate);
}

public int getEnergyTier() {
Expand Down

0 comments on commit c84caa7

Please sign in to comment.