Solved getTargetLocation

Discussion in 'Plugin Development' started by Ugleh, Feb 14, 2013.

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


    Ive never been good with vector math. I was wondering if someone could help me out with a needed function. id like to be able to get a location which is x meters away from someone including their rotation/angle.

    I used to do it like this in most other 3d games
    Start Position + <5,0,0> * Start Rotation
    That however does not work in Bukkit. Start Rotation is a vector of Roll, Pitch, and Yaw. From what I look there is no getRoll.
  2. Ugleh
    Is this not what you are looking for?
    2. Player p;
    3. Location targ = p.getTargetBlock().getLocation();
  3. Offline


  4. Offline


    Adamki11s That only returns the actual blocks location, basically a FLOORed position?
    I want the actual location not Floored.
  5. Offline


    You just want to preserve their pitch and yaw? I think if you just .teleport() to a location that doesn't include pitch and yaw it will not change. Otherwise, save pitch and yaw, then teleport, then set pitch and yaw back to saved ones.

    Is it vital that you get the exact x y and z of where the player is looking?
  6. Offline


    Thats not what I want at all. I want the location a player is looking at. Imagine 5 meters away from their face. I want that location. I know there is a way using vector math or something :/
  7. Offline


    I'm curious, why do you need the exact location they have targeted? What, in Minecraft, could require such precision? :p
  8. A tnt blast destroying the alternate universe.
  9. Offline


    So that what im doing doesnt look like crap? Also this

    I dont want the block to be aligned like it is. Those are entities so it should be ok. Can someone help me now?
  10. Offline


    Ugleh likes this.
  11. Offline


    This should do it (where distance is how far away you want):
    Location pLoc player.getLocation();
    Location wantedLoc pLoc.add(pLoc.getDirection().multiply(distance));
    Ugleh and Digi like this.
Thread Status:
Not open for further replies.

Share This Page