Vinetos

Cylinder like worldEdit

Dec 29th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. public void cylinder(Location loc, Material mat, int r) {
  2.         int cx = loc.getBlockX();
  3.         int cy = loc.getBlockY();
  4.         int cz = loc.getBlockZ();
  5.         World w = loc.getWorld();
  6.         int rSquared = r * r;
  7.  
  8.         for (int x = cx - r; x <= cx +r; x++) {
  9.                 for (int z = cz - r; z <= cz +r; z++) {
  10.                         if ((cx - x) * (cx -x) + (cz - z) * (cz - z) <= rSquared) {
  11.                                 Block b = new  Location(World, x, cy, z).getBlock();
  12.                                 b.setType(mat);
  13.                         }
  14.                 }
  15.         }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment