SwampKeyPersist

版本 v1.1.0·更新於 2026-06-24

Swamp/Crypt Key persists indefinitely - but only on servers that also run this mod (server-sanctioned, anti-cheat).

模組介紹 作者原文

Swamp Key Persist

Makes the Swamp Key / Crypt Key ($item_cryptkey) persist indefinitely instead of being

consumed one-per-use when opening a Sunken Crypt gate.

Why this exists

In vanilla Valheim the Crypt Key is not consumed — you keep it forever. Some mods change this

by hooking Door.Open and removing one key from your inventory every time you open a Sunken

Crypt gate (with no config option to turn it off). This mod counters that behavior so your key

behaves like vanilla again: open as many crypts as you like, the key stays.

How it works

Patch-order-proof and mod-agnostic. A Door.Open Prefix opens a short "protect window" and

records the door's key item name; a Finalizer closes it. Because Harmony finalizers run

after every postfix, the window reliably spans any other mod's Door.Open postfix regardless

of patch order. While the window is open, prefixes on Inventory.RemoveOneItem / RemoveItem

refuse to delete that key (and report success, so the other mod's logic is unaffected).

It only protects the key during a crypt-gate open — you can still drop, store, trade, or craft

with the key normally.

Anti-cheat: server-sanctioned

The key consume is a client-side operation, so on its own this DLL could be carried to any server

to keep keys. To prevent that, key protection only activates on a server that also runs this

mod (or when you are the host). A sanctioning server sends each connecting client a tiny

ServerHello handshake RPC; a client only protects keys once it has received that Hello. On a

server that does not run the mod, no Hello arrives, protection stays off, and keys consume

normally. The gate is hardcoded (not exposed in config) so it can't be flipped off to cheat

elsewhere.

Installation

This is a client + server mod. The server must run it to sanction key-persistence, and

each player must also install it (the consume happens on the client). Install on both with a

mod manager, or manually drop SwampKeyPersist.dll into BepInEx/plugins.

Configuration

baka.SwampKeyPersist.cfg:

| Setting | Default | Description |

| --- | --- | --- |

| Enabled | true | Master switch. |

| ProtectAllKeyedDoors | false | Protect the key of ANY keyed door, not just Sunken Crypt gates. |

| CryptDoorNameContains | sunken_crypt_gate | Comma-separated substrings; a door whose GameObject name contains any of these is treated as a crypt gate whose key must persist. |

Verifying it works

After opening a Sunken Crypt gate, the BepInEx console logs:

Preserved door key '$item_cryptkey' (blocked consume on crypt-gate open).

安裝與使用 安裝:BepInEx 外掛

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

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

前置依賴

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

denikson-BepInExPack_Valheim

檔案與校驗

檔案名稱
SwampKeyPersist-1.1.0.zip
檔案大小
151.6 KiB