From bb68a5f74b1759f250cd68c76cb1c0f03599000d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Mon, 10 Jul 2017 22:36:11 +0200 Subject: [PATCH] Made it so that multiblocks will look for empty output hatches. Previously when there was more than one fluid output multiblocks would only try to put it into one of the output hatches. --- .../GT_MetaTileEntity_MultiBlockBase.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index a02a5568..6c0f8f5a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -263,13 +263,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } addOutput(tStack); } - if (mOutputFluids != null && mOutputFluids.length == 1) { - for (FluidStack tStack : mOutputFluids) - if (tStack != null) { - addOutput(tStack); - } - } else if (mOutputFluids != null && mOutputFluids.length > 1) { - addFluidOutputs(mOutputFluids); + if (mOutputFluids != null) { + addFluidOutputs(mOutputFluids); } mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); mOutputItems = null; @@ -554,12 +549,20 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } protected void addFluidOutputs(FluidStack[] mOutputFluids2) { - for (int i = 0; i < mOutputFluids2.length; i++) { - if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) { - mOutputHatches.get(i).fill(mOutputFluids2[i], true); - } + for (FluidStack outputFluidStack : mOutputFluids2) { + if (outputFluidStack != null) { + FluidStack copiedStack = outputFluidStack.copy(); + for (GT_MetaTileEntity_Hatch_Output outputhatch : mOutputHatches) { + if (copiedStack.amount <= 0) { + break; + } + if (!isValidMetaTileEntity(outputhatch)) { + continue; + } + copiedStack.amount -= outputhatch.fill(copiedStack, true); + } + } } - } public boolean depleteInput(FluidStack aLiquid) {