Jump to content

Recommended Posts

Posted

I read the forge tutorial and I wanted to ask some precisations.
Until now I only worked with bukkit/spigot (so plugins) and I tought that the network design was that the server had all the game-logic and the client was only there as an input-output device with almost no game logic included.
Then I saw the forge tutorials and mods, where most of the code (including the game logic) is shared between client and server and the sided things are generally a few classes.
How could this work? Shouldn't this design have bugs caused by different choises taken from server and client? Where can I find some clear code or documentation that explains this?
Another question: is the vanilla minecraft networking designed like the mods too (with the shared game logic)?

Posted

If you have the same code on both client and server, why would they make 'different choices'? Code is code, it doesn't think it just does exactly what you tell it to do.

But yes the idea is to move all of your major logic to the server and make the client a 'dumb client'. This just makes good design sense because it lowers the complexity of the client. Thus lowering potential desync/processing/error issues.

But it does introduce lag, and this is why some logic is good on the client. If the client can predict what the server is going to do then it can start doing that before the server has told it to. Or better yet the server can be less accurate in the information it sends to the client and the client can interpolate between the data. For example entity movement. Instead of sending one packet per tick per entity to every client. The server can send "this entity is moving this direction" when the movement starts and a "the entity is now at x,y,z" every, 20 ticks. That's instantly 1/20th of the bandwidth/processing time used.

 

It's a balance between end user experience and performance. And there are many schools of thought onto which side is more important.

 

As for Vanilla code, Vanilla code is horrible. Its all client side because the client and server were written separately for the bulk of the early development. The dumb-client approach wasn't even thought about until about MC 1.3, and there is so much code debut that you can't really get out of it. So we work with what we have.

 

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Thank you for the answer!
 

Quote

If you have the same code on both client and server, why would they make 'different choices'? Code is code, it doesn't think it just does exactly what you tell it to do

I meant that in a big project there could be some hard-to-see bugs caused by non-synchronized variables (in a big project it isn't that far-fetched to forget a variable) or packets that arrive some ticks after they were ment to be received (due to the connection). That could cause bugs even if the code is the same, right?
 

Quote

But yes the idea is to move all of your major logic to the server and make the client a 'dumb client'

I can't seem to find really much examples of that, looking at open-source mods (like AE2) I see just the minimal code in the sided part of the code, am I misunderstanding something?

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.