示例#1
0
    @Override
    public void run() {
      @SuppressWarnings("rawtypes")
      List entities = null;

      try {
        switch (TYPE) {
          case 0:
            entities = etc.getServer().getPlayerList();
            break;
          case 1:
            entities = this.WORLD.getMobList();
            break;
          case 2:
            entities = this.WORLD.getAnimalList();
            break;
          case 3:
            entities = this.WORLD.getLivingEntityList();
            break;
          case 4:
            entities = entitiesExceptPlayers(this.WORLD.getWorld());
            break;
          case 5:
            entities = entitiesExceptPlayersItems(this.WORLD.getWorld());
            break;
        }
      } catch (ConcurrentModificationException e) {
        e.printStackTrace();
        return;
      }

      if (entities == null) return;

      boolean found = false;

      for (Object obj : entities) {
        BaseEntity entity = (BaseEntity) obj;
        if (entity.getWorld().getType().getId() != WORLD.getType().getId()) continue;

        double diffX = BLOCK.getBlockX() - entity.getX();
        double diffY = BLOCK.getBlockY() - entity.getY();
        double diffZ = BLOCK.getBlockZ() - entity.getZ();

        if (diffX * diffX + diffY * diffY + diffZ * diffZ < DISTANCE) {
          boolean result = entityInRange(entity);
          if (result) {
            found = true;
            if (DESTROY) {
              entity.destroy();
            } else {
              break;
            }
          }
        }
      }

      Redstone.setOutput(CraftBook.getCBWorld(WORLD), LEVER, found);
    }
示例#2
0
 static void toggleOutput(World world, Vector pos) {
   if (CraftBook.getBlockID(world, pos) == BlockType.LEVER) {
     setOutput(world, pos, (CraftBook.getBlockData(world, pos) & 0x8) != 0x8);
   }
 }
示例#3
0
 /**
  * Sets the output state of a redstone IC at a location.
  *
  * @param getPosition
  * @param state
  */
 static void setOutput(int worldType, Vector pos, boolean state) {
   setOutput(CraftBook.getWorld(worldType), pos, state);
 }