Package forestry.api.genetics

Examples of forestry.api.genetics.IFlowerProvider


  }

  @Override
  public boolean hasFlower(IBeeHousing housing) {

    IFlowerProvider provider = genome.getFlowerProvider();

    Vect coords = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
    Vect posCurrent = new Vect(0, 0, 0);
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f));

    if (area.x < 1)
      area.x = 1;
    if (area.y < 1)
      area.y = 1;
    if (area.z < 1)
      area.z = 1;

    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));

    boolean hasFlower = false;

    while (advancePosition(posCurrent, area)) {

      Vect posBlock = posCurrent.add(coords);
      posBlock = posBlock.add(offset);

      if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) {
        hasFlower = true;
        break;
      }

    }
View Full Code Here


    // Correct speed
    if (housing.getWorld().rand.nextInt(100) >= chance)
      return;

    // Gather required info
    IFlowerProvider provider = genome.getFlowerProvider();
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));

    if (area.x < 1)
      area.x = 1;
    if (area.y < 1)
      area.y = 1;
    if (area.z < 1)
      area.z = 1;

    // We have up to ten attempts
    for (int i = 0; i < 10; i++) {

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

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

      if (provider.growFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z))
        break;
    }
  }
View Full Code Here

TOP

Related Classes of forestry.api.genetics.IFlowerProvider

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.