Fixed fluid regulator.
This commit is contained in:
parent
1a78a8dd51
commit
104bcf62d8
1 changed files with 26 additions and 17 deletions
|
@ -1,7 +1,6 @@
|
|||
package gregtech.common.covers;
|
||||
|
||||
import gregtech.api.interfaces.tileentity.ICoverable;
|
||||
import gregtech.api.interfaces.tileentity.IMachineProgress;
|
||||
import gregtech.api.util.GT_CoverBehavior;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -19,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);
|
||||
|
@ -33,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,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;
|
||||
}
|
||||
|
||||
|
@ -80,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;
|
||||
}
|
||||
|
@ -112,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) {
|
||||
|
|
Loading…
Reference in a new issue