Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<Location> generateSphere(Location centerBlock,
- int radius, boolean hollow) {
- List<Location> centerBlocks = new ArrayList<Location>();
- radius = 15;
- int bX = centerBlock.getBlockX();
- int bY = centerBlock.getBlockY();
- int bZ = centerBlock.getBlockZ();
- for (int x = bX - radius; x <= bX + radius; x++) {
- for (int y = bY - radius; y <= bY + radius; y++) {
- for (int z = bZ - radius; z <= bZ + radius; z++) {
- double distance = ((bX - x) * (bX - x))
- + ((bZ - z) * (bZ - z) + ((bY - y)) * (bY - y));
- if (distance < radius * radius
- && !(hollow && distance < ((radius - 1) * (radius - 1)))) {
- for (Location l : generateSphere(centerBlock, radius,
- hollow)) {
- Material type = meteorBlocks.get((int) (Math
- .random() * meteorBlocks.size()));
- l.getBlock().setType(type);
- centerBlocks.add(l);
- }
- }
- }
- }
- }
- return centerBlocks;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement