if player is at cords

Discussion in 'Plugin Development' started by PizzaPixel, Aug 13, 2014.

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

    PizzaPixel

    How would i check if a player is at X, Y, Z cord
     
  2. Offline

    EnderTroll68

    Untested code:
    Code:java
    1. if((int)player.getLocation().getX() == 1 && (int)player.getLocation().getY() == 1 && (int)player.getLocation().getZ() == 1) {
    2. // do stuff
    3. }


    Casting it to an integer will remove the decimal
     
  3. Offline

    _LB

    Coordinates are double-precision floating-point types, and as with all floating point types, the equality comparison operator is next to useless. Two values that look the same will 99% of the time never be the same. You need to round or use a range.
     
  4. Offline

    _Filip

    location.getBlockX
     
  5. Offline

    teej107

Thread Status:
Not open for further replies.

Share This Page