Created
November 29, 2013 20:17
-
-
Save codebucketdev/7711362 to your computer and use it in GitHub Desktop.
With this snippet, you can pull a player to a location...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void pullPlayer(Player player, Location location) | |
{ | |
Location playerLoc = player.getLocation(); | |
playerLoc.setY(playerLoc.getY() + 0.5D); | |
player.teleport(playerLoc); | |
double g = -0.08D; | |
double d = location.distance(playerLoc); | |
double t = d; | |
double v_x = (1.0D + 0.07000000000000001D * t) * (location.getX() - playerLoc.getX()) / t; | |
double v_y = (1.0D + 0.03D * t) * (location.getY() - playerLoc.getY()) / t - 0.5D * g * t; | |
double v_z = (1.0D + 0.07000000000000001D * t) * (location.getZ() - playerLoc.getZ()) / t; | |
Vector v = player.getVelocity(); | |
v.setX(v_x); | |
v.setY(v_y); | |
v.setZ(v_z); | |
player.setVelocity(v); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment