Jump to content

[SOLVED][1.8] Syncing config files across server and client?


Apace

Recommended Posts

Hello guys,

 

I've been following TheGreyGhost's great MinecraftByExample series and have set up a configuration file for my mod.

Depending on the configuration file, the mod makes certain blocks unbreakable.

The config's loading/saving/using works perfectly in SSP.

However, when in SMP, the client still uses its own configuration file (by how awesome Forge is, I've expected it to synchronize the config automagically).

So, if the clients config file allows harvesting block A for example, and not block B, and the servers config file is the other way around, the client won't be able to mine block B (I'm setting the break speed to 0f in the BreakSpeed event), but the player will be able to start breaking block A, only to have it instantly respawn on breaking the block.

Also, if the client connects to a server without the mod installed, it won't be able to break the blocks as set up in the config file either.

 

My question is: Is there an easy work-around for this? If not, will I have to set up custom network messages which get sent when a client joins the server? If yes, is there any good tutorial out here on how to do stuff involving networking in Minecraft?

 

Thanks in advance,

 

- Apace

Link to comment
Share on other sites

Short: There is no workaround, your thinking is good.

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-x-1-8-customizing-packet-handling-with

Nice and tidy: http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

Important info: http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html

 

Longer: You will need to set client's hardness from packet after logging on (PlayerLoggedInEvent).

After sending that info you can cache it in client's config.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Yes, this can be a bit tricky.

 

Usually the configuration file is loaded/synced in the common proxy so technically it will be loaded on both sides. But the actual file would of course not be the same file on two different computers when you're running server/client or LAN.

 

So the "safe" thing to do would be to sync as needed. In the case where the config info is only used by server, then there is no problem -- just the config on the server will be used and there is only one so there is no conflict. Similarly, in some cases you might have config options that are purely client side (like maybe change rendering, or add info in HUD) and you could just allow each client to load their own config and it is okay if they are different. But in other cases you might have some config that is used on both sides. I think you're right that the config is not synced automatically so the safe way to do that is to load only on server side and sync the values to client using packets.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Thanks to both of you guys for answering!

 

I feared that there was no easy way to do this. Alright then, I guess I'll get to work.

 

Will mark as solved for now, hopefully it will stay that way. ;)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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