onPlayerMove() not always triggered

Discussion in 'Plugin Development' started by flyslasher, Mar 6, 2011.

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

    flyslasher

    I updated my build to Jenkins build #493 and spent a good day fixing all my plugins. One of them is kind of faulty when deal with onPlayerMove(). After spending a couple of minutes, it seemed as if the event wasn't always triggered. Can anyone explain how to get it triggered or a better event? I wasn't having problems before with build #440!
     
  2. Offline

    Raphfrk

    They did a change, it now only triggers if the player moves by a certain amount. I think it is 1/16 of a block.

    What is a little annoying is that the "from" field isn't updating.

    So, the x coord might go

    Event 1
    from 0.9
    to 0.95

    Event 2
    from 1.02
    To 1.07

    This means that you can't use the from/to fields to check if the player has crossed a block boundary.
     
  3. Offline

    flyslasher

    Quite annoying :p. What is a reasonable work around do you think? Maybe its just a small bug and they will fix it soon though so probably not that big of a deal. The code isn't crucial as all it does is display a message in certain parts of the worlds as you enter/exit them.
     
  4. Offline

    Shade

    Uhg, yea.
    https://github.com/Bukkit/CraftBukkit/commit/73647864179cbab9f340044e9d33add445fbe774
    https://github.com/Bukkit/CraftBukkit/commit/a759204053dfba4d9ca9a4b9eeeff836dceab485

    It's one of those commits.

    What needs to be done is to remember that last location sent.
    https://github.com/Zren/CraftBukkit...t/minecraft/server/NetServerHandler.java#L101
    Should be along the lines of:
    player.getLastLocation();

    That or change
    https://github.com/Zren/CraftBukkit...t/minecraft/server/NetServerHandler.java#L106
    To include || round(x1) != round(x2) || round(y1) != round(y2) || round(z1) != round(z2)

    So that it fires the event if the movement is from block to block. (btw, it should be floor or ceil instead of round)
     
  5. Offline

    Raphfrk

    I have submitted a pull request.

    It also adds a check for pitch and yaw, the event is triggered if they change by more than 5 degrees.
     
Thread Status:
Not open for further replies.

Share This Page