Search in sources :

Example 1 with IGate

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;
    }
}
Also used : StatementParameterRedstoneLevel(buildcraft.core.statements.StatementParameterRedstoneLevel) IGate(buildcraft.api.gates.IGate) TileGenericPipe(buildcraft.transport.TileGenericPipe) StatementParamGateSideOnly(buildcraft.core.statements.StatementParamGateSideOnly)

Example 2 with IGate

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()]);
}
Also used : IGate(buildcraft.api.gates.IGate) ArrayList(java.util.ArrayList) IStatementParameter(buildcraft.api.statements.IStatementParameter) EnumDyeColor(net.minecraft.item.EnumDyeColor)

Example 3 with IGate

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();
}
Also used : StatementSlot(buildcraft.api.statements.StatementSlot) IGate(buildcraft.api.gates.IGate) EnumFacing(net.minecraft.util.EnumFacing) IStatement(buildcraft.api.statements.IStatement)

Example 4 with IGate

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();
            }
        }
    }
}
Also used : IGate(buildcraft.api.gates.IGate) IPipeHolder(buildcraft.api.transport.pipe.IPipeHolder) PluggablePulsar(buildcraft.transport.plug.PluggablePulsar) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable)

Example 5 with IGate

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;
}
Also used : IGate(buildcraft.api.gates.IGate) IStatementParameter(buildcraft.api.statements.IStatementParameter) IWireManager(buildcraft.api.transport.IWireManager)

Aggregations

IGate (buildcraft.api.gates.IGate)6 IStatementParameter (buildcraft.api.statements.IStatementParameter)2 ArrayList (java.util.ArrayList)2 EnumDyeColor (net.minecraft.item.EnumDyeColor)2 IStatement (buildcraft.api.statements.IStatement)1 StatementSlot (buildcraft.api.statements.StatementSlot)1 IWireManager (buildcraft.api.transport.IWireManager)1 IPipeHolder (buildcraft.api.transport.pipe.IPipeHolder)1 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)1 StatementParamGateSideOnly (buildcraft.core.statements.StatementParamGateSideOnly)1 StatementParameterRedstoneLevel (buildcraft.core.statements.StatementParameterRedstoneLevel)1 TileGenericPipe (buildcraft.transport.TileGenericPipe)1 PluggablePulsar (buildcraft.transport.plug.PluggablePulsar)1 EnumFacing (net.minecraft.util.EnumFacing)1