looping blocks isnt working

Discussion in 'Plugin Development' started by naorpeled, Apr 16, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    naorpeled

    Code:Java
    1.  
    2. Location temp;
    3. for (z = 0; z < 16; ++z) {
    4. for (y = 0; y < 15; ++y) {
    5. temp = new Location(p.getWorld(), loc.getX() + 15.0D, loc.getY() + y, loc.getZ() + z);
    6. b = temp.getBlock();
    7. b.setType(Material.GLASS);
    8. }
    9. }
    10.  
     
  2. Offline

    MrSnare

    What are you trying to do?
     
  3. Offline

    naorpeled

    I`m trying to make a box( I`m using more for loops obviously.)
     
  4. Offline

    XvBaseballkidvX

    This is how I made my 'Ice Box' (It is also hollowed out as well):

    Code:java
    1. final ArrayList<Block> blocks_to_remove = new ArrayList<Block>();
    2. int Xmin, Ymin, Zmin;
    3. int Xmax, Ymax, Zmax;
    4. Location loc = player.getLocation();
    5. Xmin = loc.getBlockX() - 2;
    6. Ymin = loc.getBlockY() - 1;
    7. Zmin = loc.getBlockZ() - 2;
    8.  
    9. Xmax = Xmin + 5;
    10. Ymax = Ymin + 5;
    11. Zmax = Zmin + 5;
    12.  
    13.  
    14. for (int x = Xmin; x < Xmax; x++) {
    15. for (int y = Ymin; y < Ymax; y++) {
    16. for (int z = Zmin; z < Zmax; z++) {
    17. Block block = player.getWorld().getBlockAt(x, y, z);
    18. if (block.getType() == Material.AIR) {
    19. block.setType(Material.ICE);
    20. block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType().getId());
    21. blocks_to_remove.add(block);
    22. }
    23. }
    24. }
    25. }
    26. final Player clone = player;
    27. new BukkitRunnable() {
    28. public void run() {
    29. int Xmin, Ymin, Zmin;
    30. int Xmax, Ymax, Zmax;
    31. Location loc = clone.getLocation();
    32. Xmin = loc.getBlockX() - 1;
    33. Ymin = loc.getBlockY();
    34. Zmin = loc.getBlockZ() - 1;
    35.  
    36. Xmax = Xmin + 3;
    37. Ymax = Ymin + 3;
    38. Zmax = Zmin + 3;
    39.  
    40. //Hollowing the ice box out
    41. for (int x = Xmin; x < Xmax; x++) {
    42. for (int y = Ymin; y < Ymax; y++) {
    43. for (int z = Zmin; z < Zmax; z++) {
    44. Block block = clone.getWorld().getBlockAt(x, y, z);
    45. if (block.getType() == Material.ICE) {
    46. block.setType(Material.AIR);
    47. }
    48. }
    49. }
    50. }
    51. }
    52. }.runTaskLater(Main.getInstance(), 2);
     
  5. Offline

    naorpeled


    Well I`m trying to make a kit called "Gladiator" like mcpvp.com`s and I have all the events working but the only thing is that it doesnt generate the box.
    Code:Java
    1.  
    2.  
    3. for (int x = 0; x < 15; ++x) {
    4. for (z = 0; z < 15; ++z) {
    5. temp = new Location(p.getWorld(), loc.getX() + x, loc.getY(), loc.getZ() + z);
    6. b = temp.getBlock();
    7. b.setType(Material.GLASS);
    8. }
    9.  
    10. }
    11.  
    12. for (int x = 0; x < 16; ++x) {
    13. for (z = 0; z < 16; ++z) {
    14. temp = new Location(p.getWorld(), loc.getX() + x, loc.getY() + 15.0D, loc.getZ() + z);
    15. b = temp.getBlock();
    16. b.setType(Material.GLASS);
    17. }
    18.  
    19. }
    20.  
    21. for (int x = 0; x < 15; ++x) {
    22. for (y = 0; y < 15; ++y) {
    23. temp = new Location(p.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ());
    24. b = temp.getBlock();
    25. b.setType(Material.GLASS);
    26. }
    27. }
    28. for (int x = 0; x < 15; ++x) {
    29. for (y = 0; y < 15; ++y) {
    30. temp = new Location(p.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ() + 15.0D);
    31. b = temp.getBlock();
    32. b.setType(Material.GLASS);
    33. }
    34. }
    35.  
    36. for (z = 0; z < 15; ++z) {
    37. for (y = 0; y < 15; ++y) {
    38. temp = new Location(p.getWorld(), loc.getX(), loc.getY() + y, loc.getZ() + z);
    39. b = temp.getBlock();
    40. b.setType(Material.GLASS);
    41. }
    42. }
    43. for (z = 0; z < 16; ++z) {
    44. for (y = 0; y < 15; ++y) {
    45. temp = new Location(p.getWorld(), loc.getX() + 15.0D, loc.getY() + y, loc.getZ() + z);
    46. b = temp.getBlock();
    47. b.setType(Material.GLASS);
    48. }
    49. }
    50.  
     
  6. Offline

    coasterman10

    Does anything get generated at all, or is it simply not building any blocks whatsoever?
     
  7. Offline

    naorpeled


    Doesn`t generate any blocks.
     
  8. Offline

    coasterman10

    Try adding a couple of debug messages to see what coordinates the blocks are being built at, and then teleport near there to see what was built.

    If nothing is being built, you may want to check your loop logic.
     
  9. Offline

    naorpeled

    I did add debug messages
     
  10. Offline

    XvBaseballkidvX

    Well I am not familiar with the Gladiator Kit on mcpvp.com
    I am sure that the code that I provided will generate a hollow box made of ice.
     
  11. Offline

    naorpeled

    here`s a video:
     
Thread Status:
Not open for further replies.

Share This Page