use of buildcraft.api.gates.IGate in project BuildCraft by BuildCraft.
the class TriggerRedstoneFaderInput method isTriggerActive.
@Override
public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) {
if (!(container instanceof IGate) || parameters.length < 1 || !(parameters[0] instanceof StatementParameterRedstoneLevel)) {
return false;
}
int level = ((StatementParameterRedstoneLevel) parameters[0]).level;
IGate gate = (IGate) container;
TileGenericPipe tile = (TileGenericPipe) gate.getPipe().getTile();
int inputLevel = tile.redstoneInput;
if (parameters.length > 1 && parameters[1] instanceof StatementParamGateSideOnly && ((StatementParamGateSideOnly) parameters[1]).isOn) {
inputLevel = tile.redstoneInputSide[gate.getSide().ordinal()];
}
switch(mode) {
case LESS:
return inputLevel < level;
case EQUAL:
default:
return inputLevel == level;
case GREATER:
return inputLevel > level;
}
}
use of buildcraft.api.gates.IGate in project BuildCraft by BuildCraft.
the class ActionParameterSignal method getPossible.
@Override
public IStatementParameter[] getPossible(IStatementContainer source) {
if (!(source instanceof IGate)) {
return null;
}
IGate gate = (IGate) source;
List<IStatementParameter> poss = new ArrayList<>(1 + ColourUtil.COLOURS.length);
poss.add(EMPTY);
for (EnumDyeColor c : ColourUtil.COLOURS) {
if (TriggerPipeSignal.doesGateHaveColour(gate, c)) {
poss.add(get(c));
}
}
return poss.toArray(new IStatementParameter[poss.size()]);
}
use of buildcraft.api.gates.IGate in project BuildCraft by BuildCraft.
the class DockingStationPipe method getRequest.
@Override
public ItemStack getRequest(int slot) {
int facing = (slot & 0x70) >> 4;
int action = (slot & 0xc) >> 2;
int param = slot & 0x3;
if (facing >= 6) {
return null;
}
EnumFacing side = EnumFacing.getFront(facing);
IGate gate = getPipe().getPipe().getGate(side);
if (gate == null) {
return null;
}
List<IStatement> actions = gate.getActions();
if (actions.size() <= action) {
return null;
}
if (actions.get(action) != BuildCraftRobotics.actionStationRequestItems) {
return null;
}
List<StatementSlot> activeActions = gate.getActiveActions();
StatementSlot slotStmt = null;
for (StatementSlot stmt : activeActions) {
if (stmt.statement == actions.get(action)) {
slotStmt = stmt;
break;
}
}
if (slotStmt == null) {
return null;
}
if (slotStmt.parameters.length <= param) {
return null;
}
if (slotStmt.parameters[param] == null) {
return null;
}
return slotStmt.parameters[param].getItemStack();
}
use of buildcraft.api.gates.IGate in project BuildCraft by BuildCraft.
the class ActionPowerPulsar method actionActivate.
@Override
public void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
if (source instanceof IGate) {
IGate gate = (IGate) source;
IPipeHolder pipe = gate.getPipeHolder();
PipePluggable plug = pipe.getPluggable(side);
if (plug instanceof PluggablePulsar) {
PluggablePulsar pulsar = (PluggablePulsar) plug;
if (constant) {
pulsar.enablePulsar();
} else {
pulsar.addSinglePulse();
}
}
}
}
use of buildcraft.api.gates.IGate in project BuildCraft by BuildCraft.
the class TriggerPipeSignal method isTriggerActive.
@Override
public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) {
if (!(container instanceof IGate)) {
return false;
}
IGate gate = (IGate) container;
IWireManager wires = gate.getPipeHolder().getWireManager();
if (active) {
if (!wires.isAnyPowered(colour)) {
return false;
}
} else if (wires.isAnyPowered(colour)) {
return false;
}
for (IStatementParameter param : parameters) {
if (param != null && param instanceof TriggerParameterSignal) {
TriggerParameterSignal signal = (TriggerParameterSignal) param;
if (signal.colour != null) {
if (!wires.isAnyPowered(signal.colour)) {
return false;
}
} else if (wires.isAnyPowered(signal.colour)) {
return false;
}
}
}
return true;
}
Aggregations