Rounding Cords?

Discussion in 'Plugin Development' started by javoris767, Apr 1, 2012.

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

    javoris767

    Hey is their a way to round coordinates for a players location because
    X(-968.433041986818), Y(103.87380380545437), Z(-3072.537140139901)
    Could get pretty big and confusing.
     
  2. Offline

    s1mpl3x

    location provides getBlockX/Y/Z() methods
     
  3. Offline

    dsmyth1915

    player.getLocation() returns the players exact location.
     
  4. Offline

    RROD

    If you really wish to round:
    Use > Math.round();

    Will go to the nearest integer.
     
  5. Offline

    javoris767

    Code:java
    1. Math.round(player.getLocation().getZ());

    Like this?
     
  6. Offline

    Sir Savary

    Yes, that would work.

    Edit: Wait, I lied, that might produce buggy results depending on the decimal. Use math.floor instead.
     
  7. Offline

    Double0negative

    you can cast it to a int, which will cut the decimal off so you always stay on the block you were on and not round up to the next one. or you can use Math.floor
     
Thread Status:
Not open for further replies.

Share This Page