use of net.minecraft.world.gen.feature.WorldGenTallGrass in project Galacticraft by micdoodle8.
the class ChunkProviderAsteroids method populate.
@Override
public void populate(IChunkProvider par1IChunkProvider, int chunkX, int chunkZ) {
int x = chunkX << 4;
int z = chunkZ << 4;
if (!ChunkProviderAsteroids.chunksDone.add(new BlockVec3(x, 0, z))) {
return;
}
BlockFalling.fallInstantly = true;
this.worldObj.getBiomeGenForCoords(new BlockPos(x + 16, 0, z + 16));
BlockFalling.fallInstantly = false;
this.rand.setSeed(this.worldObj.getSeed());
long var7 = this.rand.nextLong() / 2L * 2L + 1L;
long var9 = this.rand.nextLong() / 2L * 2L + 1L;
this.rand.setSeed(chunkX * var7 + chunkZ * var9 ^ this.worldObj.getSeed());
// 50:50 chance to include small blocks each chunk
if (this.rand.nextBoolean()) {
double density = this.asteroidDensity.getNoise(chunkX * 16, chunkZ * 16) * 0.54;
double numOfBlocks = this.clamp(this.randFromPoint(chunkX, chunkZ), .4, 1) * ChunkProviderAsteroids.MAX_BLOCKS_PER_CHUNK * density + ChunkProviderAsteroids.MIN_BLOCKS_PER_CHUNK;
int y0 = this.rand.nextInt(2);
Block block;
int meta;
int yRange = ChunkProviderAsteroids.MAX_ASTEROID_Y - ChunkProviderAsteroids.MIN_ASTEROID_Y;
x += 4;
z += 4;
for (int i = 0; i < numOfBlocks; i++) {
int y = this.rand.nextInt(yRange) + ChunkProviderAsteroids.MIN_ASTEROID_Y;
// 50:50 chance vertically as well
if (y0 == (y / 16) % 2) {
int px = x + this.rand.nextInt(ChunkProviderAsteroids.CHUNK_SIZE_X);
int pz = z + this.rand.nextInt(ChunkProviderAsteroids.CHUNK_SIZE_Z);
block = this.ASTEROID_STONE;
meta = this.ASTEROID_STONE_META_1;
if (this.rand.nextInt(ILMENITE_CHANCE) == 0) {
meta = 4;
if (ConfigManagerAsteroids.disableIlmeniteGen) {
continue;
}
} else if (this.rand.nextInt(IRON_CHANCE) == 0) {
meta = 5;
if (ConfigManagerAsteroids.disableIronGen) {
continue;
}
} else if (this.rand.nextInt(ALUMINUM_CHANCE) == 0) {
meta = 3;
if (ConfigManagerAsteroids.disableAluminumGen) {
continue;
}
}
worldObj.setBlockState(new BlockPos(px, y, pz), block.getStateFromMeta(meta), 2);
int count = 9;
if (!(worldObj.getBlockState(new BlockPos(px - 1, y, pz)).getBlock() instanceof BlockAir)) {
count = 1;
} else if (!(worldObj.getBlockState(new BlockPos(px - 2, y, pz)).getBlock() instanceof BlockAir)) {
count = 3;
} else if (!(worldObj.getBlockState(new BlockPos(px - 3, y, pz)).getBlock() instanceof BlockAir)) {
count = 5;
} else if (!(worldObj.getBlockState(new BlockPos(px - 4, y, pz)).getBlock() instanceof BlockAir)) {
count = 7;
}
// LIGHTEMP worldObj.setLightFor(EnumSkyBlock.BLOCK, new BlockPos(px - (count > 1 ? 1 : 0), y, pz), count);
}
}
}
if (this.largeAsteroidsLastChunkX != chunkX || this.largeAsteroidsLastChunkZ != chunkZ) {
this.generateTerrain(chunkX, chunkZ, null, true);
}
this.rand.setSeed(chunkX * var7 + chunkZ * var9 ^ this.worldObj.getSeed());
// Look for hollow asteroids to populate
if (!this.largeAsteroids.isEmpty()) {
for (AsteroidData asteroidIndex : new ArrayList<AsteroidData>(this.largeAsteroids)) {
if (!asteroidIndex.isHollow) {
continue;
}
float[] sizeYArray = asteroidIndex.sizeYArray;
int xMin = asteroidIndex.xMinArray;
int zMin = asteroidIndex.zMinArray;
int zSize = asteroidIndex.zSizeArray;
int asteroidY = asteroidIndex.asteroidYArray;
int asteroidSize = asteroidIndex.asteroidSizeArray;
boolean treesdone = false;
if (ConfigManagerCore.challengeAsteroidPopulation || rand.nextInt(ChunkProviderAsteroids.TREE_CHANCE) == 0) {
int treeType = rand.nextInt(3);
if (treeType == 1) {
treeType = 0;
}
IBlockState log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK);
IBlockState leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
WorldGenTrees wg = new WorldGenTrees(false, 2, log, leaves, false);
for (int tries = 0; tries < 5; tries++) {
int i = rand.nextInt(16) + x + 8;
int k = rand.nextInt(16) + z + 8;
if (wg.generate(worldObj, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k))) {
break;
}
}
treesdone = true;
}
if (!treesdone || rand.nextInt(ChunkProviderAsteroids.TALL_GRASS_CHANCE) == 0) {
int i = rand.nextInt(16) + x + 8;
int k = rand.nextInt(16) + z + 8;
new WorldGenTallGrass(GRASS_TYPE).generate(worldObj, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k));
}
if (rand.nextInt(ChunkProviderAsteroids.FLOWER_CHANCE) == 0) {
int i = rand.nextInt(16) + x + 8;
int k = rand.nextInt(16) + z + 8;
int[] types = new int[] { 2, 4, 5, 7 };
new WorldGenFlowers(this.FLOWER, EnumFlowerType.getType(BlockFlower.EnumFlowerColor.RED, types[rand.nextInt(types.length)])).generate(worldObj, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k));
}
if (rand.nextInt(ChunkProviderAsteroids.LAVA_CHANCE) == 0) {
int i = rand.nextInt(16) + x + 8;
int k = rand.nextInt(16) + z + 8;
new WorldGenLakes(this.LAVA).generate(worldObj, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k));
}
if (rand.nextInt(ChunkProviderAsteroids.WATER_CHANCE) == 0) {
int i = rand.nextInt(16) + x + 8;
int k = rand.nextInt(16) + z + 8;
new WorldGenLakes(this.WATER).generate(worldObj, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k));
}
}
}
// Update all block lighting
for (int xx = 0; xx < 16; xx++) {
int xPos = x + xx;
for (int zz = 0; zz < 16; zz++) {
int zPos = z + zz;
// Asteroid at min height 48, size 20, can't have lit blocks below 16
for (int y = 16; y < 240; y++) {
// LIGHTTEMP worldObj.checkLightFor(EnumSkyBlock.BLOCK, new BlockPos(xPos, y, zPos));
}
}
}
this.dungeonGenerator.generateStructure(this.worldObj, this.rand, new ChunkCoordIntPair(chunkX, chunkZ));
}
use of net.minecraft.world.gen.feature.WorldGenTallGrass in project SpongeCommon by SpongePowered.
the class ShrubBuilder method build.
@Override
public Shrub build() throws IllegalStateException {
Shrub pop = (Shrub) new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS);
pop.getTypes().clear();
pop.getTypes().addAll(this.types);
pop.setShrubsPerChunk(this.count);
pop.setSupplierOverride(this.override);
return pop;
}
Aggregations