Fixed fluid regulator.
This commit is contained in:
parent
9e2b2f2015
commit
07f8b0d348
1 changed files with 26 additions and 16 deletions
|
@ -18,13 +18,15 @@ public class GT_Cover_FluidRegulator
|
||||||
}
|
}
|
||||||
|
|
||||||
public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) {
|
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)) {
|
if ((aTileEntity instanceof IFluidHandler)) {
|
||||||
IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(aSide);
|
IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(aSide);
|
||||||
if (tTank2 != null) {
|
if (tTank2 != null) {
|
||||||
IFluidHandler tTank1 = (IFluidHandler) aTileEntity;
|
IFluidHandler tTank1 = (IFluidHandler) aTileEntity;
|
||||||
if (aCoverVariable >0) {
|
if (aCoverVariable > 0) {
|
||||||
FluidStack tLiquid = tTank1.drain(ForgeDirection.getOrientation(aSide), aCoverVariable, false);
|
FluidStack tLiquid = tTank1.drain(ForgeDirection.UNKNOWN, 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(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.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.getOrientation(aSide), tLiquid.amount, true), true);
|
tTank2.fill(ForgeDirection.getOrientation(aSide).getOpposite(), tTank1.drain(ForgeDirection.UNKNOWN, tLiquid.amount, true), true);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
FluidStack tLiquid = tTank2.drain(ForgeDirection.getOrientation(aSide).getOpposite(), Math.abs(aCoverVariable), false);
|
||||||
if (tLiquid != null) {
|
if (tLiquid != null) {
|
||||||
tLiquid = tLiquid.copy();
|
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 (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);
|
||||||
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 {
|
} 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 {
|
} else {
|
||||||
aCoverVariable -= 16;
|
aCoverVariable -= 16;
|
||||||
}
|
}
|
||||||
if(aCoverVariable>mTransferRate){aCoverVariable=mTransferRate;}
|
if (aCoverVariable > mTransferRate) {
|
||||||
if(aCoverVariable<(0-mTransferRate)){aCoverVariable=(0-mTransferRate);}
|
aCoverVariable = mTransferRate;
|
||||||
GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: "+aCoverVariable+"L/tick "+aCoverVariable*20+"L/sec");
|
}
|
||||||
|
if (aCoverVariable < (0 - mTransferRate)) {
|
||||||
|
aCoverVariable = (0 - mTransferRate);
|
||||||
|
}
|
||||||
|
GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: " + aCoverVariable + "L/tick " + aCoverVariable * 20 + "L/sec");
|
||||||
return aCoverVariable;
|
return aCoverVariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,9 +85,13 @@ public class GT_Cover_FluidRegulator
|
||||||
} else {
|
} else {
|
||||||
aCoverVariable--;
|
aCoverVariable--;
|
||||||
}
|
}
|
||||||
if(aCoverVariable>mTransferRate){aCoverVariable=mTransferRate;}
|
if (aCoverVariable > mTransferRate) {
|
||||||
if(aCoverVariable<(0-mTransferRate)){aCoverVariable=(0-mTransferRate);}
|
aCoverVariable = mTransferRate;
|
||||||
GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: "+aCoverVariable+"L/tick "+aCoverVariable*20+"L/sec");
|
}
|
||||||
|
if (aCoverVariable < (0 - mTransferRate)) {
|
||||||
|
aCoverVariable = (0 - mTransferRate);
|
||||||
|
}
|
||||||
|
GT_Utility.sendChatToPlayer(aPlayer, "Pump speed: " + aCoverVariable + "L/tick " + aCoverVariable * 20 + "L/sec");
|
||||||
aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
|
aTileEntity.setCoverDataAtSide(aSide, aCoverVariable);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +125,7 @@ public class GT_Cover_FluidRegulator
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) {
|
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) {
|
public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
|
||||||
|
|
Loading…
Reference in a new issue