net.minecraft.world.chunk.ChunkPrimer Java Examples

The following examples show how to use net.minecraft.world.chunk.ChunkPrimer. 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: TileChunkLoadHook.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
    IChunk chunk = event.getChunk();
    Map<BlockPos, TileEntity> tiles = null;
    if (chunk instanceof ChunkPrimerWrapper) {
        chunk = ((ChunkPrimerWrapper) chunk).func_217336_u();
    }
    if (chunk instanceof Chunk) {
        tiles = ((Chunk) chunk).getTileEntityMap();
    }
    if (chunk instanceof ChunkPrimer) {
        tiles = ((ChunkPrimer) chunk).getTileEntities();
    }
    if (tiles != null) {
        for (TileEntity tile : tiles.values()) {
            if (tile instanceof IChunkLoadTile) {
                ((IChunkLoadTile) tile).onChunkLoad();
            }
        }
    }
}
 
Example #2
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 #3
Source File: MapGenMassiveRavine.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
/**
    * Recursively called by generate()
    */
@Override
   protected void recursiveGenerate(World worldIn, int chunkX, int chunkZ, int originalX, int originalZ, ChunkPrimer chunkPrimerIn)
   {
       if (this.rand.nextInt(50) == 0)
       {
           double d0 = (double)(chunkX * 16 + this.rand.nextInt(16));
           double d1 = (double)(this.rand.nextInt(this.rand.nextInt(40) + 8) + 20);
           double d2 = (double)(chunkZ * 16 + this.rand.nextInt(16));
           int i = 1;

           for (int j = 0; j < 24; ++j)
           {
               float f = this.rand.nextFloat() * ((float)Math.PI * 2F);
               float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
               float f2 = (this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F;
               this.addTunnel(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 3.0D);
           }
       }
   }
 
Example #4
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 #5
Source File: ChunkProviderSpace.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public Chunk generateChunk(int p_73154_1_, int p_73154_2_) {
	Block[] ablock = new Block[65536];
	byte[] abyte = new byte[65536];
	ChunkPrimer chunkprimer = new ChunkPrimer();
	
	//ChunkExtendedBiome
	Chunk chunk = new Chunk(this.worldObj, chunkprimer, p_73154_1_, p_73154_2_);//new Chunk(this.worldObj, ablock, abyte, p_73154_1_, p_73154_2_);
	//TODO: convert back to int
	byte[] abyte1 = chunk.getBiomeArray();

	Arrays.fill(abyte1, (byte)Biome.getIdForBiome(AdvancedRocketryBiomes.spaceBiome));

	chunk.generateSkylightMap();
	return chunk;
}
 
Example #6
Source File: BiomeGenMarsh.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand,
		ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	super.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal);

	double d1 = GRASS_COLOR_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
	x = Math.abs(x % 16);
	z = Math.abs(z % 16);
	if (d1 > 0.2D)
	{
		chunkPrimerIn.setBlockState(x, 62, z, Blocks.GRASS.getDefaultState());
		for(int y = (int)(61); y > 1; y--) {
			
			if(!chunkPrimerIn.getBlockState(x, y, z).isOpaqueCube())
				chunkPrimerIn.setBlockState(x, y, z, Blocks.GRASS.getDefaultState());
			else
				break;
		}
	}
}
 
Example #7
Source File: ChunkProviderPaths.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Chunk provideChunk(int chunkX, int chunkZ)
{
	worldX = chunkX * 16;
	worldZ = chunkZ * 16;
	islandChunkX = worldX % MAP_SIZE;
	islandChunkZ = worldZ % MAP_SIZE;
	mapX = (chunkX >> 8);
	mapZ = (chunkZ >> 8);
	islandMap = WorldGen.getInstance().getIslandMap(((chunkX*16/8) >> 12), ((chunkZ*16/8) >> 12));


	this.rand.setSeed((long)chunkX * 341873128712L + (long)chunkZ * 132897987541L);
	ChunkPrimer chunkprimer = new ChunkPrimer();
	generateTerrain(chunkprimer);
	Chunk chunk = new Chunk(this.worldObj, chunkprimer, chunkX, chunkZ);
	chunk.generateSkylightMap();
	return chunk;  
}
 
Example #8
Source File: BiomeLushSwamp.java    From Traverse-Legacy-1-12-2 with MIT License 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 #9
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 #10
Source File: ChunkGeneratorUnderWorld.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nonnull
@Override
public Chunk generateChunk(int x, int z)
{
	ChunkPrimer chunkprimer = new ChunkPrimer();

	// Get a list of blocks to check lighting for, as a "side effect" of
	// actually generating the clouds
	List<Pair<BlockPos, BlockPos>> litBlocks = generate(x, z, chunkprimer);

	Chunk chunk = new Chunk(world, chunkprimer, x, z);

	litBlocks.forEach(pair ->
	{
		BlockPos lower = pair.getFirst();
		BlockPos upper = pair.getSecond();
		for (int i = 0; i < 15; i++)
		{
			if (lower.getY() + i > upper.getY()) return;
			chunk.setLightFor(EnumSkyBlock.BLOCK, lower.up(i), 15 - i);
		}
	});
	
	return chunk;
}
 
Example #11
Source File: ChunkGeneratorTorikki.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nonnull
@Override
public Chunk generateChunk(int x, int z) {
	this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
	ChunkPrimer chunkprimer = new ChunkPrimer();

	generate(x, z, chunkprimer);

	Chunk chunk = new Chunk(world, chunkprimer, x, z);

	byte[] biomeArray = chunk.getBiomeArray();
	for (int i = 0; i < biomeArray.length; ++i) {
		biomeArray[i] = (byte) 42;
	}

	chunk.generateSkylightMap();
	return chunk;
}
 
Example #12
Source File: MapGenTofuCastle.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private void create(World p_191092_1_, ChunkProviderTofu p_191092_2_, Random p_191092_3_, int p_191092_4_, int p_191092_5_) {
    Rotation rotation = Rotation.NONE;
    ChunkPrimer chunkprimer = new ChunkPrimer();
    p_191092_2_.setBlocksInChunk(p_191092_4_, p_191092_5_, chunkprimer);
    int i = 5;
    int j = 5;


    int k = chunkprimer.findGroundBlockIdx(7, 7);
    int l = chunkprimer.findGroundBlockIdx(7, 7 + j);
    int i1 = chunkprimer.findGroundBlockIdx(7 + i, 7);
    int j1 = chunkprimer.findGroundBlockIdx(7 + i, 7 + j);
    int k1 = Math.min(Math.min(k, l), Math.min(i1, j1));


    BlockPos blockpos = new BlockPos(p_191092_4_ * 16 + 8, k1, p_191092_5_ * 16 + 8);
    List<TofuCastlePiece.TofuCastleTemplate> list = Lists.<TofuCastlePiece.TofuCastleTemplate>newLinkedList();
    TofuCastlePiece.generateCore(p_191092_1_.getSaveHandler().getStructureTemplateManager(), blockpos, rotation, list, p_191092_3_);
    this.components.addAll(list);
    this.updateBoundingBox();
    this.isValid = true;

}
 
Example #13
Source File: WorldProviderHellVoid.java    From YUNoMakeGoodMap with Apache License 2.0 6 votes vote down vote up
@Override
public Chunk generateChunk(int x, int z)
{
    ChunkPrimer data = new ChunkPrimer();

    if(YUNoMakeGoodMap.instance.shouldGenerateNetherFortress(world))
        genNetherBridge.generate(world, x, z, data);
    else
        genNetherBridge.generate(world, x, z, null);

    Chunk ret = new Chunk(world, data, x, z);
    Biome[] biomes = world.getBiomeProvider().getBiomes(null, x * 16, z * 16, 16, 16);
    byte[] ids = ret.getBiomeArray();

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

    ret.generateSkylightMap();
    return ret;
}
 
Example #14
Source File: WorldProviderEndVoid.java    From YUNoMakeGoodMap with Apache License 2.0 6 votes vote down vote up
@Override public Chunk generateChunk(int x, int z)
{
    ChunkPrimer primer = new ChunkPrimer();

    if (YUNoMakeGoodMap.instance.shouldGenerateEndCities(this.world))
        this.endCityGen.generate(world, x, z, primer);
    else
        this.endCityGen.generate(world, x, z, null);

    Chunk ret = new Chunk(world, primer, x, z);
    Biome[] biomes = world.getBiomeProvider().getBiomes(null, x * 16, z * 16, 16, 16);
    byte[] ids = ret.getBiomeArray();

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

    ret.generateSkylightMap();
    return ret;
}
 
Example #15
Source File: WorldGenSwampTree.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
private IBlockState getBlock(BlockPos pos, Block 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.AIR.getDefaultState();
	
	return blocks.getBlockState(x, y, z);
}
 
Example #16
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 #17
Source File: MapGenLargeCrystal.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
private int getHeightValue(int x, int z, ChunkPrimer blocks) {
	int y;
	if(x > 15 || x < 0 || z > 15 || z < 0)
		return 0;
	for(y = 255; blocks.getBlockState(x, y, z).getBlock() == Blocks.AIR && y > 0; y--)
	{
		//System.out.println(y);
	}
	return y;
}
 
Example #18
Source File: ChunkProviderPlanet.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void replaceBiomeBlocks(int x, int z, ChunkPrimer primer, Biome[] biomesIn)
{
	if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, x, z, primer, this.worldObj)) return;
	double d0 = 0.03125D;
	this.depthBuffer = this.surfaceNoise.getRegion(this.depthBuffer, (double)(x * 16), (double)(z * 16), 16, 16, 0.0625D, 0.0625D, 1.0D);

	for (int i = 0; i < 16; ++i)
	{
		for (int j = 0; j < 16; ++j)
		{
			Biome biome = biomesIn[j + i * 16];
			biome.genTerrainBlocks(this.worldObj, this.rand, primer, x * 16 + i, z * 16 + j, this.depthBuffer[j + i * 16]);
		}
	}
}
 
Example #19
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 #20
Source File: MapGenHighCaves.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * Recursively called by generate()
 */
protected void recursiveGenerate(World worldIn, int chunkX, int chunkZ, int originalX, int originalZ, ChunkPrimer chunkPrimerIn)
{
    int i = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(15) + 1) + 1);

    if (this.rand.nextInt(7) != 0)
    {
        i = 0;
    }

    for (int j = 0; j < i; ++j)
    {
        double d0 = (double)(chunkX * 16 + this.rand.nextInt(16));
        double d1 = (double)this.rand.nextInt(this.rand.nextInt(64) + 8) + 90;
        double d2 = (double)(chunkZ * 16 + this.rand.nextInt(16));
        int k = 1;

        if (this.rand.nextInt(4) == 0)
        {
            this.addRoom(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2);
            k += this.rand.nextInt(4);
        }

        for (int l = 0; l < k; ++l)
        {
            float f = this.rand.nextFloat() * ((float)Math.PI * 2F);
            float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
            float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat();

            if (this.rand.nextInt(10) == 0)
            {
                f2 *= this.rand.nextFloat() * this.rand.nextFloat() * 3.0F + 1.0F;
            }

            this.addTunnel(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 1.0D);
        }
    }
}
 
Example #21
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
protected void placeOreLayers(ChunkPrimer chunkprimer)
{
	Point p;
	BlockPos pos = new BlockPos(0,0,0);
	BlockPos pos2;
	double wSq = 4;
	IBlockState state;

	for(Center c : centersInChunk)
	{
		OreAttribute attrib = ((OreAttribute)c.getAttribute(Attribute.Ore));
		if(attrib != null)
		{
			for(OreAttrNode n : attrib.nodes)
			{
				OreConfig oc = OreRegistry.getInstance().getConfig(n.getOreType(), islandMap.getParams().getSurfaceRock());
				if(oc.getVeinType() != VeinType.Layer)
					continue;

				for(int x = 0; x < 16; x++)
				{
					for(int z = 0; z < 16; z++)
					{
						for(int y = n.getOffset().getY(); y < n.getOffset().getY() + n.getNodeHeight(); y++)
						{
							p = new Point(x, z);
							pos2 = pos.add(x, y, z);
							state = getState(chunkprimer, pos2);
							if(this.getHex(p) == c && Core.isStone(state))
							{
								//Add air check
								this.setState(chunkprimer, pos2, oc.getOreBlockState());
							}
						}
					}
				}
			}
		}
	}
}
 
Example #22
Source File: ChunkProviderSurface.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void createDungeons(ChunkPrimer primer)
{
	Point p = new Point(islandChunkX, islandChunkZ).toIslandCoord();
	int iChunkX = ((int)p.x >> 4);
	int iChunkZ = ((int)p.y >> 4);
	//world chunk coord for the top left of this island
	int islandStartChunkX = (islandMap.getParams().getXCoord() << 8);
	int islandStartChunkZ = (islandMap.getParams().getZCoord() << 8);

	for(Dungeon d : islandMap.dungeons)
	{
		int cX = iChunkX;
		int cZ = iChunkZ;

		DungeonChunk dc = d.getChunk(cX, cZ);
		if(dc != null)
		{
			Iterator<DungeonRoom> iter = dc.getRoomMap().values().iterator();
			while(iter.hasNext())
			{
				DungeonRoom dr = iter.next();
				if(dr != null)
				{
					genRoom(primer, d, dr);
				}
			}
		}
	}
}
 
Example #23
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 #24
Source File: ChunkGeneratorFlatVoid.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@Override public Chunk generateChunk(int x, int z)
{
    Chunk ret = new Chunk(world, new ChunkPrimer(), x, z);
    Biome[] biomes = world.getBiomeProvider().getBiomes(null, x * 16, z * 16, 16, 16);
    byte[] ids = ret.getBiomeArray();

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

    ret.generateSkylightMap();
    return ret;
}
 
Example #25
Source File: ChunkProviderPaths.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void generateTerrain(ChunkPrimer primer)
{
	for (int x = 0; x < 16; x++)
	{
		for (int z = 0; z < 16; z++)
		{
			//primer.setBlockState(x, 0, z, TFCBlocks.StoneSmooth.getDefaultState().withProperty(BlockStoneSmooth.META_PROPERTY, StoneType.Marble));
		}
	}
}
 
Example #26
Source File: ChunkProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public void replaceBiomeBlocks(int x, int z, ChunkPrimer primer, Biome[] biomesIn) {
    if (!ForgeEventFactory.onReplaceBiomeBlocks(this, x, z, primer, this.world)) return;

    this.depthBuffer = this.surfaceNoise.getRegion(this.depthBuffer, (double) (x * 16), (double) (z * 16), 16, 16, 0.0625D, 0.0625D, 1.0D);

    for (int i = 0; i < 16; ++i) {
        for (int j = 0; j < 16; ++j) {
            Biome biome = biomesIn[j + i * 16];
            biome.genTerrainBlocks(this.world, this.rand, primer, x * 16 + i, z * 16 + j, this.depthBuffer[j + i * 16]);
        }
    }
}
 
Example #27
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 #28
Source File: BiomeGenCrystal.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) {
	super.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
	
	if(x % 16 == 0 && z % 16 == 0 )
		crystalGenBase.generate(worldIn, x >> 4, z >> 4, chunkPrimerIn);
}
 
Example #29
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 #30
Source File: BiomeGenOceanSpires.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) {
	// TODO Auto-generated method stub
	super.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
	
	if(x % 16 == 0 && z % 16 == 0 )
		oceanSpire.generate(worldIn, x/16, z/16, chunkPrimerIn);
}