Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
NullReferenceFix
Fixes a vanilla Valheim bug where ZNetScene.RemoveObjects throws a NullReferenceException every frame forever once triggered.
| Date uploaded | a day ago |
| Version | 1.0.0 |
| Download link | korCaptain-NullReferenceFix-1.0.0.zip |
| Downloads | 10 |
| Dependency string | korCaptain-NullReferenceFix-1.0.0 |
This mod requires the following mods to function
denikson-BepInExPack_Valheim
BepInEx pack for Valheim. Preconfigured and includes unstripped Unity DLLs.
Preferred version: 5.4.2201README
NullReferenceFix
Tiny standalone patch for a long-standing vanilla Valheim bug: a NullReferenceException in
ZNetScene.RemoveObjects that, once triggered, repeats every single frame for the rest of
your play session, spamming the log and wasting CPU.
한국어 설명 보기 | English Description
🇰🇷 한국어 (Korean)
개요
NullReferenceFix는 발헤임 바닐라 엔진에 원래부터 있던 버그 하나를 고치는 아주 가벼운 단일 목적 모드입니다.
특정 몬스터/오브젝트 모드와 관계없이, 순수 바닐라 상태에서도 발생할 수 있는 문제입니다.
📦 필수 모드 (Dependencies)
| 모드 | 버전 | 필수 여부 |
|---|---|---|
| BepInExPack_Valheim | 5.4.2200+ | 필수 |
그 외 의존성 없음. 다른 모드와 자유롭게 함께 설치 가능합니다.
🐛 어떤 버그인가요?
같은 프레임 안에서 어떤 ZNetView의 GameObject가 다른 경로로 먼저 파괴되면, 바닐라
ZNetScene.RemoveObjects가 그 오브젝트를 내부 추적 딕셔너리(m_instances)에서 제거하기도
전에 NullReferenceException을 던집니다. 이 예외 때문에 문제의 entry가 딕셔너리에서 끝내
제거되지 못하고 남아버리고, 그 결과 다음 프레임에도 똑같은 예외가 또 발생 — 이 과정이
세션이 끝날 때까지 매 프레임 무한 반복됩니다.
이건 특정 모드가 만든 버그가 아니라 발헤임 엔진 자체의 오래된 결함입니다. 모드를 하나도 설치하지 않아도 발생할 수 있으며, 몬스터 스폰/디스폰이 잦은 상황(전투, 대규모 소환 등)일수록 더 쉽게 걸립니다.
🔧 이 모드가 하는 일
ZNetScene.RemoveObjects에 Harmony Finalizer 패치 하나만 추가합니다:
- 해당
NullReferenceException만 정확히 잡아냅니다 (다른 종류의 예외는 그대로 통과시킵니다). - 이미 파괴된(fake-null)
ZNetViewentry를m_instances에서 직접 제거합니다. - 단순히 로그만 숨기는 게 아니라, 깨진 상태 자체를 정리해서 무한 반복을 실제로 멈춥니다.
다른 모드의 코드는 전혀 건드리지 않고, 오직 바닐라 ZNetScene만 패치합니다 — 어떤 모드팩에
넣어도 충돌 걱정 없이 사용 가능합니다.
📥 설치 방법
- 권장: r2modman/Thunderstore에서 자동 설치
- 수동:
NullReferenceFix.dll을BepInEx/plugins/폴더에 복사
이 버그는 네트워크로 동기화되지 않는 로컬 상태 문제라서, 서버와 각 클라이언트가 각자 독립적으로 겪을 수 있습니다. 한쪽에만 설치하면 그쪽만 고쳐집니다 — 멀티플레이 환경이라면 서버 + 접속하는 모든 클라이언트에 설치하는 것을 권장합니다.
🏴 English
Overview
NullReferenceFix is a tiny, single-purpose mod that fixes one long-standing bug in vanilla
Valheim itself. It has nothing to do with any specific monster/object mod — it can happen on a
completely vanilla install too.
📦 Required Mods (Dependencies)
| Mod | Version | Required |
|---|---|---|
| BepInExPack_Valheim | 5.4.2200+ | Required |
No other dependencies. Safe to install alongside any other mods.
🐛 What's the bug?
If a ZNetView's GameObject is destroyed by something else in the same frame that vanilla
ZNetScene.RemoveObjects tries to clean it up, the method throws a NullReferenceException
before it can reach the line that removes the stale entry from its internal tracking dictionary
(m_instances). Because that entry never gets removed, the exact same exception fires again on
the very next frame — and every frame after that, for the rest of the session.
This is vanilla engine behavior, not something any particular mod causes. It can happen with zero mods installed; busier games (more monster spawns/despawns, heavy combat) simply hit the underlying race condition more often.
🔧 What this mod does
A single Harmony Finalizer patch on ZNetScene.RemoveObjects:
- Catches only that specific
NullReferenceException— any other exception passes through untouched. - Removes the already-destroyed (stale)
ZNetViewentry fromm_instancesdirectly. - This actually clears the broken state instead of just muting the log — the infinite loop stops for good, not just for one frame.
It doesn't touch any other mod's code, only vanilla ZNetScene — safe to drop into any
modpack.
📥 Installation
- Recommended: Install via r2modman/Thunderstore
- Manual: Copy
NullReferenceFix.dllintoBepInEx/plugins/
This bug is local state, not something synced over the network — the server and each client can hit it independently. Installing on only one side only fixes that side. In multiplayer, install it on the server and every connected client to be safe.
🎮 My Other Mods / 함께 즐기면 더 좋은 모드
🌳 CaptainSkillTree
👹 MonsterModifiers
🎵 CaptainAudio
📝 Credits / 크레딧
- Developer / 개발자: KorCaptain
- Framework / 프레임워크: BepInEx, Harmony
💬 Support / 지원
- Discord: KorCaptainSkillTree_MOD_Server - https://discord.gg/W26PTxYhug
- Ko-fi: https://ko-fi.com/korcaptain
- E-mail: [email protected]
- Issues: Report bugs and suggestions on Discord
- 문제 보고: Discord에서 버그 및 제안사항 보고
📜 License / 라이선스
Developer - KorCaptain
Enjoy a quieter log file! / 조용해진 로그를 즐기세요!
CHANGELOG
1.0.3 (긴급 패치 / Hotfix)
- 이전 배포(1.0.1, 1.0.2)에서 실수로 플러그인 DLL이 패키지에서 누락되어 모드가 전혀 동작하지 않던 문제를 수정했습니다.
- Fixed: the plugin DLL was accidentally missing from the previous releases (1.0.1, 1.0.2), so the mod did not work at all. This release restores the DLL.