Commit 97c045e 1 parent 0d45d22 commit 97c045e Copy full SHA for 97c045e
File tree 1 file changed +11
-4
lines changed
src/main/java/de/redstoneworld/redutilities/player
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 7
7
public class Teleport {
8
8
9
9
/**
10
- * This method teleports the player to the specified location. Before the teleport, however,
11
- * the velocity is set to zero so that the player does not take over any fall damage due to
12
- * the previous fall / fly. This is mainly relevant in the 'Survival-Mode'.
10
+ * This method teleports the player to the specified location.
11
+ * The velocity and fall-damage is set to zero so that the player
12
+ * does not take over any fall damage due to the previous fall / fly.
13
+ * This is mainly relevant in the 'Survival-Mode'.
13
14
*
14
15
* @param player (Player) the target player
15
16
* @param targetLocation (Location) the target teleport-location
16
17
*/
17
18
public static void teleportSafely (Player player , Location targetLocation ) {
19
+ // Stop the player's velocity to prevent continued movement
18
20
player .setVelocity (new Vector (0 , 0 , 0 ));
21
+
22
+ // Teleport the player to the target location
19
23
player .teleport (targetLocation );
24
+
25
+ // Reset the fall distance to prevent fall damage
26
+ player .setFallDistance (0 );
20
27
}
21
-
28
+
22
29
}
You can’t perform that action at this time.
0 commit comments