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 farmable : germlings) {
        ICrop crop = farmable.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
  protected boolean maintainGermlings(int x, int y, int z, ForgeDirection direction, int extent) {
    World world = getWorld();

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

      ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
      if (!isAcceptedGround(below))
        continue;

      return trySetCrop(position);
    }
View Full Code Here

Examples of forestry.core.utils.Vect

  public ICrop getCropAt(World world, int x, int y, int z) {
    Block block = world.getBlock(x, y, z);
    if (!block.isWood(world, x, y, z))
      return null;

    return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
  }
View Full Code Here

Examples of forestry.core.utils.Vect

  public boolean cancelTask(IFarmLogic logic, ForgeDirection direction) {
    return hasRedstoneSignal(direction) || hasRedstoneSignal(ForgeDirection.UP) || hasRedstoneSignal(ForgeDirection.DOWN);
  }

  private boolean hasRedstoneSignal(ForgeDirection direction) {
    Vect side = new Vect(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);

    ForgeDirection opp = direction.getOpposite();
    int dir = opp.offsetZ < 0 ? 2 : opp.offsetZ > 0 ? 3 : opp.offsetX < 0 ? 4 : opp.offsetX > 0 ? 5 : 0;
    return worldObj.getIndirectPowerLevelTo(side.x, side.y, side.z, dir) > 0 || worldObj.isBlockProvidingPowerTo(side.x, side.y, side.z, dir) > 0;
  }
View Full Code Here

Examples of forestry.core.utils.Vect

    Block block = world.getBlock(x, y, z);

    if (block != Blocks.brown_mushroom_block && block != Blocks.red_mushroom_block)
      return null;

    return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z));
  }
View Full Code Here

Examples of forestry.core.utils.Vect

  @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

Examples of forestry.core.utils.Vect

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

    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 / 2), -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 < 20; 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);

      TileEntity tile = housing.getWorld().getTileEntity(posBlock.x, posBlock.y, posBlock.z);
      if (!(tile instanceof IPollinatable)) {
        if (housing.getWorld().isAirBlock(posBlock.x, posBlock.y, posBlock.z))
          continue;
View Full Code Here

Examples of forestry.core.utils.Vect

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

    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 < 30; 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);

      IPollinatable receiver = Utils.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z);
      if(receiver == null)
        continue;
View Full Code Here

Examples of forestry.core.utils.Vect

      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

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 : germlings) {
        ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
        if (crop != null)
          crops.push(crop);
      }
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.