Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. package me.jamgallant.ExtremeWorld;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Chunk;
  6. import org.bukkit.Material;
  7. import org.bukkit.World;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.generator.BlockPopulator;
  10.  
  11. public class ExtremeOre
  12. extends BlockPopulator
  13. {
  14. int[][] values = {
  15. { 0, 0, 1 },
  16. { 1, 0, 1 },
  17. { 1 },
  18. { 0, 1 },
  19. { 0, 1, 1 },
  20. { 1, 1, 1 },
  21. { 1, 1 } };
  22.  
  23. public void populate(World world, Random rand, Chunk chunk)
  24. {
  25. for (int i = 0; i < 25; i++) {
  26. generateRandomOreChunks(chunk, rand, 128, Material.COAL_ORE, 10000);
  27. }
  28. for (int i = 0; i < 20; i++) {
  29. generateRandomOreChunks(chunk, rand, 64, Material.IRON_ORE, 5000);
  30. }
  31. for (int i = 0; i < 15; i++) {
  32. generateRandomOreChunks(chunk, rand, 23, Material.LAPIS_ORE, 2500);
  33. }
  34. for (int i = 0; i < 10; i++) {
  35. generateRandomOreChunks(chunk, rand, 128, Material.GOLD_ORE, 1250);
  36. }
  37. for (int i = 0; i < 6; i++) {
  38. generateRandomOreChunks(chunk, rand, 12, Material.REDSTONE_ORE, 1000);
  39. }
  40. for (int i = 0; i < 1; i++) {
  41. generateRandomOreChunks(chunk, rand, 12, Material.DIAMOND_ORE, 500);
  42. }
  43. for (int i = 0; i < 1; i++) {
  44. generateRandomOreChunks(chunk, rand, 32, Material.EMERALD_ORE, 0);
  45. }
  46. }
  47.  
  48. public void generateRandomOreChunks(Chunk chunk, Random rand, int maxHeight, Material material, int firstChance)
  49. {
  50. int x = rand.nextInt(14) + 1;
  51. int y = rand.nextInt(maxHeight - 2) + 1;
  52. int z = rand.nextInt(14) + 1;
  53. if (chunk.getBlock(x, y, z).getType() == Material.STONE) {
  54. chunk.getBlock(x, y, z).setType(material);
  55. }
  56. int randVal = rand.nextInt(5000);
  57. int chance = 2;
  58. setStoneToOre(material, chunk, x, y, z);
  59. for (int i = 0; i < 7; i++) {
  60. if (randVal < firstChance / chance)
  61. {
  62. setStoneToOre(material, chunk, x + this.values[i][0], y + this.values[i][1], z + this.values[i][2]);
  63. chance *= 2;
  64. }
  65. }
  66. }
  67.  
  68. public void setStoneToOre(Material material, Chunk chunk, int x, int y, int z)
  69. {
  70. Block block = chunk.getBlock(x, y - 1, z);
  71. if ((block.getType() == Material.STONE) || (block.getType() == Material.SANDSTONE) || (block.getType() == Material.ICE) || (block.getType() == Material.HARD_CLAY)) {
  72. block.setType(material);
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement