Users teleporting then being returned to start

Discussion in 'Plugin Development' started by cppchriscpp, Jan 15, 2011.

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


    So I have been porting TravelPortals to bukkit, and it's given me a minor headache, but things are mostly working, or should be. The premise is simple; when a user walks into one portal, he is teleported to the position of another one. The problem is, when I use the teleportTo method, the user is sent back to the first portal, and the console complains about the user moving wrongly. I am not sure what is going wrong, and was hoping someone could at least point me in the right direction.

    To teleport users, I am simply using:
    player.teleportTo(new Location(player.getWorld(), x, y z, rotation, 0));
    where x, y, and z are the coordinates of the block just above the floor of the portal. (Where the user would stand.)

    If there is question as to whether I am just teleporting the user twice, I have confirmed that this is not the case. I gave portals a 5 second cooldown time on both portals involved to make sure a user could not trigger one twice, and have it print out any time the warp method goes off. It only happens once.

    One person said I was somehow triggering the server's check for speed hacks. If this is the case, how do I get around it? This isn't a speedhack this is a legitimate server addon. :(
    The entire sourcecode is <Edit by Moderator: Redacted mediafire url>

    Thank you in advance for any insight you might have into this issue.

    Edit: also I realize I am a few versions behind the latest in terms of how it runs. I'll update the plugin for the breaking changes yet again once I update my server to deal with them. Right now I care more about this issue than that, however. This is linked against the builds from last night just after the change in the plugin constructor.
    Last edited by a moderator: Dec 15, 2016
  2. Offline


    I saw the same issue when porting a ServerPort.

    The code is from

                double d15 = d12 * d12 + d13 * d13 + d14 * d14;
                boolean flag1 = false;
                if (d15 > 0.0625D) {
                    flag1 = true;
                    a.warning((new StringBuilder()).append(" moved wrongly!").toString());
                    System.out.println((new StringBuilder()).append("Got position ").append(d4).append(", ").append(d6).append(", ").append(d8).toString());
                    System.out.println((new StringBuilder()).append("Expected ").append(e.p).append(", ").append(e.q).append(", ").append(e.r).toString());
    This looks like a distance check. d15 is the square of the distance (probably step size). If a player moves more than 1/4 of a block per update, that will give a squared distance of > 0.0625.
  3. Offline


    Hrm. Uhoh. So how did you get around it? Do I have to split it up so the user only moves x distance per frame? And if so, how the heck would I manage that?
  4. Offline


    I had a look at Nijikikun's WarpGate (which works) and it seems that the "to" field in player move event is considered to be the player's official location.

    You need to teleport and then set that field to the destination.

    Something like:

    Hopefully, it only happens in onPlayerMove events.
  5. Offline


    That's weird, but thank you! Testing that now, will release if it works

    Edit: IT WORKS! Thank you so much!
  6. Offline


    Np, but the trick is from Nijikikun's plugin.
Thread Status:
Not open for further replies.

Share This Page