Listen for WASD keys?

Discussion in 'Plugin Development' started by stenlankreijer, Dec 18, 2014.

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

    stenlankreijer

    Hi,
    I assume it's possible to listen when the WASD keys get pressed.
    I want to change the way a player moves, so instead of moving forward, backward, left and right I want up, down, left and right.

    Is this possible?
    If so, how?

    Thanks in advance!
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    stenlankreijer

    But you can track when a player tries to move, right?
    And then just cancel that and convert it to another kind of motion or something?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @stenlankreijer Please use the tahg or reply button when responding to somebody.
    But those movements would also be converted.
     
  5. Offline

    stenlankreijer

    What do you mean by "those movements would also be converted"?
    Do you mean it's possible?
     
  6. Offline

    timtower Administrator Administrator Moderator

    I have no idea if it is possible.
    You are saying that you will change the movement every time the user moves, so this will also happen for the vertical movement.
     
  7. Offline

    Rocoty

    Up doen left and right in a specific direction? What if the player looks to the right? Will the new right now be backwards? Be as precise as you can with this. It's an interesting idea, but very impractical in bukkit. It may be possible, but buggy.
     
    Avygeil likes this.
  8. Offline

    Avygeil

    @stenlankreijer As for capturing raw movement, you can listen for packets. See this and this (both have movement info, just the 2nd one also has rotation). You would use ProtocolLib for example, catch these packets, and write whatever you want to them. However, these packets use absolute coordinates, which would make it very hard to work with relatives (for example inverting movement) without storing the previous position. Which means there is no advantage to packets over PlayerMoveEvent or PlayerVelocityEvent.

    You could work with one of the last two events to invert movement. But as @Rocoty said, you need to provide us with more information.

    Also keep in mind that messing with movement events often result in being very choppy client side. Your client won't wait for the server to send back a position packet when you move : it's called client prediction. So cancelling or changing the movement will look like teleporting client side.
     
  9. Offline

    stenlankreijer

    @Avygeil @Rocoty @timtower Yeah what I want to do is basically make a "rocket" or "missile" that you can control and the camera position is basically in it. I was thinking of it being controlled by the WASD keys, but I could also do it by making the missile go whatever direction you're pointing at. I'll try this and post any progress I make.
     
  10. Offline

    TheOatBaron

    You cannot create a custom entity. You are getting pretty complex here. The best way would be to make the player invisible, and "replace" them with a group of particle effects that surround them and track their movement.
     
  11. Offline

    stenlankreijer

    I was actually thinking about using the disguisecraft API and disguising them as a TNT block/PrimedTNT
     
  12. Offline

    fireblast709

Thread Status:
Not open for further replies.

Share This Page