Skip to content

Commit

Permalink
Fix excessive velocity crash with Grappler
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Aug 27, 2021
1 parent 7009e61 commit a20bae5
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ public void grappler(PlayerFishEvent event) {
Player player = event.getPlayer();
if (blockAbility(player)) return;
Vector vector = player.getLocation().toVector().subtract(event.getCaught().getLocation().toVector());
event.getCaught().setVelocity(vector.multiply(0.004 + (getValue(Ability.GRAPPLER, playerData) / 25000)));
Vector result = vector.multiply(0.004 + (getValue(Ability.GRAPPLER, playerData) / 25000));

if (isUnsafeVelocity(result)) { // Prevent excessive velocity warnings
return;
}
event.getCaught().setVelocity(result);
}
}
}
}

private boolean isUnsafeVelocity(Vector vector) {
double x = vector.getX();
double y = vector.getY();
double z = vector.getZ();

return x > 4 || x < -4 || y > 4 || y < -4 || z > 4 || z < -4;
}

}

0 comments on commit a20bae5

Please sign in to comment.