use of buildcraft.api.statements.StatementSlot 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.statements.StatementSlot in project BuildCraft by BuildCraft.
the class ActionRobotFilterTool method getGateFilterStacks.
public static Collection<ItemStack> getGateFilterStacks(DockingStation station) {
ArrayList<ItemStack> result = new ArrayList<>();
for (StatementSlot slot : station.getActiveActions()) {
if (slot.statement instanceof ActionRobotFilterTool) {
for (IStatementParameter p : slot.parameters) {
if (p != null && p instanceof StatementParameterItemStack) {
StatementParameterItemStack param = (StatementParameterItemStack) p;
ItemStack stack = param.getItemStack();
if (stack != null) {
result.add(stack);
}
}
}
}
}
return result;
}
use of buildcraft.api.statements.StatementSlot in project LogisticsPipes by RS485.
the class LPBCTileGenericPipe method listEquals.
private boolean listEquals(List<StatementSlot> list1, List<StatementSlot> list2) {
ListIterator<StatementSlot> e1 = list1.listIterator();
ListIterator<StatementSlot> e2 = list2.listIterator();
while (e1.hasNext() && e2.hasNext()) {
StatementSlot o1 = e1.next();
StatementSlot o2 = e2.next();
if (!(o1 == null ? o2 == null : statementEquals(o1, o2))) {
return false;
}
}
return !(e1.hasNext() || e2.hasNext());
}
use of buildcraft.api.statements.StatementSlot in project BuildCraft by BuildCraft.
the class PipeItemsStripes method actionsActivated.
@Override
protected void actionsActivated(Collection<StatementSlot> actions) {
super.actionsActivated(actions);
actionDir = EnumPipePart.CENTER;
for (StatementSlot action : actions) {
if (action.statement instanceof ActionPipeDirection) {
actionDir = EnumPipePart.fromFacing(((ActionPipeDirection) action.statement).direction);
break;
}
}
}
use of buildcraft.api.statements.StatementSlot in project BuildCraft by BuildCraft.
the class GateLogic method resolveActions.
public void resolveActions() {
int groupCount = 0;
int groupActive = 0;
boolean[] prevTriggers = Arrays.copyOf(triggerOn, triggerOn.length);
boolean[] prevActions = Arrays.copyOf(actionOn, actionOn.length);
Arrays.fill(triggerOn, false);
Arrays.fill(actionOn, false);
activeActions.clear();
EnumSet<EnumDyeColor> previousBroadcasts = EnumSet.copyOf(wireBroadcasts);
wireBroadcasts.clear();
for (int triggerIndex = 0; triggerIndex < statements.length; triggerIndex++) {
StatementPair pair = statements[triggerIndex];
TriggerWrapper trigger = pair.trigger.get();
groupCount++;
if (trigger != null) {
IStatementParameter[] params = new IStatementParameter[pair.trigger.getParamCount()];
for (int p = 0; p < pair.trigger.getParamCount(); p++) {
params[p] = pair.trigger.getParamRef(p).get();
}
if (trigger.isTriggerActive(this, params)) {
groupActive++;
triggerOn[triggerIndex] = true;
}
}
if (connections.length == triggerIndex || !connections[triggerIndex]) {
boolean allActionsActive;
if (variant.logic == EnumGateLogic.AND) {
allActionsActive = groupActive == groupCount;
} else {
allActionsActive = groupActive > 0;
}
for (int i = groupCount - 1; i >= 0; i--) {
int actionIndex = triggerIndex - i;
StatementPair fullAction = statements[actionIndex];
ActionWrapper action = fullAction.action.get();
actionOn[actionIndex] = allActionsActive;
if (action != null) {
if (allActionsActive) {
StatementSlot slot = new StatementSlot();
slot.statement = action.delegate;
slot.parameters = fullAction.action.getParameters().clone();
slot.part = action.sourcePart;
activeActions.add(slot);
action.actionActivate(this, slot.parameters);
PipeEvent evt = new PipeEventActionActivate(getPipeHolder(), action.getDelegate(), slot.parameters, action.sourcePart);
getPipeHolder().fireEvent(evt);
} else {
action.actionDeactivated(this, fullAction.action.getParameters());
}
}
}
groupActive = 0;
groupCount = 0;
}
}
if (!previousBroadcasts.equals(wireBroadcasts)) {
IWireManager wires = getPipeHolder().getWireManager();
EnumSet<EnumDyeColor> turnedOff = EnumSet.copyOf(previousBroadcasts);
turnedOff.removeAll(wireBroadcasts);
// FIXME: add call to "wires.stopEmittingColour(turnedOff)"
EnumSet<EnumDyeColor> turnedOn = EnumSet.copyOf(wireBroadcasts);
turnedOn.removeAll(previousBroadcasts);
if (!getPipeHolder().getPipeWorld().isRemote) {
WorldSavedDataWireSystems.get(getPipeHolder().getPipeWorld()).gatesChanged = true;
}
}
if (!Arrays.equals(prevTriggers, triggerOn) || !Arrays.equals(prevActions, actionOn)) {
sendResolveData();
}
}
Aggregations