You are viewing a potentially older version of this package. View all versions.
trentinidev-GorilaChestMod-2.3.0 icon

GorilaChestMod

Craft and build from nearby chests, oversized stacks inside chests, one button quick stack, and Alt click favorites that automatic moving never touches.

Date uploaded a month ago
Version 2.3.0
Download link trentinidev-GorilaChestMod-2.3.0.zip
Downloads 271
Dependency string trentinidev-GorilaChestMod-2.3.0

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2350 icon
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.2350

README

GorilaChestMod

Chest quality of life for Valheim, in four parts:

  1. Craft from chests. Craft, upgrade and build using the items inside the chests around you, without hauling anything into your inventory first.
  2. Oversized chest stacks. A chest slot holds far more than the vanilla limit, 100000 by default, so a chest full of wood is one slot instead of twenty. Your own inventory keeps the vanilla limits.
  3. Quick stack. One button, or the J key, that pushes matching items from your inventory into the chests in range. J is free in Valheim: V is auto pickup and G opens the hotbar radial.
  4. Favorites. Mark a stack with Alt + left click and automatic moving leaves it alone, both the quick stack above and the chest's own stack button.

Runs on the client and on a dedicated server.

Game version this was built against

Item Value
Game version 1.0.7
Steam build 25185596
Engine Unity 6000.0.75f1, Mono backend
Game code valheim_Data/Managed/assembly_valheim.dll

Because the backend is Mono and not IL2CPP, the usual modding path still applies: BepInEx 5 plus Harmony, patching in memory. No game file is modified.

Install

  1. Install BepInEx 5 for Valheim, the denikson-BepInExPack_Valheim package. Launch the game once so it creates its folders.
  2. Copy GorilaChestMod.dll into Valheim/BepInEx/plugins/GorilaChestMod/, or extract the -nexus.zip release over the game folder.
  3. Start the game. BepInEx/LogOutput.log should contain a line reading GorilaChestMod 2.3.0 loaded.

With r2modman or Thunderstore Mod Manager, use Import local mod and pick the -thunderstore.zip release. Do not mix a mod manager with a manual BepInEx install in the game root, that is the classic cause of a mod loading twice or not loading at all.

On a dedicated server

Full step by step for whoever runs the server, Windows, Linux and rented panels: docs/server-install.md.

The short version is the same as above, into the server's BepInEx/plugins, and every player needs it as well. The server half exists for two reasons:

  • A server that loads a chest into memory decides how large its stacks may be. A vanilla server would clamp an oversized stack back to the vanilla limit and destroy the excess the next time it wrote that chest out.
  • The server hands its chest stack settings to every client as they connect, so the whole session agrees on the limit.

Craft from chests and quick stack are decided entirely on the player's own machine, so those two still work fine against a vanilla server.

Configuration

BepInEx/config/dev.trentini.gorilachestmod.cfg is written on first launch and can be edited with the game closed.

Section Option Default What it does
Craft from chests Enabled true Count nearby chests when crafting, upgrading and building.
Craft from chests Range 20 Radius in meters. Quick stack uses the same radius.
Craft from chests UseForBuilding true Also pay hammer, hoe and cultivator costs from chests.
Craft from chests IncludeVehicleContainers true Include containers on carts and ships.
Chest stacks Enabled true Allow oversized stacks inside chests.
Chest stacks ChestStackSize 100000 How much one chest slot may hold. The server's value wins.
Chest stacks ShrinkStackText true Shrink a slot label when the numbers get long, so 100000/100000 fits.
Quick stack Enabled true Enable the button and the hotkey.
Quick stack SkipHotbar true Leave the hotbar row alone.
Quick stack ShowButton true Show the button in the inventory screen.
Quick stack ButtonOffset 0, 0 Nudge the button in canvas units from its spot beside the weight readout.
Quick stack ButtonLabel Stack to nearby chests Caption on the button, one word per line.
Quick stack Hotkey J Hotkey for quick stacking, inventory open or closed.
Quick stack HotkeyNeedsInventory false Require the inventory to be open for the hotkey.
Favorites Enabled true Allow stacks to be marked as untouchable.
Favorites Modifier LeftAlt Hold this and left click a stack to mark it. Either side key works.
Favorites ShowMarker true Draw a star on a marked slot.
Favorites Announce true Print a line when you mark or unmark a stack.
Debug Verbose false Log every withdrawal, move and patched call.

When you are connected to a server that has the mod, that server's Enabled and ChestStackSize under Chest stacks replace your local values for as long as you are connected. Everything else stays personal.

Which chests count

A chest is only used if it passes the same rules the game applies when you try to open it:

  • it is inside the configured radius;
  • privacy is Public, or Private with you as the creator of the piece, so group chests stay out exactly like in vanilla;
  • if the chest checks for a guard stone, you need access to that ward;
  • nobody else has it open, a chest in use by another player is skipped.

Before taking anything the mod claims network ownership of the chest through ZNetView.ClaimOwnership, which is what authorises writing the inventory back into the ZDO. That is the same mechanism the game uses for "take all".

How it works

Craft from chests

The game methods read the player inventory straight from the m_inventory field, with no extension point anywhere. Rather than injecting fake items into your backpack, the mod uses transpilers to rewrite only the inventory calls inside these methods. An instance call already carries this as its first stack argument, so a static method whose first parameter is the Inventory is a drop-in replacement and the rest of the method body is left untouched.

Game method Call swapped Why
Player.HaveRequirementItems CountItems unlocks the recipe and the craft button
Player.GetFirstRequiredItem CountItems, GetItem single ingredient recipes such as meads and feasts
Player.ConsumeResources RemoveItem pays for a craft and for a placed piece
Player.HaveRequirements(Piece) HaveItem, CountItems unlocks the building piece
InventoryGui.DoCrafting RemoveItem pays the single ingredient
InventoryGui.SetupRequirement CountItems the have/need numbers in the UI

Container.Awake registers every chest that spawns, so no FindObjectsOfType sweep is ever needed, and Player.UpdatePlacement and Hud.SetupPieceInfo mark the building context so UseForBuilding can be honoured.

Oversized chest stacks

The stack limit is the plain field ItemData.m_shared.m_maxStackSize, read in a handful of places inside Inventory and InventoryGrid. A transpiler turns each of those field reads into a call that also receives the inventory being worked on, so the same item type answers 1000 in a chest and the vanilla 50 in a backpack. The list of methods is discovered from the game's own IL at startup rather than hard coded, and written to the log.

That single change covers saving and loading too: the overload of Inventory.AddItem that rebuilds an inventory from its saved bytes clamps by the same field, which is why a vanilla server or a vanilla client would otherwise trim the excess away.

Three guards keep oversized stacks from leaking out of chests:

  • Inventory.AddItem(ItemData) splits a stack that is too large for its destination across several slots, so shift clicking 1000 wood out of a chest gives you twenty vanilla stacks.
  • The slot targeted Inventory.AddItem moves only a vanilla sized portion and reports the move as partial, so the rest stays in the chest.
  • ItemDrop.DropItem splits oversized stacks into several drops, so a destroyed chest scatters normal stacks instead of one impossible pile.

Quick stack

InventoryGui.Awake clones the game's own take all button, so it inherits the vanilla look, font and sounds, and anchors it under the weight readout, outside the item grid. It is shown while the inventory is open and there is a chest in range. The hotkey works with the inventory closed too, and holds off while a menu, the console, the chat or a text field has focus. Items move only into chests that already hold that item, equipped and quest items are skipped, and the hotbar is skipped unless you say otherwise.

Favorites

The mark is a single entry in the item's own custom data, the dictionary the game already serialises next to durability and quality. That buys three things without any bookkeeping: it is saved and loaded with the item, ItemData.Clone copies it so splitting a stack keeps both halves marked, and it travels with the stack when you move it by hand. Merging is the one case the game would drop, so the slot targeted Inventory.AddItem carries the mark over when either side had it.

The click is caught in InventoryGui.OnSelectedItem: with the modifier held the click toggles the mark and is swallowed, otherwise vanilla runs untouched. The star is painted into a texture once at startup, since the game UI has no star to borrow, and the same sprite is reused for every slot.

The chest's own stack button is honoured too. It already refuses to move what you have equipped, through Humanoid.IsItemEquiped, so a transpiler points that call at a check that also answers yes for a marked stack.

Server side

The plugin loads in valheim_server.exe as well as valheim.exe. On a server there is no local player, so craft from chests and quick stack simply never fire, while the stack limit patches do their job on every chest the server touches.

Config sync is two routed RPCs of the game's own network layer: a client asks once it is connected, the server answers with its chest stack settings, and a server never takes those values from a client.

Build

dotnet build -c Release

If Valheim lives somewhere else:

dotnet build -c Release -p:ValheimDir="D:\Steam\steamapps\common\Valheim"

Game references come straight from valheim_Data/Managed, and BepInEx plus Harmony come from the BepInEx NuGet feed, already configured in nuget.config. The build copies the dll into the r2modman profile when that folder exists, and otherwise into the game's own plugins folder.

Packaging and publishing

powershell -ExecutionPolicy Bypass -File packaging\build-package.ps1

Writes both release zips into dist/:

Zip Contents Where it goes
-thunderstore.zip manifest.json, icon.png, readme, changelog and the dll at the root Thunderstore, or Import local mod in r2modman
-nexus.zip BepInEx/plugins/GorilaChestMod/GorilaChestMod.dll plus readme and changelog Nexus Mods, extracted over the game folder

The script validates what usually gets an upload rejected: an x.y.z version, an icon that is exactly 256 by 256, a manifest name made only of letters, digits and underscores, and a description within the 250 character limit. It also checks that the compiled dll carries the same version as the csproj.

The version lives only in <Version> in GorilaChestMod.csproj. The GenerateBuildInfo target turns it into the constant the BepInPlugin attribute uses, and the packaging script reads the same property for manifest.json.

The icon comes from packaging/make-icon.ps1, which lays the mod name and the author over packaging/icon-source.png. Replace the source art or edit the bands and re-run it. packaging/make-icon-badge.ps1 draws the older gorilla roundel entirely in code, if you want a mark rather than a scene. docs/nexus-description.bbcode holds the Nexus page description, ready to paste. docs/thunderstore-publish.md covers the Thunderstore upload: which file, which team, which categories, and the checks the site runs.

Compatibility check after a game update

tools/PatchCheck opens assembly_valheim.dll with Mono.Cecil and asserts that every method the mod patches still exists with the same signature, that every call site the transpilers rewrite is still there, that the stack limit is still read where it needs to be, and that the mod side signatures still line up.

cd tools/PatchCheck
dotnet run

Expected output: ALL CHECKS PASSED. Run it first whenever Valheim updates, before launching the game.

Known limitations

  • Removing the mod leaves oversized stacks behind. Vanilla clamps a stack back to its normal limit when it loads a chest, and the excess is gone. Empty your chests, or lower ChestStackSize and let the chests settle, before you uninstall. The same applies to a player without the mod opening a chest that holds oversized stacks.
  • Repairing costs no materials in Valheim, so there is nothing to do there.
  • Smelters, kilns and other stations that take ore or wood through direct interaction are not fed from chests. Crafting, upgrading and building are.
  • The quick stack button is mouse driven, there is no gamepad binding for it yet.
  • A chest another player has open at that moment is skipped until they close it.

CHANGELOG

Changelog

2.5.0

  • New: the Deconstruct tab. A third tab beside Craft and Upgrade at every crafting station takes a crafted item apart and gives its materials back, including everything spent upgrading it. ReturnPercent sets how much comes back, from 50 to 100, and a server with the mod decides it for everyone.
  • This used to be a separate mod, GorilaDeconstruct. It is now part of GorilaChestMod and is no longer updated on its own. Remove GorilaDeconstruct before updating, or the tab is built twice.
  • Favorites are honoured there too: a marked stack is refused, like everywhere else the mod moves items for you.

2.4.2

  • Documentation only, the mod itself is unchanged from 2.4.1. The readme no longer carries the build and packaging sections, which spoke to whoever compiles the mod rather than to whoever plays with it.

2.4.1

  • Fixed: items could be lost when moving an oversized stack onto an occupied slot. The game swaps the two stacks there, and a swap takes the dragged stack out of its inventory before handing it over, so the part that did not fit in the destination belonged to nobody and was gone at the next save. Reported on Nexus, thank you.
  • An oversized stack now comes out in one go. Dragging 1000 wood into your inventory fills the slot you aimed at and spreads the rest over the free slots, instead of moving one vanilla stack per click.
  • Fixed: a chest slot past the vanilla limit lights up again while you drag a matching stack over it. The highlight asked the game for the space left in the stack, which knows nothing about chests and always answered with the vanilla limit.
  • A server no longer rewrites your config file. Its chest stack settings still apply while you are connected, but they are held in memory, so leaving the server gives you your own settings back.
  • Shift clicking into an almost full inventory can no longer duplicate or destroy part of a stack: each chunk now reports how many items really landed.
  • A hooked method that no longer has a stack limit read to replace is now an error in the log instead of silence, so a game update that moves them is visible; the counts per method are in the log under Verbose.
  • Built and checked against Valheim 1.0.15.

2.4.0

  • The quick stack button is gone. It kept drawing in front of other panels, and the hotkey does the same job without getting in the way. J by default, changeable in the config. Its three settings, ShowButton, ButtonOffset and ButtonLabel, are no longer read.
  • Chest stacks default to 1000, and the setting now accepts up to 10000. A hundred thousand in a slot works but reads like a cheat.
  • Lowering the limit can no longer destroy anything. A chest filled under a larger setting keeps what it holds when it loads, it just stops growing.

2.3.0

  • New: favorites. Hold Alt and left click a stack in your inventory to mark it. A marked stack is left alone by quick stack and by the chest's own stack button, so your food, arrows and tools stop being swept into storage. Click again to unmark.
  • A small gold star sits on a marked slot, and a line in the corner confirms each change. Both can be turned off, and the modifier key is configurable.
  • The mark lives in the item's own saved data, so it survives logging out, moving the stack, and splitting it. Merging two stacks keeps the mark if either side had it.

2.2.2

  • The button clears the open chest panel: it sits further right, and its own canvas now sorts high enough that nothing draws over it.
  • The caption is broken one word per line and centred, so "Stack to Chests" reads as three stacked lines inside the square.

2.2.1

  • New icon: the chest artwork, with the mod name across the top band and the author across the bottom one. Composed by packaging/make-icon.ps1 from packaging/icon-source.png, so re-running it picks up either change. The old drawn badge is still there as make-icon-badge.ps1.
  • The hotkey defaults to J. G turned out to open the hotbar radial, which the key binding screen does not list.
  • The button is back under the weight readout where it belongs. Positioning it by world coordinates put it in the top corner instead.
  • It carries its own canvas at a higher sorting order now, which is what keeps an open chest from drawing over it, rather than relying on hierarchy order.

2.2.0

  • The quick stack hotkey defaults to G. V, the old suggestion, is taken by the game for auto pickup.
  • Chest slots default to 100000 per stack, up from 1000.
  • The button became a compact square with the caption wrapped inside it, and it moved further out to the side.
  • It is no longer buried behind an open chest. It is parented to the root that holds both panels and drawn last, so nothing covers it, and it stays glued to the weight readout.

2.1.1

  • The slot label fix from 2.1.0 never ran. It looked up InventoryElement as a nested type of InventoryGrid, and that class is top level, so the lookup came back empty and the postfix bailed out on its first line. It now references the type directly, which the compiler checks.
  • A large limit is also written in short form now, so a chest slot reads 650/100k instead of 650/100000, and the font shrinks from there. That keeps the number readable rather than merely small.
  • The quick stack button sits lower, fully clear of the inventory panel.

2.1.0

Quick stack and chest slot polish, from playing the 2.0.0 build.

  • The quick stack button moved out of the item grid. It now sits under the weight readout, to the side of the inventory, where it cannot cover a slot, and it is wide enough for its caption.
  • The button is called Stack to nearby chests.
  • Amount labels shrink as the numbers grow, so a slot holding 100000 of something still reads cleanly instead of spilling over its neighbours. Turn it off with ShrinkStackText.
  • The hotkey works with the inventory closed, so you can stand next to your chests and press it. HotkeyNeedsInventory brings the old behaviour back. It stays quiet while a menu, the console, the chat or a text field has focus.

2.0.0

Renamed from CraftFromChests to GorilaChestMod, and grew from one feature to three. The plugin id changed with the name, so the old dev.trentini.craftfromchests.cfg is not read any more, copy your settings over to dev.trentini.gorilachestmod.cfg.

  • New: oversized chest stacks. Items stack up to a configurable limit, 1000 by default, while they sit in a chest, so a slot no longer caps at the vanilla 50. Player inventories keep the vanilla limits. Stacks are split back into vanilla sized ones the moment they leave a chest, and a destroyed chest drops normal stacks.
  • New: quick stack. A button in the inventory screen, plus an optional hotkey, that pushes matching items from your inventory into the chests in range. An item only moves into a chest that already holds that item, and the hotbar is left alone by default.
  • New: runs on a dedicated server. The plugin no longer restricts itself to the game client. A server holding a chest would otherwise clamp oversized stacks back to the vanilla limit, so it needs the mod too. The server also hands its chest stack settings to every client that connects.
  • Craft from chests is unchanged, and still counts nearby chests for crafting, upgrading and building.
  • The compatibility checker in tools/PatchCheck now covers all three features.

1.0.0

First release as CraftFromChests, built against Valheim 1.0.7.

  • Craft and upgrade at a workbench using the items inside chests within the configured radius.
  • Hammer, hoe and cultivator building costs are paid from those chests too, with an option to turn that part off.
  • The recipe list, the have/need numbers and the craft button all count the contents of nearby chests.
  • Items in your own inventory are spent first, then the chests, closest one first.
  • Honours the game's own access rules: radius, chest privacy, guard stones and chests another player has open.