This commit is contained in:
asiekierka 2014-10-19 21:04:02 +02:00
parent 061a07192e
commit 2374bd1526
7 changed files with 63 additions and 33 deletions

View file

@ -66,6 +66,7 @@ import buildcraft.transport.ItemPipeWire;
import buildcraft.transport.ItemPlug; import buildcraft.transport.ItemPlug;
import buildcraft.transport.ItemRobotStation; import buildcraft.transport.ItemRobotStation;
import buildcraft.transport.Pipe; import buildcraft.transport.Pipe;
import buildcraft.transport.PipeActionProvider;
import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeTriggerProvider; import buildcraft.transport.PipeTriggerProvider;
import buildcraft.transport.TileFilteredBuffer; import buildcraft.transport.TileFilteredBuffer;
@ -533,6 +534,7 @@ public class BuildCraftTransport extends BuildCraftMod {
StatementManager.registerParameterClass("buildcraft:pipeWireTrigger", TriggerParameterSignal.class); StatementManager.registerParameterClass("buildcraft:pipeWireTrigger", TriggerParameterSignal.class);
StatementManager.registerParameterClass("buildcraft:pipeWireAction", ActionParameterSignal.class); StatementManager.registerParameterClass("buildcraft:pipeWireAction", ActionParameterSignal.class);
StatementManager.registerTriggerProvider(new PipeTriggerProvider()); StatementManager.registerTriggerProvider(new PipeTriggerProvider());
StatementManager.registerActionProvider(new PipeActionProvider());
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {
loadRecipes(); loadRecipes();

View file

@ -21,9 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.GateExpansionController;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
@ -465,8 +463,7 @@ public final class Gate implements IGate {
} }
// TRIGGERS // TRIGGERS
public void addTrigger(List<ITrigger> list) { public void addTriggers(List<ITrigger> list) {
for (PipeWire wire : PipeWire.VALUES) { for (PipeWire wire : PipeWire.VALUES) {
if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) { if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) {
list.add(BuildCraftTransport.triggerPipeWireActive[wire.ordinal()]); list.add(BuildCraftTransport.triggerPipeWireActive[wire.ordinal()]);

View file

@ -0,0 +1,42 @@
package buildcraft.transport;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider;
import buildcraft.api.transport.IPipeTile;
public class PipeActionProvider implements IActionProvider {
@Override
public Collection<IAction> getPipeActions(IPipeTile tile) {
LinkedList<IAction> result = new LinkedList<IAction>();
Pipe<?> pipe = null;
if (tile instanceof TileGenericPipe) {
pipe = ((TileGenericPipe) tile).pipe;
}
if (pipe == null) {
return result;
}
result.addAll(pipe.getActions());
for (Gate gate : pipe.gates) {
if (gate != null) {
gate.addActions(result);
}
}
return result;
}
@Override
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) {
return null;
}
}

View file

@ -39,7 +39,7 @@ public abstract class PipeTransport {
} }
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("inputOpen")) { if (nbt.hasKey("inputOpen") && nbt.hasKey("outputOpen")) {
BitSet inputBuf = BitSet.valueOf(new byte[] {nbt.getByte("inputOpen")}); BitSet inputBuf = BitSet.valueOf(new byte[] {nbt.getByte("inputOpen")});
BitSet outputBuf = BitSet.valueOf(new byte[] {nbt.getByte("outputOpen")}); BitSet outputBuf = BitSet.valueOf(new byte[] {nbt.getByte("outputOpen")});
@ -51,8 +51,8 @@ public abstract class PipeTransport {
} }
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
BitSet inputBuf = new BitSet(); BitSet inputBuf = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
BitSet outputBuf = new BitSet(); BitSet outputBuf = new BitSet(ForgeDirection.VALID_DIRECTIONS.length);
for (int b = 0; b < ForgeDirection.VALID_DIRECTIONS.length; b++) { for (int b = 0; b < ForgeDirection.VALID_DIRECTIONS.length; b++) {
if (inputsOpen[b]) { if (inputsOpen[b]) {

View file

@ -36,16 +36,20 @@ public class PipeTriggerProvider implements ITriggerProvider {
if (pipe == null) { if (pipe == null) {
return result; return result;
} else if (pipe instanceof IOverrideDefaultTriggers) {
return ((IOverrideDefaultTriggers) pipe).getTriggers();
} }
boolean containsGate = false;
for (Gate gate : pipe.gates) { for (Gate gate : pipe.gates) {
if (gate != null) { if (gate != null) {
gate.addTrigger(result); containsGate = true;
gate.addTriggers(result);
} }
} }
result.add(BuildCraftCore.triggerRedstoneActive);
result.add(BuildCraftCore.triggerRedstoneInactive);
switch (tile.getPipeType()) { switch (tile.getPipeType()) {
case ITEM: case ITEM:
result.add(TriggerPipeContents.PipeContents.empty.trigger); result.add(TriggerPipeContents.PipeContents.empty.trigger);
@ -60,7 +64,6 @@ public class PipeTriggerProvider implements ITriggerProvider {
result.add(TriggerPipeContents.PipeContents.containsEnergy.trigger); result.add(TriggerPipeContents.PipeContents.containsEnergy.trigger);
result.add(TriggerPipeContents.PipeContents.tooMuchEnergy.trigger); result.add(TriggerPipeContents.PipeContents.tooMuchEnergy.trigger);
result.add(TriggerPipeContents.PipeContents.requestsEnergy.trigger); result.add(TriggerPipeContents.PipeContents.requestsEnergy.trigger);
break; break;
case STRUCTURE: case STRUCTURE:
break; break;

View file

@ -66,8 +66,8 @@ import buildcraft.transport.gates.ItemGate;
import buildcraft.transport.utils.RobotStationState; import buildcraft.transport.utils.RobotStationState;
public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler,
IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IEnergyHandler, IPipeTile, ITileBufferHolder, IEnergyHandler, IDropControlInventory,
IDropControlInventory, ISyncedTile, ISolidSideTile, IGuiReturnHandler { ISyncedTile, ISolidSideTile, IGuiReturnHandler {
public boolean initialized = false; public boolean initialized = false;
public final PipeRenderState renderState = new PipeRenderState(); public final PipeRenderState renderState = new PipeRenderState();
@ -646,18 +646,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
sendClientUpdate = true; sendClientUpdate = true;
} }
@Override
public LinkedList<ITrigger> getTriggers() {
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
if (BlockGenericPipe.isFullyDefined(pipe) && pipe.hasGate()) {
result.add(BuildCraftCore.triggerRedstoneActive);
result.add(BuildCraftCore.triggerRedstoneInactive);
}
return result;
}
@Override @Override
public void blockRemoved(ForgeDirection from) { public void blockRemoved(ForgeDirection from) {
@ -871,6 +859,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
public boolean addGate(ForgeDirection direction, Gate gate) { public boolean addGate(ForgeDirection direction, Gate gate) {
gate.setDirection(direction); gate.setDirection(direction);
pipe.gates[direction.ordinal()] = gate;
return setPluggable(direction, new ItemGate.GatePluggable(gate)); return setPluggable(direction, new ItemGate.GatePluggable(gate));
} }

View file

@ -105,11 +105,8 @@ public class ContainerGateInterface extends BuildCraftContainer {
// Do not attempt to create a list of potential actions and triggers on // Do not attempt to create a list of potential actions and triggers on
// the client. // the client.
if (!pipe.container.getWorldObj().isRemote) { if (!pipe.container.getWorldObj().isRemote) {
potentialActions.addAll(gate.getActions());
potentialActions.addAll(pipe.getActions());
potentialTriggers.addAll(StatementManager.getPipeTriggers(pipe.container)); potentialTriggers.addAll(StatementManager.getPipeTriggers(pipe.container));
potentialActions.addAll(StatementManager.getPipeActions(pipe.container)); potentialActions.addAll(StatementManager.getPipeActions(pipe.container));
potentialTriggers.addAll(pipe.container.getTriggers());
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = pipe.container.getTile(o); TileEntity tile = pipe.container.getTile(o);