Jump to content

[1.16.5] What is the proper approach for handling a custom entity's movement?


Yun-L

Recommended Posts

I'm currently working on a mod that adds in vehicles that players can ride and control with keyboard inputs. I've been looking at the `BoatEntity` code in vanilla Minecraft as reference but have been struggling to understand how motion is handled.

For example, in `BoatEntity::tick` when a player is riding a boat, motion is updated on both the client side and server side with `BoatEntity::updateMotion` but then updated again only on the client side with `BoatEntity::controlBoat`. The logic seems like it would cause motion to desync between the client and server because the client side motion may include different values set in `BoatEntity::controlBoat`. Since this is code from vanilla Minecraft, I don't have much reason to think this is an error so it's not obvious to me why this works.

Does anyone have an explanation for how entity motion logic is supposed to be handled? Thanks in advance for any help provided.


Also, I just assumed that I'm not allowed to paste any of the vanilla Minecraft code in this post so I hope the MCP method names are good enough to reference anyone to the code I'm talking about.

Link to comment
Share on other sites

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.