Advertisement
Guest User

Untitled

a guest
May 8th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. package degubi.teamcraft.infs.worldgen;
  2.  
  3. import java.util.Random;
  4. import net.minecraft.block.Block;
  5. import net.minecraft.init.Blocks;
  6. import net.minecraft.world.World;
  7. import net.minecraft.world.biome.BiomeGenBase;
  8. import net.minecraft.world.chunk.IChunkProvider;
  9. import net.minecraft.world.gen.feature.WorldGenMinable;
  10. import cpw.mods.fml.common.IWorldGenerator;
  11. import degubi.teamcraft.TeamCraft;
  12.  
  13. public class OreGen implements IWorldGenerator {
  14.  
  15. @Override
  16. public void generate(Random random, int chunkX, int chunkZ, World world,
  17. IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  18. switch(world.provider.dimensionId){
  19. case -1: generateNether(world, random, chunkX * 16, chunkZ * 16);
  20. case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16);
  21. case 1: generateEnd(world, random, chunkX * 16, chunkZ * 16);
  22. }
  23. }
  24. private void generateEnd(World world, Random random, int x, int z) {
  25. }
  26. private void generateNether(World world, Random random, int x, int z) {
  27. }
  28. private void generateSurface(World world, Random random, int x, int z) {
  29. this.addOreSpawn(TeamCraft.MarbleStone, world, random, x, z, 16, 16, 4+random.nextInt(10), 1, 40, 70);
  30. this.addOreSpawn(TeamCraft.Granite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
  31. this.addOreSpawn(TeamCraft.Diorite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
  32. this.addOreSpawn(TeamCraft.Andesite, world, random, x, z, 16, 16, 5+random.nextInt(8), 2, 20, 100);
  33. this.addOreSpawn1(Blocks.sponge, world, random, x, z, 16, 16, 3+random.nextInt(7), 10, 40, 100);
  34.  
  35.  
  36.  
  37. BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x + 16, z + 16);
  38. if(biome == BiomeGenBase.extremeHills || biome == BiomeGenBase.extremeHillsEdge || biome == BiomeGenBase.extremeHillsPlus){
  39. this.addOreSpawn(Blocks.emerald_ore, world, random, x, z, 16, 16, 2+random.nextInt(4), 30, 20, 50);
  40. }
  41.  
  42. }
  43. public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
  44. {
  45. int maxPossY = minY + (maxY - 1);
  46. assert maxY > minY: "The maximum Y must be greater than the Minimum Y";
  47. assert maxX > 0 && maxX <= 16: "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
  48. assert minY > 0: "addOreSpawn: The Minimum Y must be greater than 0";
  49. assert maxY < 256 && maxY > 0: "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
  50. assert maxZ > 0 && maxZ <= 16: "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";
  51.  
  52. int diffBtwnMinMaxY = maxY - minY;
  53. for(int x = 0; x < chancesToSpawn; x++)
  54. {
  55. int posX = blockXPos + random.nextInt(maxX);
  56. int posY = minY + random.nextInt(diffBtwnMinMaxY);
  57. int posZ = blockZPos + random.nextInt(maxZ);
  58. (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
  59. }
  60. }
  61. public void addOreSpawn1(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
  62. {
  63. int maxPossY = minY + (maxY - 1);
  64. assert maxY > minY: "The maximum Y must be greater than the Minimum Y";
  65. assert maxX > 0 && maxX <= 16: "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
  66. assert minY > 0: "addOreSpawn: The Minimum Y must be greater than 0";
  67. assert maxY < 256 && maxY > 0: "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
  68. assert maxZ > 0 && maxZ <= 16: "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";
  69.  
  70. int diffBtwnMinMaxY = maxY - minY;
  71. for(int x = 0; x < chancesToSpawn; x++)
  72. {
  73. int posX = blockXPos + random.nextInt(maxX);
  74. int posY = minY + random.nextInt(diffBtwnMinMaxY);
  75. int posZ = blockZPos + random.nextInt(maxZ);
  76. (new WorldGenSponge(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
  77. }
  78.  
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement