// REMOVED \\

Discussion in 'Plugin Development' started by BetaNyan, Nov 4, 2014.

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

    BetaNyan

    // REMOVED \\
     
  2. Offline

    Dudemister1999

    BetaNyan I think you'd make a cuboid-like check method. Get top-left and bottom-right locations, and check if the location is inside those two. Just like that, cubic .distance checks!
     
  3. Offline

    BetaNyan

    I don't like getting "spoon-fead", or spoon-feading others just like the next guy, but how would I even attempt that?

    I can get the block, how do I get the blocks around it?
     
  4. Offline

    mythbusterma

    BetaNyan

    You can create two vectors (points in this case) that you want to define as a rectangle, then use isInAABB(Vector, Vector) on them (the actual name escapes me right now, but it's something like that) on the Vector that is the location you're at.
     
  5. Offline

    Dudemister1999

    BetaNyan Personally, I don't care about spoon-feeding. If someone doesn't get it, wouldn't it be faster to just show them? Anyways, back on topic:

    Code:java
    1. Location original = <ORIGINAL LOCATION>;
    2. Location topLeft = original.clone().add(10, 5, 10);
    3. Location bottomRight = original.clone().subtract(10, 0, 10)

    That code will give you three locations, all properly named. Then, to check if a location is inside:
    Code:java
    1. Location in = <INPUT LOCATION>;
    2.  
    3. boolean checkX = in.getX() < topLeft.getX() && in.getX() > bottomRight.getX()
    4. boolean checkY = in.getY() < topLeft.getY() && in.getY() > bottomRight.getY()
    5. boolean checkZ = in.getZ() < topLeft.getZ() && in.getZ() > bottomRight.getZ()
    6.  
    7. boolean inside = checkX && checkY && checkZ;
     
  6. Offline

    Barinade


    for (int x=player.getLocation().getX()-(distance/2); x<=player.getLocation().getX()+(distance/2); x++) {for (int y=player.getLocation().getY()-(distance/2); y<=player.getLocation().getY()+(distance/2); y++) {for (int z=player.getLocation().getZ()-(distance/2); z<=player.getLocation().getZ()+(distance/2); z++) {
    if (new Location(player.getLocation().getWorld(), x, y, z).getBlock().getType() == Material.STONE) {
    //stone found within distance
    }
    }
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page