Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get Killer Distance

Comments in 'Plugin Development' started by JackboyPlay, Feb 3, 2016.

  1. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Hello ich have an question
    How can i get the distance frm the "Hitter" to the "victim"?
    Example: I will hit Johnson i will get a message "You are {distance} Blocks from Johnson away"
    Sorry for the Bad english
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    If there isn't a function for this, I am pretty sure that you should use Pythagorean formula to calculate the distance between two coordinates, and round it.
  3. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    what about $player1->distance($player2); ?
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Is there is a such function? :oops: Hm, I was unaware of it. I was saying about a way to calculate the distance between two players since I did not know such function existed.
    (If anyone says I suck because I didn't search, I'm going to be seriously annoyed.)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use Vector3->distance().
    Note that if you just use it for comparison, use distanceSquared() instead of distance(), and compare it with the square of the value you want to compare to. For example, to see if $vA is at least 4 blocks away from $vB, you can check `$vA->distanceSquared($vB) >= 16`, where 16 is 4 ** 2.
    PocketKiller likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Although many people have no idea what Vector3 is for, it is actually an implementation of most vector operations, including addition, subtraction, scalar multiplication and division, dot and cross product, distance, length and other useful operations.
    Don't ask me what dot and cross products are. I referred to my school textbook chapter about vectors, and it only told me how to calculate them without saying what they are/how to use them; but they are very useful, I guarantee. Afaik something to do with matrixes.
    PocketKiller likes this.
  7. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Thanks :D
  8. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    what else would you use distance for?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Display to player?
  10. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Is it possible to check how many blocks a Player Walked in 40 ticks?
    If Yes How?
  11. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    one question per thread.
    Bluplayz likes this.
  12. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    okay :(

Share This Page

Advertisement