91 |
platform(player,loc,args); |
platform(player,loc,args); |
92 |
return true; |
return true; |
93 |
} |
} |
94 |
|
|
95 |
|
if (label.equals("cylinder") ) { |
96 |
|
if (validateLevelOrFill(player, label, args) ) { |
97 |
|
cylinder(player,loc,args); |
98 |
|
} |
99 |
|
return true; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
return false; |
return false; |
353 |
|
|
354 |
} |
} |
355 |
} |
} |
356 |
|
|
357 |
|
|
358 |
|
private void resetMap(boolean[][] map) { |
359 |
|
for (int x=0; x<map.length; x++) { |
360 |
|
for (int z=0; z<map[0].length; z++) { |
361 |
|
map[x][z] = false; |
362 |
|
} |
363 |
|
} |
364 |
|
} |
365 |
|
|
366 |
|
private void cylinder(Player player, Location loc, String[] split) { |
367 |
|
if (split.length != 2) { |
368 |
|
player.sendMessage("Usage: /cylinder [radius] [material] "); |
369 |
|
return; |
370 |
|
} |
371 |
|
int material = Integer.parseInt( split[1] ); |
372 |
|
|
373 |
|
int radius = Integer.parseInt(split[0]); |
374 |
|
int diameter = (radius*2) + 1; |
375 |
|
|
376 |
|
boolean map[][] = new boolean[diameter][diameter]; |
377 |
|
resetMap( map ); |
378 |
|
|
379 |
|
/* map[0][0] = true; |
380 |
|
map[0][diameter-1] = true; |
381 |
|
map[diameter-1][0] = true; |
382 |
|
map[diameter-1][diameter-1] = true;*/ |
383 |
|
|
384 |
|
for (int r=0; r<360; r++) { |
385 |
|
double rad = Math.toRadians( r ); |
386 |
|
|
387 |
|
double a = (double) radius * Math.sin( rad); |
388 |
|
double b = (double) radius * Math.cos( rad); |
389 |
|
|
390 |
|
int x = radius + (int)Math.round(a); |
391 |
|
int y = radius + (int)Math.round(b); |
392 |
|
|
393 |
|
map[x][y] = true; |
394 |
|
} |
395 |
|
|
396 |
|
|
397 |
|
drawMap( loc, map, material ); |
398 |
|
} |
399 |
|
|
400 |
|
private void drawMap(Location loc, boolean[][] map, int material) { |
401 |
|
int playerX = loc.getBlockX(); |
402 |
|
int playerY = loc.getBlockY(); |
403 |
|
int playerZ = loc.getBlockZ(); |
404 |
|
|
405 |
|
World world = loc.getWorld(); |
406 |
|
|
407 |
|
for (int i=0; i<map.length; i++) { |
408 |
|
for (int j=0; j<map[0].length; j++) { |
409 |
|
|
410 |
|
int x = playerX + i + 1; |
411 |
|
int z = playerZ + j; |
412 |
|
|
413 |
|
if (map[i][j] == true) { |
414 |
|
for (int y=world.getHighestBlockYAt(x, z); y<playerY; y++) { |
415 |
|
world.getBlockAt(x, y, z).setTypeId(material); |
416 |
|
} |
417 |
|
} |
418 |
|
|
419 |
|
} |
420 |
|
} |
421 |
|
} |
422 |
|
|
423 |
|
|
424 |
|
|
425 |
} |
} |