Test Movement

Discussion in 'Plugin Development' started by Whatshiywl, Jun 29, 2012.

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

    Whatshiywl

    So i'm stuck on something...

    is it possible to test especific movements like just walk or just took arround? because i don't want something to happen when the player looks arround but i want when they walk.... does bukkit see it as one single event or can i separate them somehow?
     
  2. Offline

    r0306

    Whatshiywl
    It's one single event and you can text it out by getting the player's location from the event, splitting the event into different components such as X, Y, and Z and then printing them out to the console.
     
  3. Offline

    Whatshiywl

    @r0306 right but isn't there a way to test if these XYZ changed without testing the other move events? sorry if this doesn't make sense or anything, i'm just new to making plugins -.-
     
  4. Offline

    r0306

    Whatshiywl
    Not that I know of. This event is only fired when the player's location changes, not the other way around. You could just press F3 in your client to view these XYZ.
     
  5. Offline

    Whatshiywl

    @r0306 so is there a way to get the previous XYZ the player was so i can compare them with his current XYZ and then see if he moved?
     
  6. Offline

    r0306

    Whatshiywl
    Use the PlayerMoveEvent's getFrom() and getTo() methods.
     
  7. Offline

    Whatshiywl

    @r0306 right so this

    Code:
    if(event.getFrom().getBlockX()!=player.getLocation().getBlockX() || event.getFrom().getBlockY()!=player.getLocation().getBlockY() || event.getFrom().getBlockZ()!=player.getLocation().getBlockZ())
    kinda works. it's supposed to be true when he changes the block he's on. but only seems to work when he's moving slowly, like sprinting... any ideas? D:
     
  8. Offline

    r0306

    Whatshiywl
    Use the getTo() instead of getLocation()
     
  9. Offline

    Whatshiywl

    @r0306 :eek: worked \o/ thanks :D
     
  10. Offline

    r0306

Thread Status:
Not open for further replies.

Share This Page