Solved Create a square

Discussion in 'Plugin Development' started by MaTaMoR_, Mar 12, 2015.

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

    MaTaMoR_

    Hi i'm trying to create a square, i got this code but when i run it the lag is just AMAZING! and it don't even changes the block xD .

    Code:java
    1.  
    2. public void setGround(Location center, Integer radius) {
    3. Location min = new Location(center.getWorld(), center.getX() - radius, center.getY() - 1, center.getZ() - radius);
    4. Location max = new Location(center.getWorld(), center.getX() + radius, center.getY() - 1, center.getZ() + radius);
    5. for (int x = (int) min.getX(); x < (int) max.getX(); x++) {
    6. for (int z = (int) min.getZ(); z < (int) max.getZ(); z++) {
    7. Location cord= new Location(center.getWorld(), x, center.getY(), z);
    8. Block block = cord.getBlock();
    9. block.setType(Material.BEDROCK);
    10. }
    11. }
    12. }
    13.  

    I also added a integer for see how much times the code is used and : Click Here
     
    Last edited: Mar 13, 2015
  2. Offline

    Skionz

    @MaTaMoR_ Why are you using a wrapper class?
     
  3. Offline

    MaTaMoR_

    I won't lie, i don't know what is "wrapper class"

    Where im using that ? (int) ? if it's that i should use double instead of a int ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 27, 2017
  4. Offline

    Skionz

  5. Offline

    drpk

    @MaTaMoR_ you're using it in your radius parameter.
     
  6. Offline

    MaTaMoR_

    What i should use ¿? int¿?
     
  7. Offline

    teej107

    Yes. You don't need to use the Integer object. Use an int primitive instead.
     
  8. Offline

    MaTaMoR_

    I changed that but the code still not working .

    Solved i was using .getY() instead of .getZ()

    /suicide

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  9. Offline

    kaif21

    @MaTaMoR_
    Maybe Post the new code which works and mark it as solved so others can benefit
     
  10. Offline

    MaTaMoR_

    i was using Y instead of Z, anyways you can see the updated post on the first post .
     
Thread Status:
Not open for further replies.

Share This Page