Getting closer or further away

Discussion in 'Plugin Development' started by Irantwomiles, Apr 21, 2015.

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

    Irantwomiles

    is it possible to check if you are getting closer or further away from a location?
     
  2. @Irantwomiles Check how far (or close) a players location is to another location. location#distanceSquared(other loc); (I beleive this is correct, on a phone, so there might be something missing...)
     
  3. Offline

    Irantwomiles

    @CodePlaysMinecraft i have it checking how at away it is but i need a way to check if I'm getting closer to is so instead of showing the how many blocks away I am I show that the player is getting hotter or colder
     
  4. Offline

    caderape

    @Irantwomiles
    location.distance(location), it return the distance in block.

    You could just check on PlayerMoveEvent. you can get the location getFrom().getBlock().getLocation() and getTo().getBlock().getLocation() and check if getTo is closer.
     
  5. @Irantwomiles Well it really depends on what you think of "hot" and "cold". Hot and cold is an int, since you want to check how many blocks a person is away from another person. Hot could be 5, or 10 blocks away from a person, and cold could be 20 or higher. (You could possibly make a config file and allow players to set these.) How you can show that the player is hot or cold can be as simple as sending a message, or using a Boss Bar to tell it to the player. You would want to use PlayerMoveEvent to check this.
     
  6. Offline

    Irantwomiles

  7. @caderape Nope - distance() shouldn't be used unless you need to know the actual distance, which just to tell if somebody is getting closer you wouldn't. Using distanceSquared() avoids the costly call to Math.sqrt()
     
Thread Status:
Not open for further replies.

Share This Page