Some more minor optimizations

This commit is contained in:
CovertJaguar 2013-12-05 18:05:32 -08:00
parent 10015f8ffb
commit 0a4193b72e
2 changed files with 13 additions and 10 deletions

View file

@ -14,6 +14,10 @@ package buildcraft.core.utils;
*/
public class MathUtils {
public static int clamp(int value, int min, int max) {
return value < min ? min : (value > max ? max : value);
}
public static float clamp(float value, float min, float max) {
return value < min ? min : (value > max ? max : value);
}

View file

@ -62,15 +62,14 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
int maxToDrain = Math.min(maxDrain, Math.min(flowRate, getAvailable()));
if (maxToDrain < 0)
int maxToDrain = getAvailable();
if (maxToDrain > maxDrain)
maxToDrain = maxDrain;
if (maxToDrain > flowRate)
maxToDrain = flowRate;
if (maxToDrain <= 0)
return null;
FluidStack drained = super.drain(maxToDrain, doDrain);
if (drained == null)
return null;
return drained;
return super.drain(maxToDrain, doDrain);
}
public void moveFluids() {
@ -88,7 +87,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
public int getAvailable() {
int all = this.getFluid() != null ? this.getFluid().amount : 0;
int all = getFluidAmount();
for (short slot : incomming) {
all -= slot;
}
@ -359,7 +358,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
internalTanks[o.ordinal()].drain(filled, true);
if (filled <= 0) {
outputTTL[o.ordinal()]--;
}
}
// else FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.worldObj, container.xCoord, container.yCoord, container.zCoord));
}
}