ValheimEffectListCompat

版本 v0.1.9·更新於 2026-09-26

Compatibility bridge for Valheim 1.0 (Unity 6): restores EffectList.Create 5-arg forwarder, Character.Message 4-arg forwarder (fixes OdinStorage), and fixes ZNetScene.RemoveObjects NRE cascade.

模組介紹 作者原文

Valheim Compatibility Bridges

-orange.svg)

A lightweight, robust two-component compatibility mod designed to restore legacy mod compatibility and eliminate game-breaking NullReferenceException cascades in Valheim 1.0 (Unity 6).

The Problems This Mod Solves

When Iron Gate upgraded Valheim to 1.0 (Unity 6000), two critical breaking changes broke dozens of existing mods and destabilized sector unloading:

  • MissingMethodException on EffectList.Create

In Valheim 1.0, Iron Gate added a 6th parameter (ZDOID targetZDO) to EffectList.Create:

// Legacy signature (used by dozens of existing mods):

EffectList.Create(Vector3 pos, Quaternion rot, Transform baseChild, float scale, int itemVariant)

// Valheim 1.0 signature:

EffectList.Create(Vector3 pos, Quaternion rot, Transform baseChild, float scale, int itemVariant, ZDOID targetZDO)

Any mod compiled against older versions of Valheim throws:

System.MissingMethodException: Method not found: EffectList.Create

  • AmbiguousMatchException in Harmony

When multiple overloads exist without proper parameter discrimination, Harmony lookups by method name fail with:

System.Reflection.AmbiguousMatchException: Ambiguous match found for EffectList.Create

  • Unity 6 ZNetScene.RemoveObjects NRE Cascade (5,000+ Errors per Session)

In Unity 6, native C++ object destruction and managed reference lifetime behavior changed. When objects leave player sectors, ZNetScene.RemoveObjects iterates m_instances.Values. If an external mod destroyed a ZNetView or its associated GameObject during gameplay, vanilla code dereferences the dead object:

NullReferenceException: Object reference not set to an instance of an object

at ZNetScene.RemoveObjects (System.Collections.Generic.List1[ZDO] currentNearObjects, System.Collections.Generic.List1[ZDO] currentDistantObjects)

at ZNetScene.CreateDestroyObjects ()

at ZNetScene.Update ()

This causes an infinite loop of thousands of NREs every frame, severe stuttering, memory leaks, and broken entity despawning.

How It Works

This package provides a clean, two-layer architecture:

Valheim Game Launch

│

├──► 1. Preloader Patcher (ValheimEffectListCompat.dll)

│ ├─ Injected via Mono.Cecil before game assemblies load

│ ├─ Adds legacy 5-argument EffectList.Create forwarder

│ └─ Installs Harmony resolver hook for by-name patches

│

└──► 2. Runtime Scene Plugin (ValheimSceneCompat.dll)

├─ Intercepts ZNetScene.RemoveObjects

├─ Phase 1: Cleans dead/corrupted keys from m_instances

├─ Phase 2: Safely unloads entities leaving active sector

├─ Phase 3: Cleans up non-persistent owned ZDOs in ZDOMan

└─ Installs safety Finalizers on CreateDestroyObjects & RemoveObjects

Component 1: Cecil Preloader (ValheimEffectListCompat.dll)

  • Location: BepInEx/patchers/Ntxfloy-ValheimEffectListCompat/ValheimEffectListCompat.dll
  • Target: netstandard2.0 with zero dependencies on game assemblies.
  • EffectList Forwarder: Injects a lightweight IL wrapper that forwards 5-argument calls to the native 6-argument method with a default ZDOID.None.
  • Harmony Resolver: Automatically directs ambiguous Harmony EffectList.Create patches to the primary game implementation by metadata token order.

Component 2: Runtime Scene Plugin (ValheimSceneCompat.dll)

  • Location: BepInEx/plugins/Ntxfloy-ValheimSceneCompat/ValheimSceneCompat.dll
  • Target: netstandard2.1 standard BaseUnityPlugin.
  • Safe Dictionary Sanitization: Sweeps and removes null/destroyed keys and dead references before iterating.
  • Guaranteed Removal: m_instances.Remove(zdo) is guaranteed in a finally block, ensuring clean sector transitions.
  • Vanilla Parity for Non-Persistent ZDOs: Correctly unregisters temporary owned entities (arrows, projectiles, transient VFX) via ZDOMan.DestroyZDO inside an isolated block, preventing world database leaks.
  • Safety Finalizers: Catches and suppresses any rogue exceptions in CreateDestroyObjects and RemoveObjects, ensuring the game's main loop never aborts.
  • Smart Error Throttling: Logs the first occurrenc

安裝與使用 安裝:BepInEx 外掛

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

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

前置依賴

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

denikson-BepInExPack_Valheim

檔案與校驗

檔案名稱
ValheimEffectListCompat-0.1.9.zip
檔案大小
15.9 KiB