Jump to content

Recommended Posts

Posted (edited)

I'm trying to make a config option that the client doesn't sync with the server. I want the option to be toggleable in game via the Mod Options. I'm currently using the config annotations provided by Forge. The options display and operate correctly for singleplayer. However, when connecting to servers, the options are synced with the server and changing them does nothing while in multiplayer. I've seen other mods with client side only config, but I have been having a hard time looking through their source code. Here is the only class I have that handles config things:

package dialupking.nepcraft.managers;

import dialupking.nepcraft.Nepcraft;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;

/**
 * Handles configuration data.
 * 
 * @author Nickolas Bradham
 *
 */
@Config(modid = Nepcraft.S_MODID)
public final class NepConfigManager {

	@Config.Comment("Voice cool-down duration in ms.")
	@Config.RangeInt(min = 0)
	public static int voiceCool = 1000;
	@Config.Comment("Special activation cool-down duration in ms.")
	@Config.RangeInt(min = 0)
	public static int specialCool = 10000;
	@Config.Comment("Special duration in ticks.")
	@Config.RangeInt(min = 0)
	public static int specialDuration = 100;

	@Config.Comment("Use alt voice lines.")
	public static boolean useAltVoice = false; // Player decides this on client side.

	/**
	 * @see ConfigManager#sync
	 */
	public final void sync() {
		ConfigManager.sync(Nepcraft.S_MODID, Config.Type.INSTANCE);
	}
}

The only other thing is my main mod class calls the sync() function in the onConfigChanged() SubscribeEvent.

 

Any help would be appreciated. Thanks!

Edited by Dialup_King
Inaccurate information because it was late/
Posted

I found out that the config sync has nothing to do with the actual issue. It was actually due to all processing being done server side so the client decides nothing. Hindsite, I should have realised this initially. So my new approach is to send a packet on login and config change that tells the server which voice to use. It will be stored in the player NBT data. Then, whenever a voice line is played, it looks at the NBT data. I doubt this is the right, or even a good, way to do this but it works.

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.