From 07f8b0d34840c27caadcd150a99ff0d7792f69f3 Mon Sep 17 00:00:00 2001 From: Dimach Date: Sat, 8 Oct 2016 06:50:42 +0300 Subject: [PATCH] Fixed fluid regulator. --- .../covers/GT_Cover_FluidRegulator.java | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java index 94fcba6b..c3d101ba 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java @@ -18,13 +18,15 @@ public class GT_Cover_FluidRegulator } public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { - if(aCoverVariable==0){return aCoverVariable;} + if (aCoverVariable == 0) { + return aCoverVariable; + } if ((aTileEntity instanceof IFluidHandler)) { IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(aSide); if (tTank2 != null) { IFluidHandler tTank1 = (IFluidHandler) aTileEntity; - if (aCoverVariable >0) { - FluidStack tLiquid = tTank1.drain(ForgeDirection.getOrientation(aSide), aCoverVariable, false); + if (aCoverVariable > 0) { + FluidStack tLiquid = tTank1.drain(ForgeDirection.UNKNOWN, aCoverVariable, false); if (tLiquid != null) { tLiquid = tLiquid.copy(); tLiquid.amount = tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid, false); @@ -32,10 +34,10 @@ public class GT_Cover_FluidRegulator if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) { if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) { aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true); - tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.getOrientation(aSide), tLiquid.amount, true), true); + tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.UNKNOWN, tLiquid.amount, true), true); } } else { - tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.getOrientation(aSide), tLiquid.amount, true), true); + tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.UNKNOWN, tLiquid.amount, true), true); } } } @@ -43,15 +45,15 @@ public class GT_Cover_FluidRegulator FluidStack tLiquid = tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), Math.abs(aCoverVariable), false); if (tLiquid != null) { tLiquid = tLiquid.copy(); - tLiquid.amount = tTank1.fill(ForgeDirection.getOrientation(aSide), tLiquid, false); + tLiquid.amount = tTank1.fill(ForgeDirection.UNKNOWN, tLiquid, false); if (tLiquid.amount > 0) { if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) { if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) { aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true); - tTank1.fill(ForgeDirection.getOrientation(aSide), tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid.amount, true), true); + tTank1.fill(ForgeDirection.UNKNOWN, tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid.amount, true), true); } } else { - tTank1.fill(ForgeDirection.getOrientation(aSide), tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid.amount, true), true); + tTank1.fill(ForgeDirection.UNKNOWN, tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), tLiquid.amount, true), true); } } } @@ -67,9 +69,13 @@ public class GT_Cover_FluidRegulator } else { aCoverVariable -= 16; } - if(aCoverVariable>mTransferRate){aCoverVariable=mTransferRate;} - if(aCoverVariable<(0-mTransferRate)){aCoverVariable=(0-mTransferRate);} - GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: "+aCoverVariable+"L/tick "+aCoverVariable*20+"L/sec"); + if (aCoverVariable > mTransferRate) { + aCoverVariable = mTransferRate; + } + if (aCoverVariable < (0 - mTransferRate)) { + aCoverVariable = (0 - mTransferRate); + } + GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: " + aCoverVariable + "L/tick " + aCoverVariable * 20 + "L/sec"); return aCoverVariable; } @@ -79,9 +85,13 @@ public class GT_Cover_FluidRegulator } else { aCoverVariable--; } - if(aCoverVariable>mTransferRate){aCoverVariable=mTransferRate;} - if(aCoverVariable<(0-mTransferRate)){aCoverVariable=(0-mTransferRate);} - GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: "+aCoverVariable+"L/tick "+aCoverVariable*20+"L/sec"); + if (aCoverVariable > mTransferRate) { + aCoverVariable = mTransferRate; + } + if (aCoverVariable < (0 - mTransferRate)) { + aCoverVariable = (0 - mTransferRate); + } + GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: " + aCoverVariable + "L/tick " + aCoverVariable * 20 + "L/sec"); aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); return true; } @@ -111,11 +121,11 @@ public class GT_Cover_FluidRegulator } public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; + return false; } public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; + return aFluid == null; } public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {