Merge pull request #797 from Dimach/fluidregulator-fix

Fixed #796.
This commit is contained in:
Archengius 2016-12-12 01:22:59 +07:00 committed by GitHub
commit 248b88e8bc

View file

@ -24,26 +24,32 @@ public class GT_Cover_FluidRegulator extends GT_CoverBehavior {
if ((aTileEntity instanceof IFluidHandler)) { if ((aTileEntity instanceof IFluidHandler)) {
IFluidHandler tTank1; IFluidHandler tTank1;
IFluidHandler tTank2; IFluidHandler tTank2;
ForgeDirection directionFrom;
ForgeDirection directionTo;
if (aCoverVariable > 0) { if (aCoverVariable > 0) {
tTank2 = aTileEntity.getITankContainerAtSide(aSide); tTank2 = aTileEntity.getITankContainerAtSide(aSide);
tTank1 = (IFluidHandler) aTileEntity; tTank1 = (IFluidHandler) aTileEntity;
directionFrom = ForgeDirection.UNKNOWN;
directionTo = ForgeDirection.getOrientation(aSide).getOpposite();
} else { } else {
tTank1 = aTileEntity.getITankContainerAtSide(aSide); tTank1 = aTileEntity.getITankContainerAtSide(aSide);
tTank2 = (IFluidHandler) aTileEntity; tTank2 = (IFluidHandler) aTileEntity;
directionFrom = ForgeDirection.getOrientation(aSide).getOpposite();
directionTo = ForgeDirection.UNKNOWN;
} }
if (tTank1 != null && tTank2 != null) { if (tTank1 != null && tTank2 != null) {
FluidStack tLiquid = tTank1.drain(ForgeDirection.UNKNOWN, Math.abs(aCoverVariable), false); FluidStack tLiquid = tTank1.drain(directionFrom, Math.abs(aCoverVariable), false);
if (tLiquid != null) { if (tLiquid != null) {
tLiquid = tLiquid.copy(); tLiquid = tLiquid.copy();
tLiquid.amount = tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid, false); tLiquid.amount = tTank2.fill(directionTo, tLiquid, false);
if (tLiquid.amount > 0) { if (tLiquid.amount > 0) {
if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) { if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) {
if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) { if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) {
aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true); aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true);
tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.UNKNOWN, tLiquid.amount, true), true); tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true);
} }
} else { } else {
tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.UNKNOWN, tLiquid.amount, true), true); tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true);
} }
} }
} }