Valheim
Install with App

Details

Latest version
1.0.0
Last Updated
First Uploaded
Downloads
21
Likes
0
Size
16KB
Dependants
ADDatHost Valheim hosting
€1

RunicInventoryFix

⚠️ 请先读:这不是 bug / Applicability Notice

中文

这不是 bug。 Chazman-RunicInventoryJStack424-Stackmaster 两个模组本身都没有问题, 它们各自都完全按自己的设计正常工作。这只是两个独立开发的模组恰好都把 LeftAlt 选作了自己的 修饰键,属于「按键撞车」这种纯粹的巧合,不是任何一方的编码错误

  • 原模组作者不应被追责。 本补丁与 ChazmanJStack424 两位作者没有任何关系, 也没有经过他们的同意或审查。有问题请找我,不要去打扰原作者
  • 本补丁只在同时装了这两个模组、并且你在意 Stackmaster 那套 Alt+鼠标 手势时才有意义。 只装其中一个模组 ⇒ 根本不存在冲突,装本补丁纯属多余。
  • 本补丁只做一件事:让 RunicInventory 的鼠标锁格手势不再拦截输入。 不改任何数值、不加任何功能、不碰存档格式。
  • 这是一个取舍,不是「谁对谁错」:本补丁选择保留 Stackmaster 的手势、关掉 RunicInventory 的。 如果你的偏好相反,不要装本补丁,改成把 Stackmaster 的 Storage-action keybind 修饰键从 LeftAlt 换成别的键即可(两个模组的功能都能保住,见文末)。
  • 上游任意一方之后若自行解决了这个撞车,请优先升级上游并停用本补丁

English:

This is not a bug. Neither Chazman-RunicInventory nor JStack424-Stackmaster is defective — both work exactly as designed. Two independently developed mods simply happened to pick LeftAlt as their modifier key. It is a plain hotkey collision, not a coding error on anyone's part.

  • The original authors should not be blamed. This patch is unaffiliated with and not endorsed by Chazman or JStack424. Report anything to me, not to them.
  • It only matters if you run both mods and care about Stackmaster's Alt+mouse gestures. With only one of them installed there is no collision at all, and this patch is pointless.
  • It does exactly one thing: stop RunicInventory's mouse lock gesture from intercepting input. No values changed, no features added, no save format touched.
  • This is a trade-off, not a verdict: it keeps Stackmaster's gestures and disables RunicInventory's. If you prefer the opposite, do not install this — instead change Stackmaster's Storage-action keybind modifier away from LeftAlt (see the end of this page).

🤖 本模组的代码由 AI 生成(AI Generated),需求、验证与发布由人类完成。


它解决的是什么

两个模组都拿 LeftAlt 当修饰键,而 RunicInventory 的手势补丁点更靠上游:

InventoryGrid.OnRightDown          ← RunicInventory 补丁在这里(上游)
   └─ m_onRightClick 委托
        └─ InventoryGui.OnRightClickItem   ← Stackmaster 的 Alt+右键 挂在这里(下游)

RunicInventory 的补丁逻辑是:

// InventoryGridRightClickLockPatch.Prefix —— 补丁 InventoryGrid.OnRightDown
return !InventoryRuntime.TryTogglePointerLock(grid, handler);

只要 TryTogglePointerLock 返回 true,Prefix 就 return false原版 OnRightDown 整条不执行 ⇒ 它内部的 m_onRightClick 委托不会被调用 ⇒ 挂在下游的 Stackmaster 右键功能永远收不到调用(症状就是「静默失效」,连报错都没有)。

TryTogglePointerLock 在下列情况下都会返回 true:

情况 结果
RequireLockState() 为假(锁功能不可用:尺寸不匹配 / 持久化状态对不上) 返回 true ⇒ 掐断
Alt+右键没落在有效的背包格子上 返回 true ⇒ 掐断
成功切换了锁定 返回 true ⇒ 掐断

⇒ 实际上「按住 Alt 在玩家背包上点右键」几乎必然掐断整条链路

顺带澄清一个容易误判的点:RunicInventory 补丁了 InventoryGui.OnSelectedItem (Stackmaster 的 Alt+左键落点),但它的 InventoryRuntime.AllowSelectedAction恒返回 true(IL 全文只有 ldc.i4.1; ret)⇒ 对左键不构成拦截。 也就是说按代码推演,被真正掐断的是 Alt + 右键,不是左键。

它是怎么修的

TryTogglePointerLock 在 RunicInventory 1.1.9 里只有一个调用点 (已用 member_refs_dll.py 反查确认),所以补这一个方法就够:

[HarmonyPatch(typeof(InventoryRuntime), "TryTogglePointerLock", ...)]   // 实际用反射定位
static bool Prefix(ref bool __result)
{
    __result = false;
    return false;                 // false = 不执行原方法
}

⇒ 该方法恒返回 false ⇒ RunicInventory 自己的 Prefix 算出 !false = true放行原版 ⇒ Stackmaster 的 OnRightClickItem / OnSelectedItem 都能正常收到调用。

为什么用 Prefix 跳过,而不是 Postfix 只改返回值(重要)

TryTogglePointerLock 在命中格子时会内部真的调用 ToggleLockAt 去切换锁定。 若只用 Postfix 改返回值,锁定依然会被切换(副作用已经发生)—— 而我们要的是「手势彻底关掉」。 Prefix 跳过原方法还顺带避免了它在「锁不可用 / 没点到格子」时弹出的 Notify 提示。

刻意保留、绝不触碰的部分

保留项 原因
RunicInventory 键盘锁格键(默认 L + LeftAlt 它走 Plugin.Update → InventoryRuntime.Tick → KeyboardInput.ShortcutDown(ToggleLock) → ToggleFocusedLock与本补丁的目标方法无关
RunicInventory 的额外装备行 / 整理 / 拾取过滤 / UI / 拓扑 全部不涉及本补丁的目标方法
Stackmaster 的 Alt+左键 / Alt+右键 这正是要救回来的
Stackmaster 的 Alt+E 存料、合成/建造取料 不受影响

配置

BepInEx/config/s6652289.RunicInventoryFix.cfg

默认 说明
SuppressMouseLockGesture true 关掉 RunicInventory 的鼠标锁格手势。设 false = 本补丁什么都不做,冲突照旧
Verbose true 打印补丁安装与目标签名确认细节

⚠️ 开关不支持热切换Awake 时读取一次,改了要重启游戏。

怎么看它生效了

日志(BepInEx/LogOutput.log)里搜 [Fix]

[Fix] 已打补丁:RunicInventory.Integration.InventoryRuntime.TryTogglePointerLock → Prefix 恒返回 false(跳过原方法)
[Fix] 效果:RunicInventory 的『左Alt+右键』不再拦截 InventoryGrid.OnRightDown,
[Fix]       Stackmaster 的 Alt+左键 / Alt+右键 应恢复正常。
[Fix] 目标方法签名确认:Boolean TryTogglePointerLock(InventoryGrid, UIInputHandler)

关键判据:打开背包 → Alt + 左键 点物品 → 出现 Stackmaster: item protected. / Stackmaster: item unprotected. 提示 = 修好了。

若看到下面任一条,说明是环境问题而非补丁问题,本补丁不会做任何改动:

[Fix] 180 秒内没等到 RunicInventory.Integration.InventoryRuntime —— RunicInventory 可能没装或版本不匹配,本模组未做任何改动。
[Fix] 找到类型但没有 TryTogglePointerLock —— RunicInventory 版本不匹配,拒绝打补丁(本模组不做任何改动)。
[Fix] 目标方法签名不符(期望 实例方法 bool ...)—— 拒绝打补丁。

安装 / 卸载

  • 安装:把 RunicInventoryFix.dll 放到 BepInEx/plugins/RunicInventoryFix/
  • 卸载:删掉该目录
  • 依赖:denikson-BepInExPack_Valheim + Chazman-RunicInventory不需要 Stackmaster 才能启动,但没装 Stackmaster 时本补丁没有意义。
  • 纯客户端,不联网,不引用 RunicInventory.dll(全部走反射定位) ⇒ RunicInventory 没装或不兼容时本模组只是安静地不做事,不会导致启动失败

如果你其实是想要相反的效果

不要装本补丁。改成在 Stackmaster 的 cfg 里把修饰键挪开:

# BepInEx/config/com.jstack424.stackmaster.cfg
# 默认:Storage-action keybind = E + LeftAlt
Storage-action keybind = E + LeftControl

Stackmaster 的这一个值同时驱动 Alt+E(存料)、Alt+左键(保护物品)、Alt+右键 ⇒ 改成 LeftControl 就整体挪开,两个模组的功能都能保住(代价是 Stackmaster 的组合键从 Alt 变 Ctrl)。

源码

D:\WorkBuddy\RunicInventoryFix\(本地工作区)

已知边界

  • 本文的结论全部来自静态 IL 反汇编RunicInventory.dll 1.1.9 + Stackmaster.dll 1.1.4) 与 cfg,未做联机/专用服务器场景的实机验证
  • 只验证到 RunicInventory 1.1.9。上游若改掉 TryTogglePointerLock 的名字或签名, 本补丁会在安装阶段打印「拒绝打补丁」并保持不做任何事(不会造成新的破坏)。
  • 本补丁不处理手柄(Controller)侧的按键冲突:那边 RunicInventory 走的是 ControllerGetButton* 系列补丁 + ControllerChordSession,与鼠标手势是两条独立链路。
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro