From 9f0403a41cd31fc2d3dc31abfca8f9e8702204dd Mon Sep 17 00:00:00 2001 From: asiekierka Date: Fri, 28 Nov 2014 21:36:33 +0100 Subject: [PATCH] fix #2246, try to fix #2244 --- common/buildcraft/core/TileBuildCraft.java | 4 ++- .../transport/PipeTransportPower.java | 28 +++++++++++++++---- .../transport/pipes/PipePowerWood.java | 16 +---------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index e439fca3..f41c2793 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; +import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyReceiver; import buildcraft.BuildCraftCore; import buildcraft.api.core.ISerializable; @@ -27,7 +28,8 @@ import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.PacketTileUpdate; import buildcraft.core.utils.Utils; -public abstract class TileBuildCraft extends TileEntity implements IEnergyReceiver, ISynchronizedTile, ISerializable { +// TODO: Move back to IEnergyReceiver when EIO updates +public abstract class TileBuildCraft extends TileEntity implements IEnergyHandler, ISynchronizedTile, ISerializable { protected TileBuffer[] cache; protected HashSet guiWatchers = new HashSet(); diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 967f78c4..3cc61cf8 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -21,8 +21,11 @@ import cofh.api.energy.IEnergyReceiver; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; +import buildcraft.api.power.IEngine; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; +import buildcraft.core.TileBuildCraft; +import buildcraft.energy.TileEngine; import buildcraft.transport.network.PacketPowerUpdate; import buildcraft.transport.pipes.PipePowerCobblestone; import buildcraft.transport.pipes.PipePowerDiamond; @@ -92,14 +95,12 @@ public class PipeTransportPower extends PipeTransport { } if (container.pipe instanceof PipePowerWood) { - if (tile instanceof IEnergyConnection && ((IEnergyConnection) tile).canConnectEnergy(side.getOpposite())) { - // Disregard tiles which are consumers but NOT providers - return !(tile instanceof IEnergyReceiver && !(tile instanceof IEnergyProvider)); - } else { - // Disregard tiles which can't connect either, I guess. + return isPowerSource(tile, side); + } else { + if (tile instanceof IEngine) { + // Disregard engines for this. return false; } - } else { if (tile instanceof IEnergyReceiver) { IEnergyReceiver handler = (IEnergyReceiver) tile; if (handler != null && handler.canConnectEnergy(side.getOpposite())) { @@ -111,6 +112,21 @@ public class PipeTransportPower extends PipeTransport { return false; } + public boolean isPowerSource(TileEntity tile, ForgeDirection side) { + if (tile instanceof IEnergyConnection && ((IEnergyConnection) tile).canConnectEnergy(side.getOpposite())) { + // TODO: Remove this hack! It's only done until Ender IO/MFR move to the new RF API + if (tile instanceof TileBuildCraft && !(tile instanceof IEngine)) { + // Disregard non-engine BC tiles + return false; + } + // Disregard tiles which are consumers but NOT providers + return (tile instanceof IEngine) || !(tile instanceof IEnergyReceiver && !(tile instanceof IEnergyProvider)); + } else { + // Disregard tiles which can't connect either, I guess. + return false; + } + } + @Override public void onNeighborBlockChange(int blockId) { super.onNeighborBlockChange(blockId); diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index 5bde29dd..509cafdd 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -74,7 +74,7 @@ public class PipePowerWood extends Pipe implements IPipeTran } else { TileEntity tile = container.getTile(o); - if (powerSources[o.ordinal()] = isPowerSource(tile, o)) { + if (powerSources[o.ordinal()] = transport.isPowerSource(tile, o)) { sources++; } } @@ -184,20 +184,6 @@ public class PipePowerWood extends Pipe implements IPipeTran } } - public boolean isPowerSource(TileEntity tile, ForgeDirection from) { - if (!transport.inputOpen(from)) { - return false; - } else { - if (tile instanceof IEnergyConnection && ((IEnergyConnection) tile).canConnectEnergy(from.getOpposite())) { - // Disregard tiles which are consumers but NOT providers - return !(tile instanceof IEnergyReceiver && !(tile instanceof IEnergyProvider)); - } else { - // Disregard tiles which can't connect either, I guess. - return false; - } - } - } - @Override public boolean canConnectEnergy(ForgeDirection from) { return true;