Jump to content

Recommended Posts

Posted

Recently I added a config file to my mod and it works perfectly when in single player mode. However when I start a server and a player tries to join in with different config than the config of server, things don't work as they should. I understand I must use packets to send a packet to client and update it's config values. But... how do I do this. I already have used packets for other things like potion effects, removal of blocks and so on, but I do not know how to do this.

Posted
16 minutes ago, diesieben07 said:

You need to send a packet containing all the config values in PlayerLoggedInEvent. Then on the client store them in a static field somewhere so you can access them. Do not modify the actual Configuration instance.

I think I got it. (SERVER PlayerLogsIn) -> Send Package to Client  (Client Received Package) -> Store temporary in static fields

But let's suppose that a certain config option e.g. registration of a block is changed. Then the player would have to restart to apply changes but those changes would be lost... (I do not have such a problem, I just want to learn if such a problem can be resolved)

Posted
7 minutes ago, diesieben07 said:

I am not sure why you think those changes would be lost.



Maybe I didn't explain it well. So let's say I have a field in conf file that determines if a custom block will be registered or not. Let's suppose that Client has this field set to false(Block won't be registered) but Server has it set to true. When the Client tries to connect it will receive the config values and see that this specific value is different. So in order to get this block registered it will have to restart. But uppon loading won't the client load the old configuration file again? So the block will still be unregistered and the same thing will repeat. So as it seems the config file will have to be edited....

Posted
9 minutes ago, diesieben07 said:

Don't let the config decide whether or not to register things. Always register everything and then disable crafting recipes and creative-menu display when the server-side configuration arrives. This works even in SinglePlayer, no special-casing required.

Thank you very much for your quick and helpful responses! 

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.