Examples of Vect


Examples of forestry.core.utils.Vect

  public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();

    Stack<ICrop> crops = new Stack<ICrop>();
    for (int i = 0; i < extent; i++) {
      Vect position = translateWithOffset(x, y + 1, z, direction, i);
      for (IFarmable seed : seeds) {
        ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
        if (crop != null)
          crops.push(crop);
      }
View Full Code Here

Examples of forestry.core.utils.Vect

  public Collection<ItemStack> collect() {

    Collection<ItemStack> products = produce;
    produce = new ArrayList<ItemStack>();

    Vect coords = new Vect(housing.getCoords());
    Vect area = new Vect(housing.getArea());
    Vect offset = new Vect(housing.getOffset());

    Vect min = coords.add(offset);
    Vect max = coords.add(offset).add(area);

    AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
    List<Entity> list = housing.getWorld().getEntitiesWithinAABB(Entity.class, harvestBox);

    int i;
View Full Code Here

Examples of forestry.core.utils.Vect

  @Override
  protected boolean maintainCrops(int x, int y, int z, ForgeDirection direction, int extent) {

    for (int i = 0; i < extent; i++) {
      Vect position = translateWithOffset(x, y, z, direction, i);
      if (!isAirBlock(position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z))
        continue;

      ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
      if (ground.getItem() != below.getItem())
        continue;
      if (below.getItemDamage() <= 0)
        continue;
View Full Code Here

Examples of forestry.core.utils.Vect

  public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();

    Stack<ICrop> crops = new Stack<ICrop>();
    for (int i = 0; i < extent; i++) {
      Vect position = translateWithOffset(x, y + 1, z, direction, i);
      for (IFarmable seed : seeds) {
        ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
        if (crop != null)
          crops.push(crop);
      }
View Full Code Here

Examples of forestry.core.utils.Vect

  @Override
  public ICrop getCropAt(World world, int x, int y, int z) {
    if (world.getBlock(x, y + (matureHeight - 1), z) != block)
      return null;

    return new CropBlock(world, block, 0, new Vect(x, y + (matureHeight - 1), z));
  }
View Full Code Here

Examples of forestry.core.utils.Vect

      return storedData;
    default:
    }

    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));

    for (int i = 0; i < 1; i++) {

      Vect randomPos = new Vect(world.rand.nextInt(area.x), world.rand.nextInt(area.y), world.rand.nextInt(area.z));

      Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
      posBlock = posBlock.add(offset);

      // Put snow on the ground
      if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false))
        continue;
View Full Code Here

Examples of forestry.core.utils.Vect

      // System.out.println(String.format("Master at %s/%s/%s:%s", xCoord, yCoord, zCoord, groundY));
      ArrayList<FarmTarget> potential = new ArrayList<FarmTarget>();

      int xDistance = 0;
      int zDistance = 0;
      Vect candidate = new Vect(xCoord, groundY, zCoord);

      // Determine distance from master TE
      while (true) {
        xDistance += direction.offsetX;
        zDistance += direction.offsetZ;
        // System.out.println(String.format("New offset for %s: x:%s z:%s", direction, xDistance, zDistance));
        // System.out.println(String.format("Validating for %s: x:%s y:%s z:%s", direction, xCoord + xDistance, groundY, zCoord + zDistance));

        TileEntity tile = worldObj.getTileEntity(xCoord + xDistance, groundY, zCoord + zDistance);
        if (tile == null)
          // System.out.println("NUll TE");
          break;
        if (!(tile instanceof IFarmComponent))
          // System.out.println("Not instaceof of farm component");
          break;

        candidate = new Vect(xCoord + xDistance, groundY, zCoord + zDistance);
      }
      // System.out.println(String.format("Determined distance for %s at %s.", direction, candidate));

      // Determine block to start search from
      ForgeDirection search;
      if (direction.offsetX != 0)
        search = ForgeDirection.SOUTH;
      else
        search = ForgeDirection.EAST;

      int xOffset = 0;
      int zOffset = 0;
      Vect start = candidate;
      while (true) {
        xOffset += search.offsetX;
        zOffset += search.offsetZ;

        TileEntity tile = worldObj.getTileEntity(candidate.x + xOffset, candidate.y, candidate.z + zOffset);
        if (tile == null)
          break;
        if (!(tile instanceof IFarmComponent))
          break;

        start = new Vect(candidate.x + xOffset, candidate.y, candidate.z + zOffset);
      }
      // 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);
View Full Code Here

Examples of forestry.core.utils.Vect

      ForgeDirection direction = entry.getKey();
      for (FarmTarget target : entry.getValue()) {

        int yOffset;
        for (yOffset = 2; yOffset > -3; yOffset--) {
          Vect position = new Vect(target.getStart().x, target.getStart().y + yOffset, target.getStart().z);
          if (StructureLogicFarm.bricks.contains(worldObj.getBlock(position.x, position.y, position.z)))
            break;
        }
        target.setYOffset(yOffset + 1);

        int extent;
        // Determine extent limit
        int limit = allowedExtent;
        if (target.getLimit() > 0)
          limit = target.getLimit();

        // Determine extent
        for (extent = 0; extent < limit; extent++) {
          Vect position = new Vect(target.getStart().x + direction.offsetX * extent, target.getStart().y + yOffset, target.getStart().z
              + direction.offsetZ * extent);
          if (!StructureLogicFarm.bricks.contains(worldObj.getBlock(position.x, position.y, position.z)))
            break;
        }

View Full Code Here

Examples of forestry.core.utils.Vect

  @Override
  public Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent) {

    Collection<ICrop> crops = null;

    Vect start = new Vect(x, y, z);
    if (!lastExtents.containsKey(start))
      lastExtents.put(start, 0);

    int lastExtent = lastExtents.get(start);
    if (lastExtent > extent)
      lastExtent = 0;

    // Proxies.log.finest("Logic %s is searching in direction %s at %s/%s/%s with extension %s.", getClass(), direction, x, y, z, lastExtent);

    Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
    crops = getHarvestBlocks(position);
    lastExtent++;
    lastExtents.put(start, lastExtent);

    return crops;
View Full Code Here

Examples of forestry.core.utils.Vect

    // Get additional candidates to return
    for (int i = -1; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = -1; k < 2; k++) {
          Vect candidate = new Vect(position.x + i, position.y + j, position.z + k);
          if (candidate.equals(position))
            continue;
          if (Math.abs(candidate.x - start.x) > 5)
            continue;
          if (Math.abs(candidate.z - start.z) > 5)
            continue;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.