Skip to content

Commit

Permalink
fixed machine outputs not outputting to additional output tanks when …
Browse files Browse the repository at this point in the history
…possible
  • Loading branch information
Trinsdar committed May 30, 2024
1 parent 019187e commit adb7699
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected boolean empty(FluidTanks tank) {

public long fillOutput(FluidHolder stack, boolean simulate) {
if (getOutputTanks() != null) {
return getOutputTanks().insertFluid(stack, simulate);
return getOutputTanks().internalInsert(stack, simulate);
}
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import muramasa.antimatter.blockentity.BlockEntityBase;
import muramasa.antimatter.machine.event.IMachineEvent;
import muramasa.antimatter.util.AntimatterPlatformUtils;
import muramasa.antimatter.util.Utils;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
Expand Down Expand Up @@ -197,6 +198,27 @@ public long insertFluid(FluidHolder fluid, boolean simulate) {
return getTank(tank).insertFluid(fluid, simulate);
}

@Override
public long internalInsert(FluidHolder fluids, boolean simulate) {
long inserted = insertFluid(fluids, simulate);
if (inserted >= fluids.getFluidAmount()) {
return inserted;
}
FluidHolder copy = fluids.copyWithAmount(fluids.getFluidAmount() - inserted);
long originalAmount = copy.getFluidAmount();
for (FluidTank tank : tanks) {
if (copy.getFluidAmount() == 0) break;
inserted = tank.insertFluid(copy, simulate);
if (inserted > 0) {
copy.setAmount(copy.getFluidAmount() - inserted);
}
}
if (copy.getFluidAmount() < originalAmount){
return originalAmount - copy.getFluidAmount();
}
return 0;
}

@Override
public FluidHolder extractFluid(FluidHolder fluid, boolean simulate) {
for (int i = 0; i < tanks.length; i++) {
Expand Down

0 comments on commit adb7699

Please sign in to comment.