示例#1
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) {
      chip.setOutput(0, hurt());
    }
  }
示例#2
0
  @Override
  public void think(ChipState chip) {

    if (chip.getInput(0)) {
      triggerClock(chip);
    }
  }
示例#3
0
  @Override
  public void execute(ChipState chip, boolean[] state, WithLineInfo<String>[] code)
      throws PlcException {

    boolean[] tt = new boolean[32];
    boolean a = chip.getInputCount() > 0 && chip.getInput(0);
    boolean b = chip.getInputCount() > 1 && chip.getInput(1);
    boolean c = chip.getInputCount() > 2 && chip.getInput(2);

    for (int i = 0; i < chip.getOutputCount(); i++)
      if (i < code.length) {
        Boolean r = executeFunction(i, state, tt, code, a, b, c, new boolean[0], new int[1], 0);
        if (r == null) {
          chip.setOutput(i, false);
        } else {
          chip.setOutput(i, r);
        }
      } else {
        chip.setOutput(i, false);
      }
  }
示例#4
0
  public boolean setMemory(ChipState chip) {
    try {
      File f = new File("plugins/CraftBookCircuits/ROM/", getSign().getLine(2));
      if (!f.exists()) f.createNewFile();
      PrintWriter pw = new PrintWriter(f);
      for (int i = 0; i < 2; i++)
        if (chip.getInput(i)) pw.println("1");
        else pw.println("0");
      pw.close();
    } catch (Exception e) {

    }
    return false;
  }
示例#5
0
  @Override
  public void trigger(ChipState chip) {

    int on = 0, valid = 0;
    for (int i = 0; i < chip.getInputCount(); i++) {

      if (chip.isValid(i)) {
        valid++;

        if (chip.getInput(i)) on++;
      }
    }

    // Condition; all valid must be ON, at least one valid.
    chip.setOutput(0, (on == valid && valid > 0));
  }
示例#6
0
 @Override
 public void think(ChipState state) {
   if (state.getInput(0)) {
     for (Player p : getSign().getWorld().getPlayers()) {
       int radius = 10, effectID = 1, effectAmount = 1, effectTime = 10;
       try {
         effectID = Integer.parseInt(getSign().getLine(2).split(":")[0]);
         effectAmount = Integer.parseInt(getSign().getLine(2).split(":")[1]);
         effectTime = Integer.parseInt(getSign().getLine(2).split(":")[2]);
         radius = Integer.parseInt(getSign().getLine(3));
       } catch (Exception e) {
       }
       if (p.getLocation().distance(getSign().getLocation()) > radius) continue;
       p.addPotionEffect(
           new PotionEffect(PotionEffectType.getById(effectID), effectTime * 20, effectAmount - 1),
           true);
     }
   }
 }
示例#7
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) shootFire(5);
  }