Added to wood pipes the ability to interact with all BC energy APIs.

Close #1824
This commit is contained in:
SpaceToad 2014-05-18 15:55:19 +02:00
parent 9e4519ccf1
commit 89f71c515b
2 changed files with 42 additions and 2 deletions

View file

@ -46,6 +46,9 @@ import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.mj.MjBattery;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeWire;
@ -63,7 +66,7 @@ import buildcraft.core.utils.Utils;
import buildcraft.transport.gates.GateDefinition;
import buildcraft.transport.gates.GateFactory;
public class TileGenericPipe extends TileEntity implements IFluidHandler,
public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler,
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder,
IDropControlInventory, ISyncedTile, ISolidSideTile, IGuiReturnHandler {
@ -1030,4 +1033,20 @@ public class TileGenericPipe extends TileEntity implements IFluidHandler,
((IGuiReturnHandler) pipe).readGuiData(data, sender);
}
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side) {
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IPowerReceptor) {
return ((IPowerReceptor) pipe).getPowerReceiver(null);
} else {
return null;
}
}
@Override
public void doWork(PowerHandler workProvider) {
if (BlockGenericPipe.isValid(pipe) && pipe instanceof IPowerReceptor) {
((IPowerReceptor) pipe).doWork(workProvider);
}
}
}

View file

@ -19,15 +19,20 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.mj.MjAPILegacy;
import buildcraft.api.mj.MjBattery;
import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import buildcraft.api.transport.IPipeTile;
import buildcraft.transport.IPipeTransportPowerHook;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTransportPower;
public class PipePowerWood extends Pipe<PipeTransportPower> implements IPipeTransportPowerHook {
public class PipePowerWood extends Pipe<PipeTransportPower> implements IPowerReceptor, IPipeTransportPowerHook {
public final boolean[] powerSources = new boolean[6];
@ -39,6 +44,8 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPipeTran
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker(1);
private boolean full;
private MjAPILegacy powerHandler;
public PipePowerWood(Item item) {
super(new PipeTransportPower(), item);
transport.initFromPipe(getClass());
@ -165,4 +172,18 @@ public class PipePowerWood extends Pipe<PipeTransportPower> implements IPipeTran
public boolean isPowerSource(ForgeDirection from) {
return container.getTile(from) instanceof IPowerEmitter;
}
@Override
public PowerReceiver getPowerReceiver(ForgeDirection side) {
if (powerHandler == null) {
powerHandler = MjAPILegacy.from(container, Type.PIPE);
}
return powerHandler.getPowerReceiver(ForgeDirection.UNKNOWN);
}
@Override
public void doWork(PowerHandler workProvider) {
}
}