Ab5oluteZer0-AutoSortChests icon

AutoSortChests

Adds a Sort button to every chest window: merges identical stacks and orders items by type and name.

Last updated 2 hours ago
Total downloads 219
Total rating 0 
Categories Mods Client-side Utility AI Generated
Dependency string Ab5oluteZer0-AutoSortChests-1.0.1
Dependants 0 other packages depend on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2351 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.2351

README

Valheim Auto Sort Chests

BepInEx mod for Valheim that adds a Sort button to every container (chest) window, between the game's own "Take all" and "Place stacks" buttons.

Clicking it:

  1. Merges identical item stacks into as few stacks as possible (same rule the game itself uses to decide if two items can stack).
  2. Lays out the remaining items in a consistent order: by item type, then alphabetically by name.

A chest after sorting: stacks merged and grouped

Unofficial mod. This is a fan-made mod, not affiliated with or endorsed by Iron Gate. It marks your game as modded (the game shows this in the main menu), as Iron Gate asks mod authors to do.

Requirements

  • Valheim (tested on 1.0.15)
  • BepInEx 5.4.x

Installation (players)

  1. Install BepInEx for Valheim if you haven't already (see link above, or use r2modman).
  2. Download AutoSortChests.dll from the latest release.
  3. Drop it into <Valheim install folder>\BepInEx\plugins\AutoSortChests\.
  4. Launch the game and open any chest - you'll see the new "Sort" button.

Upgrading from 0.1.0: the DLL used to be called Mod3-AutoSortChests.dll. Delete the old BepInEx\plugins\Mod3-AutoSortChests\ folder after installing the new version (the mod keeps no data there).

Building from source

Requires the .NET 8 SDK (or newer) and a local Valheim install with BepInEx installed.

git clone https://github.com/Ab5oluteZer0/valheim-auto-sort-chests.git
cd valheim-auto-sort-chests
dotnet build -c Release -p:ValheimPath="C:\Path\To\Valheim"

If you don't pass -p:ValheimPath, the build looks for a VALHEIM_PATH environment variable, then falls back to the default Steam location (C:\Program Files (x86)\Steam\steamapps\common\Valheim).

The build automatically copies the built DLL into <Valheim>\BepInEx\plugins\AutoSortChests\ for quick in-game testing.

How it works

A Harmony postfix on InventoryGui.Awake clones the existing "Stack All" button to create the new "Sort" button (same style, correctly anchored), positioned between "Take All" and "Stack All". Sorting operates directly on Inventory.GetAllItems() (the live internal list) and reassigns each item's grid position - no reflection into private container internals needed beyond one field lookup for the currently-open container.

Support

All my mods are free and will stay free. If you enjoy them and want to say thanks, you can leave a voluntary tip via PayPal - it doesn't unlock anything, it just helps me keep making mods.

License

MIT - see LICENSE.