You are viewing a potentially older version of this package. View all versions.
UllrHeim-NishinkusSmelterLink-0.2.0 icon

NishinkusSmelterLink

Mark an input, fuel and output chest per smelter, kiln or blast furnace. Linked smelters keep running while you are away. Craft the Linking Rod to see the whole network at once.

Date uploaded a month ago
Version 0.2.0
Download link UllrHeim-NishinkusSmelterLink-0.2.0.zip
Downloads 244
Dependency string UllrHeim-NishinkusSmelterLink-0.2.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
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
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.

Status

Built and tested for singleplayer.

Links live in the ZDO so they replicate on their own, and clients get feeding and output routing for loaded smelters. But only the host simulates unloaded smelters — two peers running the conversion loop over the same smelter would produce the same bar twice — and none of the multiplayer paths have been tested. Treat shared worlds as unproven.

CHANGELOG

Changelog

0.3.0

Fixes found and diagnosed by Belo, who wrote SmelterLinkMPFix as an external patch for 0.2.0. Thanks — this release folds those fixes into the mod itself, so the separate fix is no longer needed alongside it.

  • Links no longer break after a world restart. They were stored as raw ZDOIDs, but Valheim renumbers every object on load, so a saved link pointed at whatever happened to take that number. Chests now carry a persistent id of their own instead.
  • Links are never deleted automatically. A chest that cannot be found — not loaded yet, or not sent to this client — used to clear the link.
  • Chests no longer get stuck "in use". Chest contents are only changed by whoever owns the chest, and a chest another player has open is left alone.
  • Output goes live into an open output chest instead of dropping on the floor. If the chest is full the smelter holds onto it or vanilla drops it; nothing is destroyed.
  • The host no longer smelts a smelter another player is already handling.
  • Marking no longer triggers game actions. 1/2/3 used hotbar items, X sat down and Esc opened the menu. Only movement is allowed while marking, and taking damage cancels it. Both are configurable.

Old 0.2.0 links cannot be converted — the id they were stored under is meaningless after a restart, so converting would lock in a wrong chest rather than an obvious gap. Mark those smelters again; the log says how many are affected.

0.2.0

  • Added the Linking Rod: a craftable tool that draws every link within range, fades all but the ones touching the chest you are looking at, and makes each chest report what it feeds.
  • Marking now works off the smelter's own switches — the ore slot asks for an input chest, the fuel slot for a fuel chest, the empty slot for an output chest.
  • Added an on-screen panel while marking, and chests now say what they would become.
  • Fixed links being written against the wrong ZNetView. A chest nested under another networked object stored its link against the parent, which moved no items and drew the link line off to wherever the parent stood.
  • A link whose far end no longer looks like a chest is now ignored rather than used.
  • Only the host simulates unloaded smelters. Clients would otherwise each run the conversion loop over the same smelter and produce the same bar more than once.

0.1.0

  • Per-smelter input, fuel and output chests, stored in the smelter's ZDO.
  • Feeding and smelting continue while the smelter is unloaded, removing vanilla's one-hour catch-up clamp.
  • Output routed into the linked chest instead of dropping on the ground.