Java Code Examples for net.minecraftforge.event.terraingen.TerrainGen#populate()

The following examples show how to use net.minecraftforge.event.terraingen.TerrainGen#populate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OilGeneratorFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void populate( PopulateChunkEvent.Post event )
{
  try
  {
    if( _mBuildCraftOilBlock == null ) {
        return;
    }

    int tMinDist = MainRegistry.CoreConfig.OilFixConfig.OilDepostMinDistance;
    if (tMinDist > 1)
    {
      if (event.chunkX % tMinDist != 0 || event.chunkZ % tMinDist != 0) {
          return;
      }
    }
    
    boolean doGen = TerrainGen.populate( event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, PopulateChunkEvent.Populate.EventType.CUSTOM );

    if( !doGen ) {
        return;
    }

    int worldX = event.chunkX << 4;
    int worldZ = event.chunkZ << 4;

    generateOil( event.world, event.rand, worldX + event.rand.nextInt( 16 ), worldZ + event.rand.nextInt( 16 ), false );
  }
  catch( Exception e )
  {
    e.printStackTrace();
  }
}
 
Example 2
Source File: ChunkProviderRoss128b.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) {
    BlockFalling.fallInstantly = true;
    int k = p_73153_2_ * 16;
    int l = p_73153_3_ * 16;
    BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
    this.rand.setSeed(this.worldObj.getSeed());
    if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) {
        long i1 = this.rand.nextLong() / 2L * 2L + 1L;
        long j1 = this.rand.nextLong() / 2L * 2L + 1L;
        this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed());
    }

    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false));

    int x1;
    int y1;
    int z1;
    if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, LAKE)) {
        x1 = k + this.rand.nextInt(16) + 8;
        y1 = this.rand.nextInt(256);
        z1 = l + this.rand.nextInt(16) + 8;
        int rni = this.rand.nextInt(8);
        if (rni == 0)
            (new WorldGenLakes(Blocks.ice)).generate(this.worldObj, this.rand, x1, y1, z1);
        else if (rni == 4)
            (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, x1, y1, z1);
    }
    if (biomegenbase != BiomeGenBase.ocean && biomegenbase != BiomeGenBase.deepOcean && biomegenbase != BiomeGenBase.river && biomegenbase != BiomeGenBase.frozenOcean && biomegenbase != BiomeGenBase.frozenRiver
            && this.rand.nextInt(ConfigHandler.ross128bRuinChance) == 0) {
        x1 = k + this.rand.nextInt(16) + 3;
        y1 = this.rand.nextInt(256);
        z1 = l + this.rand.nextInt(16) + 3;
        this.ruinsBase.generate(this.worldObj, this.rand, x1, y1, z1);
    }

    biomegenbase.decorate(this.worldObj, this.rand, k, l);

    k += 8;
    l += 8;

    boolean doGen = TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, ICE);
    for (x1 = 0; doGen && x1 < 16; ++x1) {
        for (y1 = 0; y1 < 16; ++y1) {
            z1 = this.worldObj.getPrecipitationHeight(k + x1, l + y1);

            if (this.worldObj.isBlockFreezable(x1 + k, z1 - 1, y1 + l)) {
                this.worldObj.setBlock(x1 + k, z1 - 1, y1 + l, Blocks.ice, 0, 2);
            }

            if (this.worldObj.func_147478_e(x1 + k, z1, y1 + l, true)) {
                this.worldObj.setBlock(x1 + k, z1, y1 + l, Blocks.snow_layer, 0, 2);
            }
        }
    }

    BWOreGen.generate(this.rand, p_73153_2_, p_73153_3_, this.worldObj, this, this);
    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false));

    BlockFalling.fallInstantly = false;
}
 
Example 3
Source File: NH_QuarryPopulator.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void generate(PopulateChunkEvent.Pre event) {
    if(TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) {
        generateQuarry(event.world, event.rand, event.chunkX, event.chunkZ);
    }
}
 
Example 4
Source File: NH_GeodePopulator.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void generate(PopulateChunkEvent.Pre event) {
    if(TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) {
        generateGeode(event.world, event.rand, event.chunkX, event.chunkZ);
    }
}
 
Example 5
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void populate(int x, int z)
{
	net.minecraft.block.BlockFalling.fallInstantly = true;

	BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);
	Biome Biome = this.worldObj.getBiome(blockpos.add(16, 0, 16));
	this.rand.setSeed(this.worldObj.getSeed());
	long k = this.rand.nextLong() / 2L * 2L + 1L;
	long l = this.rand.nextLong() / 2L * 2L + 1L;
	this.rand.setSeed(x * k + z * l ^ this.worldObj.getSeed());
	boolean flag = false;
	ChunkPos ChunkPos = new ChunkPos(x, z);

	ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, x, z, flag);

	TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.LAKE);
	TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.LAVA);

	Biome.decorate(this.worldObj, this.rand, new BlockPos(x * 16, 0, z * 16));

	if(TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.ANIMALS))
	{
		BlockPos chunkWorldPos = new BlockPos(x * 16, 0, z * 16);
		worldX = x * 16;
		worldZ = z * 16;
		islandChunkX = worldX % MAP_SIZE;
		islandChunkZ = worldZ % MAP_SIZE;
		Point islandPos = new Point(islandChunkX, islandChunkZ).toIslandCoord();
		IslandMap map = Core.getMapForWorld(worldObj, chunkWorldPos);
		Center centerInChunk = null;

		Center temp = map.getClosestCenter(islandPos);
		if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16))
			centerInChunk = temp;
		else 
		{
			temp = map.getClosestCenter(islandPos.plus(15, 0));
			if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16))
				centerInChunk = temp;
			else
			{
				temp = map.getClosestCenter(islandPos.plus(0, 15));
				if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16))
					centerInChunk = temp;
				else
				{
					temp = map.getClosestCenter(islandPos.plus(15, 15));
					if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16))
						centerInChunk = temp;
				}
			}
		}
	}

	blockpos = blockpos.add(8, 0, 8);

	if (TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.ICE))
	{
		for (int k2 = 0; k2 < 16; k2++)
		{
			for (int j3 = 0; j3 < 16; j3++)
			{
				BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(k2, 0, j3));
				BlockPos blockpos2 = blockpos1.down();

				if (this.worldObj.canBlockFreezeWater(blockpos2))
				{
					this.worldObj.setBlockState(blockpos2, Blocks.ICE.getDefaultState(), 2);
				}

				if (this.worldObj.canSnowAt(blockpos1, true))
				{
					this.worldObj.setBlockState(blockpos1, Blocks.SNOW_LAYER.getDefaultState(), 2);
				}
			}
		}
	}

	ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, x, z, flag);

	net.minecraft.block.BlockFalling.fallInstantly = false;
}