Advertisement
Guest User

OreGeneration

a guest
Dec 3rd, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package com.smith.mod.generate;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.smith.mod.Smithing;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.init.Blocks;
  9. import net.minecraft.world.World;
  10. import net.minecraft.world.chunk.IChunkProvider;
  11. import net.minecraft.world.gen.feature.WorldGenMinable;
  12. import cpw.mods.fml.common.IWorldGenerator;
  13.  
  14. public class OreGeneration implements IWorldGenerator {
  15.  
  16. @Override
  17. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
  18. switch(world.provider.dimensionId)
  19. {
  20. case 1:
  21. generateEnd(world, random, chunkX, chunkZ);
  22. break;
  23. case 0:
  24. generateOverworld(world, random, chunkX, chunkZ);
  25. break;
  26. case -1:
  27. generateNether(world, random, chunkX, chunkZ);
  28. break;
  29. }
  30. }
  31.  
  32. public void generateEnd(World world, Random rand, int x, int z) {
  33.  
  34. }
  35.  
  36. public void generateOverworld(World world, Random rand, int x, int z) {
  37. //world, rand, x, z, Minimal blocks to spawn, Maximal blocks to spawn, Chance to spawn, Minimal height to spawn, Maximal height to spawn, Block to spawn in
  38. generateOre(Smithing.oreCopperOre, world, rand, x, z, 2, 7, 22, 5, 30, Blocks.stone);
  39. generateOre(Smithing.oreTinOre, world, rand, x, z, 2, 7, 22, 5, 30, Blocks.stone);
  40. generateOre(Smithing.oreAluminiumOre, world, rand, x, z, 2, 7, 10, 20, 30, Blocks.stone);
  41. generateOre(Smithing.orePlatinumOre, world, rand, x, z, 2, 5, 10, 0, 20, Blocks.stone);
  42. generateOre(Smithing.oreAmazoniteOre, world, rand, x, z, 2, 3, 1, 0, 15, Blocks.stone);
  43. generateOre(Smithing.oreMagnesiumOre, world, rand, x, z, 2, 5, 10, 0, 20, Blocks.stone);
  44. }
  45.  
  46. public void generateNether(World world, Random rand, int x, int z) {
  47.  
  48. }
  49.  
  50. public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize, int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
  51. int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
  52. int heightRange = maxY - minY;
  53. WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
  54. for (int i = 0; i < chance; i++) {
  55. int xRand = chunkX * 16 + random.nextInt(16);
  56. int yRand = random.nextInt(heightRange) + minY;
  57. int zRand = chunkZ * 16 + random.nextInt(16);
  58. gen.generate(world, random, xRand, yRand, zRand);
  59. }
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement