Package buildcraft.api.statements

Examples of buildcraft.api.statements.IStatementParameter


   * Return true if the tile given in parameter activates the trigger, given
   * the parameters.
   */
  @Override
  public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
    IStatementParameter parameter = null;
    if (parameters.length > 0) {
      parameter = parameters[0];
    }

    if (!(tile instanceof TileHatch))
      return false;

    ITileStructure central = ((TileHatch) tile).getCentralTE();
    if (central == null || !(central instanceof TileFarmPlain))
      return false;

    ItemStack filter;
    if (parameter == null || parameter.getItemStack() == null) {
      filter = new ItemStack(Blocks.bedrock, threshold);
    } else {
      filter = parameter.getItemStack().copy();
      filter.stackSize = threshold;
    }

    return !((TileFarmPlain) central).hasResources(new ItemStack[] { filter });
  }
View Full Code Here


      }
     
      for (int j = 0; j < Gate.MAX_PARAMETERS; ++j) {
        if (gateNBT.hasKey("triggerParameters[" + i + "][" + j + "]")) {
          NBTTagCompound cpt = gateNBT.getCompoundTag("triggerParameters[" + i + "][" + j + "]");
          IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
          parameter.readFromNBT(cpt);
         
          parameter = parameter.rotateLeft();
         
          parameter.writeToNBT(cpt);
          gateNBT.setTag("triggerParameters[" + i + "][" + j + "]", cpt);
        }
       
        if (gateNBT.hasKey("actionParameters[" + i + "][" + j + "]")) {
          NBTTagCompound cpt = gateNBT.getCompoundTag("actionParameters[" + i + "][" + j + "]");
          IStatementParameter parameter = StatementManager.createParameter(cpt.getString("kind"));
          parameter.readFromNBT(cpt);
         
          parameter = parameter.rotateLeft();
         
          parameter.writeToNBT(cpt);
          gateNBT.setTag("actionParameters[" + i + "][" + j + "]", cpt);
        }
      }
    }
View Full Code Here

    return StringUtils.localize("gate.trigger.redstone.input." + (active ? "active" : "inactive"));
  }
 
    @Override
    public IStatementParameter createParameter(int index) {
    IStatementParameter param = null;
 
    if (index == 0) {
        param = new StatementParameterRedstoneGateSideOnly();
    }
 
View Full Code Here

    return StringUtils.localize("gate.action.redstone.signal");
  }
 
    @Override
    public IStatementParameter createParameter(int index) {
    IStatementParameter param = null;
 
    if (index == 0) {
        param = new StatementParameterRedstoneGateSideOnly();
    }
 
View Full Code Here

      } else {
        container.setTrigger(triggerSlot.slot, changed.getUniqueTag(), true);
      }

      for (StatementParameterSlot p : triggerSlot.parameters) {
        IStatementParameter parameter = null;
        if (changed != null && p.slot < changed.minParameters()) {
          parameter = changed.createParameter(p.slot);
        }
        container.setTriggerParameter(triggerSlot.slot, p.slot, parameter, true);
      }
    } else if (slot instanceof ActionSlot) {
      ActionSlot actionSlot = (ActionSlot) slot;

      IStatement changed = null;
      if (actionSlot.getStatement() == null) {

        if (k == 0) {
          changed = container.getFirstAction();
        } else {
          changed = container.getLastAction();
        }

      } else {
        Iterator<IStatement> it = container.getActionIterator(k != 0);

        for (; it.hasNext();) {
          IStatement action = it.next();

          if (!it.hasNext()) {
            changed = null;
            break;
          }

          if (action == actionSlot.getStatement()) {
            changed = it.next();
            break;
          }
        }
      }

      if (changed == null) {
        container.setAction(actionSlot.slot, null, true);
      } else {
        container.setAction(actionSlot.slot, changed.getUniqueTag(), true);
      }

      for (StatementParameterSlot p : actionSlot.parameters) {
        IStatementParameter parameter = null;
        if (changed != null && p.slot < changed.minParameters()) {
          parameter = changed.createParameter(p.slot);
        }
        container.setActionParameter(actionSlot.slot, p.slot, parameter, true);
      }
    } else if (slot instanceof StatementParameterSlot) {
      StatementParameterSlot paramSlot = (StatementParameterSlot) slot;
      StatementSlot statement = paramSlot.statementSlot;

      if (statement.isDefined() && statement.getStatement().maxParameters() != 0) {
        IStatementParameter param = paramSlot.getParameter();

        if (param == null) {
          param = statement.getStatement().createParameter(paramSlot.slot);
        }

        if (param != null) {
          param.onClick(gate, statement.getStatement(), mc.thePlayer.inventory.getItemStack(),
              new StatementMouseClick(k, isShiftKeyDown()));
          paramSlot.setParameter(param, true);
        }
      }
    }
View Full Code Here

      return getParameter() != null;
    }

    @Override
    public String getDescription() {
      IStatementParameter parameter = getParameter();

      if (parameter != null) {
        return parameter.getDescription() != null ? parameter.getDescription() : "";
      } else {
        return null;
      }
    }
View Full Code Here

      }
    }
   
    @Override
    public ItemStack getItemStack() {
      IStatementParameter parameter = getParameter();

      if (parameter != null) {
        return parameter.getItemStack();
      } else {
        return null;
      }
    }
View Full Code Here

      }
    }

    @Override
    public IIcon getIcon() {
      IStatementParameter parameter = getParameter();

      if (parameter != null) {
        return parameter.getIcon();
      } else {
        return null;
      }
    }
View Full Code Here

    icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level));
  }
 
    @Override
    public IStatementParameter createParameter(int index) {
    IStatementParameter param = null;
 
    if (index == 0) {
        param = new StatementParameterRedstoneGateSideOnly();
    }
 
View Full Code Here

    icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level));
  }
 
    @Override
    public IStatementParameter createParameter(int index) {
    IStatementParameter param = null;
 
    if (index == 0) {
        param = new StatementParameterRedstoneGateSideOnly();
    }
 
View Full Code Here

TOP

Related Classes of buildcraft.api.statements.IStatementParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.