Package forestry.farming

Examples of forestry.farming.FarmTarget


      // System.out.println(String.format("Determined start block for %s at %s.", direction, candidate));

      ForgeDirection reverse = search.getOpposite();
      ForgeDirection tocenter = direction.getOpposite();
      Vect last = new Vect(start.x + direction.offsetX, start.y, start.z + direction.offsetZ);
      potential.add(new FarmTarget(last));
      while (true) {
        // Switch to next potential block in the farm.
        last = new Vect(last.x + reverse.offsetX, last.y, last.z + reverse.offsetZ);
        // Check validity.
        TileEntity tile = worldObj.getTileEntity(last.x + tocenter.offsetX, last.y, last.z + tocenter.offsetZ);

        // break if we have reached the end of the farm's length.
        if (tile == null)
          break;
        if (!(tile instanceof IFarmComponent))
          break;

        potential.add(new FarmTarget(last));
      }

      // System.out.println(String.format("Adding %s to %s", potential.size(), direction));

      // Set the maximum allowed extent.
      int size = potential.size() * 3;
      if (size > allowedExtent)
        allowedExtent = size;
      targets.put(direction, potential.toArray(new FarmTarget[0]));
    }

    // Fill out the corners
    // System.out.println("Trying to round corners");
    TreeMap<ForgeDirection, FarmTarget[]> cache = new TreeMap<ForgeDirection, FarmTarget[]>();

    for (Map.Entry<ForgeDirection, FarmTarget[]> entry : targets.entrySet()) {
      ForgeDirection direction = entry.getKey();
      // If the count of possible targets does matches the allowedExtent, we are on the long side and will not process
      if (direction == ForgeDirection.SOUTH || direction == ForgeDirection.NORTH) {
        cache.put(entry.getKey(), entry.getValue());
        continue;
      }

      // Set start and direction to search
      ArrayList<FarmTarget> targ = new ArrayList<FarmTarget>(Arrays.asList(entry.getValue()));
      int sidecount = targ.size();

      FarmTarget start = entry.getValue()[0];
      ForgeDirection search = ForgeDirection.SOUTH;
      int cornerShift = 0;
      if (!Config.squareFarms)
        cornerShift = 1;
      // System.out.println(String.format("Processing start at %s for direction %s.", start.getStart(), direction));

      for (int i = cornerShift; i < allowedExtent + 1; i++) {
        FarmTarget corner = new FarmTarget(new Vect(start.getStart().x + search.offsetX * i, start.getStart().y, start.getStart().z + search.offsetZ
            * i));
        if (!Config.squareFarms) {
          corner.setLimit(allowedExtent - i);
          // System.out.println(String.format("Setting %s at extent %s", corner.getStart().toString(), corner.getExtent()));
          if (corner.getLimit() > 0)
            targ.add(0, corner);
        } else
          targ.add(0, corner);
      }

      search = search.getOpposite();
      for (int i = sidecount; i < sidecount + allowedExtent - cornerShift; i++) {
        FarmTarget corner = new FarmTarget(new Vect(start.getStart().x + search.offsetX * i, start.getStart().y, start.getStart().z + search.offsetZ
            * i));
        if (!Config.squareFarms)
          corner.setLimit(sidecount + allowedExtent - 1 - i);
        // System.out.println(String.format("Setting %s at extent %s", corner.getStart().toString(), corner.getExtent()));
        targ.add(corner);
      }

      cache.put(entry.getKey(), targ.toArray(new FarmTarget[0]));
View Full Code Here


      if (doCollection(logic))
        didWork = true;
      else
        for (int i = 0; i < entry.getValue().length; i++) {

          FarmTarget target = entry.getValue()[i];
          if (target.getExtent() <= 0)
            continue;
          else
            hasFarmland = true;

          if (!stage) {
View Full Code Here

TOP

Related Classes of forestry.farming.FarmTarget

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.