Jump to content

Recommended Posts

Posted

Is this just as simple as making a KeyHandler and sending a packet on keyPressed and keyReleased?

 

Boats work by using this.riddenByEntity.motionA and translating to this.motionA, which is what I've been trying. But it's well known that boats are complete crap. I noticed that I'm having difficulty with things like jumping and moving fast. I'll randomly get teleported back, I assume the server thinks I'm trying to speedhack or something? So I'm thinking of hooking the movement keybinds (wasd) directly to Player.ridingEntity. Trouble is that I can't find where wasd is translated to movement in vanilla.

So does someone know the class for handling wasd movement? Any other advice?

Posted

Yes, pretty much as you are thinking.  (and yes, the boat code is crap)

 

I have done alot of vehicle type work for my mod (ancientwarfare.wikispaces.com) and my solution:

 

Handle client movement on the client, relay information to the server regarding input.  Do not let server update local (ridden) client, only let server relay motion and input to other clients.  That way the player riding the entity gets 100% smooth motion, done client side.  Server gets relayed position and input updates from client periodically, and relays these to other clients.  Movement on other clients is sometimes jumpy......but it was either suffer from boat issues in first-person, or let the third-party see a bit of jumping (which actually is not too bad with this model).

 

Basically--register a dummy keybind handler(see FML javadocs), tick handler on client to poll for keys pressed--actually I used a proxy class for the vehicleMovementHelper, and relayed from that--, and when input changes, relay the new change to the server (no need to relay every tick, only when changed).  Server then relays to all _other_ clients the new input/velocity/position.

 

Hopefully someone has a better model than this (as I'm looking to redo it), but it was the best solution I could find to solve the jumpiness client side.

 

I've got my source up on github, and can provide links/examples if necessary (send me a PM, or w/e).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.