Ejemplo n.º 1
0
  public void decorateHives(
      IChunkProvider chunkProvider,
      World world,
      Random rand,
      int chunkX,
      int chunkZ,
      boolean hasVillageGenerated) {
    if (!TerrainGen.populate(
        chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) {
      return;
    }

    decorateHives(world, rand, chunkX, chunkZ);
  }
Ejemplo n.º 2
0
  @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;
  }
Ejemplo n.º 3
0
  /** Populates chunk with ores etc etc */
  @Override
  public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {
    long time = System.currentTimeMillis();
    BlockSand.fallInstantly = true;
    int k = par2 * 16;
    int l = par3 * 16;
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
    this.rand.setSeed(this.worldObj.getSeed());
    long i1 = this.rand.nextLong() / 2L * 2L + 1L;
    long j1 = this.rand.nextLong() / 2L * 2L + 1L;
    this.rand.setSeed((long) par2 * i1 + (long) par3 * j1 ^ this.worldObj.getSeed());
    boolean flag = false;

    MinecraftForge.EVENT_BUS.post(
        new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag));

    /*
    if (this.mapFeaturesEnabled)
    {
        this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
        flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
        this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
        this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
    }*/

    int k1;
    int l1;
    int i2;

    if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAVA)
        && !flag
        && this.rand.nextInt(8) == 0) {
      k1 = k + this.rand.nextInt(16) + 8;
      l1 = this.rand.nextInt(this.rand.nextInt(120) + 8);
      i2 = l + this.rand.nextInt(16) + 8;

      if (l1 < 63 || this.rand.nextInt(10) == 0) {
        (new WorldGenLakes(Block.lavaStill.blockID)).generate(this.worldObj, this.rand, k1, l1, i2);
      }
    }

    /*boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, DUNGEON);
    for (k1 = 0; doGen && k1 < 8; ++k1)
    {
        l1 = k + this.rand.nextInt(16) + 8;
        i2 = this.rand.nextInt(128);
        int j2 = l + this.rand.nextInt(16) + 8;

        if ((new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2))
        {
            ;
        }
    }*/

    biomegenbase.decorate(this.worldObj, this.rand, k, l);
    SpawnerAnimals.performWorldGenSpawning(
        this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand);
    k += 8;
    l += 8;

    MinecraftForge.EVENT_BUS.post(
        new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag));

    BlockSand.fallInstantly = false;

    // System.out.println("Populating chunk: " + (System.currentTimeMillis() - time) + "ms");
  }
  public void rPopulatePreDecorate(
      IChunkProvider ichunkprovider,
      World worldObj,
      Random rand,
      int chunkX,
      int chunkZ,
      boolean flag) {
    int worldX = chunkX * 16;
    int worldZ = chunkZ * 16;
    boolean gen = true;

    gen =
        TerrainGen.populate(
            ichunkprovider,
            worldObj,
            rand,
            chunkX,
            chunkZ,
            flag,
            PopulateChunkEvent.Populate.EventType.LAKE);

    // Underground water lakes.
    if (ConfigRTG.enableWaterUndergroundLakes) {

      if (gen && (waterUndergroundLakeChance > 0)) {

        int i2 = worldX + rand.nextInt(16) + 8;
        int l4 = RandomUtil.getRandomInt(rand, 1, 50);
        int i8 = worldZ + rand.nextInt(16) + 8;

        if (rand.nextInt(waterUndergroundLakeChance) == 0
            && (RandomUtil.getRandomInt(rand, 1, ConfigRTG.waterUndergroundLakeChance) == 1)) {

          (new WorldGenLakes(Blocks.water)).generate(worldObj, rand, i2, l4, i8);
        }
      }
    }

    // Surface water lakes.
    if (ConfigRTG.enableWaterSurfaceLakes) {

      if (gen && (waterSurfaceLakeChance > 0)) {

        int i2 = worldX + rand.nextInt(16) + 8;
        int i8 = worldZ + rand.nextInt(16) + 8;
        int l4 = worldObj.getHeightValue(i2, i8);

        // Surface lakes.
        if (rand.nextInt(waterSurfaceLakeChance) == 0
            && (RandomUtil.getRandomInt(rand, 1, ConfigRTG.waterSurfaceLakeChance) == 1)) {

          if (l4 > 63) {

            (new WorldGenLakes(Blocks.water)).generate(worldObj, rand, i2, l4, i8);
          }
        }
      }
    }

    gen =
        TerrainGen.populate(
            ichunkprovider,
            worldObj,
            rand,
            chunkX,
            chunkZ,
            flag,
            PopulateChunkEvent.Populate.EventType.LAVA);

    // Underground lava lakes.
    if (ConfigRTG.enableLavaUndergroundLakes) {

      if (gen && (lavaUndergroundLakeChance > 0)) {

        int i2 = worldX + rand.nextInt(16) + 8;
        int l4 = RandomUtil.getRandomInt(rand, 1, 50);
        int i8 = worldZ + rand.nextInt(16) + 8;

        if (rand.nextInt(lavaUndergroundLakeChance) == 0
            && (RandomUtil.getRandomInt(rand, 1, ConfigRTG.lavaUndergroundLakeChance) == 1)) {

          (new WorldGenLakes(Blocks.lava)).generate(worldObj, rand, i2, l4, i8);
        }
      }
    }

    // Surface lava lakes.
    if (ConfigRTG.enableLavaSurfaceLakes) {

      if (gen && (lavaSurfaceLakeChance > 0)) {

        int i2 = worldX + rand.nextInt(16) + 8;
        int i8 = worldZ + rand.nextInt(16) + 8;
        int l4 = worldObj.getHeightValue(i2, i8);

        // Surface lakes.
        if (rand.nextInt(lavaSurfaceLakeChance) == 0
            && (RandomUtil.getRandomInt(rand, 1, ConfigRTG.lavaSurfaceLakeChance) == 1)) {

          if (l4 > 63) {

            (new WorldGenLakes(Blocks.lava)).generate(worldObj, rand, i2, l4, i8);
          }
        }
      }
    }

    if (ConfigRTG.generateDungeons) {

      gen =
          TerrainGen.populate(
              ichunkprovider,
              worldObj,
              rand,
              chunkX,
              chunkZ,
              flag,
              PopulateChunkEvent.Populate.EventType.DUNGEON);
      for (int k1 = 0; k1 < 8 && gen; k1++) {
        int j5 = worldX + rand.nextInt(16) + 8;
        int k8 = rand.nextInt(128);
        int j11 = worldZ + rand.nextInt(16) + 8;

        (new WorldGenDungeons()).generate(worldObj, rand, j5, k8, j11);
      }
    }
  }