Niflheim HammerTiers
We've had all these metals but no way to make the hammer better than 300 durability?HammerTiers
Adds metal-gated upgrade levels to the Valheim hammer, on top of the upgrade levels it already has. Each metal you reach adds another level at the workbench:
Tin → Copper → Bronze → Iron → Silver → BlackMetal → FlametalNew → Gold
Three ingots per level, plus wood and stone. The metal is the only gate. The station requirement is pinned to the recipe's own minimum, so it never climbs out of reach.
Base materials cost BaseMaterialsPerLevel x the target quality. At the default N = 1:
| Level | Metal | Wood | Stone | Max durability |
|---|---|---|---|---|
| 4 | 3 Tin | 4 | 4 | 600 |
| 5 | 3 Copper | 5 | 5 | 900 |
| 6 | 3 Bronze | 6 | 6 | 1200 |
| 7 | 3 Iron | 7 | 7 | 1500 |
| 8 | 3 Silver | 8 | 8 | 2000 |
| 9 | 3 BlackMetal | 9 | 9 | 2500 |
| 10 | 3 FlametalNew | 10 | 10 | 3000 |
| 11 | 3 Gold (Bloodgold) | 11 | 11 | 5000 |
N = 2 doubles every wood/stone figure (8 through 20); N = 0 drops them and leaves metal only.
Whichever materials the tool's own recipe uses are the ones that scale, so this works unchanged for
Hoe or Cultivator. Levels 1-3 keep their vanilla costs untouched.
Only genuine crafting materials scale. The hammer's resource list also includes
Upgrader0Weapon ("Wooden Battle Idol"), which never appears at a workbench; it belongs to the
Forge of Potential, see below. Those are left alone
rather than scaled, and the startup log prints every base resource with its flags so you can check
what was included:
base resource: Wood amount=3 perLevel=1 upgraderResource=False
base resource: Stone amount=2 perLevel=1 upgraderResource=False
base resource: Upgrader0Weapon amount=1 perLevel=0 upgraderResource=True [Forge of Potential ingredient, left alone]
Important: the vanilla hammer already upgrades
The hammer is upgradeable in vanilla and its quality already scales durability:
| Quality | 1 | 2 | 3 |
|---|---|---|---|
| Durability | 100 | 200 | 300 |
| Cost | 3 Wood, 2 Stone | 1 Wood, 1 Stone | 2 Wood, 2 Stone |
| Workbench level | 1 | 2 | 3 |
So vanilla max quality is 3, and with the default tier list this mod puts the seven metals on levels 4 through 10, ending at 3000 durability.
Those vanilla upgrade costs are reproduced exactly rather than reimplemented: the mod points levels
1-3 back at the untouched vanilla requirement array, whose own curve is what produces the 1/1 and 2/2
above. That curve is not a straight (q - 1) * m_amountPerLevel, see
How it works, it bends at quality 4.
The mod still doesn't hardcode the 3; it reads m_shared.m_maxQuality from the loaded prefab at
runtime and logs it, so a game patch that adds a vanilla level shifts the metals up instead of
silently overwriting one:
Vanilla Hammer max quality is 3 (read from the game, not assumed).
Level 4 requires 3x Tin, 4x Wood, 4x Stone (durability 600)
...
Hammer max quality 3 -> 10 (7 metal levels from 4).
By default the metal levels start after the vanilla ones, and the vanilla levels keep their own
costs untouched. Set ReplaceVanillaUpgrades = true if you'd rather metals replace them from
level 2 onward.
The prefab's real m_maxQuality can't be read off disk; it lives in a 756 MB LZ4 asset bundle with
type trees stripped, which is why it's read at runtime rather than hardcoded. (The published stats
on the weirdgloop wiki agree with what it reads, so the tables above are checkable; the runtime read
is still what the mod acts on, because a game patch can move them.)
Toolchain, and why it looks unusual
The normal Valheim mod stack is BepInEx (loader) + HarmonyX (runtime method patching) +
optionally Jötunn (a community library for registering new content, items, recipes, pieces,
with correct ObjectDB/ZNetScene timing, localization and server config sync), built in Visual
Studio against the .NET Framework 4.6.2 targeting pack.
This mod uses BepInEx + Harmony for the behaviour, and depends on Jötunn for two things only:
NetworkCompatibility to make the server reject clients without the mod, and admin-only config
entries so the server's settings are pushed to clients. It registers no new content through Jötunn,
because it edits an existing item rather than adding one.
There's no .NET SDK on this machine, so build.sh drives the Roslyn compiler that ships with
Visual Studio instead. It is a current C# compiler, so nothing in the source is held back to an old
language level.
The engine itself lives in families/ToolTiers/ToolTiers.cs, shared verbatim with HoeTiers and
CultivatorTiers. The only file in this folder is src/PluginInfo.cs, holding four consts: GUID,
display name, version, and the default ToolPrefab. A fix to the engine lands in all three mods at
the next build. See ../../README.md.
Build
No .NET SDK needed; it builds with the Roslyn compiler that ships with Visual Studio.
./build.sh # src/PluginInfo.cs + families/ToolTiers/ToolTiers.cs -> build/HammerTiers.dll
./package.sh # rebuilds and zips NifusionDotDev-Niflheim_HammerTiers-<version>.zip
Override VALHEIM, BEPINEX, JOTUNN or CSC env vars if your paths differ.
Install
Requires BepInEx. Drop HammerTiers.dll into the BepInEx/plugins folder of the profile you
play, or install it through a mod manager.
Config lands in BepInEx/config/niflheim.hammertiers.cfg on first run.
Upgrading from 0.1.0
0.1.0 was a standalone build under the plugin id nifusion.hammertiers. This one is
niflheim.hammertiers, so BepInEx writes a fresh config file and your old settings are not
carried across. If you had changed anything, copy the values out of nifusion.hammertiers.cfg
first, then delete it. Leaving it in place does nothing but take up a line in the folder.
Sibling mods, same engine pointed at a different tool: HoeTiers and CultivatorTiers. All three can be installed together, see Running more than one.
The Forge of Potential is left alone
Valheim 1.0 can already push an item past its max quality: bring a Wooden Battle Idol to the
Forge of Potential and gamble on a level, at the risk of destroying the item. That is what the
hammer's Upgrader0Weapon entry is for.
m_upgraderResource is a filter, not a hide flag, and both the UI and the requirement check apply it
the same way:
if (station != null && station.m_upgrader != req.m_upgraderResource) continue;
A normal station shows only the entries without the flag; an upgrader station (CraftingStation
with m_upgrader set, which is what the Forge of Potential is) shows only the ones with it. Same
Recipe, same m_resources array, opposite halves.
This mod swaps m_resources for a per-level array that contains no upgrader entry at all. Swapping
it at the Forge of Potential would leave the idol upgrade with an empty requirement list, and
because HaveRequirementItems applies the same filter, an empty list is a satisfied list, so the
upgrade would have become free. Since 0.2.0 Apply checks GetCurrentCraftingStation().m_upgrader
and puts the vanilla array back instead, so the idol path behaves exactly as it does without the mod.
(Player.RequiredCraftingStation returns true outright at an upgrader station, so the station
level is never gating there either. The GetRequiredStationLevel postfix bows out there too, since
its number would only ever show up as a wrong label.)
Config
| Key | Default | Meaning |
|---|---|---|
ToolPrefab |
Hammer |
Which tool gets the levels. Hoe and Cultivator also work. |
Tiers |
Tin:3:300,... |
Ordered Prefab:Amount:Durability list. One entry per added level. |
ReplaceVanillaUpgrades |
false |
false stacks metals after the vanilla levels; true replaces them from level 2. |
BaseMaterialsPerLevel |
1 |
Wood/stone per metal level = N x quality. 0 for metal only. |
PlaceDistancePerLevel |
1.0 |
Extra build reach per level above vanilla max. Vanilla base reach is 5. |
Verbose |
false |
Logs each requirement swap. |
Prefab names that don't exist in your game version are skipped with a warning rather than breaking the mod, so a renamed metal costs you that level and nothing else.
Flametal is a trap. The flametal bar is
FlametalNew. The prefab namedFlametalstill exists as the pre-Ashlands item, converted to "Ancient metal" and unusable, so naming it here would resolve to a real-but-dead item rather than failing loudly.
Bloodgold is the same trap backwards. The Deep North metal the game calls Bloodgold has the prefab name
Gold, and its ore isGoldOre. There is no prefab namedBloodGold.
Levels stay hidden until you find the metal
The offered max quality is capped at the first tier material you have never picked up, so an upgrade for a metal you have not seen is neither shown nor craftable. Pick up your first black metal and level 9 appears on its own.
This uses the game's own discovery set: Player.m_knownMaterial, which AddKnownItem fills with
m_shared.m_name the first time you pick an item up. It is recomputed every frame the crafting
panel is open, and logged when it changes:
Offered max quality is now 6 of 10 (capped at the first unknown tier material).
What the levels get you
Durability, roughly 300 per biome. Vanilla's ItemData.GetMaxDurability(q) is
m_maxDurability + max(0, q - 1) * m_durabilityPerLevel, one flat step per level. The metal levels
need uneven steps: 300 per level through iron, then 500 each for silver, black metal and flametal. A postfix on that method computes the value from the per-tier
figures in Tiers; vanilla levels 1-3 fall through to the original untouched. It is worth having
because the hammer genuinely spends durability:
Player.UpdatePlacement decrements m_durability on both piece placement and piece removal, gated
on m_shared.m_useDurability and scaled by Game.m_durabilityRate.
Build reach, via PlaceDistancePerLevel, applied only to levels above the vanilla max so the
vanilla levels behave exactly as they always did. Set it to 0 for durability-only.
Running more than one
HammerTiers, HoeTiers and CultivatorTiers coexist. The one place they could have collided is build
reach: all three write Player.m_maxPlaceDistance, and 0.1.0 treated whatever the field held as the
vanilla baseline, which, with a sibling installed, is a sibling's bonus, compounding every frame.
PieceRayTest reads that field from Player.LateUpdate rather than from UpdatePlacement, so the
raised value has to persist on the field; raising and restoring it around the one call would leave
the placement ghost at vanilla reach. So instead:
- the baseline is captured once in a
Player.Awakepostfix, before any tool is in hand, which is the one moment all three mods read the same untouched value; - the field is written only while this mod's tool is held, and put back exactly once when it stops being held, so a sibling holding its own tool is left alone rather than overwritten every frame.
The cost is that a reach mod which sets m_maxPlaceDistance from its own Player.Awake postfix may
or may not be seen, depending on patch order. 0.1.0 re-read the field to catch that case, and traded
it away for not fighting its own siblings.
Upgrading always returns a full-durability tool
DoCrafting removes the old item and rebuilds it through
Inventory.AddItem(name, stack, quality, ...), which does SetQuality(quality) and then
unconditionally sets m_durability = GetMaxDurability(). So a hammer reading 0/300 is simply worn
out from building; repair it at a workbench.
How it works
Two things in vanilla stand in the way, both confirmed by reading assembly_valheim.dll IL:
-
Recipes can't express per-level materials.
Piece.Requirement.GetAmount(quality)is one curve applied to every resource at every level, so "tin at level 5, copper at 6" is not representable:if (quality <= 1) return m_amount; float steps = quality < 4 ? quality - 1 : 4f + (quality - 4) / 2f; return (int)Math.Floor(steps * m_amountPerLevel + (m_upgraderResource ? m_amount : 0));Note the bend: linear to quality 3, a jump to 4 steps at quality 4, half-rate after that. Vanilla already anticipates qualities above 3, because the Forge of Potential can reach them.
The mod prebuilds one requirement array per level and repoints
Recipe.m_resourcesat the right one immediately before the game reads it, inInventoryGui.SetupRequirementList(the UI),Player.HaveRequirements(the button gate) andInventoryGui.DoCrafting(the actual spend). Each re-readsm_resourcesat the point of use, which is what makes the swap safe. Levels at or below the vanilla max point back at the untouched vanilla array.Base materials on the metal levels are clones of the tool's own requirements with a fixed amount, never the vanilla objects themselves, so setting them cannot disturb levels 1-3.
Every tier requirement is built with
m_amountPerLevel = 0, which the formula above prices at zero for any quality past 1. The flat per-level amount is therefore supplied by a prefix onGetAmount, answering for this mod's ownRequirementobjects only, matched by reference, so every other requirement in the game falls through to the original method.Setting
m_upgraderResourceto get a flat amount out of vanilla instead is not an option: as the formula shows it does addm_amountflat, but the flag is also the Forge of Potential filter, so the cost would move to that station and disappear from the workbench entirely. -
The station requirement scales past what's buildable.
Recipe.GetRequiredStationLevelreturnsMathf.Max(1, m_minStationLevel) + (quality - 1), which is exactly why vanilla levels 1-3 want workbench 1/2/3, and why a level 11 upgrade would want a level 11 workbench that cannot exist (the bench caps at 5). A postfix pins the metal levels of this one recipe to the recipe's ownm_minStationLevel, so the requirement stops climbing. This is not a difficulty setting and there is deliberately no config behind it: material access is the gate, enforced separately by the max-quality cap. Levels 1-3 keep vanilla's 1/2/3, and every other recipe in the game is untouched.
m_maxQuality itself is raised on ObjectDB.Awake / CopyOtherDB, guarded so that reloading the
database re-reads the captured vanilla values rather than compounding the mod's own edits.
Status
Run in-game and working. Every metal resolves, max quality goes 3 to 11, the upgrade panel offers the next level with the metal's icon and cost, and no unbuildable station is ever demanded.
0.3.0 added the Bloodgold level, dropped the station-level config, and moved the engine into
families/ToolTiers/ToolTiers.cs so a fix lands in all three tool mods at once. The plugin id
changed from nifusion.* to niflheim.* in the same release; see
Upgrading from 0.1.0.
Multiplayer and dedicated servers
The feature itself cannot be server-only. The upgrade panel is drawn by each client from its own
ObjectDB, and DoCrafting spends the resources in the local player's inventory. A vanilla client's
hammer has m_maxQuality = 3 and nothing the server sends changes that, so every player who wants
the extra levels needs the DLL. Valheim has no mod delivery, so distribute it as a Thunderstore
modpack or hand out the zip.
What is server-authoritative, via Jotunn:
1. The server can require the mod. The plugin is marked
[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.Minor)]
so Jotunn compares module lists on connect and refuses clients that are missing it or running a different minor version, with a message naming the mod. Nobody silently plays without it.
2. The server owns every setting. All config entries are bound with IsAdminOnly, which is what
makes Jotunn push the server's values to clients on connect. A player editing Tiers or
BaseMaterialsPerLevel locally has it overwritten, so costs are the server's decision, not theirs.
Edit the config on the server and it propagates.
This adds a hard dependency on Jotunn (ValheimModding-Jotunn-2.30.0), which must be installed
on the server and on every client.
Not verified
Neither the version enforcement nor the config sync has been tested against a live dedicated server.
Both are wired to APIs read out of the installed Jotunn.dll, not from documentation.
Credits
Part of Niflheim, a set of single-issue Valheim modlets by NifusionDotDev. Each one does one thing and is installed on its own; none of them depend on the others.
Written by a human doing his best to enjoy his hobby. Reviewed and documented with AI help, which is why the README is longer than the mod is.
