public StructureVillageStartTFC(
      World par1World, Random par2Random, int par3, int par4, int par5) {
    ArrayList var7 =
        StructureVillagePiecesTFC.getStructureVillageWeightedPieceList(par2Random, par5);
    ComponentVillageStartPieceTFC var8 =
        new ComponentVillageStartPieceTFC(
            par1World.getWorldChunkManager(),
            0,
            par2Random,
            (par3 << 4) + 2,
            (par4 << 4) + 2,
            var7,
            par5);
    this.components.add(var8);
    var8.buildComponent(var8, this.components, par2Random);
    ArrayList var9 = var8.field_35106_f;
    ArrayList var10 = var8.field_35108_e;
    int var11;

    while (!var9.isEmpty() || !var10.isEmpty()) {
      StructureComponentTFC var12;

      if (!var9.isEmpty()) {
        var11 = par2Random.nextInt(var9.size());
        var12 = (StructureComponentTFC) var9.remove(var11);
        var12.buildComponent(var8, this.components, par2Random);
      } else {
        var11 = par2Random.nextInt(var10.size());
        var12 = (StructureComponentTFC) var10.remove(var11);
        var12.buildComponent(var8, this.components, par2Random);
      }
    }

    this.updateBoundingBox();
    var11 = 0;
    Iterator var14 = this.components.iterator();

    while (var14.hasNext()) {
      StructureComponentTFC var13 = (StructureComponentTFC) var14.next();

      if (!(var13 instanceof ComponentVillageRoadPieceTFC)) {
        ++var11;
      }
    }

    this.hasMoreThanTwoComponents = var11 > 2;
  }
  /** attempts to find a next Structure Component to be spawned, private Village function */
  private static StructureComponentTFC getNextVillageStructureComponent(
      ComponentVillageStartPieceTFC par0ComponentVillageStartPiece,
      List par1List,
      Random par2Random,
      int par3,
      int par4,
      int par5,
      int par6,
      int par7) {
    if (par7 > 50) {
      return null;
    } else if (Math.abs(par3 - par0ComponentVillageStartPiece.getBoundingBox().minX) <= 112
        && Math.abs(par5 - par0ComponentVillageStartPiece.getBoundingBox().minZ) <= 112) {
      ComponentVillageTFC var8 =
          getNextVillageComponent(
              par0ComponentVillageStartPiece,
              par1List,
              par2Random,
              par3,
              par4,
              par5,
              par6,
              par7 + 1);

      if (var8 != null) {
        int var9 = (var8.boundingBox.minX + var8.boundingBox.maxX) / 2;
        int var10 = (var8.boundingBox.minZ + var8.boundingBox.maxZ) / 2;
        int var11 = var8.boundingBox.maxX - var8.boundingBox.minX;
        int var12 = var8.boundingBox.maxZ - var8.boundingBox.minZ;
        int var13 = var11 > var12 ? var11 : var12;

        if (par0ComponentVillageStartPiece
            .getWorldChunkManager()
            .areBiomesViable(var9, var10, var13 / 2 + 4, MapGenVillageTFC.villageSpawnBiomes)) {
          par1List.add(var8);
          par0ComponentVillageStartPiece.field_35108_e.add(var8);
          return var8;
        }
      }

      return null;
    } else {
      return null;
    }
  }
  private static StructureComponentTFC getNextComponentVillagePath(
      ComponentVillageStartPieceTFC par0ComponentVillageStartPiece,
      List par1List,
      Random par2Random,
      int par3,
      int par4,
      int par5,
      int par6,
      int par7) {
    if (par7 > 3 + par0ComponentVillageStartPiece.terrainType) {
      return null;
    } else if (Math.abs(par3 - par0ComponentVillageStartPiece.getBoundingBox().minX) <= 112
        && Math.abs(par5 - par0ComponentVillageStartPiece.getBoundingBox().minZ) <= 112) {
      StructureBoundingBox var8 =
          ComponentVillagePathGenTFC.func_35087_a(
              par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6);

      if (var8 != null && var8.minY > 10) {
        ComponentVillagePathGenTFC var9 =
            new ComponentVillagePathGenTFC(par7, par2Random, var8, par6);
        int var10 = (var9.boundingBox.minX + var9.boundingBox.maxX) / 2;
        int var11 = (var9.boundingBox.minZ + var9.boundingBox.maxZ) / 2;
        int var12 = var9.boundingBox.maxX - var9.boundingBox.minX;
        int var13 = var9.boundingBox.maxZ - var9.boundingBox.minZ;
        int var14 = var12 > var13 ? var12 : var13;

        if (par0ComponentVillageStartPiece
            .getWorldChunkManager()
            .areBiomesViable(var10, var11, var14 / 2 + 4, MapGenVillageTFC.villageSpawnBiomes)) {
          par1List.add(var9);
          par0ComponentVillageStartPiece.field_35106_f.add(var9);
          return var9;
        }
      }

      return null;
    } else {
      return null;
    }
  }
  /** attempts to find a next Village Component to be spawned */
  private static ComponentVillageTFC getNextVillageComponent(
      ComponentVillageStartPieceTFC par0ComponentVillageStartPiece,
      List par1List,
      Random par2Random,
      int par3,
      int par4,
      int par5,
      int par6,
      int par7) {
    int var8 =
        getAvailablePieceWeight(par0ComponentVillageStartPiece.structureVillageWeightedPieceList);

    if (var8 <= 0) {
      return null;
    } else {
      int var9 = 0;

      while (var9 < 5) {
        ++var9;
        int var10 = par2Random.nextInt(var8);
        Iterator var11 =
            par0ComponentVillageStartPiece.structureVillageWeightedPieceList.iterator();

        while (var11.hasNext()) {
          StructureVillagePieceWeight var12 = (StructureVillagePieceWeight) var11.next();
          var10 -= var12.villagePieceWeight;

          if (var10 < 0) {
            if (!var12.canSpawnMoreVillagePiecesOfType(par7)
                || var12 == par0ComponentVillageStartPiece.structVillagePieceWeight
                    && par0ComponentVillageStartPiece.structureVillageWeightedPieceList.size()
                        > 1) {
              break;
            }

            ComponentVillageTFC var13 =
                getVillageComponentFromWeightedPiece(
                    var12, par1List, par2Random, par3, par4, par5, par6, par7);

            if (var13 != null) {
              ++var12.villagePiecesSpawned;
              par0ComponentVillageStartPiece.structVillagePieceWeight = var12;

              if (!var12.canSpawnMoreVillagePieces()) {
                par0ComponentVillageStartPiece.structureVillageWeightedPieceList.remove(var12);
              }

              return var13;
            }
          }
        }
      }

      StructureBoundingBox var14 =
          ComponentVillageTorchTFC.findValidPlacement(par1List, par2Random, par3, par4, par5, par6);

      if (var14 != null) {
        return new ComponentVillageTorchTFC(par7, par2Random, var14, par6);
      } else {
        return null;
      }
    }
  }