Reset player fall-distance on select teleports.

Sets the player fall-distance to zero before performing a player
teleport during "move player" steps. This should cancel out any already
calculated, added fall-distance that might result in unintentional
fall damage.

Fixes #698
This commit is contained in:
sepulzera 2021-10-28 22:23:11 +02:00 committed by Andreas Troelsen
parent 71b261e691
commit 05396f4d49
1 changed files with 2 additions and 4 deletions

View File

@ -7,8 +7,6 @@ import org.bukkit.util.Vector;
import java.util.function.Supplier;
abstract class MovePlayerStep extends PlayerStep {
private static final Vector NULL_VECTOR = new Vector(0, 0, 0);
private final Supplier<Location> destination;
private Location location;
@ -22,13 +20,13 @@ abstract class MovePlayerStep extends PlayerStep {
public void run() {
location = player.getLocation();
player.setVelocity(NULL_VECTOR);
player.setFallDistance(0.0F);
player.teleport(destination.get());
}
@Override
public void undo() {
player.setVelocity(NULL_VECTOR);
player.setFallDistance(0.0F);
player.teleport(location);
}
}