Movement Help

Discussion in 'Plugin Development' started by Jakesully123456, May 28, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Jakesully123456

    Hello,
    I have an invisibility ability and I need it so that when a player moves it is removed, but not if they moved their head, if they actually used WASD to move.
    Any ideas how to do this?
     
  2. Offline

    Agentleader1

    Really easy.
    Watch:
    Code:
    @EventHandler
    public void onMove(PlayerMoveEvent pme){
        Player player = pme.getPlayer();
        if(pme.getTo().getX() != pme.getFrom().getX() ||
                pme.getTo().getY() != pme.getFrom().getY() ||
                 pme.getTo().getZ() != pme.getFrom().getZ()){
            player.removePotionEffect(PotionEffectType.INVISIBLITY);
        }
    }
    http://pastebin.com/euXPL4tC
     
  3. Offline

    Jakesully123456

    I tried that, however, got an issue that it would sometimes still go ahead, even though the F3 menu showed no change in my X Y or Z co-ords.!
     
  4. Offline

    glory_fades

    try putitng them in an array list whenever they go invisible or whatever then see if they are in that arraylist while they move like so,

    Code:
    @EventHandler
    public void onMove(PlayerMoveEvent e) {
        final Player p = e.getPlayer();
        if ((e.getFrom().getBlockX() == e.getTo().getBlockX()) && (e.getFrom().getBlockZ() == e.getTo().getBlockZ()) && (e.getFrom().getBlockY() == e.getTo().getBlockY())) {
            return;
            }
            if (this.move.contains(p.getName())) {
                p.removePotionEffect(PotionEffectType.INVISIBILITY);
    }
    }
     
  5. Offline

    Agentleader1

Thread Status:
Not open for further replies.

Share This Page