Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chef.mod.generate;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.util.BlockPos;
- import net.minecraft.world.World;
- import net.minecraft.world.biome.BiomeGenBase;
- import net.minecraft.world.biome.BiomeGenForest;
- import net.minecraft.world.biome.BiomeGenPlains;
- import net.minecraft.world.biome.BiomeGenTaiga;
- import net.minecraft.world.chunk.IChunkProvider;
- import net.minecraftforge.fml.common.IWorldGenerator;
- import com.chef.mod.generate.features.WorldGenBush;
- import com.chef.mod.generate.features.WorldGenCorn;
- import com.chef.mod.init.MyBlocks;
- public class BushGeneration implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
- switch(world.provider.getDimensionId())
- {
- case 1:
- generateEnd(world, random, chunkX*16, chunkZ*16);
- break;
- case 0:
- generateOverworld(world, random, chunkX*16, chunkZ*16);
- break;
- case -1:
- generateNether(world, random, chunkX*16, chunkZ*16);
- break;
- }
- }
- public void generateEnd(World world, Random rand, int x, int z) {
- }
- public void generateOverworld(World world, Random random, int x, int z) {
- //this.addOreSpawn(MyBlocks.blockWathever, world, random, x, z, maxX, maxZ, chanceToSpawn, minY, maxY);
- this.addBushSpawn(MyBlocks.strawberry_bush, world, random, x, z, 16, 16, 3, 50, 100);
- this.addBushSpawn(MyBlocks.blueberry_bush, world, random, x, z, 16, 16, 3, 50, 100);
- this.addBushSpawn(MyBlocks.bell_pepper_bush, world, random, x, z, 16, 16, 1, 50, 100);
- this.addBushSpawn(MyBlocks.tomato_bush, world, random, x, z, 16, 16, 3, 50, 100);
- this.addBushSpawn(MyBlocks.asparagus_bush, world, random, x, z, 16, 16, 2, 50, 100);
- this.addBushSpawn(MyBlocks.onion_bush, world, random, x, z, 16, 16, 2, 50, 100);
- }
- public void generateNether(World world, Random rand, int x, int z) {
- }
- public void addBushSpawn(Block block, World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ, int chanceToSpawn, int minY, int maxY) {
- for (int i = 0; i < chanceToSpawn; i++) {
- int posX = blockXpos + random.nextInt(maxX);
- int posY = minY + random.nextInt(maxY - minY);
- int posZ = blockZpos + random.nextInt(maxZ);
- BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(posX, posY, posZ));
- if (block == MyBlocks.strawberry_bush || block == MyBlocks.blueberry_bush && biome instanceof BiomeGenForest || biome instanceof BiomeGenTaiga) {
- (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
- }
- if (block == MyBlocks.bell_pepper_bush || block == MyBlocks.tomato_bush && biome instanceof BiomeGenForest || biome instanceof BiomeGenTaiga) {
- (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
- }
- if (block == MyBlocks.asparagus_bush && biome == BiomeGenBase.roofedForest) {
- (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
- }
- if (block == MyBlocks.onion_bush && biome == BiomeGenBase.birchForest || biome == BiomeGenBase.birchForestHills) {
- (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
- }
- }
- }
- public void addCornSpawn(World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ, int chanceToSpawn, int minY, int maxY) {
- for (int i = 0; i < chanceToSpawn; i++) {
- int posX = blockXpos + random.nextInt(maxX);
- int posY = minY + random.nextInt(maxY - minY);
- int posZ = blockZpos + random.nextInt(maxZ);
- BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(posX, posY, posZ));
- if (biome instanceof BiomeGenPlains) {
- (new WorldGenCorn()).generate(world, random, (new BlockPos(posX, posY, posZ)));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement