Fix Spout speed limiting (#590)

This commit is contained in:
Christopher Martin 2016-10-08 14:09:03 -07:00 committed by GitHub
parent df273dce6e
commit 2fd345de8a

View file

@ -1088,22 +1088,20 @@ public class PKListener implements Listener {
return;
}
// else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) {
// Vector vel = new Vector();
// vel.setX(event.getTo().getX() - event.getFrom().getX());
// vel.setY(event.getTo().getY() - event.getFrom().getY());
// vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
// // You now know the old velocity. Set to match recommended velocity
// double currspeed = vel.length();
// double maxspeed = .15;
// if (currspeed > maxspeed) {
// // only if moving set a factor
// vel = vel.normalize().multiply(maxspeed);
// // apply the new velocity (MAY REQUIRE A SCHEDULED TASK
// // INSTEAD!)
// event.getPlayer().setVelocity(vel);
// }
// }
else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) {
Vector vel = new Vector();
vel.setX(event.getTo().getX() - event.getFrom().getX());
vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
double currspeed = vel.length();
double maxspeed = .2;
if (currspeed > maxspeed) {
// apply only if moving set a factor
vel = vel.normalize().multiply(maxspeed);
// apply the new velocity
event.getPlayer().setVelocity(vel);
}
}
else if (Bloodbending.isBloodbent(player)) {
double distance1, distance2;