Advertisement
Guest User

BushGeneration

a guest
Feb 27th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. package com.chef.mod.generate;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.util.BlockPos;
  7. import net.minecraft.world.World;
  8. import net.minecraft.world.biome.BiomeGenBase;
  9. import net.minecraft.world.biome.BiomeGenForest;
  10. import net.minecraft.world.biome.BiomeGenPlains;
  11. import net.minecraft.world.biome.BiomeGenTaiga;
  12. import net.minecraft.world.chunk.IChunkProvider;
  13. import net.minecraftforge.fml.common.IWorldGenerator;
  14.  
  15. import com.chef.mod.generate.features.WorldGenBush;
  16. import com.chef.mod.generate.features.WorldGenCorn;
  17. import com.chef.mod.init.MyBlocks;
  18.  
  19. public class BushGeneration implements IWorldGenerator {
  20.  
  21.  
  22. @Override
  23. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  24. switch(world.provider.getDimensionId())
  25. {
  26. case 1:
  27. generateEnd(world, random, chunkX*16, chunkZ*16);
  28. break;
  29. case 0:
  30. generateOverworld(world, random, chunkX*16, chunkZ*16);
  31. break;
  32. case -1:
  33. generateNether(world, random, chunkX*16, chunkZ*16);
  34. break;
  35. }
  36. }
  37.  
  38. public void generateEnd(World world, Random rand, int x, int z) {
  39.  
  40. }
  41.  
  42. public void generateOverworld(World world, Random random, int x, int z) {
  43.  
  44.  
  45.  
  46. //this.addOreSpawn(MyBlocks.blockWathever, world, random, x, z, maxX, maxZ, chanceToSpawn, minY, maxY);
  47.  
  48. this.addBushSpawn(MyBlocks.strawberry_bush, world, random, x, z, 16, 16, 3, 50, 100);
  49.  
  50. this.addBushSpawn(MyBlocks.blueberry_bush, world, random, x, z, 16, 16, 3, 50, 100);
  51.  
  52. this.addBushSpawn(MyBlocks.bell_pepper_bush, world, random, x, z, 16, 16, 1, 50, 100);
  53.  
  54. this.addBushSpawn(MyBlocks.tomato_bush, world, random, x, z, 16, 16, 3, 50, 100);
  55.  
  56. this.addBushSpawn(MyBlocks.asparagus_bush, world, random, x, z, 16, 16, 2, 50, 100);
  57.  
  58. this.addBushSpawn(MyBlocks.onion_bush, world, random, x, z, 16, 16, 2, 50, 100);
  59.  
  60. }
  61.  
  62. public void generateNether(World world, Random rand, int x, int z) {
  63.  
  64. }
  65.  
  66. public void addBushSpawn(Block block, World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ, int chanceToSpawn, int minY, int maxY) {
  67.  
  68. for (int i = 0; i < chanceToSpawn; i++) {
  69. int posX = blockXpos + random.nextInt(maxX);
  70. int posY = minY + random.nextInt(maxY - minY);
  71. int posZ = blockZpos + random.nextInt(maxZ);
  72.  
  73. BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(posX, posY, posZ));
  74.  
  75. if (block == MyBlocks.strawberry_bush || block == MyBlocks.blueberry_bush && biome instanceof BiomeGenForest || biome instanceof BiomeGenTaiga) {
  76.  
  77. (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
  78. }
  79.  
  80. if (block == MyBlocks.bell_pepper_bush || block == MyBlocks.tomato_bush && biome instanceof BiomeGenForest || biome instanceof BiomeGenTaiga) {
  81.  
  82. (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
  83. }
  84.  
  85. if (block == MyBlocks.asparagus_bush && biome == BiomeGenBase.roofedForest) {
  86.  
  87. (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
  88. }
  89.  
  90. if (block == MyBlocks.onion_bush && biome == BiomeGenBase.birchForest || biome == BiomeGenBase.birchForestHills) {
  91.  
  92. (new WorldGenBush(block)).generate(world, random, (new BlockPos(posX, posY, posZ)));
  93.  
  94. }
  95. }
  96. }
  97.  
  98. public void addCornSpawn(World world, Random random, int blockXpos, int blockZpos, int maxX, int maxZ, int chanceToSpawn, int minY, int maxY) {
  99.  
  100. for (int i = 0; i < chanceToSpawn; i++) {
  101. int posX = blockXpos + random.nextInt(maxX);
  102. int posY = minY + random.nextInt(maxY - minY);
  103. int posZ = blockZpos + random.nextInt(maxZ);
  104.  
  105. BiomeGenBase biome = world.getBiomeGenForCoords(new BlockPos(posX, posY, posZ));
  106.  
  107. if (biome instanceof BiomeGenPlains) {
  108.  
  109. (new WorldGenCorn()).generate(world, random, (new BlockPos(posX, posY, posZ)));
  110. }
  111. }
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement