A Fabric and NeoForge mod for Minecraft that makes copper golems stop wandering from chest to chest looking for the right one. They know what is in every chest in range, walk straight to the right one, and leave items nobody wants in a dedicated Overflow Chest.
The Overflow Chest in its four oxidation stages (left to right), next to a vanilla copper chest with its grey lock and a double Overflow Chest:

A golem leaves an item that has no home in the Overflow Chest, walking past the empty chests on either side:

Everything else is sorted by contents: the golem takes items from a copper chest and goes straight to the chest that already holds them.

The golem behaviour runs on the server, so the mod must be installed there (in single player that is automatic). Because the Overflow Chest is a new block, clients that join need the mod too.
Vanilla rules still apply: a golem takes items out of copper chests and delivers them to regular chests (and trapped chests). A typical setup is an input copper chest, a row of regular chests each already holding one kind of item (put one item in each to teach it what belongs there), and an Overflow Chest for everything else. A copper golem is built from a copper block and a carved pumpkin.
Craft it like a shulker box: a chest between two copper blocks, stacked vertically. Place two next to each other to make a double chest.
copper block
chest
copper block
Items a golem is carrying that match no chest in range always go here, however many empty chests are around. If there is no Overflow Chest in range (or it is full), the golem simply keeps the item until something changes. Honeycomb waxes it (crafting chest + honeycomb also works); an axe scrapes one oxidation stage or removes the wax.
config/smartgolems.json is created the first time the game runs:
{
"horizontalRadius": 32,
"verticalRadius": 8
}
| Setting | Default | Allowed | Meaning |
|---|---|---|---|
| <code>horizontalRadius</code> | 32 | 1-128 | blocks sideways from the golem that it looks for chests and walks to |
| <code>verticalRadius</code> | 8 | 1-64 | blocks up and down |
Restart the game or server after changing it (on a server, edit the server's file). A golem can only see chests in loaded chunks, so a very large radius does not reach past your render and simulation distance. Values outside the allowed range are clamped.
The mod changes how a golem chooses its next chest (a mixin on TransportItemsBetweenContainers, the behaviour vanilla copper golems use). Vanilla picks the nearest chest of the right type and only finds out what is inside once it arrives; this mod reads the contents of every candidate chest in range first and ranks them, so the golem goes to the right one straight away. Everything else (walking, animations, the 16-item carry limit, queuing at a busy chest) is vanilla.
GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later). The LGPL is an addition to the GNU GPL v3, whose text is in LICENSE.GPL.
In short: you may use the mod, including in modpacks and alongside mods under any licence. If you distribute the mod or a modified version of it, you must make the source of the mod (with your changes) available under the LGPL and keep the licence notices.