Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Sync Config between Client and Server
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
GeorgeTsak

Sync Config between Client and Server

By GeorgeTsak, May 9, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

GeorgeTsak    0

GeorgeTsak

GeorgeTsak    0

  • Tree Puncher
  • GeorgeTsak
  • Members
  • 0
  • 17 posts
Posted May 9, 2017

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.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45660 posts
Posted May 9, 2017

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.

  • Quote

Share this post


Link to post
Share on other sites

GeorgeTsak    0

GeorgeTsak

GeorgeTsak    0

  • Tree Puncher
  • GeorgeTsak
  • Members
  • 0
  • 17 posts
Posted May 9, 2017
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)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45660 posts
Posted May 9, 2017

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

  • Quote

Share this post


Link to post
Share on other sites

GeorgeTsak    0

GeorgeTsak

GeorgeTsak    0

  • Tree Puncher
  • GeorgeTsak
  • Members
  • 0
  • 17 posts
Posted May 9, 2017
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....

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45660 posts
Posted May 9, 2017

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.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

GeorgeTsak    0

GeorgeTsak

GeorgeTsak    0

  • Tree Puncher
  • GeorgeTsak
  • Members
  • 0
  • 17 posts
Posted May 9, 2017
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! 

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • kdcswag
      Can't download forge (AdBlock Problem)

      By kdcswag · Posted 1 hour ago

      Are you even trying to fix the issue?
    • DaemonUmbra
      [solved]

      By DaemonUmbra · Posted 1 hour ago

      For future reference: 1.7.10 is no longer supported on this forum due to its age. Update to a modern version of Minecraft to receive support.
    • OdachiPlayz
      [solved]

      By OdachiPlayz · Posted 2 hours ago

      I DONT KNOW HOW TO DELETE THIS POST BUT IM DUMB AND SOLVED THE ISSUE MYSELF ADMINS PLEASE DELETE  
    • KingMax
      Endsieg WW2 - Server due to start very soon - Working guns and vehicles!

      By KingMax · Posted 2 hours ago

      Greetings Comrade/Captain/Hauptmann! Welcome to Europe's final theater of war, Scandinavia! Despite the fall of Berlin the third Reich continues to hold out in Norway and the surrounding areas, the war is not yet over. Ultimate Victory will require many more battles to be fought. Infrastructure will need to be built, tanks, planes and ships shall have to be designed and produced and factories will be needed to produce the weapons of war.Endsieg has a multitude of special mechanics found on almost no other MC servers: fully functional ground, air and sea vehicles, guns, factories and more!Will you fight for the Allies to liberate Norway from tyranny?Will you defend the Soviet motherland by finally defeating the fascist menace?Will you take up the mantle of saving the remains of the Third Reich?Will you preserve the territorial integrity of the Republic of Finland?Will you help the Kingdom of Sweden once again rise to prominence as a Baltic powerhouse?Due to launch in a short matter of days or weeks, join our discord!discord.gg/anp3BJQ
    • Crack3dC0d3
      [1.14.4] Multiple models on the same item.

      By Crack3dC0d3 · Posted 2 hours ago

      bump
  • Topics

    • kdcswag
      9
      Can't download forge (AdBlock Problem)

      By kdcswag
      Started December 1

    • OdachiPlayz
      1
      [solved]

      By OdachiPlayz
      Started 2 hours ago

    • KingMax
      0
      Endsieg WW2 - Server due to start very soon - Working guns and vehicles!

      By KingMax
      Started 2 hours ago

    • Crack3dC0d3
      4
      [1.14.4] Multiple models on the same item.

      By Crack3dC0d3
      Started December 2

    • snivinia
      2
      unable to connect to friend's modded server

      By snivinia
      Started 20 hours ago

  • Who's Online (See full list)

    • saxon564
    • coolsim
    • snivinia
    • CelloKit
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Sync Config between Client and Server
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community