Jump to content

Recommended Posts

Posted

I have been working on a rewrite of the minecart systems to remove some things I didn't like, and a whole bunch of new features, namely a train implementation and complete prevention of minecarts (on rails at least) ever being allowed to clip into each other, and certainly not right through the minecart in front.

 

However I have run into an issue when the player is interacting with powered rails (e.g. via a lever). If the player changes the power state which part of a train is on the piece of track, it seems the client and server are getting this change on different ticks in the train simulation, which seems to create the possiblity for the client train to make it past the now deactivated powered rail block, which the server train gets stopped entirely (at least until the next server->client train sync packet which moves the client train back to where the server one stopped).

 

I am not sure if this is an issue with the onNeighborBlockChange occurring at different times for the client or server, or because of some delay in sending my custom server->client packets leaving the client-side train always behind (although if the client train was notably behind the server, I would expect to see the client train getting stopped while the server train makes it past a newly deactivated powered rail, not the opposite?). Either way what can be done about it to keep the client/server simulation in sync?

 

 

The rail block updates its power bit in response to a onNeighborBlockChange call (as in the original rail code, using world.isBlockIndirectlyGettingPowered for upto 8 rail blocks)

http://paste.minecraftforge.net/view/f5325d73 (Small fragment from rail where the powered rail effect is queried)

 

The Train entity (representing one or more vehicles forming a train on the track) is then responsible for the entire on-track simulation, with the server and client running the same code, but the server is authoritative sending the data required to rebuild a trains state every 2.5 seconds.

http://paste.minecraftforge.net/view/99d3fbf2 (Small fragment from the Train entity where motion is updated and data sent to client)

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.