You are viewing a potentially older version of this package. View all versions.
Baka_Gaijin-PortalMetalLock-1.5.1 icon

PortalMetalLock

Metals/ores/bars/scrap (vanilla AND mod-added) can't be carried through wood portals; the Ashlands stone portal still carries everything. Server-enforced for all clients; config is server-authoritative (locked).

Date uploaded a month ago
Version 1.5.1
Download link Baka_Gaijin-PortalMetalLock-1.5.1.zip
Downloads 165
Dependency string Baka_Gaijin-PortalMetalLock-1.5.1

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2333 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.2333
ValheimModding-Jotunn-2.29.0 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.29.0

README

PortalMetalLock

Keep metals where they belong. Metals, ores, bars, and scrap — vanilla and mod-added — can no longer be carried through normal (wood) portals. The Ashlands stone portal (the "advanced" portal) still carries everything, exactly like vanilla.

Why

Vanilla already blocks vanilla metals from wood portals, but many content mods add their own ores/bars and leave them teleportable, quietly undoing that restriction. PortalMetalLock closes that gap: it scans the item database (including items registered late by Jotunn-based mods) and flags matching materials as non-teleportable, so wood portals refuse them again.

How it works

Valheim wood portals refuse to teleport a player whose inventory holds any non-teleportable item. The Ashlands stone portal sets m_allowAllItems, which the game checks before the per-item test, so it keeps carrying everything with no extra handling.

This mod simply sets m_teleportable = false on matching items. Matching is restricted to items of type Material, so weapons, armour, tools, and jewellery (e.g. SwordBronze, SilverNecklace) are never affected — only raw metal/ore/bar/scrap.

Configuration (server-authoritative — locked on clients)

All settings are admin-only and synchronised from the server via Jötunn. When connected to a server, the server's values are pushed to every client and locked — players cannot edit their local config to make metals teleportable again. Only the server admin can change these (edit baka.PortalMetalLock.cfg on the server while it is stopped, or via the in-game Configuration Manager as an admin):

Setting Default Description
Enabled true Master switch. When on, matching materials are made non-teleportable.
MetalKeywords copper,tin,bronze,iron,silver,blackmetal,flametal,ore,scrap,ingot Comma-separated, case-insensitive substrings. Any Material whose prefab name or localized name contains one is blocked.
ExtraPrefabs (empty) Comma-separated EXACT prefab names to also block, for mod metals the keywords miss. Use VNEI in-game to find exact names.
ExcludePrefabs BronzeNails,LeatherScraps Comma-separated EXACT prefab names to never touch (false-positive guard).

After changing keywords/prefabs on the server, reload the world (or restart) so the item database is re-scanned.

Server enforcement

This mod uses Jötunn's NetworkCompatibility at level EveryoneMustHaveMod with Minor version strictness. When it runs on a dedicated server, every connecting client must also have PortalMetalLock installed at a matching major.minor version — clients that are missing the mod or on a mismatched version are rejected at the connection handshake with an error screen. This guarantees the rule is enforced for everyone on the server, not just players who happen to have it.

(The teleport gate itself is evaluated client-side, so without this enforcement a vanilla/missing-mod client could otherwise carry mod metals through. EveryoneMustHaveMod closes that gap.)

Requirements

  • BepInEx
  • Jötunn (for the server-side enforcement handshake)

Notes

This is a personal quality-of-life / rules mod. It only flips a per-item teleport flag; no world data, recipes, or items are otherwise changed. Safe to add or remove at any time.

CHANGELOG

Changelog

1.5.1

  • Adds a second teleport-gate patch on Humanoid.IsTeleportable as a fallback for Valheim builds where the portal calls the Humanoid method directly. The original Inventory.IsTeleportable patch is kept. Both patches re-stamp the inventory at the instant of the teleport check.
  • Startup patch verification — logs exactly which Harmony patches applied and warns if a critical gate is missing, making silent patch failures visible in the BepInEx log.
  • Diagnostic logging — when the teleport-gate re-stamp catches items that had reverted to teleportable, it logs the count (throttled to avoid spam).

1.5.0

  • Fixes modded metals still teleporting through wood portals. In 1.4.0 the vanilla metals were blocked, but the Final Sunset (Balrond) modded tiers — Lead, Zinc, Nickel, Cupronickel, their ores/scraps, and ingots — could still be carried through a wood portal. Cause: those modded items are rebuilt by the mod loader with a fresh "teleportable" flag at the moment of teleport, which the per-inventory/per-drop re-stamp could miss. The item prefab was correctly flagged (confirmed in the item dump), but the live item the portal actually checks wasn't always caught in time. The mod now re-stamps the flag on the exact inventory the wood portal is about to check, at the instant it checks it, so a modded metal can never slip through on a timing edge. Vanilla metals were unaffected (the base game already marks them non-teleportable), which is why only modded metals leaked. The Ashlands stone portal still carries everything (it short-circuits the per-item check before this runs).
  • Brass Chain is no longer blocked. BrassChain_bal is a finished component you craft from metal (like nails), not a raw bar/ore/scrap, so it now teleports through wood portals in line with the rule "raw metal can't teleport, but things you make from metal can." (All nails — Bronze, Iron, Darksteel, Wood — were already teleportable.)
  • This minor bump is mandatory for everyone. Because the wood-portal check runs on each player's own client, every client must update to 1.5.0 (the server enforces a matching major.minor or the client is kicked at connect).

1.4.0

  • Fixes the drop/pickup bypass. Previously a freshly-crafted metal was correctly blocked, but after you dropped it on the ground (or stashed it in a chest) and picked it back up, it became teleportable again. Cause: the non-teleportable flag lives only on the item prefab and is never saved per-item — the game re-derives it from the item database every time an item is rebuilt, and modded item databases get rebuilt in several waves, resetting the flag. The mod now re-stamps the flag on the live item whenever your inventory changes and whenever an item is dropped in the world, so metals stay blocked across drop / pickup / chest / reload. (It only ever adds the block — it never makes another mod's item teleportable, so the Ashlands stone portal still carries everything.)
  • All equipment is now guaranteed to go through wood portals. 1.3.0 wrongly blocked metal-named gear — bronze pendant, iron brooch, iron horse armour, metal trinkets, capes, and even the vanilla "Heart of the Forest." The block is now hard-gated to raw Material items only; weapons, armour, tools, trinkets, jewellery, capes and food can never be blocked regardless of their name.
  • Expanded keyword coverage for the Final Sunset (Balrond) metals that were slipping through — Nickel, Zinc, Lead, Brass, Cupronickel, Bell metal, Cobalt, Dark steel, Frosteel, Molten steel (displays as "Aurametal"), White metal, Vanadium, Gold, plus Ferroboron/Dark iron ("Thorium") and Ifrytium ("Cerium") by both their internal and displayed names.
  • Verifiable classification. With LogDecisions on, the mod now writes a full item dump to BepInEx/config/PortalMetalLock_items.txt (prefab | display | type | teleportable | decision) so exactly what is and isn't blocked can be checked from ground truth.

1.3.0

  • Matching is now genuinely mod-aware and far more accurate. The old version matched a small English keyword list as a raw substring, which caused two bugs:
    • False positives (items wrongly blocked from portals): tin matched chitin, ore matched surtlingcore, iron matched IronNails, scrap matched meat scraps.
    • Misses (modded metals that wrongly stayed teleportable): Nickel, Zinc, Lead, Brass, Cupronickel were never in the keyword list; and metal "scrap" items registered as a non-Material type slipped past the Material-only gate.
  • Keywords now match on whole tokens (names are split on camelCase + non-letters), so tin no longer matches chitin and ore no longer matches core.
  • Greatly expanded default keyword list: adds metal, steel, nickel, zinc, lead, brass, cupronickel, bellmetal, frosteel, darksteel, moltensteel, and more. Bare scrap/bar are intentionally NOT keywords (metal scraps/bars already carry the metal's name token), preventing leather/food false positives.
  • New ExcludeTokens guard (default nail,nails,meat,necklace,food,fish,key,coin,gem) keeps nails, food and jewellery teleportable.
  • The type gate is relaxed from "Material only" to "anything that is not equipment/consumable" (toggle IncludeNonEquipTypes, default on), so metal scraps some mods register as Misc/Trophy are caught while weapons/armour/tools/food/jewellery stay teleportable.
  • Extra delayed rescans (12s/18s/30s after load) catch mods that register metals in late waves.
  • New LogDecisions option (default on) logs exactly what was marked non-teleportable and which metal-ish items were skipped (and why), so the block list can be tuned from config with no rebuild.

1.2.0

  • Config is now server-authoritative: all settings are admin-only and synced from the server via Jötunn, then locked on clients. Players can no longer edit their local config to bypass the rule — the server defines what is blocked for everyone.

1.1.0

  • Server-enforced via Jötunn NetworkCompatibility (EveryoneMustHaveMod, Minor strictness): every connecting client must have a matching major.minor version of the mod installed or it is rejected at the connection handshake. This guarantees the rule applies to everyone on the server, since the teleport gate is evaluated client-side.
  • Adds Jötunn as a dependency.

1.0.0

  • Initial release.
  • Marks metals/ores/bars/scrap (vanilla and mod-added) as non-teleportable so wood portals refuse them.
  • Ashlands stone portal still carries everything (vanilla m_allowAllItems behaviour).
  • Matching restricted to Material-type items to protect weapons/armour/tools/jewellery.
  • Re-scans on ObjectDB.Awake, ObjectDB.CopyOtherDB, and a delayed pass after scene load to catch Jotunn-registered mod items.
  • Configurable keywords, extra prefabs, and exclusion list.