ModConfigEnforcer

版本 v4.0.4·更新於 2025-11-15

Mod Config Enforcer is a utility mod for mod authors. It allows them to support servers setting configs and then enforcing those settings onto connecting clients using their mod.

模組介紹 作者原文

UPDATE: Version 4.0 involves enough changes to completely deprecate previous versions. Any mods relying on versions 2.X will no long be supported and will have to update themselves. MCE will now conflict with the Better Networking mod, due to both mods making changes to Valheim's networking subsystem. You can disable MCE's networking optimizations via its new config file. MCE now removes buffer limits for Steam users, making Better Networking unnecessary when using mods that also use MCE. This change was necessary to support the sending of large data packages in an optimized way.

UPDATE: Version 3.0 is a major version change due to breaking backwards compatibility. If you are a user, do not update MCE unless a mod you are using that uses it tells you to. This change is a lot less painful than the version 2 break, and the biggest benefit is the ability for mod authors to now take advantage of MCE syncing their configs without having a hard dependency on MCE. This means for playing by yourself, MCE isn't required to have. Mod authors can now, with a little code, have their mods be "MCE Compatible" with no required downloading or bundling.

Mod Config Enforcer is a utility mod for mod authors. It allows them to support servers setting configs and then enforcing those settings onto connecting clients using their mod. The mod allows mod authors to define config variables that can be local only (no server enforcement) as well as server enforced.

Manual Installation: Download and copy the ModConfigEnforcer.dll to your Valheim\Bepinex\plugins folder.

If you are downloading MCE because another mod relies on it for server config enforcement, you're done! When setup correctly, you will see two new DLL files created in the plugins folder, ZstdNet.dll and libzstd.dll. These files are necessary for MCE to compress and decompress ZPackage data for optimal performance.

Hard dependency usage is still supported as it's the best way to do more complex configuration management with MCE, but it is no longer the only option. MCE v3 now supports config-by-convention, which is very easy to setup and ideal for smaller mods which simply use ConfigEntry objects for their Bepinex config. For a mod to be MCE compatible with automated config discovery, simply follow this example:

public class Plugin: BaseUnityPlugin

{

// this field is required to exist and be set to an object in order for MCE to process your mod

object AutomatedConfigDiscovery;

// this field will be discovered and picked up by MCE

public ConfigEntry Something;

// this field will be discovered and picked up by MCE, with the value expected to be a full path to a file you want servers to sync to clients

public string File_TestFile = "C:\Steam\steamapps\common\Valheim\BepInEx\plugins\testfile.txt";

// this field will be ignored by MCE and thus not synced from servers to clients

[NonSerialized]

public ConfigEntry OtherVar;

public Awake()

{

 // setting this here in Awake is required in order to guarantee MCE's automated config discovery finding your mod properly

 AutomatedConfigDiscovery = this;

 // all ConfigEntry fields you want MCE to discover must be bound before Awake ends for your mod

 Something = Config.Bind("Section", "Something", 0, "Description");

 OtherVar = Config.Bind("Section", "Other Var", true, "A config setting that will be ignored by MCE due to the [NonSerialized] attribute on it");

}

// these are entirely optional. If you don't have them, your mod simply won't get a callback for when these events happen

void ServerConfigReceived() {}

void ConfigReloaded() {}

 // if file syncing is desired, this method is required to exist

 void FileChanged() {}

}

If your Plugin class (name isn't required to be "Plugin", just that it extends BaseUnityPlugin, which is required for your mod to work with Valheim anyways), doesn't contain a field named "AutomatedConfigDiscovery" (spelling matters but not capitalization), MCE will not proces

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。 多人連線時,主機與所有用戶端需要安裝一致的模組。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

denikson-BepInExPack_Valheim

檔案與校驗

檔案名稱
ModConfigEnforcer-4.0.4.zip
檔案大小
405.8 KiB