From 5923e2333c863e448d81c2dce28f8f0f1e93ba07 Mon Sep 17 00:00:00 2001 From: Andrew Dudney Date: Tue, 21 Oct 2014 16:26:46 -0600 Subject: [PATCH] Optimized power transport pipes a bit --- .../transport/PipeTransportPower.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 2367526a..ecebda16 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -172,16 +172,12 @@ public class PipeTransportPower extends PipeTransport { // amount of power queried int totalPowerContained = 0; - - for (int in = 0; in < 6; ++in) { - totalPowerContained += internalPower[in]; - } - int totalPowerQuery = 0; - for (int out = 0; out < 6; ++out) { - if (internalPower[out] == 0) { - totalPowerQuery += powerQuery[out]; + for (int dir = 0; dir < 6; ++dir) { + totalPowerContained += internalPower[dir]; + if (internalPower[dir] == 0) { + totalPowerQuery += powerQuery[dir]; } } @@ -195,8 +191,7 @@ public class PipeTransportPower extends PipeTransport { externalPower[out] = 0; if (powerQuery[out] > 0 && internalPower[out] == 0) { - int powerConsumed = (int) Math.floor((double) (powerQuery[out] * totalPowerContained) - / totalPowerQuery); + int powerConsumed = powerQuery[out] * totalPowerContained / totalPowerQuery; boolean tilePowered = false; if (tiles[out] instanceof TileGenericPipe) { @@ -245,7 +240,7 @@ public class PipeTransportPower extends PipeTransport { if (totalPowerConsumed > 0) { for (int in = 0; in < 6; ++in) { - int powerConsumed = (int) ((double) internalPower[in] * (double) totalPowerConsumed / totalPowerContained); + int powerConsumed = internalPower[in] * totalPowerConsumed / totalPowerContained; displayPower[in] += powerConsumed; } } @@ -260,7 +255,7 @@ public class PipeTransportPower extends PipeTransport { highestPower = displayPower[i]; } - if (displayPower[i] < 0.01) { + if (displayPower[i] < 0) { displayPower[i] = 0; } }