Jump to content

Confusion as to how often I need to specify a "side" in code


MrChoke

Recommended Posts

I get the concept of sides, a server thread (or separate JVM if dedicated) versus a client thread.  What confuses me is when should we specify a side in our code?  I know if its rendering stuff it should be client only.  But how about other things, like entity movement, AI, process mouse clicks, etc??  Is there someplace I can check or read up on to help with this?  I fear I am not specifying the side enough (I barely have it at all) and does that mean I have the client loading and/or doing too much stuff that it doesn't need to.

 

 

Link to comment
Share on other sites

22 minutes ago, MrChoke said:

entity movement

Depends. Players move on the client and just send the server their new position.

 

22 minutes ago, MrChoke said:

AI

Entirely server sided.

 

22 minutes ago, MrChoke said:

mouse clicks

How would a server even handle mouse clicks if it may not even have a mouse? This is entirely client-side.

 

In general everything rendering or input related is client side only, and pretty much everything else is either common or server sided. Note that when I say server sided I mean the logical server, not the physical server.

 

Every time you need to do something think about it. Could a dedicated server perform it? It has no controlling player, no mouse input, no keyboard input and may not even have any display at all. If it can't - then the thing you are trying to do is client based. Otherwise the server is likely the entity that needs to do it.

 

22 minutes ago, MrChoke said:

does that mean I have the client loading and/or doing too much stuff that it doesn't need to.

In general the client doesn't do much at all anyway, it mostly displays stuff. Most logic runs on the server and if you have any custom logic you should run it on a server aswell.

 

22 minutes ago, MrChoke said:

I am not specifying the side enough (I barely have it at all)

Define "not specifying the side". 

Link to comment
Share on other sites

By sides, I mean specifying a side, with world.isRemote() or @Side.

 

I guess I will just follow the common sense approach when I add sides.  Right now I am running in any integrated server sop I know my code is going need work when I move to dedicated.

 

Link to comment
Share on other sites

3 hours ago, MrChoke said:

specifying a side, with world.isRemote() or @Side.

These are completely different things. World.isRemote checks whether you are on a logical client or not. @SideOnly removes the method completely from the class on the physical side opposite to the one specified.

Link to comment
Share on other sites

https://mcforge.readthedocs.io/en/latest/concepts/sides/

Physical Side - Client software application or Server software application

Logical Side - Where logic like keystrokes (client) and mob spawning (server) is done. It can be either Server Thread or Client Thread (the Integrated (Physical) Client has both a server and client thread so you can play single player. The Physical Server does not have a client thread.)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.



×
×
  • Create New...

Important Information

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