public static int getBlacklistBiomeIDWithinRange(World world, int x, int z, int radius) {
    FRLog.debug("Checking Biomes...");
    float reciprocalRootOf2 = 0.70710678f;
    int adjRadius = Math.round(radius * reciprocalRootOf2);
    BlockPos pos = new BlockPos(x, 64, z);
    EnumFacing[] NSEW = EnumFacing.values();

    int biomeID = world.getBiomeGenForCoords(pos).biomeID;
    if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;

    for (EnumFacing fd : NSEW) {
      for (int i = radius; i > 0; i = i - 2) {
        biomeID = world.getBiomeGenForCoords(pos.offset(fd, i)).biomeID;
        if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;
      }
    }

    for (int ns = 0; ns < 2; ns++)
      for (int ew = 2; ew < 4; ew++)
        for (int r = adjRadius; r > 0; r = r - 2) {
          biomeID = world.getBiomeGenForCoords(pos.offset(NSEW[ns], r).offset(NSEW[ew], r)).biomeID;
          if (CommonUtils.isIDInList(biomeID, biomeIDBlacklist)) return biomeID;
        }

    return -1;
  }
  @Override
  public void processCommand(ICommandSender icommandsender, String[] astring) {

    ArrayList<ChunkCoordinates> ccListsb = new ArrayList<ChunkCoordinates>();
    ArrayList<ChunkCoordinates> ccListdb = new ArrayList<ChunkCoordinates>();
    boolean sameBiome;
    int offset = 1;
    ChunkCoordinates cc = icommandsender.getPlayerCoordinates();
    EntityPlayerMP player = getCommandSenderAsPlayer(icommandsender);

    World w = player.worldObj;
    BiomeGenBase bg = w.getBiomeGenForCoords(cc.posX, cc.posZ);

    sameBiome = true;

    int olddb, newdb;

    newdb = 0;

    while (sameBiome == true) {

      olddb = newdb;

      for (int i = -offset; i <= offset; i++) {
        for (int j = -offset; j <= offset; j++) {
          if (w.getBiomeGenForCoords(cc.posX + i, cc.posZ + j) == bg) {
            ccListsb.add(new ChunkCoordinates(cc.posX + i, 0, cc.posZ + j));
          } else {
            ccListdb.add(new ChunkCoordinates(cc.posX + i, 0, cc.posZ + j));
          }
        }
      }

      newdb = ccListdb.size();

      if ((newdb - olddb >= offset * 8 || offset == 512)) {
        System.out.println("" + ccListsb.size());
        sameBiome = false;
      } else {
        ccListdb.clear();
        ccListsb.clear();
      }

      offset++;
    }

    for (int j = 0; j < ccListsb.size(); j++) {
      for (int i = 0; i < 256; i++) {
        if (w.blockExists(ccListsb.get(j).posX, i, ccListsb.get(j).posZ))
          w.destroyBlock(ccListsb.get(j).posX, i, ccListsb.get(j).posZ, false);
      }
    }

    System.out.println("Done");
  }
  void displayPlayers() {
    Main.server
        .mc_server
        .getCommandManager()
        .executeCommand(Main.server.mc_server, "say Localisation des joueurs:");

    for (World world : Main.server.mc_server.worldServers) {
      for (Object obj : world.playerEntities) {
        EntityPlayer p = (EntityPlayer) obj;
        int x = (int) p.posX;
        int y = (int) p.posY;
        int z = (int) p.posZ;
        String biom = world.getBiomeGenForCoords(x, z).biomeName;
        Main.server
            .mc_server
            .getCommandManager()
            .executeCommand(
                Main.server.mc_server,
                "say "
                    + p.getCommandSenderName()
                    + ": X:"
                    + x
                    + " Y:"
                    + y
                    + " Z:"
                    + z
                    + " Biom: "
                    + biom);
      }
    }
  }
  @Override
  public void generate(
      Random rand,
      int chunkX,
      int chunkZ,
      World world,
      IChunkProvider chunkGenerator,
      IChunkProvider chunkProvider) {
    chunkX = chunkX << 4;
    chunkZ = chunkZ << 4;
    final BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkZ);

    if (BiomeSettings.GREENSWAMP.getBiome().isPresent()
            && biome == BiomeSettings.GREENSWAMP.getBiome().get()
        || BiomeSettings.MOUNTAINRIDGE.getBiome().isPresent()
            && biome == BiomeSettings.MOUNTAINRIDGE.getBiome().get()
        || BiomeSettings.REDWOODLUSH.getBiome().isPresent()
            && biome == BiomeSettings.REDWOODLUSH.getBiome().get()
        || BiomeSettings.WOODLANDS.getBiome().isPresent()
            && biome == BiomeSettings.WOODLANDS.getBiome().get())
      for (int i = 0; i < 2; i++) {
        final int x = chunkX + rand.nextInt(16) + 8;
        final int y = rand.nextInt(128);
        final int z = chunkZ + rand.nextInt(16) + 8;
        leafPileGen.generate(world, rand, x, y, z);
      }
  }
  @Override
  public void generate(
      Random random,
      int chunkX,
      int chunkZ,
      World world,
      IChunkProvider chunkGenerator,
      IChunkProvider chunkProvider) {
    BiomeGenBase biome = world.getBiomeGenForCoords(chunkX * 16, chunkZ * 16);
    BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);

    if (types.length == 1 && types[0] == BiomeDictionary.Type.PLAINS) {
      int flaxPlants = 0;
      while (random.nextFloat() < 0.8f && flaxPlants < 10) flaxPlants++;

      for (int flower = 0; flower < flaxPlants; ++flower) {
        int x = chunkX * 16 + random.nextInt(16) + 8;
        int z = chunkZ * 16 + random.nextInt(16) + 8;
        int y = random.nextInt(world.getHeightValue(x, z) + 32);

        plantGen.func_150550_a(YGCBlocks.flaxPlant, 7 - (random.nextFloat() < 0.1f ? 1 : 0));
        plantGen.generate(world, random, x, y, z);
      }
    }
  }
Beispiel #6
0
  private void runGenerator(
      WorldGenerator generator,
      World world,
      Random rand,
      int chunk_X,
      int chunk_Z,
      int chanceToSpawn,
      int minHeight,
      int maxHeight) {

    if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
      throw new IllegalArgumentException("FUUUUUUUUUCK YOU STEVEN!!!");
    /*"Illegal Height Arguments for WorldGenerator" side note: who's steven?*/

    int heightDiff = maxHeight - minHeight + 1;
    for (int i = 0; i < chanceToSpawn; i++) {
      int x = chunk_X * 16 + rand.nextInt(16);
      int y = minHeight + rand.nextInt(heightDiff);
      int z = chunk_Z * 16 + rand.nextInt(16);
      // generator.generate(world, rand, new BlockPos(x, y, z));
      if (world
          .getBiomeGenForCoords(new BlockPos(x, y, z))
          .equals(biomeCrystal.getBiome(configFile.BIOMECRYSTALBLACK))) {
        generator.generate(world, rand, new BlockPos(x, y, z));
      }
    }
  }
  @Override
  public void func_149878_d(World world, int x, int y, int z, Random rand) {
    if (world.isRemote || !TerrainGen.saplingGrowTree(world, rand, x, y, z)) return;

    int meta = damageDropped(world.getBlockMetadata(x, y, z));
    world.setBlockToAir(x, y, z);

    switch (meta) {
      case 1:
        if (MineFactoryReloadedWorldGen.generateSacredSpringRubberTree(world, rand, x, y, z))
          return;
        break;
      case 2:
        if (MineFactoryReloadedWorldGen.generateMegaRubberTree(world, rand, x, y, z, false)) return;
        break;
      case 3:
        if (new WorldGenMassiveTree().setSloped(true).generate(world, rand, x, y, z)) return;
        break;
      default:
      case 0:
        BiomeGenBase b = world.getBiomeGenForCoords(x, z);
        if (b != null && b.biomeName.toLowerCase().contains("mega"))
          if (rand.nextInt(50) == 0)
            if (MineFactoryReloadedWorldGen.generateMegaRubberTree(world, rand, x, y, z, true))
              return;
        if (treeGen.growTree(world, rand, x, y, z)) return;
        break;
    }
    world.setBlock(x, y, z, this, meta, 4);
  }
  public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) {
    if (hive.genChance() * Config.getBeehivesRate() < rand.nextFloat() * 100.0f) {
      return false;
    }

    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;

    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
      return false;
    }

    for (int tries = 0; tries < 4; tries++) {
      int x = worldX + rand.nextInt(16);
      int z = worldZ + rand.nextInt(16);

      if (tryGenHive(world, x, z, hive)) {
        return true;
      }
    }

    return false;
  }
  /**
   * Generates Ore in a specific pattern
   *
   * @param only if true only the listed bioms else not the listed Bioms
   */
  public void generateIt(
      Random random,
      int chunkX,
      int chunkZ,
      World world,
      IChunkProvider chunkGenerator,
      IChunkProvider chunkProvider,
      Block ID,
      Block target,
      String[] bioms,
      boolean only,
      int tries) {

    boolean nosucsess;
    int trieCount = 0;
    BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ);
    int yRandom;
    int zRandom;
    int xRandom;

    if (isBiom(bioms, b.biomeName) == only) {
      do {
        zRandom = random.nextInt(16);
        xRandom = random.nextInt(16);

        int S1 = world.getTopSolidOrLiquidBlock(xRandom + chunkX * 16, zRandom + chunkZ * 16);

        if (S1 > 19) {
          yRandom = random.nextInt(S1 - 19);
        } else {
          yRandom = 2;
        }

        int x = chunkX * 16 + xRandom;
        int y = yRandom;
        int z = chunkZ * 16 + zRandom;

        if (world.getBlock(x, y, z).isReplaceableOreGen(world, x, y, z, target)
            && world.getBlock(x, y - 1, z).isReplaceableOreGen(world, x, y - 1, z, target)
            && world.getBlock(x + 1, y, z).isReplaceableOreGen(world, x, y, z, target)
            && world.getBlock(x + 1, y - 1, z).isReplaceableOreGen(world, x, y, z, target)) {

          world.setBlock(x, y, z, ID);
          world.setBlock(x, y - 1, z, ID);
          world.setBlock(x + 1, y, z, ID);
          world.setBlock(x + 1, y - 1, z, ID);
          nosucsess = false;
          LogHelper.debug(
              "Generated " + ID.getLocalizedName() + " at " + " X: " + x + " Y: " + y + " Z: " + z);
        } else {
          nosucsess = true;
          trieCount++;
          LogHelper.debug("Had no sucess,try :" + trieCount + "/" + tries);
        }

      } while (nosucsess && trieCount < tries);
    }
  }
Beispiel #10
0
  // 現在地のバイオームを確認。
  // 複数のクラスで利用するので、ここにまとめた。
  public static BiomeGenBase checkCurrentBiome(World world, EntityPlayer player) {
    BiomeGenBase biome = BiomeGenBase.plains;

    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);

    biome = world.getBiomeGenForCoords(x, z);

    return biome;
  }
  @Override
  public void generate(
      Random random,
      int chunkX,
      int chunkZ,
      World world,
      IChunkProvider chunkGenerator,
      IChunkProvider chunkProvider) {
    chunkX = chunkX << 4;
    chunkZ = chunkZ << 4;
    final BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkX);

    if (BiomeManager.marsh.isPresent() && biome == BiomeManager.marsh.get())
      generateMarsh(random, chunkX, chunkZ, world);
  }
  @Override
  public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
    super.randomDisplayTick(world, x, y, z, rand);

    if (world.getTotalWorldTime() % 100 == 0
        && world.getBiomeGenForCoords(x, z) == AdvancedRocketryBiomes.stormLandsBiome) {
      FxSystemElectricArc.spawnArc(world, x + 0.5f, y + 0.5f, z + 0.5f, .3, 7);
      world.playSound(
          x,
          y,
          z,
          "advancedrocketry:ElectricShockSmall",
          .7f,
          0.975f + world.rand.nextFloat() * 0.05f,
          false);
    }
  }
  @Override
  public void updateTick(World world, int x, int y, int z, Random rand) {
    super.updateTick(world, x, y, z, rand);

    if (!world.isRemote
        && Configuration.electricPlantsSpawnLightning
        && world.isRaining()
        && world.getBiomeGenForCoords(x, z) == AdvancedRocketryBiomes.stormLandsBiome) {
      int lightningX = x + rand.nextInt(24) - 12;
      int lightningZ = z + rand.nextInt(24) - 12;
      world.addWeatherEffect(
          new EntityLightningBolt(
              world,
              lightningX,
              world.getTopSolidOrLiquidBlock(lightningX, lightningZ),
              lightningZ));
    }
  }
  private void decorateHivesDebug(World world, int chunkX, int chunkZ, List<Hive> hives) {
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
    EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);

    for (int x = 0; x < 16; x++) {
      for (int z = 0; z < 16; z++) {
        Collections.shuffle(hives, world.rand);
        for (Hive hive : hives) {
          if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) {
            continue;
          }

          tryGenHive(world, worldX + x, worldZ + z, hive);
        }
      }
    }
  }
  private void convertToRainbowForest(World world, int x, int y, int z) {
    int rx = ReikaRandomHelper.getRandomPlusMinus(x, 32);
    int rz = ReikaRandomHelper.getRandomPlusMinus(z, 32);

    if (world.checkChunksExist(rx, 0, rz, rx, 255, rz)) {
      int r = 3;
      for (int i = -r; i <= r; i++) {
        for (int k = -r; k <= r; k++) {
          int dx = rx + i;
          int dz = rz + k;
          BiomeGenBase biome = world.getBiomeGenForCoords(dx, dz);
          int id = biome.biomeID;
          if (id != DyeTrees.forest.biomeID) {
            ReikaWorldHelper.setBiomeForXZ(world, dx, dz, DyeTrees.forest);
          }
        }
      }
    }
  }
  private void fightEerie(World world, int x, int y, int z) {
    int rx = ReikaRandomHelper.getRandomPlusMinus(x, 32);
    int rz = ReikaRandomHelper.getRandomPlusMinus(z, 32);

    if (world.checkChunksExist(rx, 0, rz, rx, 255, rz)) {
      int r = 3;
      for (int i = -r; i <= r; i++) {
        for (int k = -r; k <= r; k++) {
          int dx = rx + i;
          int dz = rz + k;
          BiomeGenBase biome = world.getBiomeGenForCoords(dx, dz);
          int id = biome.biomeID;
          if (id == ThaumBlockHandler.getInstance().eerieBiomeID) {
            BiomeGenBase natural = ReikaWorldHelper.getNaturalGennedBiomeAt(world, dx, dz);
            if (natural != null) {
              ReikaWorldHelper.setBiomeForXZ(world, dx, dz, natural);
            }
          }
        }
      }
    }
  }
  private void convertPureNodeMagic(World world, int x, int y, int z) {
    int rx = ReikaRandomHelper.getRandomPlusMinus(x, 64);
    int rz = ReikaRandomHelper.getRandomPlusMinus(z, 64);

    if (world.checkChunksExist(rx, 0, rz, rx, 255, rz)) {
      int r = 3;
      for (int i = -r; i <= r; i++) {
        for (int k = -r; k <= r; k++) {
          int dx = rx + i;
          int dz = rz + k;
          BiomeGenBase biome = world.getBiomeGenForCoords(dx, dz);
          int id = biome.biomeID;
          if (id == ThaumBlockHandler.getInstance().magicBiomeID) {
            BiomeGenBase natural = ReikaWorldHelper.getNaturalGennedBiomeAt(world, dx, dz);
            if (natural != null && DyeTrees.isRainbowForest(natural)) {
              ReikaWorldHelper.setBiomeForXZ(world, dx, dz, natural);
            }
          }
        }
      }
    }
  }
  @Override
  public HashMap getDetails(World world, Object obj, boolean additional) {

    Vec3 location = (Vec3) obj;

    HashMap response = new HashMap();

    int x = (int) location.xCoord;
    int y = (int) location.yCoord;
    int z = (int) location.zCoord;

    response.put("Dimension", world.getWorldInfo().getDimension());
    response.put("Biome", world.getBiomeGenForCoords(x, z).biomeName);
    response.put("LightLevel", world.getBlockLightValue(x, y, z));
    response.put("Raining", world.isRaining());
    response.put("Thundering", world.isThundering());
    response.put("Daytime", world.isDaytime());
    response.put("MoonPhase", world.getMoonPhase());
    response.put("CelestialAngle", world.getCelestialAngle(1.0F));

    return response;
  }
  private boolean tryGenHive(World world, int x, int z, Hive hive) {

    int y = hive.getYForHive(world, x, z);

    if (y < 0) {
      return false;
    }

    if (!hive.canReplace(world, x, y, z)) {
      return false;
    }

    BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
    EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z));
    if (!hive.isGoodTemperature(temperature)) {
      return false;
    }

    if (!hive.isValidLocation(world, x, y, z)) {
      return false;
    }

    return setHive(world, x, y, z, hive);
  }
 @Override
 protected boolean canPerform(World world, int x, int y, int z) {
   return y < MAXY
       && ReikaBiomeHelper.isOcean(world.getBiomeGenForCoords(x, z))
       && this.isOceanFloor(world, x, y, z);
 }
  @Override
  public void populate(int chunkX, int chunkZ) {
    BlockFalling.fallInstantly = true;

    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    BlockPos blockPos = new BlockPos(worldX, 0, worldZ);
    Biome biome = worldObj.getBiomeGenForCoords(blockPos.add(16, 0, 16));
    BiomeDecorator decorator = biome.theBiomeDecorator;
    int worldHeight = worldObj.provider.getActualHeight();

    ForgeEventFactory.onChunkPopulate(true, this, worldObj, rand, chunkX, chunkZ, false);

    int x, y, z;

    if (CavelandConfig.generateLakes) {
      if (TerrainGen.populate(this, worldObj, rand, chunkX, chunkZ, false, EventType.LAKE)) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight - 16);
        z = rand.nextInt(16) + 8;

        lakeWaterGen.generate(worldObj, rand, blockPos.add(x, y, z));
      }

      if (rand.nextInt(30) == 0
          && TerrainGen.populate(this, worldObj, rand, chunkX, chunkZ, false, EventType.LAVA)) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight / 2);
        z = rand.nextInt(16) + 8;

        lakeLavaGen.generate(worldObj, rand, blockPos.add(x, y, z));
      }
    }

    MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(worldObj, rand, blockPos));

    MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(worldObj, rand, blockPos));

    for (CaveVein vein : CavelandConfig.veinManager.getCaveVeins()) {
      vein.generateVeins(worldObj, rand, blockPos);
    }

    MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(worldObj, rand, blockPos));

    for (int i = 0; i < 10; ++i) {
      x = rand.nextInt(16) + 8;
      y = rand.nextInt(worldHeight - 10);
      z = rand.nextInt(16) + 8;

      acresiaGen.generate(worldObj, rand, blockPos.add(x, y, z));
    }

    for (int i = 0; i < 15; ++i) {
      x = rand.nextInt(16) + 8;
      y = rand.nextInt(worldHeight / 2 - 10) + worldHeight / 2;
      z = rand.nextInt(16) + 8;

      acresiaGen.generate(worldObj, rand, blockPos.add(x, y, z));
    }

    if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.SHROOM)) {
      for (int i = 0; i < 5; ++i) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight - 10);
        z = rand.nextInt(16) + 8;

        decorator.mushroomBrownGen.generate(worldObj, rand, blockPos.add(x, y, z));
      }

      for (int i = 0; i < 5; ++i) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight - 10);
        z = rand.nextInt(16) + 8;

        decorator.mushroomRedGen.generate(worldObj, rand, blockPos.add(x, y, z));
      }
    }

    if (BiomeDictionary.isBiomeOfType(biome, Type.SANDY)) {
      if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.CACTUS)) {
        for (int i = 0; i < 80; ++i) {
          x = rand.nextInt(16) + 8;
          y = rand.nextInt(worldHeight - 5);
          z = rand.nextInt(16) + 8;

          decorator.cactusGen.generate(worldObj, rand, blockPos.add(x, y, z));
        }
      }

      if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.DEAD_BUSH)) {
        for (int i = 0; i < 10; ++i) {
          x = rand.nextInt(16) + 8;
          y = rand.nextInt(worldHeight - 5);
          z = rand.nextInt(16) + 8;

          deadBushGen.generate(worldObj, rand, blockPos.add(x, y, z));
        }
      }
    } else {
      if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.FLOWERS)) {
        for (int i = 0; i < 8; ++i) {
          x = rand.nextInt(16) + 8;
          y = rand.nextInt(worldHeight - 5);
          z = rand.nextInt(16) + 8;

          decorator.yellowFlowerGen.generate(worldObj, rand, blockPos.add(x, y, z));
        }
      }

      for (int i = 0; i < 18; ++i) {
        x = rand.nextInt(16) + 8;
        y = rand.nextInt(worldHeight - 5);
        z = rand.nextInt(16) + 8;

        biome.getRandomWorldGenForGrass(rand).generate(worldObj, rand, blockPos.add(x, y, z));
      }

      if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.TREE)) {
        WorldGenAbstractTree treeGen = null;

        if (BiomeDictionary.isBiomeOfType(biome, Type.JUNGLE)) {
          treeGen =
              new WorldGenTreesPerverted(
                  false, 4 + rand.nextInt(7), BlockPlanks.EnumType.JUNGLE, true);
        } else if (BiomeDictionary.isBiomeOfType(biome, Type.FOREST)
            || !BiomeDictionary.isBiomeOfType(biome, Type.PLAINS)
            || rand.nextInt(10) == 0) {
          if (BiomeDictionary.isBiomeOfType(biome, Type.COLD)) {
            treeGen = new WorldGenSpruceTreePerverted(false);
          } else if (rand.nextInt(3) == 0) {
            treeGen = new WorldGenBirchTreePerverted(false, false);
          } else {
            treeGen = new WorldGenTreesPerverted(false, 3, BlockPlanks.EnumType.OAK, true);
          }
        }

        if (treeGen != null) {
          for (int i = 0; i < 80; ++i) {
            x = rand.nextInt(16) + 8;
            y = rand.nextInt(worldHeight);
            z = rand.nextInt(16) + 8;

            BlockPos pos = blockPos.add(x, y, z);

            if (treeGen.generate(worldObj, rand, pos)) {
              treeGen.generateSaplings(worldObj, rand, pos);
            }
          }

          for (int i = 0; i < 60; ++i) {
            x = rand.nextInt(16) + 8;
            y = 8 + rand.nextInt(5);
            z = rand.nextInt(16) + 8;

            BlockPos pos = blockPos.add(x, y, z);

            if (treeGen.generate(worldObj, rand, pos)) {
              treeGen.generateSaplings(worldObj, rand, pos);
            }
          }
        }
      }

      if (decorator.generateLakes) {
        if (BiomeDictionary.isBiomeOfType(biome, Type.WATER)) {
          if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.LAKE_WATER)) {
            for (int i = 0; i < 150; ++i) {
              x = rand.nextInt(16) + 8;
              y = rand.nextInt(rand.nextInt(worldHeight - 16) + 10);
              z = rand.nextInt(16) + 8;

              liquidWaterGen.generate(worldObj, rand, blockPos.add(x, y, z));
            }
          }
        } else {
          if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.LAKE_WATER)) {
            for (int i = 0; i < 100; ++i) {
              x = rand.nextInt(16) + 8;
              y = rand.nextInt(rand.nextInt(worldHeight - 16) + 10);
              z = rand.nextInt(16) + 8;

              liquidWaterGen.generate(worldObj, rand, blockPos.add(x, y, z));
            }
          }

          if (TerrainGen.decorate(worldObj, rand, blockPos, Decorate.EventType.LAKE_LAVA)) {
            for (int i = 0; i < 20; ++i) {
              x = rand.nextInt(16) + 8;
              y = rand.nextInt(worldHeight / 2);
              z = rand.nextInt(16) + 8;

              liquidLavaGen.generate(worldObj, rand, blockPos.add(x, y, z));
            }
          }
        }
      }
    }

    MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(worldObj, rand, blockPos));

    ForgeEventFactory.onChunkPopulate(false, this, worldObj, rand, chunkX, chunkZ, false);

    BlockFalling.fallInstantly = false;
  }
  public void generate(int i, int k) {
    int volcCenterX = i;
    int volcCenterZ = k;
    int steepnessMod =
        worldObj.getBiomeGenForCoords(i, k) == BiomeGenTropicraft.tropics
            ? LAND_STEEPNESS_MOD
            : OCEAN_STEEPNESS_MOD;

    long seed =
        (long) volcCenterX * 341873128712L
            + (long) volcCenterZ * 132897987541L
            + worldObj.getWorldInfo().getSeed()
            + (long) 4291726;
    Random rand = new Random(seed);

    int radiusX = rand.nextInt(MAX_RADIUS - MIN_RADIUS) + MIN_RADIUS;
    int radiusZ = rand.nextInt(MAX_RADIUS - MIN_RADIUS) + MIN_RADIUS;

    int[] heightmap = new int[(radiusX * 2) * (radiusZ * 2)];

    // System.out.println(radius);

    for (int x = -radiusX; x < radiusX; x++) {
      for (int z = -radiusZ; z < radiusZ; z++) {
        for (int y = 127; y > 0; y--) {
          int blockID = getBlock(x + i, y, z + k, null);
          if (blockID == Block.sand.blockID
              || blockID == Block.dirt.blockID
              || blockID == Block.grass.blockID) {
            heightmap[(x + radiusX) * (radiusZ * 2) + (z + radiusZ)] = y;
            break;
          }
          if (y < 30) {
            heightmap[(x + radiusX) * (radiusZ * 2) + (z + radiusZ)] = y;
            break;
          }
        }
      }
    }

    NoiseModule volcNoise = new Gradient(seed, 1, 1);
    volcNoise.amplitude = 0.6;
    for (int x = -radiusX; x < radiusX; x++) {
      for (int z = -radiusZ; z < radiusZ; z++) {
        float relativeX = ((x + i) - volcCenterX);
        float relativeZ = ((z + k) - volcCenterZ);

        float distanceSquared =
            ((relativeX / radiusX) * (relativeX / radiusX)
                + (relativeZ / radiusZ) * (relativeZ / radiusZ));

        float perlin =
            (float) volcNoise.getNoise(relativeX * 0.05 + 0.0001, relativeZ * 0.05 + 0.0001) + 1;
        double volcanoHeight = steepnessMod / (distanceSquared) * perlin - steepnessMod - 1;
        int groundHeight = heightmap[(x + radiusX) * (radiusZ * 2) + (z + radiusZ)];
        if (distanceSquared < 1) {
          for (int y = CHUNK_SIZE_Y; y > 0; y--) {
            if (volcanoHeight + groundHeight < CALDERA_CUTOFF) {
              if (volcanoHeight + groundHeight <= VOLCANO_TOP) {
                if (y <= volcanoHeight + groundHeight && y >= groundHeight) {
                  placeBlock(x + i, y, z + k, TropicraftBlocks.chunkOHead.blockID, null);
                }
              } else {
                if (y <= VOLCANO_TOP) {
                  placeBlock(x + i, y, z + k, TropicraftBlocks.chunkOHead.blockID, null);
                }
              }
            } else {
              if (y == VOLCANO_CRUST && rand.nextInt(CRUST_HOLE_CHANCE) != 0) {
                placeBlock(x + i, y, z + k, TropicraftBlocks.chunkOHead.blockID, null);
              }
              if (y <= LAVA_LEVEL) {
                placeBlock(x + i, y, z + k, Block.lavaStill.blockID, null);
              }
            }
          }
        }
      }
    }
    System.out.println("Done");
  }
  /**
   * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it
   * closes Mineshafts at the end, it adds Fences...
   */
  public boolean addComponentParts(
      World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) {
    BiomeGenBase biomegenbase =
        par1World.getBiomeGenForCoords(this.getXWithOffset(3, 5), this.getZWithOffset(3, 5));
    this.fillWithBlocks(
        par1World,
        par3StructureBoundingBox,
        -1,
        -1,
        0,
        5,
        5,
        6,
        Block.stone.blockID,
        Block.stone.blockID,
        false);
    this.fillWithBlocks(
        par1World,
        par3StructureBoundingBox,
        -1,
        5,
        0,
        5,
        5,
        6,
        biomegenbase.topBlock,
        biomegenbase.topBlock,
        false);
    this.fillWithRandomizedBlocks(
        par1World,
        par3StructureBoundingBox,
        0,
        0,
        0,
        4,
        4,
        6,
        false,
        par2Random,
        StructureSkyStrongholdPieces.getStrongholdStones());
    this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.doorType, 1, 1, 0);
    this.placeDoor(par1World, par2Random, par3StructureBoundingBox, EnumDoor.OPENING, 1, 1, 6);
    this.fillWithBlocks(
        par1World,
        par3StructureBoundingBox,
        3,
        1,
        2,
        3,
        1,
        4,
        Block.stoneBrick.blockID,
        Block.stoneBrick.blockID,
        false);
    this.placeBlockAtCurrentPosition(
        par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 1, par3StructureBoundingBox);
    this.placeBlockAtCurrentPosition(
        par1World, Block.stoneSingleSlab.blockID, 5, 3, 1, 5, par3StructureBoundingBox);
    this.placeBlockAtCurrentPosition(
        par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 2, par3StructureBoundingBox);
    this.placeBlockAtCurrentPosition(
        par1World, Block.stoneSingleSlab.blockID, 5, 3, 2, 4, par3StructureBoundingBox);
    int i;

    for (i = 2; i <= 4; ++i) {
      this.placeBlockAtCurrentPosition(
          par1World, Block.stoneSingleSlab.blockID, 5, 2, 1, i, par3StructureBoundingBox);
    }

    if (!this.hasMadeChest) {
      i = this.getYWithOffset(2);
      int j = this.getXWithOffset(3, 3);
      int k = this.getZWithOffset(3, 3);

      if (par3StructureBoundingBox.isVecInside(j, i, k)) {
        this.hasMadeChest = true;
        this.generateStructureChestContents(
            par1World,
            par3StructureBoundingBox,
            par2Random,
            3,
            2,
            3,
            ChestGenHooks.getItems(STRONGHOLD_CORRIDOR, par2Random),
            ChestGenHooks.getCount(STRONGHOLD_CORRIDOR, par2Random));
      }
    }
    return true;
  }
  public void spawnStructure(String type, Vector3f pos) throws ScriptErrorException {
    final Chunk chk = _world.getChunkFromBlockCoords((int) pos.getX(), (int) pos.getZ());
    BiomeGenBase biome = _world.getBiomeGenForCoords((int) pos.getX(), (int) pos.getZ());
    if (type.toLowerCase() == "village") {
      if (MapGenVillage.villageSpawnBiomes instanceof AbstractList) {
        MapGenVillage.villageSpawnBiomes = new ArrayList(MapGenVillage.villageSpawnBiomes);
      }
      boolean added = false;
      if (!MapGenVillage.villageSpawnBiomes.contains(biome)) {
        MapGenVillage.villageSpawnBiomes.add(biome);
        added = true;
      }
      MapGenVillage vilGen =
          new MapGenVillage() {
            @Override
            protected boolean canSpawnStructureAtCoords(int par1, int par2) {
              return par1 == chk.xPosition && par2 == chk.zPosition;
            }
          };
      vilGen.generate(
          _world.getChunkProvider(), _world, chk.xPosition, chk.zPosition, new byte[] {});
      for (int var11 = chk.xPosition - 8; var11 <= chk.xPosition + 8; ++var11) {
        for (int var12 = chk.zPosition - 8; var12 <= chk.zPosition + 8; ++var12) {
          vilGen.generateStructuresInChunk(_world, _world.rand, var11, var12);
        }
      }
      if (added) {
        MapGenVillage.villageSpawnBiomes.remove(biome);
      }
    } else if (type.toLowerCase() == "stronghold") {
      if (MapGenStronghold.allowedBiomes instanceof AbstractList) {
        MapGenStronghold.allowedBiomes = new ArrayList(MapGenStronghold.allowedBiomes);
      }
      boolean added = false;
      if (!MapGenStronghold.allowedBiomes.contains(biome)) {
        MapGenStronghold.allowedBiomes.add(biome);
        added = true;
      }
      MapGenStronghold strGen =
          new MapGenStronghold() {
            @Override
            protected boolean canSpawnStructureAtCoords(int par1, int par2) {
              return par1 == chk.xPosition && par2 == chk.zPosition;
            }

            @Override
            protected List getCoordList() {
              return new ArrayList();
            }
          };
      strGen.generate(
          _world.getChunkProvider(), _world, chk.xPosition, chk.zPosition, new byte[] {});
      for (int var11 = chk.xPosition - 8; var11 <= chk.xPosition + 8; ++var11) {
        for (int var12 = chk.zPosition - 8; var12 <= chk.zPosition + 8; ++var12) {
          strGen.generateStructuresInChunk(_world, _world.rand, var11, var12);
        }
      }
      if (added) {
        MapGenStronghold.allowedBiomes.remove(biome);
      }
    } else if (type.toLowerCase() == "netherfort") {
      MapGenNetherBridge strGen =
          new MapGenNetherBridge() {
            @Override
            protected boolean canSpawnStructureAtCoords(int par1, int par2) {
              return par1 == chk.xPosition && par2 == chk.zPosition;
            }

            @Override
            protected List getCoordList() {
              return new ArrayList();
            }
          };
      strGen.generate(
          _world.getChunkProvider(), _world, chk.xPosition, chk.zPosition, new byte[] {});
      for (int var11 = chk.xPosition - 8; var11 <= chk.xPosition + 8; ++var11) {
        for (int var12 = chk.zPosition - 8; var12 <= chk.zPosition + 8; ++var12) {
          strGen.generateStructuresInChunk(_world, _world.rand, var11, var12);
        }
      }
    } else {
      // no mineshafts sorry, it has the bad tendancy to crash the client
      throw new ScriptErrorException("type needs to be village, stronghold or mineshaft");
    }
  }
 @Override
 public boolean areCoordsValidForGeneration(World world, BlockPos pos, Random rand) {
   if (!(world.getBiomeGenForCoords(pos) instanceof BiomeGenFrozenTundra) || pos.getY() < 36)
     return false;
   return super.areCoordsValidForGeneration(world, pos, rand) && this.getRarity(200);
 }
 public String getBiome(Vector3f pos) {
   return _world.getBiomeGenForCoords((int) pos.getX(), (int) pos.getZ()).biomeName;
 }
  @Override
  public List<SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
    Biome biome = worldObj.getBiomeGenForCoords(pos);

    return biome.getSpawnableList(creatureType);
  }
  public void generateSurface(World world, Random random, int chunkX, int chunkZ) {

    if (AbyssalCraft.generateDarklandsStructures) {
      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new AChouse1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new AChouse2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACplatform1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACplatform2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACscion1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACscion2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }
    }

    if (AbyssalCraft.generateCoraliumOre) {
      for (int rarity = 0; rarity < 3; rarity++) {
        int veinSize = 2 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(40);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
            world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.SWAMP))
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y, z));
      }

      for (int rarity = 0; rarity < 6; rarity++) {
        int veinSize = 4 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(40);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
                world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.OCEAN)
            && world.getBiomeGenForCoords(new BlockPos(x, 0, z)) != Biomes.DEEP_OCEAN)
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y, z));
        if (world.getBiomeGenForCoords(new BlockPos(x, 0, z)) == Biomes.DEEP_OCEAN)
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y - 20, z));
      }
    }

    if (AbyssalCraft.generateNitreOre)
      for (int rarity = 0; rarity < 3; rarity++) {
        int veinSize = 4 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(30);
        int z = chunkZ + random.nextInt(16);

        new WorldGenMinable(ACBlocks.nitre_ore.getDefaultState(), veinSize)
            .generate(world, random, new BlockPos(x, y, z));
      }

    if (AbyssalCraft.generateShoggothLairs)
      for (int i = 0; i < 1; i++) {
        int x = chunkX + random.nextInt(16);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
                world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.SWAMP)
            || BiomeDictionary.isBiomeOfType(
                    world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.RIVER)
                && !BiomeDictionary.isBiomeOfType(
                    world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.OCEAN))
          if (random.nextInt(100) == 0)
            new StructureShoggothPit()
                .generate(world, random, world.getHeight(new BlockPos(x, 0, z)));
      }
  }
  @Override
  public boolean displaceIfPossible(World world, BlockPos pos) {

    if (!world.isRemote) {
      if (!world.provider.isSurfaceWorld()) {
        if (world.getBlockState(pos).getBlock() == Blocks.WATER
            && AbyssalCraft.shouldSpread == false) return false;
        if (world.getBlockState(pos).getMaterial().isLiquid()
            && world.getBlockState(pos).getBlock() != this
            && world.getBlockState(pos).getBlock() != ACBlocks.liquid_antimatter)
          world.setBlockState(pos, getDefaultState());
        if (AbyssalCraft.breakLogic == true
            && world
                .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
                .getMaterial()
                .isLiquid()
            && world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock()
                != this
            && world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ())).getBlock()
                != ACBlocks.liquid_antimatter)
          world.setBlockState(
              new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), getDefaultState());
      } else {
        if (BiomeDictionary.isBiomeOfType(world.getBiomeGenForCoords(pos), Type.OCEAN)
            && world.getBlockState(pos).getBlock() == this)
          if (AbyssalCraft.destroyOcean) world.setBlockState(pos, getDefaultState());
          else world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState());

        if (AbyssalCraft.shouldSpread) {
          if (world.getBlockState(pos).getMaterial().isLiquid()
              && world.getBlockState(pos).getBlock() != this
              && world.getBlockState(pos).getBlock() != ACBlocks.liquid_antimatter)
            world.setBlockState(pos, getDefaultState());
          if (AbyssalCraft.breakLogic == true
              && world
                  .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
                  .getMaterial()
                  .isLiquid()
              && world
                      .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
                      .getBlock()
                  != this
              && world
                      .getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
                      .getBlock()
                  != ACBlocks.liquid_antimatter)
            world.setBlockState(
                new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()), getDefaultState());
        }
      }
      if (dusts.contains(world.getBlockState(pos))
          && world.getBlockState(pos) != ACBlocks.abyssal_nitre_ore.getDefaultState()
          && world.getBlockState(pos) != ACBlocks.abyssal_coralium_ore)
        if (oresToBlocks(OreDictionary.getOres("oreSaltpeter")).contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_nitre_ore.getDefaultState());
        else world.setBlockState(pos, ACBlocks.abyssal_coralium_ore.getDefaultState());
      else if (metalloids.contains(world.getBlockState(pos))
          && !metals.contains(world.getBlockState(pos)))
        if (oresToBlocks(OreDictionary.getOres("oreIron")).contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_iron_ore.getDefaultState());
        else if (oresToBlocks(OreDictionary.getOres("oreGold")).contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_gold_ore.getDefaultState());
        else if (oresToBlocks(OreDictionary.getOres("oreTin")).contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_tin_ore.getDefaultState());
        else if (oresToBlocks(OreDictionary.getOres("oreCopper"))
            .contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_copper_ore.getDefaultState());
        else world.setBlockState(pos, ACBlocks.liquified_coralium_ore.getDefaultState());
      else if (gems.contains(world.getBlockState(pos))
          && world.getBlockState(pos) != ACBlocks.abyssal_diamond_ore.getDefaultState())
        if (oresToBlocks(OreDictionary.getOres("oreDiamond")).contains(world.getBlockState(pos)))
          world.setBlockState(pos, ACBlocks.abyssal_diamond_ore.getDefaultState());
        else world.setBlockState(pos, ACBlocks.pearlescent_coralium_ore.getDefaultState());
      else if (stones.contains(world.getBlockState(pos)))
        if (BiomeDictionary.isBiomeOfType(world.getBiomeGenForCoords(pos), Type.OCEAN)) {
          if (world.getBlockState(pos).getBlock() != Blocks.COBBLESTONE)
            world.setBlockState(pos, ACBlocks.abyssal_stone.getDefaultState());
        } else world.setBlockState(pos, ACBlocks.abyssal_stone.getDefaultState());
      else if (bricks.contains(world.getBlockState(pos)))
        world.setBlockState(pos, ACBlocks.abyssal_stone_brick.getDefaultState());
    }
    return super.displaceIfPossible(world, pos);
  }
  @Override
  public boolean generate(World world, Random rand, BlockPos start) {
    int widthOff = width / 2;
    start = new BlockPos(start.getX() - widthOff, start.getY(), start.getZ() - widthOff);

    int heightOff = height / 2 + 1;

    while (start.getY() > heightOff && world.isAirBlock(start))
      start = new BlockPos(start.getX(), start.getY() - 1, start.getZ());
    --heightOff;
    if (start.getY() <= heightOff) return false;

    start = new BlockPos(start.getX(), start.getY() - heightOff, start.getZ());
    boolean[] spawnBlock = new boolean[width * width * height];

    int W = width - 1, H = height - 1;

    for (int i = 0, e = rand.nextInt(4) + 4; i < e; ++i) {
      double xSize = rand.nextDouble() * 6.0D + 3.0D;
      double ySize = rand.nextDouble() * 4.0D + 2.0D;
      double zSize = rand.nextDouble() * 6.0D + 3.0D;
      double xCenter = rand.nextDouble() * (width - xSize - 2.0D) + 1.0D + xSize / 2.0D;
      double yCenter = rand.nextDouble() * (height - ySize - 4.0D) + 2.0D + ySize / 2.0D;
      double zCenter = rand.nextDouble() * (width - zSize - 2.0D) + 1.0D + zSize / 2.0D;

      for (int x = 1; x < W; ++x) {
        for (int z = 1; z < W; ++z) {
          for (int y = 1; y < H; ++y) {
            double xDist = (x - xCenter) / (xSize / 2.0D);
            double yDist = (y - yCenter) / (ySize / 2.0D);
            double zDist = (z - zCenter) / (zSize / 2.0D);
            double dist = xDist * xDist + yDist * yDist + zDist * zDist;

            if (dist < 1.0D) spawnBlock[(x * width + z) * height + y] = true;
          }
        }
      }
    }

    int x;
    int y;
    int z;

    for (x = 0; x < width; ++x) {
      for (z = 0; z < width; ++z) {
        for (y = 0; y < height; ++y) {
          boolean flag =
              spawnBlock[(x * width + z) * height + y]
                  || ((x < W && spawnBlock[((x + 1) * width + z) * height + y])
                      || (x > 0 && spawnBlock[((x - 1) * width + z) * height + y])
                      || (z < W && spawnBlock[(x * width + (z + 1)) * height + y])
                      || (z > 0 && spawnBlock[(x * width + (z - 1)) * height + y])
                      || (y < H && spawnBlock[(x * width + z) * height + (y + 1)])
                      || (y > 0 && spawnBlock[(x * width + z) * height + (y - 1)]));

          if (flag) {
            if (y >= heightOff) {
              BlockPos pos = new BlockPos(start.getX() + x, start.getY() + y, start.getZ() + z);
              Material material = world.getBlockState(pos).getBlock().getMaterial();
              if (material.isLiquid()) return false;
            } else {
              if (!canGenerateInBlock(
                  world, start.getX() + x, start.getY() + y, start.getZ() + z, genBlock)) {
                return false;
              }
            }
          }
        }
      }
    }

    for (x = 0; x < width; ++x) {
      for (z = 0; z < width; ++z) {
        for (y = 0; y < height; ++y) {
          if (spawnBlock[(x * width + z) * height + y]) {
            if (y < heightOff)
              generateBlock(
                  world, start.getX() + x, start.getY() + y, start.getZ() + z, genBlock, cluster);
            else if (canGenerateInBlock(
                world, start.getX() + x, start.getY() + y, start.getZ() + z, genBlock))
              generateBlock(world, start.getX() + x, start.getY() + y, start.getZ() + z, gapBlock);
          }
        }
      }
    }

    for (x = 0; x < width; ++x) {
      for (z = 0; z < width; ++z) {
        for (y = 0; y < height; ++y) {
          if (spawnBlock[(x * width + z) * height + y]
              && world
                  .getBlockState(
                      new BlockPos(start.getX() + x, start.getY() + y - 1, start.getZ() + z))
                  .getBlock()
                  .equals(Blocks.dirt)
              && world
                      .getBlockState(
                          new BlockPos(start.getX() + x, start.getY() + y, start.getZ() + z))
                      .getBlock()
                      .getLightValue()
                  > 0) {
            BiomeGenBase bgb =
                world.getBiomeGenForCoords(new BlockPos(start.getX() + x, 0, start.getZ() + z));
            // world.setBlock(start.getX() + x, start.getY() + y - 1, start.getZ() + z,
            // bgb.topBlock, bgb.field_150604_aj, 2);
            world.setBlockState(
                new BlockPos(start.getX() + x, start.getY() + y - 1, start.getZ() + z),
                bgb.topBlock
                    .getBlock()
                    .getStateFromMeta(bgb.topBlock.getBlock().getMetaFromState(bgb.topBlock)));
          }
        }
      }
    }

    if (outlineBlock != null) {
      for (x = 0; x < width; ++x) {
        for (z = 0; z < width; ++z) {
          for (y = 0; y < height; ++y) {
            boolean flag =
                !spawnBlock[(x * width + z) * height + y]
                    && ((x < W && spawnBlock[((x + 1) * width + z) * height + y])
                        || (x > 0 && spawnBlock[((x - 1) * width + z) * height + y])
                        || (z < W && spawnBlock[(x * width + (z + 1)) * height + y])
                        || (z > 0 && spawnBlock[(x * width + (z - 1)) * height + y])
                        || (y < H && spawnBlock[(x * width + z) * height + (y + 1)])
                        || (y > 0 && spawnBlock[(x * width + z) * height + (y - 1)]));

            if (flag
                && (solidOutline | y < heightOff || rand.nextInt(2) != 0)
                && (totalOutline
                    || world
                        .getBlockState(
                            new BlockPos(start.getX() + x, start.getY() + y, start.getZ() + z))
                        .getBlock()
                        .getMaterial()
                        .isSolid())) {
              generateBlock(
                  world, start.getX() + x, start.getY() + y, start.getZ() + z, outlineBlock);
            }
          }
        }
      }
    }
    System.out.println("gen at " + start.getX() + "," + start.getY() + "," + start.getZ());
    return true;
  }