Java Code Examples for net.minecraft.world.chunk.ChunkPrimer#setBlockState()

The following examples show how to use net.minecraft.world.chunk.ChunkPrimer#setBlockState() . 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: MapGenTofuCaves.java    From TofuCraftReload with MIT License 6 votes vote down vote up
protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop, IBlockState state, IBlockState up) {
    net.minecraft.world.biome.Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16));
    IBlockState top = biome.topBlock;
    IBlockState filler = biome.fillerBlock;

    if (this.canReplaceBlock(state, up) || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock()) {
        if (y - 1 < 10) {
            data.setBlockState(x, y, z, BLK_LAVA);
        } else {
            data.setBlockState(x, y, z, BLK_AIR);

            if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock()) {
                data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState());
            }
        }
    }
}
 
Example 2
Source File: BiomeLushSwamp.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	double d0 = GRASS_COLOR_NOISE.getValue((double) x * 0.25D, (double) z * 0.25D);

	if (d0 > 0.0D) {
		int i = x & 15;
		int j = z & 15;

		for (int k = 255; k >= 0; --k) {
			if (chunkPrimerIn.getBlockState(j, k, i).getMaterial() != Material.AIR) {
				if (k == 62 && chunkPrimerIn.getBlockState(j, k, i).getBlock() != Blocks.WATER) {
					chunkPrimerIn.setBlockState(j, k, i, WATER);

					if (d0 < 0.12D) {
						chunkPrimerIn.setBlockState(j, k + 1, i, WATER_LILY);
					}
				}

				break;
			}
		}
	}

	this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
 
Example 3
Source File: MapGenRavineExt.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop)
{
    net.minecraft.world.biome.Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16));
    IBlockState state = data.getBlockState(x, y, z);
    IBlockState top = isExceptionBiome(biome) ? Blocks.GRASS.getDefaultState() : biome.topBlock;
    IBlockState filler = isExceptionBiome(biome) ? Blocks.DIRT.getDefaultState() : biome.fillerBlock;

    if (state.getBlock() == Blocks.STONE || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock() || (fillerBlock != null && state.getBlock() == fillerBlock.getBlock()))
    {
        if (y - 1 < 10)
        {
            data.setBlockState(x, y, z, FLOWING_LAVA);
        }
        else
        {
            data.setBlockState(x, y, z, AIR);

            if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock())
            {
                data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState());
            }
        }
    }
}
 
Example 4
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
protected void genRoom(ChunkPrimer primer, Dungeon dungeon, DungeonRoom room)
{
	RoomSchematic schem = room.getSchematic();

	for(SchemBlock b : schem.getProcessedBlockList(dungeon))
	{
		DungeonDirection borderFacing = isOnBorder(b);
		if(borderFacing != null && b.state.getBlock() == Blocks.OAK_DOOR)
		{
			if(!room.hasConnection(borderFacing))
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), dungeon.blockMap.get("dungeon_wall"));
				continue;
			}
			else if(room.hasConnection(borderFacing) && !room.getConnection(borderFacing).placeDoor)
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), Blocks.AIR.getDefaultState());
				continue;
			}
		}
		else if(borderFacing != null && b.state.getBlock() == Blocks.AIR)
		{
			if(!room.hasConnection(borderFacing) && b.pos.getY() < 10)//the <10 check here makes sure that the surface sections of entrances
			{
				primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), dungeon.blockMap.get("dungeon_wall"));
				continue;
			}
		}
		primer.setBlockState(8+b.pos.getX(), room.getPosition().getY() + b.pos.getY(), 8+b.pos.getZ(), b.state);
	}
}
 
Example 5
Source File: ChunkProviderCavePlanet.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * Generates the chunk at the specified position, from scratch
 */
 public Chunk generateChunk(int x, int z)
{
	this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
	ChunkPrimer chunkprimer = super.getChunkPrimer(x, z);
	
	for(int i = 16; i < 128; i++)
	{
		for(int xx = 0; xx < 16; xx++)
			for(int zz = 0; zz < 16; zz++)
				chunkprimer.setBlockState(xx, i + 128 - 16, zz, chunkprimer.getBlockState(xx, i, zz));
	}
	
	this.prepareHeights(x, z, chunkprimer);
	this.buildSurfaces(x, z, chunkprimer);
	this.genNetherCaves.generate(this.world, x, z, chunkprimer);
	this.genHighCaves.generate(this.world, x, z, chunkprimer);
	this.genRavines.generate(this.world, x, z, chunkprimer);
	
	if (this.generateStructures)
	{
	}
	
	Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
	Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16);
	byte[] abyte = chunk.getBiomeArray();

	for (int i = 0; i < abyte.length; ++i)
	{
		abyte[i] = (byte)Biome.getIdForBiome(abiome[i]);
	}

	chunk.setLightPopulated(true);
	return chunk;
}
 
Example 6
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This is for stripping a chunk of all but ore and BEDROCK for easier testing.
 */
protected void stripChunk(ChunkPrimer primer)
{
	Point p;
	Center closestCenter;
	IBlockState state;
	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			p = new Point(x, z);
			closestCenter = this.getHex(p);
			int hexElev = this.getHexElevation(closestCenter, p);

			if(closestCenter.hasAnyMarkersOf(Marker.Coast, Marker.Ocean))
				continue;

			for(int y = hexElev; y >= 0; y--)
			{
				state = primer.getBlockState(x, y, z);
				if(state.getBlock() != TFCBlocks.Ore && state.getBlock() != Blocks.BEDROCK && state.getBlock() != Blocks.WOOL)
				{
					primer.setBlockState(x, y, z, Blocks.AIR.getDefaultState());
				}
			}
		}
	}
}
 
Example 7
Source File: ChunkGeneratorUnderWorld.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private List<Pair<BlockPos, BlockPos>> generate(int chunkX, int chunkZ, ChunkPrimer primer)
{
	double[][] upperValues = new double[16][16];
	double[][] lowerValues = new double[16][16];
	for (int x = 0; x < 16; x++)
	{
		for (int z = 0; z < 16; z++)
		{
			upperValues[x][z] = upper.getValue((chunkX * 16 + x) / UPPER_X_SCALE, (chunkZ * 16 + z) / UPPER_Z_SCALE);
			lowerValues[x][z] = lower.getValue((chunkX * 16 + x) / LOWER_X_SCALE, (chunkZ * 16 + z) / LOWER_Z_SCALE);
		}
	}

	List<Pair<BlockPos, BlockPos>> litBlocks = new LinkedList<>();
	for (int x = 0; x < 16; x++)
	{
		for (int z = 0; z < 16; z++)
		{
			int minY = (int) (lowerValues[x][z] * LOWER_Y_SCALE + LOWER_LEVEL);
			int maxY = (int) (upperValues[x][z] * UPPER_Y_SCALE + UPPER_LEVEL);
			litBlocks.add(new Pair<>(new BlockPos(chunkX * 16 + x, minY, chunkZ * 16 + z), new BlockPos(chunkX * 16 + x, maxY, chunkZ * 16 + z)));
			for (int y = minY; y <= maxY; y++)
			{
				if (y == minY)
					primer.setBlockState(x, y, z, ModBlocks.CLOUD.getDefaultState().withProperty(BlockCloud.HAS_LIGHT_VALUE, true));
				else
				{
					// if (y >= minY + 6 && y <= maxY - 6)
					// primer.setBlockState(x, y, z,
					// ModFluids.LETHE.getActualBlock().getDefaultState());
					// else
					primer.setBlockState(x, y, z, ModBlocks.CLOUD.getDefaultState());
				}
			}
		}
	}
	return litBlocks;
}
 
Example 8
Source File: ChunkGeneratorTorikki.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * ok so
 * this is supposed to work by genning everything below 128
 * and then mirroring it over y - 128
 * y = y > 128 ? 256 - y : y is the gud code
 * idk how to make it work
 */
//0-15 for local, 16*chunk + 0-15 for noise
private void generate(int chunkX, int chunkZ, ChunkPrimer primer) {
	//go through x
	for (int locX = 0; locX < 16; locX++) {
		//go through y (irrelevant of chunk location)
		for (int locY = 0; locY < 256; locY++) {
			//and now for z
			for (int locZ = 0; locZ < 16; locZ++) {
				if ((locY <= 64 && locY > 1) || (locY > 192 && locY < 255)) {
					primer.setBlockState(locX, locY, locZ, DIRT);
				} else if (locY == 1 || locY == 255) {
					primer.setBlockState(locX, locY, locZ, BEDROCK);
				}
			}
			//if the noise <1, air, else torikki Grass?
		}
	}
	//mirroring!
	for (int locX = 0; locX < 16; locX++) {
		for (int locY = 65; locY < 128; locY++) {
			for (int locZ = 0; locZ < 16; locZ++) {
				if(.5 <noise.getValue(chunkZ, chunkX)){
					primer.setBlockState(locX,locY,locZ,DIRT);
				}
			}
		}
	}
}
 
Example 9
Source File: BiomeGenDeepSwamp.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand,
		ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	
	double d0 = GRASS_COLOR_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);

       if (d0 > 0.0D)
       {
           int i = x & 15;
           int j = z & 15;

           for (int k = 255; k >= 0; --k)
           {
               if (chunkPrimerIn.getBlockState(j, k, i).getMaterial() != Material.AIR)
               {
                   if (k == 62 && chunkPrimerIn.getBlockState(j, k, i).getBlock() != Blocks.WATER)
                   {
                       chunkPrimerIn.setBlockState(j, k, i, WATER);

                       if (d0 < 0.12D)
                       {
                           chunkPrimerIn.setBlockState(j, k + 1, i, Blocks.WATERLILY.getDefaultState());
                       }
                   }

                   break;
               }
           }
       }

       this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);

       
	//Decoration time takes too long due to block relights, so run at terrain gen time
	///swampTree.func_151539_a(null, world, x, z, block); //Arg 1 never actually used so fake it
	//Yes this is hacky
	if(x % 16 == 0 && z % 16 == 0 )
		swampTree.generate(worldIn, x/16, z/16, chunkPrimerIn);
}
 
Example 10
Source File: WorldGenSwampTree.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
private void setBlock(BlockPos pos, IBlockState block, ChunkPrimer blocks) {
	
	int x = pos.getX();
	int y = pos.getY();
	int z = pos.getZ();
	
	if(x > 15 || x < 0 || z > 15 || z < 0 || y < 0 || y > 255)
		return;
	
	blocks.setBlockState(x, y, z, block);
}
 
Example 11
Source File: ChunkProviderCavePlanet.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void prepareHeights(int p_185936_1_, int p_185936_2_, ChunkPrimer primer)
{
	int i = 4;
	int j = this.world.getSeaLevel() / 2 + 1;
	int k = 5;
	int l = 17;
	int i1 = 5;
	this.buffer = this.getHeights(this.buffer, p_185936_1_ * 4, 0, p_185936_2_ * 4, 5, 17, 5);

	for (int j1 = 0; j1 < 4; ++j1)
	{
		for (int k1 = 0; k1 < 4; ++k1)
		{
			for (int l1 = 0; l1 < 16; ++l1)
			{
				double d0 = 0.125D;
				double d1 = this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 0];
				double d2 = this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 0];
				double d3 = this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 0];
				double d4 = this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 0];
				double d5 = (this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 1] - d1) * 0.125D;
				double d6 = (this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 1] - d2) * 0.125D;
				double d7 = (this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 1] - d3) * 0.125D;
				double d8 = (this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 1] - d4) * 0.125D;

				for (int i2 = 0; i2 < 8; ++i2)
				{
					double d9 = 0.25D;
					double d10 = d1;
					double d11 = d2;
					double d12 = (d3 - d1) * 0.25D;
					double d13 = (d4 - d2) * 0.25D;

					for (int j2 = 0; j2 < 4; ++j2)
					{
						double d14 = 0.25D;
						double d15 = d10;
						double d16 = (d11 - d10) * 0.25D;

						for (int k2 = 0; k2 < 4; ++k2)
						{
							IBlockState iblockstate = null;

							if (l1 * 8 + i2 < j)
							{
								iblockstate = this.oceanBlock;
							}

							if (d15 > 0.0D)
							{
								iblockstate = this.fillblock;
							}

							int l2 = j2 + j1 * 4;
							int i3 = i2 + l1 * 8;
							int j3 = k2 + k1 * 4;
							primer.setBlockState(l2, i3, j3, iblockstate);
							d15 += d16;
						}

						d10 += d12;
						d11 += d13;
					}

					d1 += d5;
					d2 += d6;
					d3 += d7;
					d4 += d8;
				}
			}
		}
	}
}
 
Example 12
Source File: ChunkProviderCavePlanet.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void buildSurfaces(int p_185937_1_, int p_185937_2_, ChunkPrimer primer)
{
	if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, primer, this.world)) return;
	int i = this.world.getSeaLevel() + 1;
	double d0 = 0.03125D;
	this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D);
	this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_185937_1_ * 16, 109, p_185937_2_ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D);
	this.depthBuffer = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.depthBuffer, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D);

	for (int j = 0; j < 16; ++j)
	{
		for (int k = 0; k < 16; ++k)
		{
			boolean flag = this.slowsandNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D;
			boolean flag1 = this.gravelNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D;
			int l = (int)(this.depthBuffer[j + k * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
			int i1 = -1;
			IBlockState iblockstate = this.fillblock;
			IBlockState iblockstate1 = this.fillblock;

			for (int j1 = 127; j1 >= 0; --j1)
			{
				IBlockState iblockstate2 = primer.getBlockState(k, j1, j);

				if (iblockstate2.getBlock() != null && iblockstate2.getMaterial() != Material.AIR)
				{
					if (iblockstate2 == fillblock)
					{
						if (i1 == -1)
						{
							if (l <= 0)
							{
								iblockstate = AIR;
								iblockstate1 = this.fillblock;
							}
							else if (j1 >= i - 4 && j1 <= i + 1)
							{
								iblockstate = this.fillblock;
								iblockstate1 = this.fillblock;
							}

							if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR))
							{
								iblockstate = oceanBlock;
							}

							i1 = l;

							if (j1 >= i - 1)
							{
								primer.setBlockState(k, j1, j, iblockstate);
							}
							else
							{
								primer.setBlockState(k, j1, j, iblockstate1);
							}
						}
						else if (i1 > 0)
						{
							--i1;
							primer.setBlockState(k, j1, j, iblockstate1);
						}
					}
				}
				else
				{
					i1 = -1;
				}
			}
		}
	}
}
 
Example 13
Source File: MapGenLargeCrystal.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
private void setBlock(int x, int y, int z , IBlockState block, ChunkPrimer blocks) {

		if(x > 15 || x < 0 || z > 15 || z < 0 || y < 0 || y > 255)
			return;
		blocks.setBlockState(x, y, z, block);
	}
 
Example 14
Source File: MapGenGeode.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
protected void recursiveGenerate(World world, int chunkX,
		int chunkZ, int p_180701_4_, int p_180701_5_,
		ChunkPrimer chunkPrimerIn) {

	if(rand.nextInt(chancePerChunk) == Math.abs(chunkX) % chancePerChunk || rand.nextInt(chancePerChunk) == Math.abs(chunkZ) % chancePerChunk) {

		int radius = rand.nextInt(Configuration.geodeVariation) + Configuration.geodeBaseSize - (Configuration.geodeVariation/2); //24; 24 -> 48

		//TODO: make hemisphere from surface and line the side with ore of some kind

		int depth = radius*radius;

		int xCoord = -chunkX + p_180701_4_;
		int zCoord =  -chunkZ + p_180701_5_;

		BlockPos pos = new BlockPos(chunkX*16, 0, chunkZ*16);

		int avgY = (int) ((world.getBiome(pos).getBaseHeight() + 2) *32) - 3*radius/4;

		for(int x = 15; x >= 0; x--) {
			for(int z = 15; z >= 0; z--) {
				int index;

				for(int y = 255; y >= 0; y--) {
					index = (x * 16 + z) * 256 + y;
					if(chunkPrimerIn.getBlockState(x, y, z) != Blocks.AIR.getDefaultState())
						break;
				}

				int count = ( depth - ( ((xCoord*16)+x)*((xCoord*16)+x) + ((zCoord*16)+z)*((zCoord*16)+z) ) )/(radius*2);

				//Check for IOB exceptions early, in case it generates near bedrock or something
				if(avgY-count < 1 || avgY+count > 255)
					continue;

				//Clears air for the ceiling
				for(int dist = -count; dist < Math.min(count,3); dist++) {
					index = (x * 16 + z) * 256 + avgY -dist;
					chunkPrimerIn.setBlockState(x, avgY - dist, z, Blocks.AIR.getDefaultState());
				}

				if(count >= 0) {

					if(count > 4) {
						int size = rand.nextInt(4) + 4;

						//Generates ore hanging from the ceiling
						if( x % 4 > 0 && z % 4 > 0) {
							for(int i = 1; i < size; i++)
								chunkPrimerIn.setBlockState(x, avgY + count - i, z, ores.get((x/4 + z/4) % ores.size()).getBlockState());
						}
						else {
							size -=2;
							for(int i = 1; i < size; i++) {
								chunkPrimerIn.setBlockState(x, avgY + count - i, z, Blocks.STONE.getDefaultState());
							}
						}

						//Generates ore in the floor
						if( (x+2) % 4 > 0 && (z+2) % 4 > 0) {
							for(int i = 1; i < size; i++)
								chunkPrimerIn.setBlockState(x, avgY - count + i, z, ores.get((x/4 + z/4) % ores.size()).getBlockState());
						}

					}

					chunkPrimerIn.setBlockState(x, avgY - count, z, AdvancedRocketryBlocks.blocksGeode.getDefaultState());
					chunkPrimerIn.setBlockState(x, avgY + count, z, AdvancedRocketryBlocks.blocksGeode.getDefaultState());
				}
			}
		}
	}
}
 
Example 15
Source File: ChunkProviderPlanet.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void setBlocksInChunk(int x, int z, ChunkPrimer primer)
{
	byte b0 = 63;
	//TODO: may break for little planets
	this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);
       this.generateHeightmap(x * 4, 0, z * 4);

       for (int i = 0; i < 4; ++i)
       {
           int j = i * 5;
           int k = (i + 1) * 5;

           for (int l = 0; l < 4; ++l)
           {
               int i1 = (j + l) * 33;
               int j1 = (j + l + 1) * 33;
               int k1 = (k + l) * 33;
               int l1 = (k + l + 1) * 33;

               for (int i2 = 0; i2 < 32; ++i2)
               {
                   double d0 = 0.125D;
                   double d1 = this.heightMap[i1 + i2];
                   double d2 = this.heightMap[j1 + i2];
                   double d3 = this.heightMap[k1 + i2];
                   double d4 = this.heightMap[l1 + i2];
                   double d5 = (this.heightMap[i1 + i2 + 1] - d1) * 0.125D;
                   double d6 = (this.heightMap[j1 + i2 + 1] - d2) * 0.125D;
                   double d7 = (this.heightMap[k1 + i2 + 1] - d3) * 0.125D;
                   double d8 = (this.heightMap[l1 + i2 + 1] - d4) * 0.125D;

                   for (int j2 = 0; j2 < 8; ++j2)
                   {
                       double d9 = 0.25D;
                       double d10 = d1;
                       double d11 = d2;
                       double d12 = (d3 - d1) * 0.25D;
                       double d13 = (d4 - d2) * 0.25D;

                       for (int k2 = 0; k2 < 4; ++k2)
                       {
                           double d14 = 0.25D;
                           double d16 = (d11 - d10) * 0.25D;
                           double lvt_45_1_ = d10 - d16;

                           for (int l2 = 0; l2 < 4; ++l2)
                           {
                               if ((lvt_45_1_ += d16) > 0.0D)
                               {
                                   primer.setBlockState(i * 4 + k2, heightmapOffset + i2 * 8 + j2, l * 4 + l2, this.fillblock);
                               }
                               else if (i2 * 8 + j2 < worldObj.getSeaLevel())
                               {
                                   primer.setBlockState(i * 4 + k2, heightmapOffset + i2 * 8 + j2, l * 4 + l2, this.oceanBlock);
                               }
                           }

                           d10 += d12;
                           d11 += d13;
                       }

                       d1 += d5;
                       d2 += d6;
                       d3 += d7;
                       d4 += d8;
                   }
               }
           }
       }
}
 
Example 16
Source File: BiomeCragCliffs.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	int i = worldIn.getSeaLevel();
	IBlockState iblockstate = this.topBlock;
	IBlockState iblockstate1 = this.fillerBlock;
	int j = -1;
	int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
	int l = x & 15;
	int i1 = z & 15;
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

	for (int j1 = 255; j1 >= 0; --j1) {
		if (j1 <= rand.nextInt(5)) {
			chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
		} else {
			IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

			if (iblockstate2.getMaterial() == Material.AIR) {
				j = -1;
			} else if (iblockstate2.getBlock() == Blocks.STONE) {
				if (j == -1) {
					if (k <= 0) {
						iblockstate = AIR;
						iblockstate1 = STONE;
					} else if (j1 >= i - 4 && j1 <= i + 1) {
						iblockstate = this.topBlock;
						iblockstate1 = this.fillerBlock;
					}

					if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
						if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
							iblockstate = ICE;
						} else {
							iblockstate = WATER;
						}
					}

					j = k;

					if (j1 >= i - 1) {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
					} else if (j1 < i - 7 - k) {
						iblockstate = AIR;
						iblockstate1 = STONE;
						chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
					} else {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
					}
				} else if (j > 0) {
					--j;
					chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);

					if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
					}

					if (j == 0 && iblockstate == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate = blueRock;
					}

					if (j == 0 && iblockstate1 == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = blueRock;
					}
				}
			}
		}
	}
}
 
Example 17
Source File: BiomeCanyon.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	int i = worldIn.getSeaLevel();
	IBlockState iblockstate = this.topBlock;
	IBlockState iblockstate1 = this.fillerBlock;
	int j = -1;
	int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
	int l = x & 15;
	int i1 = z & 15;
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

	for (int j1 = 255; j1 >= 0; --j1) {
		if (j1 <= rand.nextInt(5)) {
			chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
		} else {
			IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

			if (iblockstate2.getMaterial() == Material.AIR) {
				j = -1;
			} else if (iblockstate2.getBlock() == Blocks.STONE) {
				if (j == -1) {
					if (k <= 0) {
						iblockstate = AIR;
						iblockstate1 = STONE;
					} else if (j1 >= i - 4 && j1 <= i + 1) {
						iblockstate = this.topBlock;
						iblockstate1 = this.fillerBlock;
					}

					if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
						if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
							iblockstate = ICE;
						} else {
							iblockstate = WATER;
						}
					}

					j = k;

					if (j1 >= i - 1) {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
					} else if (j1 < i - 7 - k) {
						iblockstate = AIR;
						iblockstate1 = STONE;
						chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
					} else {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
					}
				} else if (j > 0) {
					--j;
					chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);

					if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
					}

					if (j == 0 && iblockstate == redRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate = redRock;
					}

					if (j == 0 && iblockstate1 == redRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = redRock;
					}
				}
			}
		}
	}
}
 
Example 18
Source File: BiomeCragCliffs.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	int i = worldIn.getSeaLevel();
	IBlockState iblockstate = this.topBlock;
	IBlockState iblockstate1 = this.fillerBlock;
	int j = -1;
	int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
	int l = x & 15;
	int i1 = z & 15;
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

	for (int j1 = 255; j1 >= 0; --j1) {
		if (j1 <= rand.nextInt(5)) {
			chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
		} else {
			IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

			if (iblockstate2.getMaterial() == Material.AIR) {
				j = -1;
			} else if (iblockstate2.getBlock() == Blocks.STONE) {
				if (j == -1) {
					if (k <= 0) {
						iblockstate = AIR;
						iblockstate1 = STONE;
					} else if (j1 >= i - 4 && j1 <= i + 1) {
						iblockstate = this.topBlock;
						iblockstate1 = this.fillerBlock;
					}

					if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
						if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
							iblockstate = ICE;
						} else {
							iblockstate = WATER;
						}
					}

					j = k;

					if (j1 >= i - 1) {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
					} else if (j1 < i - 7 - k) {
						iblockstate = AIR;
						iblockstate1 = STONE;
						chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
					} else {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
					}
				} else if (j > 0) {
					--j;
					chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);

					if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
					}

					if (j == 0 && iblockstate == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate = blueRock;
					}

					if (j == 0 && iblockstate1 == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = blueRock;
					}
				}
			}
		}
	}
}
 
Example 19
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
protected void generateTerrain(ChunkPrimer chunkprimer, int chunkX, int chunkZ)
{
	Point p;
	Center closestCenter = null;
	double[] dts = new double[] {0,0};
	double dist = 0;
	double loc = 0;

	int maxHeightOfChunk = 255;

	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			p = new Point(x, z);
			closestCenter = this.getHex(p);


			int hexElev = 0;
			if(!closestCenter.hasAttribute(Attribute.River) && !closestCenter.hasMarker(Marker.Coast) && !closestCenter.hasMarker(Marker.CoastWater) && !closestCenter.hasAttribute(Attribute.Lake))
			{
				//hexElev = convertElevation(getSmoothHeightHex(closestCenter, p));
				hexElev = convertElevation(getSmoothHeightHex(closestCenter, p)) + (int)Math.ceil(turbMap.GetValue(worldX+p.x, worldZ+p.y));
			}
			else if(closestCenter.hasMarker(Marker.CoastWater))
			{
				hexElev = convertElevation(closestCenter.getElevation()) + getBeachTurb(closestCenter, p, 2);
			}
			else 
			{
				hexElev = convertElevation(getSmoothHeightHex(closestCenter, p));
			}
			int scanElev = hexElev;

			if(closestCenter.biome == BiomeType.LAKE || closestCenter.biome == BiomeType.LAKESHORE)
			{
				LakeAttribute attrib = (LakeAttribute) closestCenter.getAttribute(Attribute.Lake);
				scanElev = convertElevation(attrib.getLakeElev());
			}

			if(closestCenter.hasMarker(Marker.Ocean))
			{
				Vector<Center> nearCenters = getCentersNear(p, 9);
				boolean onlyOcean = true;
				for(Center c : nearCenters)
				{
					if(!c.hasMarker(Marker.Ocean))
					{
						onlyOcean = false;
					}
				}

				if(onlyOcean)
					hexElev = convertElevation(getSmoothHeightHex(closestCenter, p, 9));
			}

			if(closestCenter.hasMarker(Marker.Spire))
			{
				Random r = new Random(closestCenter.index);
				double heightMult = r.nextDouble();
				double spireElev = closestCenter.getElevation() + (1-closestCenter.getElevation())*(0.5+heightMult*0.3);
				double diff = spireElev - closestCenter.getElevation();
				double rad = 20;
				dist = closestCenter.point.plus(-5+r.nextInt(11), -5+r.nextInt(11)).distance(p.plus(new Point(worldX, worldZ).toIslandCoord()));
				dist /= 20;
				dist = 1-dist;

				if(dist > 0.95)
					dist = 0.95;

				hexElev = convertElevation(getSmoothHeightHex(closestCenter, p) + (diff*(Math.pow(dist, 5))));
				scanElev = hexElev;
			}


			maxHeightOfChunk = Math.max(maxHeightOfChunk, scanElev);
			elevationMap[z << 4 | x] = hexElev;
			for(int y = Math.min(Math.max(scanElev, Global.SEALEVEL), 255); y >= 0; y--)
			{
				Block b = Blocks.AIR;
				if(y < hexElev)
				{
					b = Blocks.STONE;
				}
				else if(y < Global.SEALEVEL || (closestCenter.hasAttribute(Attribute.Lake) && y < scanElev))
				{
					b = Blocks.WATER;
				}

				if(y <= hexElev * 0.2)
					b = Blocks.BEDROCK;

				chunkprimer.setBlockState(x, y, z, b.getDefaultState());
			}
		}
	}
}
 
Example 20
Source File: ChunkProviderTofu.java    From TofuCraftReload with MIT License 4 votes vote down vote up
private void buildSurfaces(ChunkPrimer primer) {
    int l;
    IBlockState iblockstate, iblockstate1, desertstone;
    for (int i = 0; i < 16; ++i) {

        for (int j = 0; j < 16; ++j) {
            l = -1;

            Biome biome = this.biomesForGeneration[j + i * 16];
            iblockstate = biome.topBlock;
            iblockstate1 = biome.fillerBlock;
            desertstone = BlockLoader.tofuTerrain.getDefaultState();

            for (int i1 = 127; i1 >= 0; --i1) {

                IBlockState iblockstate2 = primer.getBlockState(i, i1, j);

                if (iblockstate2.getMaterial() == Material.AIR) {
                    l = -3;

                } else if (iblockstate2.getBlock() == BlockLoader.tofuTerrain) {
                    if (l <= -1) {
                        if (l == -3) {
                            primer.setBlockState(i, i1, j, iblockstate);
                        } else {
                            primer.setBlockState(i, i1, j, iblockstate1);

                        }

                        l += 1;

                    } else if (l > 0) {
                        --l;
                        primer.setBlockState(i, i1, j, desertstone);

                    }
                }
            }
        }
    }
}