diff --git a/common/buildcraft/core/utils/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java index 4a676d97..ad6432fe 100644 --- a/common/buildcraft/core/utils/MathUtils.java +++ b/common/buildcraft/core/utils/MathUtils.java @@ -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); } diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index d474ca2f..9c5bfa1e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -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)); } }