parent
061a07192e
commit
2374bd1526
7 changed files with 63 additions and 33 deletions
|
@ -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,7 +534,8 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()]);
|
||||||
|
|
42
common/buildcraft/transport/PipeActionProvider.java
Normal file
42
common/buildcraft/transport/PipeActionProvider.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -39,8 +39,8 @@ 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")});
|
||||||
|
|
||||||
for (int b = 0; b < ForgeDirection.VALID_DIRECTIONS.length; b++) {
|
for (int b = 0; b < ForgeDirection.VALID_DIRECTIONS.length; b++) {
|
||||||
|
@ -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]) {
|
||||||
|
|
|
@ -36,15 +36,19 @@ 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:
|
||||||
|
@ -59,11 +63,10 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
||||||
result.add(TriggerPipeContents.PipeContents.empty.trigger);
|
result.add(TriggerPipeContents.PipeContents.empty.trigger);
|
||||||
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;
|
||||||
|
case STRUCTURE:
|
||||||
break;
|
break;
|
||||||
case STRUCTURE:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) {
|
||||||
|
|
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue