if player is at cords

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

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


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


    Untested code:
    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


    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


  5. Offline


Thread Status:
Not open for further replies.

Share This Page