1.7.10 setVelocity

Discussion in 'Spigot Plugin Development' started by AsuraFlame, Feb 1, 2020.

  1. So I tried to make a grappling hook and im kinda in the pit with it


    private void pullPlayerSlightly(final Player p, final Location loc) {
    if (loc.getY() > p.getLocation().getY()) {
    p.setVelocity(new Vector()); <---- Error
    return;
    }
    final Location playerLoc = p.getLocation();
    final org.bukkit.util.Vector vector = loc.toVector().subtract(playerLoc.toVector());
    p.setVelocity(vector);
    }

    If anyone knows how to fix it please help me out.
    (Note: it is 1.8 aswell)
     
  2. You don't tell what the error is, are we supposed to guess?
    This does nothing, the values of the vector are empty.
     
  3. I assume that you have imported the wrong Vector...
    There is java.util.Vector and org.bukkit.util.Vector, you want the latter one
    Also, as @robertlit said, please elaborate more and wrap your code inside the [.CODE] [./CODE] blocks.
     
  4. The error is the p.setVelocity and i have no idea why because i havent had a problem before using that
     
  5. WHAT is the error?!?!
     
    • Agree Agree x 1
  6. I AM GUESSING, You have imported the wrong Vector in the "new Vector()" Import this org.bukkit.util.Vector
     
  7. If you want to set the speed walking of a player there's just p.setwalkspeed
    create before a value to put, because it requires a float
    float vf = Float.valueOf(0.1f);
    0.1f is normal speed