Remove IPipe, cleanup IPipeTile

This commit is contained in:
CovertJaguar 2013-12-20 16:55:47 -08:00
parent 2aa52ef61b
commit c1cd0fa02b
18 changed files with 170 additions and 172 deletions

View file

@ -11,7 +11,6 @@ import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.recipes.BuildcraftRecipes;
import buildcraft.api.transport.IExtractionHandler;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.PipeManager;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
@ -42,6 +41,7 @@ import buildcraft.transport.blueprints.BptItemPipeIron;
import buildcraft.transport.blueprints.BptItemPipeWooden;
import buildcraft.transport.gates.GateExpansionPulsar;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.transport.PipeWire;
import buildcraft.transport.network.PacketHandlerTransport;
import buildcraft.transport.pipes.PipeFluidsCobblestone;
import buildcraft.transport.pipes.PipeFluidsEmerald;
@ -159,21 +159,21 @@ public class BuildCraftTransport {
public static BCTrigger triggerPipeContainsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_CONTAINS_ENERGY, Kind.ContainsEnergy);
public static BCTrigger triggerPipeRequestsEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_REQUESTS_ENERGY, Kind.RequestsEnergy);
public static BCTrigger triggerPipeTooMuchEnergy = new TriggerPipeContents(DefaultProps.TRIGGER_PIPE_TOO_MUCH_ENERGY, Kind.TooMuchEnergy);
public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_ACTIVE, true, IPipe.WireColor.Red);
public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_INACTIVE, false, IPipe.WireColor.Red);
public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_ACTIVE, true, IPipe.WireColor.Blue);
public static BCTrigger triggerBlueSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_INACTIVE, false, IPipe.WireColor.Blue);
public static BCTrigger triggerGreenSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_ACTIVE, true, IPipe.WireColor.Green);
public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, IPipe.WireColor.Green);
public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, IPipe.WireColor.Yellow);
public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, IPipe.WireColor.Yellow);
public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_ACTIVE, true, PipeWire.Red);
public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_RED_SIGNAL_INACTIVE, false, PipeWire.Red);
public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_ACTIVE, true, PipeWire.Blue);
public static BCTrigger triggerBlueSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_BLUE_SIGNAL_INACTIVE, false, PipeWire.Blue);
public static BCTrigger triggerGreenSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_ACTIVE, true, PipeWire.Green);
public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_GREEN_SIGNAL_INACTIVE, false, PipeWire.Green);
public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_ACTIVE, true, PipeWire.Yellow);
public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal(DefaultProps.TRIGGER_YELLOW_SIGNAL_INACTIVE, false, PipeWire.Yellow);
public static BCTrigger triggerTimerShort = new TriggerQuartzTimer(DefaultProps.TRIGGER_TIMER_SHORT, TriggerQuartzTimer.Time.Short);
public static BCTrigger triggerTimerMedium = new TriggerQuartzTimer(DefaultProps.TRIGGER_TIMER_MEDIUM, TriggerQuartzTimer.Time.Medium);
public static BCTrigger triggerTimerLong = new TriggerQuartzTimer(DefaultProps.TRIGGER_TIMER_LONG, TriggerQuartzTimer.Time.Long);
public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, IPipe.WireColor.Red);
public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, IPipe.WireColor.Blue);
public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, IPipe.WireColor.Green);
public static BCAction actionYellowSignal = new ActionSignalOutput(DefaultProps.ACTION_YELLOW_SIGNAL, IPipe.WireColor.Yellow);
public static BCAction actionRedSignal = new ActionSignalOutput(DefaultProps.ACTION_RED_SIGNAL, PipeWire.Red);
public static BCAction actionBlueSignal = new ActionSignalOutput(DefaultProps.ACTION_BLUE_SIGNAL, PipeWire.Blue);
public static BCAction actionGreenSignal = new ActionSignalOutput(DefaultProps.ACTION_GREEN_SIGNAL, PipeWire.Green);
public static BCAction actionYellowSignal = new ActionSignalOutput(DefaultProps.ACTION_YELLOW_SIGNAL, PipeWire.Yellow);
public static BCAction actionEnergyPulser = new ActionEnergyPulser(DefaultProps.ACTION_ENERGY_PULSER);
public static BCAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(DefaultProps.ACTION_SINGLE_ENERGY_PULSE);
public static BCAction[] actionPipeColor = new BCAction[16];

View file

@ -1,6 +1,6 @@
package buildcraft.api.gates;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
@ -71,7 +71,7 @@ public class ActionManager {
return actions;
}
public static LinkedList<ITrigger> getPipeTriggers(IPipe pipe) {
public static LinkedList<ITrigger> getPipeTriggers(IPipeTile pipe) {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
for (ITriggerProvider provider : triggerProviders) {

View file

@ -9,7 +9,7 @@
package buildcraft.api.gates;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
@ -19,7 +19,7 @@ public interface ITriggerProvider {
/**
* Returns the list of triggers that are available from the pipe holding the gate.
*/
public abstract LinkedList<ITrigger> getPipeTriggers(IPipe pipe);
public abstract LinkedList<ITrigger> getPipeTriggers(IPipeTile pipe);
/**
* Returns the list of triggers available to a gate next to the given block.

View file

@ -1,45 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.transport;
import net.minecraft.tileentity.TileEntity;
public interface IPipe {
enum DrawingState {
DrawingPipe, DrawingRedWire, DrawingBlueWire, DrawingGreenWire, DrawingYellowWire, DrawingGate
}
enum WireColor {
Red, Blue, Green, Yellow;
public WireColor reverse() {
switch (this) {
case Red:
return Yellow;
case Blue:
return Green;
case Green:
return Blue;
default:
return Red;
}
}
}
public boolean isWired(WireColor color);
public boolean hasGate();
public TileEntity getContainer();
public boolean isWireConnectedTo(TileEntity tile, WireColor color);
}

View file

@ -9,18 +9,14 @@ package buildcraft.api.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
public interface IPipeTile extends ISolidSideTile, IFluidHandler {
public interface IPipeTile {
public enum PipeType {
ITEM, FLUID, POWER, STRUCTURE;
}
@Deprecated
IPipe getPipe();
PipeType getPipeType();
/**
@ -34,6 +30,20 @@ public interface IPipeTile extends ISolidSideTile, IFluidHandler {
* @return Amount of items used from the passed stack.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
/**
* True if the pipe is connected to the block/pipe in the specific direction
*
* @param wire
* @return true if connect
*/
boolean isPipeConnected(ForgeDirection with);
/**
* True if the pipe has a powered wire of the specified color.
*
* @param wire
* @return true if powered
*/
boolean isWireActive(PipeWire wire);
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.transport;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public enum PipeWire {
Red, Blue, Green, Yellow;
public PipeWire reverse() {
switch (this) {
case Red:
return Yellow;
case Blue:
return Green;
case Green:
return Blue;
default:
return Red;
}
}
}

View file

@ -4,7 +4,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerProvider;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import buildcraft.core.IMachine;
import java.util.LinkedList;
import net.minecraft.block.Block;
@ -58,7 +58,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
}
@Override
public LinkedList<ITrigger> getPipeTriggers(IPipe pipe) {
public LinkedList<ITrigger> getPipeTriggers(IPipeTile pipe) {
return null;
}
}

View file

@ -7,6 +7,7 @@
*/
package buildcraft.transport;
import buildcraft.api.transport.PipeWire;
import buildcraft.transport.gates.ItemGate;
import java.util.ArrayList;
import java.util.HashMap;
@ -38,8 +39,6 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.GateExpansions;
import buildcraft.api.gates.IGateExpansion;
import buildcraft.api.tools.IToolWrench;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.ISolidSideTile;
import buildcraft.core.BlockBuildCraft;
import buildcraft.core.BlockIndex;
import buildcraft.core.CoreConstants;
@ -668,19 +667,19 @@ public class BlockGenericPipe extends BlockBuildCraft {
// interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player);
else if (currentItem.getItem() == BuildCraftTransport.redPipeWire) {
if (addOrStripWire(player, pipe, IPipe.WireColor.Red)) {
if (addOrStripWire(player, pipe, PipeWire.Red)) {
return true;
}
} else if (currentItem.getItem() == BuildCraftTransport.bluePipeWire) {
if (addOrStripWire(player, pipe, IPipe.WireColor.Blue)) {
if (addOrStripWire(player, pipe, PipeWire.Blue)) {
return true;
}
} else if (currentItem.getItem() == BuildCraftTransport.greenPipeWire) {
if (addOrStripWire(player, pipe, IPipe.WireColor.Green)) {
if (addOrStripWire(player, pipe, PipeWire.Green)) {
return true;
}
} else if (currentItem.getItem() == BuildCraftTransport.yellowPipeWire) {
if (addOrStripWire(player, pipe, IPipe.WireColor.Yellow)) {
if (addOrStripWire(player, pipe, PipeWire.Yellow)) {
return true;
}
} else if (currentItem.getItem() instanceof ItemGate) {
@ -752,7 +751,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
return false;
}
private boolean addOrStripWire(EntityPlayer player, Pipe pipe, IPipe.WireColor color) {
private boolean addOrStripWire(EntityPlayer player, Pipe pipe, PipeWire color) {
if (addWire(pipe, color)) {
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().splitStack(1);
@ -762,7 +761,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
return player.isSneaking() && stripWire(pipe, color);
}
private boolean addWire(Pipe pipe, IPipe.WireColor color) {
private boolean addWire(Pipe pipe, PipeWire color) {
if (!pipe.wireSet[color.ordinal()]) {
pipe.wireSet[color.ordinal()] = true;
pipe.signalStrength[color.ordinal()] = 0;
@ -772,7 +771,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
return false;
}
private boolean stripWire(Pipe pipe, IPipe.WireColor color) {
private boolean stripWire(Pipe pipe, PipeWire color) {
if (pipe.wireSet[color.ordinal()]) {
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
dropWire(color, pipe);
@ -853,7 +852,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
}
// Try to strip wires second, starting with yellow.
for (IPipe.WireColor color : IPipe.WireColor.values()) {
for (PipeWire color : PipeWire.values()) {
if (stripWire(pipe, color))
return true;
}
@ -866,7 +865,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
*
* @param color
*/
private void dropWire(IPipe.WireColor color, Pipe pipe) {
private void dropWire(PipeWire color, Pipe pipe) {
Item wireItem;
switch (color) {

View file

@ -1,5 +1,6 @@
package buildcraft.transport;
import buildcraft.api.transport.PipeWire;
import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
@ -7,7 +8,6 @@ import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.gates.TriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.core.GuiIds;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.ActionRedstoneOutput;
@ -261,22 +261,22 @@ public final class Gate {
// / TRIGGERS
public void addTrigger(List<ITrigger> list) {
if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && material == GateMaterial.IRON) {
if (pipe.wireSet[PipeWire.Red.ordinal()] && material == GateMaterial.IRON) {
list.add(BuildCraftTransport.triggerRedSignalActive);
list.add(BuildCraftTransport.triggerRedSignalInactive);
}
if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && material == GateMaterial.IRON) {
if (pipe.wireSet[PipeWire.Blue.ordinal()] && material == GateMaterial.IRON) {
list.add(BuildCraftTransport.triggerBlueSignalActive);
list.add(BuildCraftTransport.triggerBlueSignalInactive);
}
if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && material == GateMaterial.GOLD) {
if (pipe.wireSet[PipeWire.Green.ordinal()] && material == GateMaterial.GOLD) {
list.add(BuildCraftTransport.triggerGreenSignalActive);
list.add(BuildCraftTransport.triggerGreenSignalInactive);
}
if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && material == GateMaterial.DIAMOND) {
if (pipe.wireSet[PipeWire.Yellow.ordinal()] && material == GateMaterial.DIAMOND) {
list.add(BuildCraftTransport.triggerYellowSignalActive);
list.add(BuildCraftTransport.triggerYellowSignalInactive);
}
@ -295,16 +295,16 @@ public final class Gate {
// / ACTIONS
public void addActions(List<IAction> list) {
if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && material == GateMaterial.IRON)
if (pipe.wireSet[PipeWire.Red.ordinal()] && material == GateMaterial.IRON)
list.add(BuildCraftTransport.actionRedSignal);
if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()] && material == GateMaterial.IRON)
if (pipe.wireSet[PipeWire.Blue.ordinal()] && material == GateMaterial.IRON)
list.add(BuildCraftTransport.actionBlueSignal);
if (pipe.wireSet[IPipe.WireColor.Green.ordinal()] && material == GateMaterial.GOLD)
if (pipe.wireSet[PipeWire.Green.ordinal()] && material == GateMaterial.GOLD)
list.add(BuildCraftTransport.actionGreenSignal);
if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] && material == GateMaterial.DIAMOND)
if (pipe.wireSet[PipeWire.Yellow.ordinal()] && material == GateMaterial.DIAMOND)
list.add(BuildCraftTransport.actionYellowSignal);

View file

@ -1,4 +1,4 @@
package buildcraft.api.transport;
package buildcraft.transport;
import net.minecraftforge.common.ForgeDirection;

View file

@ -7,6 +7,7 @@
*/
package buildcraft.transport;
import buildcraft.api.transport.PipeWire;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.IIconProvider;
import buildcraft.api.core.SafeTimeTracker;
@ -14,7 +15,6 @@ import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.TriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.core.IDropControlInventory;
import buildcraft.core.inventory.InvUtils;
import buildcraft.core.network.TilePacketWrapper;
@ -37,8 +37,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropControlInventory {
public abstract class Pipe<T extends PipeTransport> implements IDropControlInventory {
public int[] signalStrength = new int[]{0, 0, 0, 0};
public TileGenericPipe container;
public final T transport;
@ -252,7 +251,7 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
initialized = true;
}
private void readNearbyPipesSignal(WireColor color) {
private void readNearbyPipesSignal(PipeWire color) {
boolean foundBiggerSignal = false;
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
@ -288,12 +287,12 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
}
public void updateSignalState() {
for (IPipe.WireColor c : IPipe.WireColor.values()) {
for (PipeWire c : PipeWire.values()) {
updateSignalStateForColor(c);
}
}
private void updateSignalStateForColor(IPipe.WireColor color) {
private void updateSignalStateForColor(PipeWire color) {
if (!wireSet[color.ordinal()])
return;
@ -323,7 +322,7 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
}
}
private boolean receiveSignal(int signal, IPipe.WireColor color) {
private boolean receiveSignal(int signal, PipeWire color) {
if (container.worldObj == null)
return false;
@ -382,7 +381,7 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
// / @Override TODO: should be in IPipe
public boolean isWired() {
for (WireColor color : WireColor.values()) {
for (PipeWire color : PipeWire.values()) {
if (isWired(color))
return true;
}
@ -390,12 +389,10 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
return false;
}
@Override
public boolean isWired(WireColor color) {
public boolean isWired(PipeWire color) {
return wireSet[color.ordinal()];
}
@Override
public boolean hasGate() {
return gate != null;
}
@ -442,19 +439,19 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
}
public void onBlockRemoval() {
if (wireSet[IPipe.WireColor.Red.ordinal()]) {
if (wireSet[PipeWire.Red.ordinal()]) {
dropItem(new ItemStack(BuildCraftTransport.redPipeWire));
}
if (wireSet[IPipe.WireColor.Blue.ordinal()]) {
if (wireSet[PipeWire.Blue.ordinal()]) {
dropItem(new ItemStack(BuildCraftTransport.bluePipeWire));
}
if (wireSet[IPipe.WireColor.Green.ordinal()]) {
if (wireSet[PipeWire.Green.ordinal()]) {
dropItem(new ItemStack(BuildCraftTransport.greenPipeWire));
}
if (wireSet[IPipe.WireColor.Yellow.ordinal()]) {
if (wireSet[PipeWire.Yellow.ordinal()]) {
dropItem(new ItemStack(BuildCraftTransport.yellowPipeWire));
}
@ -496,13 +493,11 @@ public abstract class Pipe<T extends PipeTransport> implements IPipe, IDropContr
protected void actionsActivated(Map<IAction, Boolean> actions) {
}
@Override
public TileGenericPipe getContainer() {
return container;
}
@Override
public boolean isWireConnectedTo(TileEntity tile, WireColor color) {
public boolean isWireConnectedTo(TileEntity tile, PipeWire color) {
if (!(tile instanceof TileGenericPipe))
return false;

View file

@ -4,7 +4,7 @@ import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerProvider;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile;
import buildcraft.transport.pipes.PipePowerWood;
import java.util.LinkedList;
import net.minecraft.block.Block;
@ -13,31 +13,36 @@ import net.minecraft.tileentity.TileEntity;
public class PipeTriggerProvider implements ITriggerProvider {
@Override
public LinkedList<ITrigger> getPipeTriggers(IPipe iPipe) {
if (iPipe instanceof IOverrideDefaultTriggers)
return ((IOverrideDefaultTriggers) iPipe).getTriggers();
public LinkedList<ITrigger> getPipeTriggers(IPipeTile tile) {
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
Pipe pipe = null;
if (tile instanceof TileGenericPipe)
pipe = ((TileGenericPipe) tile).pipe;
if (pipe == null)
return result;
if (pipe instanceof IOverrideDefaultTriggers)
return ((IOverrideDefaultTriggers) pipe).getTriggers();
Pipe pipe = (Pipe) iPipe;
if (pipe.hasGate()) {
if (pipe.hasGate())
pipe.gate.addTrigger(result);
}
if (pipe.transport instanceof PipeTransportItems) {
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeItems);
} else if (pipe.transport instanceof PipeTransportPower) {
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeContainsEnergy);
result.add(BuildCraftTransport.triggerPipeTooMuchEnergy);
if (pipe instanceof PipePowerWood) {
result.add(BuildCraftTransport.triggerPipeRequestsEnergy);
}
} else if (pipe.transport instanceof PipeTransportFluids) {
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeFluids);
switch (tile.getPipeType()) {
case ITEM:
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeItems);
break;
case FLUID:
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeFluids);
break;
case POWER:
result.add(BuildCraftTransport.triggerPipeEmpty);
result.add(BuildCraftTransport.triggerPipeContainsEnergy);
result.add(BuildCraftTransport.triggerPipeTooMuchEnergy);
if (pipe instanceof PipePowerWood) {
result.add(BuildCraftTransport.triggerPipeRequestsEnergy);
}
break;
}
return result;

View file

@ -7,6 +7,7 @@
*/
package buildcraft.transport;
import buildcraft.api.transport.PipeWire;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -35,10 +36,8 @@ import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeConnection;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.ISolidSideTile;
import buildcraft.core.DefaultProps;
import buildcraft.core.IDropControlInventory;
import buildcraft.core.ITileBufferHolder;
@ -223,7 +222,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
}
// WireState
for (IPipe.WireColor color : IPipe.WireColor.values()) {
for (PipeWire color : PipeWire.values()) {
renderState.wireMatrix.setWire(color, pipe.wireSet[color.ordinal()]);
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color));
@ -312,11 +311,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
}
}
@Override
public IPipe getPipe() {
return pipe;
}
public boolean isInitialized() {
return initialized;
}
@ -497,6 +491,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
return pipeConnectionsBuffer[with.ordinal()];
}
@Override
public boolean isWireActive(PipeWire wire) {
if (pipe == null)
return false;
return pipe.signalStrength[wire.ordinal()] > 0;
}
@Override
public boolean doDrop() {
if (BlockGenericPipe.isValid(pipe))

View file

@ -84,7 +84,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
// the client.
if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
_potentialActions.addAll(pipe.getActions());
_potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe));
_potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container));
if (pipe.container instanceof IOverrideDefaultTriggers) {
_potentialTriggers.addAll(((IOverrideDefaultTriggers) pipe.container).getTriggers());

View file

@ -11,8 +11,6 @@ import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftCore.RenderMode;
import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.GateExpansionController;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipe.WireColor;
import buildcraft.core.CoreConstants;
import buildcraft.core.render.RenderEntityBlock;
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
@ -20,6 +18,7 @@ import buildcraft.core.utils.EnumColor;
import buildcraft.core.render.RenderUtils;
import buildcraft.core.utils.MatrixTranformations;
import buildcraft.transport.Pipe;
import buildcraft.api.transport.PipeWire;
import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState;
import buildcraft.transport.PipeTransportFluids;
@ -27,6 +26,7 @@ import buildcraft.transport.PipeTransportItems;
import buildcraft.transport.PipeTransportPower;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TravelingItem;
import buildcraft.api.transport.PipeWire;
import com.google.common.collect.Maps;
import java.util.HashMap;
import net.minecraft.block.Block;
@ -275,20 +275,20 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
private void renderGatesWires(TileGenericPipe pipe, double x, double y, double z) {
PipeRenderState state = pipe.renderState;
if (state.wireMatrix.hasWire(WireColor.Red)) {
pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Red, x, y, z);
if (state.wireMatrix.hasWire(PipeWire.Red)) {
pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, PipeWire.Red, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Blue)) {
pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Blue, x, y, z);
if (state.wireMatrix.hasWire(PipeWire.Blue)) {
pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, PipeWire.Blue, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Green)) {
pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, IPipe.WireColor.Green, x, y, z);
if (state.wireMatrix.hasWire(PipeWire.Green)) {
pipeWireRender(pipe, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, PipeWire.Green, x, y, z);
}
if (state.wireMatrix.hasWire(WireColor.Yellow)) {
pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, IPipe.WireColor.Yellow, x, y, z);
if (state.wireMatrix.hasWire(PipeWire.Yellow)) {
pipeWireRender(pipe, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, PipeWire.Yellow, x, y, z);
}
if (pipe.pipe.gate != null) {
@ -296,7 +296,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
}
}
private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, IPipe.WireColor color, double x, double y, double z) {
private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, PipeWire color, double x, double y, double z) {
PipeRenderState state = pipe.renderState;

View file

@ -9,16 +9,17 @@
package buildcraft.transport.triggers;
import buildcraft.api.transport.IPipe;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCAction;
import buildcraft.transport.Pipe;
import buildcraft.api.transport.PipeWire;
import java.util.Locale;
public class ActionSignalOutput extends BCAction {
public IPipe.WireColor color;
public PipeWire color;
public ActionSignalOutput(int id, IPipe.WireColor color) {
public ActionSignalOutput(int id, PipeWire color) {
super(id, "buildcraft.pipe.wire.output." + color.name().toLowerCase(Locale.ENGLISH));
this.color = color;

View file

@ -8,19 +8,19 @@
package buildcraft.transport.triggers;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.core.triggers.ActionTriggerIconProvider;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.transport.ITriggerPipe;
import buildcraft.transport.Pipe;
import buildcraft.api.transport.PipeWire;
import java.util.Locale;
public class TriggerPipeSignal extends BCTrigger implements ITriggerPipe {
boolean active;
IPipe.WireColor color;
PipeWire color;
public TriggerPipeSignal(int legacyId, boolean active, IPipe.WireColor color) {
public TriggerPipeSignal(int legacyId, boolean active, PipeWire color) {
super(legacyId, "buildcraft.pipe.wire.input." + color.name().toLowerCase(Locale.ENGLISH) + (active ? ".active" : ".inactive"));
this.active = active;

View file

@ -1,6 +1,7 @@
package buildcraft.transport.utils;
import buildcraft.api.transport.IPipe;
import buildcraft.transport.Pipe;
import buildcraft.api.transport.PipeWire;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@ -10,44 +11,44 @@ import net.minecraftforge.common.ForgeDirection;
public class WireMatrix {
//private final boolean[] _hasWire = new boolean[IPipe.WireColor.values().length];
private final BitSet _hasWire = new BitSet(IPipe.WireColor.values().length);
private final BitSet _hasWire = new BitSet(PipeWire.values().length);
private final BitSetCodec _bitSetCodec = new BitSetCodec();
private final ConnectionMatrix _wires[] = new ConnectionMatrix[IPipe.WireColor.values().length];
private final int[] _wireIconIndex = new int[IPipe.WireColor.values().length];
private final ConnectionMatrix _wires[] = new ConnectionMatrix[PipeWire.values().length];
private final int[] _wireIconIndex = new int[PipeWire.values().length];
private boolean dirty = false;
public WireMatrix() {
for (int i = 0; i < IPipe.WireColor.values().length; i++) {
for (int i = 0; i < PipeWire.values().length; i++) {
_wires[i] = new ConnectionMatrix();
}
}
public boolean hasWire(IPipe.WireColor color) {
public boolean hasWire(PipeWire color) {
return _hasWire.get(color.ordinal());
}
public void setWire(IPipe.WireColor color, boolean value) {
public void setWire(PipeWire color, boolean value) {
if (_hasWire.get(color.ordinal()) != value) {
_hasWire.set(color.ordinal(), value);
dirty = true;
}
}
public boolean isWireConnected(IPipe.WireColor color, ForgeDirection direction) {
public boolean isWireConnected(PipeWire color, ForgeDirection direction) {
return _wires[color.ordinal()].isConnected(direction);
}
public void setWireConnected(IPipe.WireColor color, ForgeDirection direction, boolean value) {
public void setWireConnected(PipeWire color, ForgeDirection direction, boolean value) {
_wires[color.ordinal()].setConnected(direction, value);
}
public int getWireIconIndex(IPipe.WireColor color){
public int getWireIconIndex(PipeWire color){
return _wireIconIndex[color.ordinal()];
}
public void setWireIndex(IPipe.WireColor color, int value){
public void setWireIndex(PipeWire color, int value){
if (_wireIconIndex[color.ordinal()] != value){
_wireIconIndex[color.ordinal()] = value;
dirty = true;
@ -56,7 +57,7 @@ public class WireMatrix {
public boolean isDirty() {
for (int i = 0; i < IPipe.WireColor.values().length; i++) {
for (int i = 0; i < PipeWire.values().length; i++) {
if (_wires[i].isDirty())
return true;
}
@ -65,7 +66,7 @@ public class WireMatrix {
}
public void clean() {
for (int i = 0; i < IPipe.WireColor.values().length; i++) {
for (int i = 0; i < PipeWire.values().length; i++) {
_wires[i].clean();
}
dirty = false;
@ -74,7 +75,7 @@ public class WireMatrix {
public void writeData(DataOutputStream data) throws IOException {
data.writeByte(_bitSetCodec.encode(_hasWire));
for (int i = 0; i < IPipe.WireColor.values().length; i++) {
for (int i = 0; i < PipeWire.values().length; i++) {
_wires[i].writeData(data);
data.writeByte(_wireIconIndex[i]);
}
@ -82,7 +83,7 @@ public class WireMatrix {
public void readData(DataInputStream data) throws IOException {
_bitSetCodec.decode(data.readByte(), _hasWire);
for (int i = 0; i < IPipe.WireColor.values().length; i++) {
for (int i = 0; i < PipeWire.values().length; i++) {
_wires[i].readData(data);
_wireIconIndex[i] = data.readByte();
}