Exemplo n.º 1
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) {
      chip.setOutput(0, shoot());
    }
  }
Exemplo n.º 2
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) {
      setDoor(true);
    } else {
      setDoor(false);
    }

    chip.setOutput(0, chip.getInput(0));
  }
Exemplo n.º 3
0
  @Override
  public void trigger(ChipState chip) {

    boolean value = chip.getInput(0);
    boolean targetB = chip.getInput(1);
    boolean targetC = chip.getInput(2);

    if (targetB) {
      chip.setOutput(1, value);
    }
    if (targetC) {
      chip.setOutput(2, value);
    }
  }
Exemplo n.º 4
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) {
      terraform(true);
    }
  }
Exemplo n.º 5
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) {
      doEffect();
    }
  }
Exemplo n.º 6
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(2)) {
      chip.setOutput(0, false);
    } else if (chip.getInput(1) && chip.isTriggered(1)) {
      chip.setOutput(0, chip.getInput(0));
    }
  }
Exemplo n.º 7
0
  @Override
  public void think(ChipState chip) {

    chip.setOutput(0, stock());
  }
Exemplo n.º 8
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) chip.setOutput(0, stock());
  }
Exemplo n.º 9
0
 @Override
 public void think(ChipState chip) {
   chip.setOutput(0, collect());
 }
Exemplo n.º 10
0
  @Override
  public void think(ChipState state) {

    state.setOutput(0, isDetected());
  }
Exemplo n.º 11
0
  @Override
  public void trigger(ChipState chip) {

    if (!location.getChunk().isLoaded()) return;

    if (!chip.getInput(0)) return;
    Block left = SignUtil.getLeftBlock(BukkitUtil.toSign(getSign()).getBlock());
    ChangedSign effectSign = null;
    if (left.getTypeId() == BlockID.WALL_SIGN) {
      effectSign = BukkitUtil.toChangedSign(left);
    }

    Block right = SignUtil.getRightBlock(BukkitUtil.toSign(getSign()).getBlock());
    ChangedSign armourSign = null;
    if (right.getTypeId() == BlockID.WALL_SIGN) {
      armourSign = BukkitUtil.toChangedSign(right);
    }

    for (int i = 0; i < amount; i++) {
      Entity ent = BukkitUtil.toSign(getSign()).getWorld().spawn(location, type.getEntityClass());

      if (armourSign != null) { // Apply armor
        if (ent instanceof LivingEntity) {

          for (int s = 0; s < 4; s++) {
            String bit = armourSign.getLine(s);

            ItemStack slot = ItemUtil.makeItemValid(ItemUtil.getItem(bit));

            if (s == 0) ((LivingEntity) ent).getEquipment().setHelmet(slot);
            if (s == 1) ((LivingEntity) ent).getEquipment().setChestplate(slot);
            if (s == 2) ((LivingEntity) ent).getEquipment().setLeggings(slot);
            if (s == 3) ((LivingEntity) ent).getEquipment().setBoots(slot);
          }
        }
      }

      Boolean upwards = null;

      while (effectSign != null) { // Apply effects
        for (int s = 0; s < 4; s++) {
          String bit = effectSign.getLine(s);
          if (bit == null || bit.trim().isEmpty()) continue;

          String[] data = RegexUtil.COLON_PATTERN.split(bit);

          if (data[0].equalsIgnoreCase("e")) CreatureSpawner.setEntityData(ent, bit.substring(2));
          else if (data[0].equalsIgnoreCase("r")) {
            EntityType rider = EntityType.fromName(data[1].trim());
            Entity rid = BukkitUtil.toSign(getSign()).getWorld().spawnEntity(location, rider);
            ent.setPassenger(rid);
          } else if (data[0].equalsIgnoreCase("p") && ent instanceof LivingEntity) {
            for (int a = 1; a < data.length; a++) {
              try {
                String[] potionBits = RegexUtil.SEMICOLON_PATTERN.split(data[a]);
                PotionEffect effect =
                    new PotionEffect(
                        PotionEffectType.getById(Integer.parseInt(potionBits[0])),
                        Integer.parseInt(potionBits[1]),
                        Integer.parseInt(potionBits[2]));
                ((LivingEntity) ent).addPotionEffect(effect, true);
              } catch (Exception e) {
              }
            }
          } else if (data[0].equalsIgnoreCase("v")) {
            try {
              double x, y, z;
              String[] coords = RegexUtil.COMMA_PATTERN.split(data[1]);
              x = Double.parseDouble(coords[0]);
              y = Double.parseDouble(coords[1]);
              z = Double.parseDouble(coords[2]);
              ent.setVelocity(new org.bukkit.util.Vector(x, y, z));
            } catch (Exception ignored) {
            }
          } else if (data[0].equalsIgnoreCase("s")) {
            if (!(ent instanceof LivingEntity)) continue;

            ItemStack slot = ItemUtil.makeItemValid(ItemUtil.getItem(bit.replace("s:", "")));
            ((LivingEntity) ent).getEquipment().setItemInHand(slot);
          }
        }
        if (upwards == null) {
          if (BukkitUtil.toSign(effectSign).getBlock().getRelative(0, 1, 0).getTypeId()
              == BlockID.WALL_SIGN) {
            effectSign =
                BukkitUtil.toChangedSign(
                    BukkitUtil.toSign(effectSign).getBlock().getRelative(0, 1, 0));
            upwards = true;
          } else if (BukkitUtil.toSign(effectSign).getBlock().getRelative(0, -1, 0).getTypeId()
              == BlockID.WALL_SIGN) {
            effectSign =
                BukkitUtil.toChangedSign(
                    BukkitUtil.toSign(effectSign).getBlock().getRelative(0, -1, 0));
            upwards = false;
          } else break;
        } else {
          if (BukkitUtil.toSign(effectSign)
                  .getBlock()
                  .getRelative(0, upwards ? 1 : -1, 0)
                  .getTypeId()
              == BlockID.WALL_SIGN)
            effectSign =
                BukkitUtil.toChangedSign(
                    BukkitUtil.toSign(effectSign).getBlock().getRelative(0, upwards ? 1 : -1, 0));
          else break;
        }
      }
    }
  }
Exemplo n.º 12
0
  @Override
  public void trigger(ChipState chip) {

    chip.setOutput(0, chip.getInput(0));
  }
Exemplo n.º 13
0
  @Override
  public void think(ChipState chip) {

    chip.setOutput(0, harvest());
  }
Exemplo n.º 14
0
  @Override
  public void trigger(ChipState chip) {

    if (chip.getInput(0)) chip.setOutput(0, invertOutput ? !isDetected() : isDetected());
  }