Radius

Discussion in 'Plugin Development' started by messageofdeath, Nov 24, 2012.

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

    messageofdeath

    How do I make something when someone places a block then it checks if its within a 5 block radius of someone else's block, if it is then cancel the event.

    EDIT: It would also help if it had these params

    Code:java
    1. public static boolean isWithinSomeoneElseBlock(String loc) {
    2. //@param loc = 1,1,1 or x,y,z
    3. }
     
  2. Offline

    md_5

    Just add radius to the x,y,z and do the same for subtraction.
    ie 3 nested for int (x...) loops.
     
  3. Offline

    messageofdeath

    Like this?

    x = 1, y = 2, z = 3;
    x = x + radius;
    y = y + radius;
    z = z + radius;

    Thats it?

    I think it would be helpful if you give me some code, not to be rude of course.
     
  4. Offline

    md_5

    Code:
    for (int x = startX - radius; x < startX + radius; x++)
    Now just put that line below, change x to y, and then copy again and change y to z.
     
  5. Offline

    messageofdeath

    Cool, I'll try it out.

    It works!!! thanks so much md_5

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  6. Offline

    messageofdeath

    md_5 there is a slight problem. When you have the radius set to any number but for this case we'll use 5. So on two of the sides of the block only protects 4 blocks out while the other two sides protects 5 blocks out. Is this my code or the code you gave me
     
  7. Offline

    fireblast709

    replace
    Code:java
    1. x < startX + radius
    with
    Code:java
    1. x <= startX + radius
     
  8. Offline

    messageofdeath

    Thanks it worked.
     
Thread Status:
Not open for further replies.

Share This Page