parent
b76846e971
commit
9f0403a41c
3 changed files with 26 additions and 22 deletions
|
@ -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<EntityPlayer> guiWatchers = new HashSet<EntityPlayer>();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PipePowerWood extends Pipe<PipeTransportPower> 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<PipeTransportPower> 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;
|
||||
|
|
Loading…
Reference in a new issue