Need ideas for separating my client, server, and common code for my game
Title isn't good, but it's the best I can think of. I've been working on a game for almost 17 months now, and when I just tried to add multiplayer, I came across an issue. I have my world separated into modifiable chunks. These chunks have code for rendering and storing the world data inside. Both client and server need the storing part, but only the client needs rendering part. I can't think of a good way to separate them so that both client and server get their versions of common, but client having the rendering stuff. I also want my games to be able to have mods that run on client and server. The rendering code is far too much to feasibly use but code manipulation to inject at compile (and I also wouldn't have complete source code). This is very frustrating, as I thought I would need only a few more weeks to be able to release my game. Now I have to refactor the entire thing. The point of this post is to ask for ideas to fix this. Please help, any suggestions will be appreciated.
8 Replies
⌛
This post has been reserved for your question.
Hey @The Typhothanian! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
I think the information you gave are too scarce, but I suppose youre doing something like Minecraft, am I right? If that's the case I think there's no other way than to refactor all of it. As for separation of concerns, we can steal the idea from Minecraft itself and just make a copy of loaded chunks both on server and client. Client would then send events to the server and server would respond back with chunk updates
Maybe it's not an ideal solution, but it should work
No, that's the simple part. I thought of those already. The "refactor all of it" part is the problem. How to refactor it so the client and server get the same chunk code but only the client gets the rendering code, and making everything look good under the hood and designed well. Just basic java design stuff, but I'm absolutely stumped. Hope this helps clear it up.
What do you mean by rendering code, exactly?
You mean faces you want to draw, block that are visible or a complete copy of chunk?
General rendering stuff that won't be needed on server
here's a good explanation I wrote https://www.reddit.com/r/javahelp/comments/1ibahg2/comment/m9gpjxp/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
Reddit
TheTyphothanian's comment on "Need ideas for separating my client, ...
Explore this conversation and more from the javahelp community
solved, doing renderer interface in Chunk that is only used in client
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.