Java Code Examples for net.minecraft.world.biome.Biome#decorate()

The following examples show how to use net.minecraft.world.biome.Biome#decorate() . 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: ChunkProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void populate(int x, int z) {
    BlockFalling.fallInstantly = true;
    BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);

    Biome biome = this.world.getBiome(blockpos.add(16, 0, 16));

    rand.setSeed(world.getSeed());
    long xSeed = rand.nextLong() / 2L * 2L + 1L;
    long zSeed = rand.nextLong() / 2L * 2L + 1L;
    rand.setSeed(chunkX * xSeed + chunkZ * zSeed ^ world.getSeed());

    int i = x * 16;
    int j = z * 16;

    if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.world, this.rand, diamondGen, blockpos, OreGenEvent.GenerateMinable.EventType.CUSTOM))
        for (int l1 = 0; l1 < 12; ++l1)
        {
            this.diamondGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), this.rand.nextInt(30), this.rand.nextInt(16)));
        }


    ChunkPos chunkpos = new ChunkPos(x, z);

    if (mapFeaturesEnabled) {
        this.mineshaft.generateStructure(this.world, this.rand, chunkpos);
        this.villageGenerator.generateStructure(this.world, this.rand, chunkpos);
        this.tofuCastle.generateStructure(this.world, this.rand, chunkpos);
    }

    biome.decorate(world, rand, blockpos);


    if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS))
        WorldEntitySpawner.performWorldGenSpawning(this.world, biome, i + 8, j + 8, 16, 16, this.rand);

    net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false);

    BlockFalling.fallInstantly = false;
}
 
Example 2
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;
}
 
Example 3
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;
}