UllrHeim-NishinkusSmelterLink icon

NishinkusSmelterLink

Pick which chest each smelter, kiln or blast furnace takes its ore and fuel from, and which chest the finished bars go into. Linked smelters keep working while you are somewhere else.

Last updated a week ago
Total downloads 511
Total rating 1 
Categories Mods Tweaks Crafting AI Generated
Dependency string UllrHeim-NishinkusSmelterLink-0.3.0
Dependants 2 other packages depend on this package

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
ValheimModding-Jotunn-2.30.1 icon
ValheimModding-Jotunn

Jötunn (/ˈjɔːtʊn/, 'giant'), the Valheim Library was created with the goal of making the lives of mod developers easier. It enables you to create mods for Valheim using an abstracted API so you can focus on the actual content creation.

Preferred version: 2.30.1

README

Nishinku's SmelterLink

Mark a specific input, fuel and output chest per smelter, kiln, blast furnace, windmill or spinning wheel. Linked smelters keep running while you are away from them.

Built against Valheim 1.0.12 (network version 40, Unity 6000.0.75), BepInEx 5.4.2350.

Using it

Marking hangs off the switches the smelter already has, so what you are looking at decides what you are about to set:

Looking at Press G to set
the ore / item slot input chest
the fuel slot fuel chest
the empty / output slot output chest

The hover text on each switch says which one it is and what is currently linked. Once selection has started, a panel appears at the top of the screen showing all three slots, and every chest you look at says what it would become.

Key While selecting
G on a chest Bind it to the active slot
1 / 2 / 3 Switch to input / fuel / output
X Clear the active slot
Esc Cancel

The 1 / 2 / 3 fallback exists because not every piece has all three switches — a charcoal kiln has no separate fuel slot, for instance.

Lines are drawn to whatever is already linked while you are marking. Several smelters can point at the same chest, and distance does not matter.

The linker rod

A craftable rod that makes the whole network visible at once. Workbench, 5 wood, 1 surtling core, 2 resin.

While it is in hand:

  • every link within Range (default 64m) is drawn, colour-coded per slot
  • looking at a chest fades all links except the ones touching it
  • a chest's hover text says what it feeds — Feeds: 3 input 1 fuel, or that it is unused

Marking still works without the rod; the rod is for reading a base rather than editing one.

The rod is registered through Jotunn and reuses the club model, so it looks like a wooden stick. Change the second argument of the CustomItem call in src/LinkerTool.cs to clone something else. Because it is a modded item, any rod sitting in an inventory will be dropped from the save if this mod is ever uninstalled.

Why a marked chest is better than a radius

Vanilla picks the first item in m_conversion that it can find — there is no notion of preferring one fuel over another. A charcoal kiln will happily eat core wood and fine wood. Radius-based feeder mods inherit the same problem from the other side: they pull from whatever chest happens to be nearby.

Linking makes the chest itself the filter. A kiln pointed at a wood-only chest burns wood and nothing else, and when that chest runs dry the kiln stops instead of moving on to your building material.

Running while unloaded

Valheim only instantiates objects in loaded zones, but all of a smelter's state — fuel, the ore queue, the bake timer, the pending output — lives in its ZDO, and a chest's contents live in its ZDO as a serialised ZPackage under items. In singleplayer the whole ZDO database is resident in memory, so this mod runs the conversion loop directly on that data. No zones are kept alive and no physics or AI is simulated.

Offline production requires a linked output chest, because there is nowhere to put the result otherwise — the vanilla code path instantiates an ItemDrop at the smelter, which needs the object to exist.

Two things the simulation cannot observe without the object: the roof check and windmill wind. Both are cached in the ZDO on every vanilla tick, so they reflect the last time you were standing there.

The vanilla 1-hour cliff

Vanilla smelters do advance while unloaded — Smelter.UpdateSmelter computes elapsed time from StartTime in the ZDO — but the accumulator is clamped to 3600f. Being away for five hours yields one hour of smelting and discards the rest. This mod ticks continuously, so the clamp never comes into play. MaxCatchupSeconds sets the mod's own limit (default 24h).

World time only advances while the world is loaded, so closing the game does not bank production.

Config

BepInEx/config/nishinku.smelterlink.cfg

Setting Default
LinkKey G Marking hotkey
TickInterval 2 Seconds between background passes
OfflineSmelting true Run unloaded smelters
MaxCatchupSeconds 86400 Cap on catch-up per smelter
Range 64 How far the linker rod reveals links
BlockInputWhileMarking true Only movement while marking
CancelOnDamage true Stop marking when you take damage
Verbose false Log every transfer

Known conflicts

Any mod that feeds smelters from nearby containers by radius will fight the explicit links. AutoFuel is the common one: set SmelterOreRange and SmelterFuelRange to 0 in aedenthorn.AutoFuel.cfg to keep its torch and firepit refuelling while taking it off smelters. It is not in the active Thunderstore profile, so this does not currently apply.

Building

Requires the .NET SDK.

dotnet build NishinkusSmelterLink.csproj -c Release

The build copies the DLL into the live BepInEx profile. Two paths in NishinkusSmelterLink.csproj control this:

  • ValheimDir — the Steam install, used only for the assembly references
  • ProfileDir — the Thunderstore Mod Manager profile the game actually launches with

The game is started through Thunderstore Mod Manager, which loads BepInEx from the profile folder rather than from the Steam directory; the BepInEx tree inside the Steam folder is a separate, unused Vortex deployment. Update ProfileDir when switching profiles.

Because the plugin is dropped into the profile by hand it does not appear in the mod manager's list, and a profile repair or reinstall may remove it. Re-running the build puts it back.

Packaging

powershell -File tools\pack.ps1

Builds, validates and writes dist/NishinkusSmelterLink-<version>.zip ready for Thunderstore. Validation covers the things the upload form rejects: package name characters, semver, the 250-character description limit, a 256×256 icon, and the version matching across manifest.json, Plugin.cs and the csproj.

Bump the version in all three of those before packaging. tools\make-icon.ps1 regenerates the icon.

How a link is stored

Not as a ZDOID. ZDO.Load starts with m_uid.SetID(++ZDOID.m_loadID), so every object in the world is renumbered on each load and a ZDOID is only a runtime handle. Saving one and reading it back after a restart resolves to whichever object inherited that number, which is worse than resolving to nothing.

Instead the mod stamps a persistent long onto the chest and stores that on the smelter, with an index from id to current ZDOID rebuilt by scanning the world's ZDOs at load. A link that cannot be resolved is left alone, never deleted — a chest can be missing simply because its ZDO has not reached this client yet.

Multiplayer

Everyone needs the mod installed. Only the host simulates unloaded smelters, and it skips any smelter another player owns, so the same bar is never produced twice. Chest contents are only changed by the owner of that chest, and a chest someone has open is left alone.

Chests on carts and ships are not supported.

Credits

The multiplayer problems in 0.2.0 were found and diagnosed by Belo, who published SmelterLinkMPFix as an external patch. Those fixes are part of the mod as of 0.3.0, so the separate patch is no longer needed.