Jump to content

Forge's networking design


SnowyCoder

Recommended Posts

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)?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I'm trying to render a single quad in the world. I'm mixing into the ChestRenderer class. If I understand correctly, BufferSource#getBuffer opens a buffer according to the supplied RenderType (Quads with POSITION_COLOR in my case). Then, I can supply my vertices (a simple 1-block plane along the Z Axis) and close the buffer using BufferSource#endBatch for rendering. This is the code I'm using: @Inject(at = @At("TAIL"), method = "render(...)V") public void render(T blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, int packedOverlay, CallbackInfo ci) { BlockPos pos = blockEntity.getBlockPos(); AABB box = new AABB(pos, pos.offset(1, 1, 1)); BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); VertexConsumer consumer = buffer.getBuffer(RenderType.guiOverlay()); poseStack.pushPose(); poseStack.translate(-pos.getX(), -pos.getY(), -pos.getZ()); consumer.vertex(box.minX, box.maxY, box.minZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.maxY, box.maxZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.minY, box.maxZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.minY, box.minZ).color(1, 1, 1, 1).endVertex(); buffer.endBatch(RenderType.guiOverlay()); poseStack.popPose(); } However, the plane does not get rendered. However, if I replace those 4 vertices with a call to LevelRenderer#renderLineBox and set the RenderType to LINES, it works. Do I need something else to render planes other than the 4 edges of the quad? I used QUADS back in 1.8 where it was still the raw OpenGL type and it worked then. Or am I missing something else entirely? Thanks!
    • The Essential Role of Brunoe Quick Hack in Bitcoin Recovery Efforts The Brunoe Quick Hack has emerged as a vital tool in the ongoing efforts to recover lost or stolen Bitcoin. As the cryptocurrency landscape has evolved, the need for reliable and effective methods to regain access to misplaced or compromised digital assets has become increasingly pressing. The Brunoe Quick Hack, a specialized software solution, has stepped in to fill this critical void, offering Bitcoin users a lifeline when faced with the devastating prospect of permanently losing their hard-earned cryptocurrency holdings. At the core of this innovative technique lies a deep understanding of the underlying blockchain technology that powers Bitcoin, combined with a meticulous, methodical approach to identifying and exploiting vulnerabilities in the system. Through a series of carefully orchestrated steps, the Brunoe Quick Hack is able to bypass security measures, recover private keys, and restore access to Bitcoin wallets that were previously thought to be irretrievable. This process, while highly technical and requiring a skilled hand, has proven to be a game-changer for countless individuals and businesses who have fallen victim to the inherent risks of the cryptocurrency ecosystem. As the adoption of Bitcoin continues to grow, the Brunoe Quick Hack has emerged as an essential safeguard, providing a crucial safety net for those navigating the complex and ever-evolving world of digital finance. Contact this experts through: WhtasApp: + 170-"578-42"-635 Website: brunoequickhack.COM Email: brunoequickhack (AT) GMAIL (DOT) COM Thanks.
    • it doesnt let me import the zip that i use with curseforge
    • it doesnt let me import the zip that i use with curseforge
    • Halo semua, Kembali lagi bersama kami di situs Duta89 situs Aman, Terpercaya dan Situs yang memberikan hadiah terbesar kepada semua membernya. Pada kesempatan kali ini kami akan memberi tahu kalian semua mengenai situs permainan online yang bisa menghasilkan uang dengan cepat hanya dengan modal receh. Permainan apa kah itu? Saran bukan? >>>akungameaman<<< >>>akunminecrafsuper<<< >>>daftarsitus<<<
  • Topics

×
×
  • Create New...

Important Information

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