Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public static List<Location> generateSphere(Location centerBlock,
  2. int radius, boolean hollow) {
  3. List<Location> centerBlocks = new ArrayList<Location>();
  4.  
  5. radius = 15;
  6.  
  7. int bX = centerBlock.getBlockX();
  8. int bY = centerBlock.getBlockY();
  9. int bZ = centerBlock.getBlockZ();
  10. for (int x = bX - radius; x <= bX + radius; x++) {
  11. for (int y = bY - radius; y <= bY + radius; y++) {
  12. for (int z = bZ - radius; z <= bZ + radius; z++) {
  13.  
  14. double distance = ((bX - x) * (bX - x))
  15. + ((bZ - z) * (bZ - z) + ((bY - y)) * (bY - y));
  16.  
  17. if (distance < radius * radius
  18. && !(hollow && distance < ((radius - 1) * (radius - 1)))) {
  19.  
  20. for (Location l : generateSphere(centerBlock, radius,
  21. hollow)) {
  22. Material type = meteorBlocks.get((int) (Math
  23. .random() * meteorBlocks.size()));
  24. l.getBlock().setType(type);
  25.  
  26. centerBlocks.add(l);
  27.  
  28. }
  29. }
  30.  
  31. }
  32.  
  33. }
  34.  
  35. }
  36. return centerBlocks;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement