# How Exact Teleportation?

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

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:

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

Sorry for bad English, iam German!

#1
2. Offline

### Forge_User_60359873

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!

#3
4. Offline

### Forge_User_60359873

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?

#5
6. Offline

### Forge_User_60359873

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).

#7
8. Offline

### zDubsCrazy

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

#8
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
`    Location pl = e.getBlock().getLocation();     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
#9
10. Offline

#10
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).

#11
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

#12
13. Offline

### Pit910

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

#13
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.

#14
15. Offline

### Necrodoom

Er...
Should be

#15
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.

#16
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.

#17
18. Offline

### Necrodoom

Thats what he has currently, due to getting the location of a block.

#18