From 2fd345de8a9473852141c718d62ca16b3f70c387 Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Sat, 8 Oct 2016 14:09:03 -0700 Subject: [PATCH] Fix Spout speed limiting (#590) --- .../projectkorra/projectkorra/PKListener.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index b52716fd..b6fdbd71 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -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;