Examples of Vect


Examples of forestry.core.utils.Vect

  }

  private boolean maintainWater(int x, int y, int z, ForgeDirection direction, int extent) {
    // Still not done, check water then
    for (int i = 0; i < extent; i++) {
      Vect position = translateWithOffset(x, y, z, direction, i);

      if (trySetWater(position))
        return true;
    }
View Full Code Here

Examples of forestry.core.utils.Vect

  private boolean canPlaceWater(Vect position) {
    // don't place water close to other water
    for (int x = -2; x <= 2; x++) {
      for (int z = -2; z <= 2; z++) {
        Vect offsetPosition = position.add(new Vect(x, 0, z));
        if (isWaterBlock(offsetPosition))
          return false;
      }
    }

    // don't place water if it can flow into blocks next to it
    for (int x = -1; x <= 1; x++) {
      Vect offsetPosition = position.add(new Vect(x, 0, 0));
      if (isAirBlock(offsetPosition))
        return false;
    }
    for (int z = -1; z <= 1; z++) {
      Vect offsetPosition = position.add(new Vect(0, 0, z));
      if (isAirBlock(offsetPosition))
        return false;
    }

    return true;
View Full Code Here

Examples of forestry.core.utils.Vect

  protected final ItemStack getAsItemStack(Vect position) {
    return new ItemStack(getBlock(position), 1, getBlockMeta(position));
  }

  protected final Vect translateWithOffset(int x, int y, int z, ForgeDirection direction, int step) {
    return new Vect(x + direction.offsetX * step, y + direction.offsetY * step, z + direction.offsetZ * step);
  }
 
View Full Code Here

Examples of forestry.core.utils.Vect

    return true;
  }

  protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));

    Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
    Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);

    return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
  }
View Full Code Here

Examples of forestry.core.utils.Vect

  private final HashMap<Vect, Integer> lastExtentsCultivation = new HashMap<Vect, Integer>();

  @Override
  public boolean cultivate(int x, int y, int z, ForgeDirection direction, int extent) {

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

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

    Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent);
    boolean result = tryPlantingCocoa(position);

    lastExtent++;
    lastExtentsCultivation.put(start, lastExtent);
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 (!lastExtentsHarvest.containsKey(start))
      lastExtentsHarvest.put(start, 0);

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

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

    return crops;
View Full Code Here

Examples of forestry.core.utils.Vect

  private boolean tryPlantingCocoa(Vect position) {

    World world = getWorld();

    Vect current = position;
    while (isWoodBlock(current) && BlockLog.func_150165_c(getBlockMeta(current)) == 3) {

      for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        if (direction == ForgeDirection.UP || direction == ForgeDirection.DOWN)
          continue;

        Vect candidate = new Vect(current.x + direction.offsetX, current.y, current.z + direction.offsetZ);
        if (isAirBlock(candidate))
          return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z);
      }

      current = current.add(new Vect(0, 1, 0));
      if (current.y - position.y > 1)
        break;
    }

    return false;
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

Examples of forestry.core.utils.Vect

    if (isHalted(storedData, housing))
      return storedData;

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

    // Radioactivity hurts players and mobs
    Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
    Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);

    AxisAlignedBB hurtBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);

    @SuppressWarnings("rawtypes")
    List list = housing.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);

    for (Object obj : list) {
      EntityLivingBase entity = (EntityLivingBase) obj;

      int damage = 8;

      // Players are not attacked if they wear a full set of apiarist's
      // armor.
      if (entity instanceof EntityPlayer) {
        int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
        // Full set, no damage/effect
        if (count > 3)
          continue;
        else if (count > 2)
          damage = 1;
        else if (count > 1)
          damage = 2;
        else if (count > 0)
          damage = 3;
      }

      entity.attackEntityFrom(damageSourceBeeRadioactive, damage);

    }

    Random rand = housing.getWorld().rand;
    // Radioactivity destroys environment
    for (int i = 0; i < 20; i++) {

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

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

      if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight())
        continue;

      // Don't destroy ourself and blocks below us.
View Full Code Here

Examples of forestry.core.utils.Vect

    if (world.getBlock(x, y, z) != block)
      return null;
    if (world.getBlockMetadata(x, y, z) != mature)
      return null;

    return new CropBlock(world, block, mature, new Vect(x, y, z));
  }
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.