From 2eb8e868f2ba2ead73d8bd8ea938fb5dc810aa9c Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Sun, 18 May 2014 18:44:53 +0200 Subject: [PATCH] tentative fix for #1826 --- common/buildcraft/energy/TileEngine.java | 25 +++++++++++-------- .../transport/PipeTransportPower.java | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 1aa5e887..1ac3f073 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -278,15 +278,18 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto private double getPowerToExtract() { TileEntity tile = getTileBuffer(orientation).getTile(); - if (tile instanceof IPowerReceptor) { + IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()); + + if (battery != null) { + return extractEnergy(0, battery.getEnergyRequested(), false); + } else if (tile instanceof IPowerReceptor) { PowerReceiver receptor = ((IPowerReceptor) tile) .getPowerReceiver(orientation.getOpposite()); return extractEnergy(receptor.getMinEnergyReceived(), receptor.getMaxEnergyReceived(), false); } else { - return extractEnergy(0, MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()) - .getEnergyRequested(), false); + return 0; } } @@ -295,7 +298,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto if (isPoweredTile(tile, orientation)) { double extracted = getPowerToExtract(); - if (tile instanceof IPowerReceptor) { + IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()); + + if (battery != null) { + battery.addEnergy(extractEnergy(0, battery.maxReceivedPerCycle(), + true)); + } else if (tile instanceof IPowerReceptor) { PowerReceiver receptor = ((IPowerReceptor) tile) .getPowerReceiver(orientation.getOpposite()); @@ -306,11 +314,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto extractEnergy(receptor.getMinEnergyReceived(), needed, true); } - } else { - IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()); - - battery.addEnergy(extractEnergy(0, battery.maxReceivedPerCycle(), - true)); } } } @@ -519,10 +522,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public boolean isPoweredTile(TileEntity tile, ForgeDirection side) { if (tile == null) { return false; + } else if (MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()) != null) { + return true; } else if (tile instanceof IPowerReceptor) { return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null; } else { - return MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()) != null; + return false; } } diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 9fd37d81..da6a4c85 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -264,7 +264,7 @@ public class PipeTransportPower extends PipeTransport { for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = tiles [dir.ordinal()]; - if (!(tile instanceof TileGenericPipe)) { + if (!(tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower)) { PowerReceiver prov = getReceiverOnSide(dir); if (prov != null) { double request = prov.powerRequest();