PieceReplacer

版本 v1.1.12·更新於 2026-09-25

Replace compatible Valheim building pieces in place, including connected walls and floors, with safe material and placement validation.

模組介紹 作者原文

PieceReplacer v1.1.9

Quality-of-life replacement modes for Valheim's Hammer.

Single replacement

  • Equip the Hammer.
  • Select the build piece you want to use as the replacement.
  • Aim at an existing compatible build piece.
  • Hold Left Alt and place normally.

The replacement is locked to the old structural slot while rotation stays under normal Valheim player control. Equivalent material prefabs are aligned by their snap-point geometry rather than assuming identical prefab pivots, and the exact visible preview transform is used for the final piece.

Connected surface replacement

v1.1 adds a batch mode for connected planar surfaces such as floors and walls.

  • Select the replacement piece with the Hammer.
  • Aim at one piece of the surface.
  • Hold Left Alt + Left Shift.
  • Review the batch information shown near the bottom of the screen.
  • Left-click to replace the complete connected surface.

A batch only follows pieces that:

  • use the same source prefab as the aimed piece,
  • lie on the same geometric plane,
  • and share an actual snap-point edge with the next piece.

This means a wall around a 90-degree corner is treated as a separate surface and floor tiles that only touch diagonally at one corner are not merged.

The seed preview controls the rotation delta for the complete batch. For example, flipping the preview wall by 180 degrees flips every wall in that selected surface by 180 degrees relative to its previous orientation.

Batch material preview and validation

While Left Alt + Left Shift is held, PieceReplacer displays:

  • number of pieces in the connected surface,
  • source and replacement piece,
  • total material requirement for the complete batch,
  • how much of each material is currently available,
  • missing amounts when the batch cannot be afforded.

The replacement is blocked unless the player has enough material for the entire batch before it starts. Old pieces are refunded only after the new batch has been placed, so refunds are not used to finance a partially completed replacement.

Removal permissions and required crafting-station range are checked for every piece before committing the batch.

Compatibility

Two pieces can replace each other when they are covered by an explicit safe group or when the automatic structural compatibility check accepts them.

Automatic checks use:

  • Piece category,
  • Valheim Hammer usage tags,
  • functional components,
  • local snap-point geometry.

Vanilla beam/pole families additionally have explicit safe compatibility for horizontal 1/2/4 m pieces, 26°/45°/67° angled beams, and vertical 1/2/4 m poles. This avoids false negatives caused by material variants with different local snap layouts.

Safety defaults

AllowBoundsFallback = false by default. Pieces without enough snap points are therefore not automatically matched solely because their visual size happens to be similar.

Connected-surface replacement has a default maximum of 250 pieces. If a surface exceeds that limit the operation is blocked rather than silently replacing only part of it.

Build.\build.ps1

Build and install:.\build.ps1 -Install

Config

Generated at:

BepInEx/config/uk.ainzworth.valheim.piecereplacer.cfg

Important settings:

[General]

ModifierKey = LeftAlt

BatchModifierKey = LeftShift

[Compatibility]

AutoCompatibility = true

RequireSameCategory = true

RequireSameUsageTags = true

SnapPointTolerance = 0.035

AllowBoundsFallback = false

BoundsTolerance = 0.075

[Batch Replacement]

Enabled = true

MaxPieces = 250

ConnectionTolerance = 0.08

PlaneTolerance = 0.12

ShowHud = true

For diagnostics, set DebugLogging = true.

v1.1.1 wall compatibility fix

Straight wall size families now have explicit Vanilla compatibility overrides for:

  • full 2x2 walls
  • half 1x2 walls
  • quarter 1x1 walls

This fixes material replacement cases where equivalent wall variants use different prefab-local snap geometry. Full, half and quarter walls remain separate groups so differently sized walls cannot replace each other.

v1.1.

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。 多人連線時,主機與所有用戶端需要安裝一致的模組。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

denikson-BepInExPack_Valheim

檔案與校驗

檔案名稱
PieceReplacer-1.1.12.zip
檔案大小
39.4 KiB