Another perf tweak

This commit is contained in:
CovertJaguar 2013-11-30 13:57:25 -08:00
parent 0dd0c6c885
commit 1f65388c80
2 changed files with 6 additions and 1 deletions

View file

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

View file

@ -9,6 +9,7 @@ package buildcraft.transport.pipes;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.core.utils.MathUtils;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportItems;
@ -39,6 +40,6 @@ public class PipeItemsGold extends Pipe {
public void eventHandler(PipeEventItem.AdjustSpeed event) {
event.handled = true;
TravelingItem item = event.item;
item.setSpeed(Math.min(Math.max(TransportConstants.PIPE_NORMAL_SPEED, item.getSpeed()) * 4f, TransportConstants.PIPE_NORMAL_SPEED * 20F));
item.setSpeed(MathUtils.clamp(item.getSpeed() * 4F, TransportConstants.PIPE_NORMAL_SPEED * 4F, TransportConstants.PIPE_NORMAL_SPEED * 20F));
}
}