How Exact Teleportation?

Discussion in 'Plugin Development' started by Pit910, Apr 23, 2014.

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

    Pit910

    Hey,

    iam writing a SurvivalGames Plugin. Now i have the Problem that the Players does not Teleport excact in the middle of the Diamond Block. Lock at the Screen:



    2014-04-23_19.03.53.png

    How can i make that the Players would be exact teleport in The midlle of the Diamond Block?

    I Teleport the Players to the Location with an Double like this: X -11.0 Y 70.0 Z 20.0


    Thanks a lot in advance!

    Sorry for bad English, iam German!
     
  2. Pit910 The decimal parts decide where on the block they are.
     
  3. Offline

    zDubsCrazy

    Pit910
    Use file: 'data.yml', to save coordinates exactly... And after teleport the player to coordinates saved!
     
  4. zDubsCrazy For exact middle, I don't think he really needs to save them, but useful advice for other times I guess
     
  5. Offline

    Pit910

    How i can get the decimal Parts?
     
  6. Pit910 Well, one way would be to go in game and look with the F3 menu on... But for exactly half, surely it would be something.5, right?
     
  7. Offline

    GaaTavares

    X,Y,Z are double. That means they are decimal. To "center" the location, use location.add(0,5,0,0,5).
     
  8. Offline

    zDubsCrazy

    AdamQpzm
    Using the file, can be used commands, to set locations, such as: /setlocation
     
  9. Offline

    Pit910

    Thanks. I use alread a File and i would now use location.add(0,5,0,0,5).

    Now i get this Error:
    The method add(double, double, double) in the type Location is not applicable for the arguments (int, int, int, int, int)

    My code:
    Code:java
    1. Location pl = e.getBlock().getLocation();
    2.  
    3. pl.add(0,5,0,0,5);


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  10. Offline

    zDubsCrazy

    :)
     
  11. Offline

    Wizehh

    Depending on how you look at it, you have either one too many arguments, or one too less.
    You should have five arguments, so you can save the pitch and yaw of the location (for precise teleportations).
     
  12. Offline

    Konkz

    Why don't you just save the location as a double?

    Quick revision, basic level: int is a whole number. double is 0.0
     
  13. Offline

    Pit910

    I save the Location as Double. But what must it do to get the Center Location of the Block?
     
  14. Offline

    Wizehh

    Use the pitch and yaw of the location. OH, I see what your problem is: you're using Location#getBlockX(), but you should be using Location#getX() if you want the exact coordinate.
     
  15. Offline

    Necrodoom

    Er...
    pl.add(0,5,0,0,5)
    Should be
    pl.add(0.5,0,0.5)

    Reading the error is important.
     
    Konkz likes this.
  16. Offline

    Konkz

    I cri, no mod ;-;

    But yea, if you read the error it
    a) wanted doubles not integers
    b) it told you how many doubles you needed and how many you had.
     
  17. Offline

    coasterman10

    The best would be to save the locations as integers and then add 0.5 to them making them doubles when you get the actual location. This would prevent small discrepancies caused by not standing directly on the center of the block when you save the location.
     
  18. Offline

    Necrodoom

    Thats what he has currently, due to getting the location of a block.
     
Thread Status:
Not open for further replies.

Share This Page