From 8882f934c804749ea243b9712dbe7a3bee9842a9 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Mon, 28 Sep 2015 10:59:02 +0200 Subject: [PATCH] improve power transmission logic, add 7.0.26 changelog --- buildcraft_resources/changelog/7.0.26 | 10 ++++++++++ common/buildcraft/transport/PipeTransportPower.java | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 buildcraft_resources/changelog/7.0.26 diff --git a/buildcraft_resources/changelog/7.0.26 b/buildcraft_resources/changelog/7.0.26 new file mode 100644 index 00000000..7eaa86b7 --- /dev/null +++ b/buildcraft_resources/changelog/7.0.26 @@ -0,0 +1,10 @@ +Improvements: + +* [#3039] Slight item insertion optimization (Speiger) +* Improved power transmission logic (asie) + +Bugs fixed: + +* [#3041] GUI crash with Robot gate parameters (asie) +* [#3038] Server crash on corrupt BC map loading (asie) +* [#3035] Builder GUI crash (asie) diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 725e39ee..03ed073d 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -214,10 +214,12 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable { } if (totalPowerQuery > 0) { + int unusedPowerQuery = totalPowerQuery; for (int j = 0; j < 6; ++j) { if (j != i && powerQuery[j] > 0) { Object ep = providers[j]; - double watts = Math.min(internalPower[i] * powerQuery[j] / totalPowerQuery, internalPower[i]); + double watts = Math.min(internalPower[i] * powerQuery[j] / unusedPowerQuery, internalPower[i]); + unusedPowerQuery -= powerQuery[j]; if (ep instanceof IPipeTile && ((IPipeTile) ep).getPipeType() == IPipeTile.PipeType.POWER) { Pipe nearbyPipe = (Pipe) ((IPipeTile) ep).getPipe(); @@ -238,18 +240,17 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable { iWatts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), iWatts, false); } - internalPower[i] -= iWatts; - dbgEnergyOutput[j] += iWatts; } else if (ep instanceof IEnergyReceiver) { IEnergyReceiver handler = (IEnergyReceiver) ep; if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) { iWatts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(), iWatts, false); } - internalPower[i] -= iWatts; - dbgEnergyOutput[j] += iWatts; } + internalPower[i] -= iWatts; + dbgEnergyOutput[j] += iWatts; + powerAverage[j].push(iWatts); powerAverage[i].push(iWatts); } @@ -258,6 +259,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable { } } } + short highestPower = 0; for (int i = 0; i < 6; i++) { powerAverage[i].tick();