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.
StoreAndCraftMucCompat
Lets StoreAndCraft's take-stack hotkey pull from chests another player has open, when Multi User Chest is installed. One guard removed, nothing else changed.
| Last updated | 2 days ago |
| Total downloads | 32 |
| Total rating | 0 |
| Categories | Tweaks Server-side Client-side AI Generated |
| Dependency string | PICS0UL-StoreAndCraftMucCompat-1.0.0 |
| Dependants | 0 other packages depend on this package |
This mod requires the following mods to function
denikson-BepInExPack_Valheim
BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.
Preferred version: 5.4.2350Morda-StoreAndCraft
Base that works with you: auto-store, dump, craft from chests, [E] + auto-fill, cooking auto-drop [N], Storage Displays, favorites, search. Server + all clients.
Preferred version: 1.3.3MSchmoecker-MultiUserChest
Allows multiple players to interact with the same chest at the same time
Preferred version: 0.6.2README
StoreAndCraft MUC Compat
Multi User Chest makes shared chests safe. This lets StoreAndCraft use them.
A one-guard compatibility patch between StoreAndCraft and Multi User Chest. Install it and forget about it.
The problem
Run both mods and almost everything already works. StoreAndCraft was built with the same rule Multi User Chest enforces — never steal ownership of a chest someone else is using — so its dump, craft-pull, station feed and auto-store all route through its own RPC to the chest's owner and stay correct.
One feature doesn't. Take-stack (Ctrl + middle click by default, "fill the hovered stack from nearby chests") checks whether the chest is in use before asking its owner:
if (chest.IsInUse())
return 0;
That's the right call in vanilla, where touching a chest someone has open risks losing items. But Multi User Chest exists to make exactly that safe. With both mods installed the check still fires, so take-stack silently does nothing on any chest a teammate happens to have open — the one situation the chest mod was added to fix.
The fix
This mod neutralises that single check, and only while Multi User Chest is loaded.
The refill still goes through StoreAndCraft's own KAC_Remove RPC to the chest's owner. Multi User Chest still reconciles concurrent access. Nothing takes ownership from anyone. The only thing that changes is that take-stack stops giving up early.
| Before | After |
|---|---|
| Take-stack does nothing on chests others have open | Take-stack works on every chest in range |
| Everything else | Unchanged |
What it deliberately does not touch
StoreAndCraft has two other owner-gated features that look like the same restriction:
- Sort (
SortOpenChest) - Auto-stack (
AutoStack.Tick)
Both bail out on chests you don't own, and both must keep doing so. They rearrange chests by writing m_gridPos and m_stack as direct field assignments, which Multi User Chest cannot intercept — it hooks Inventory.AddItem and Inventory.RemoveItem. Lifting those guards would desync the chest and can lose items. They are correct as written and this mod leaves them alone.
Requirements
Both mods must be installed; BepInEx will not load this without them.
- StoreAndCraft 1.3.3 or newer
- Multi User Chest 0.6.2 or newer
Verified against StoreAndCraft 1.3.3 and its current source. The guard this mod removes is unchanged as far back as 1.1.x, so older versions work too — 1.3.3 is simply the floor worth installing.
Client-side. It changes nothing on the wire, so it does not need to be on the server and players without it simply keep StoreAndCraft's stock behaviour. Multi User Chest itself must still be on the server and on every client at a matching version — that requirement is unchanged.
Configuration
BepInEx/config/com.pics0ul.valheim.storeandcraftmuccompat.cfg
| Setting | Default | Meaning |
|---|---|---|
Enabled |
true |
Turn off to restore StoreAndCraft's stock behaviour without uninstalling. |
Checking it worked
On startup the log prints:
StoreAndCraft MUC Compat 1.0.0 loaded - take-stack enabled on chests other players have open.
If StoreAndCraft ever restructures that method, you get a warning naming exactly what was not found instead of silence:
StoreAndCraft.TransferService.TakeIntoExistingStack was not found.
In that case the mod does nothing and nothing is at risk — but tell me, and it gets fixed.
To see it work you need two players: have someone stand in an open chest, hover a partial stack in your inventory, and press take-stack. Before this mod that did nothing.
How it works
A single Harmony transpiler on StoreAndCraft.TransferService.TakeIntoExistingStack swaps the Container.IsInUse() call for a predicate of the same shape:
public static bool BlocksRemoteTakeStack(Container container)
{
if (container == null) return false;
if (Plugin.Enabled != null && !Plugin.Enabled.Value) return container.IsInUse();
return false;
}
Same argument in, same type out, so StoreAndCraft's surrounding branch and the RPC after it are untouched. The target is resolved by type and method name rather than by offset, which is why it spans StoreAndCraft 1.1.x through 1.3.x unchanged.
Credits
- Morda for StoreAndCraft
- MSchmoecker for Multi User Chest, whose
QuickStackPatchis the model this follows - Quick Stack Store Sort Trash Restock, whose
ShouldAffectNonOwnerContainerdrops the same check the same way
License
MIT