You are viewing a potentially older version of this package. View all versions.
BatBoys-TownPortal-1.0.34 icon

TownPortal

Open a blue wood portal back to your bed. Allies can follow. A return field stays for 15 minutes. Mysterious Tomes drop in Meadows and Black Forest chests, or from Haldor after the Elder.

Date uploaded 3 days ago
Version 1.0.34
Download link BatBoys-TownPortal-1.0.34.zip
Downloads 19
Dependency string BatBoys-TownPortal-1.0.34

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.30.2 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.2

README

Town Portal

Field manual: valtownportal.sprekn.com

Open a blue wood portal back to the bed you have claimed. Anyone can walk through it to the caster's spawn. A return field at that spawn sends you back to where the door was opened. The caster's trip back closes both ends. Otherwise they last 15 minutes.

The door uses the wood portal model and a blue glow. The portal script, tag, and pairing are removed, so it never joins the normal portal network.

The mod does not ship any game assets. The wood portal mesh is taken from the game at runtime.

Use it

  1. Put a Tome of Town Portal anywhere in your inventory. It does not need to be equipped, and using the door does not consume it.
  2. Press Left Alt + H. On a controller, hold L2 and click the right stick (LT + R3). A quick tap of L2 still sheathes. Hold it, then click. That click does not crouch.
  3. A wood portal opens on the nearest clear spot beside you. Walk through it. While the door is up, the map shows a blue circle labeled with your name and "town portal".
  4. You arrive at the caster's claimed bed. If they never claimed one, you arrive at the starting stones.
  5. A blue, mostly transparent field about one Viking tall stands at that spawn. It does not push players, creatures, or furniture. Hover it to see the time left.
  6. Anyone but the caster can press E to go back to the door, then walk through again. The pair stays up.
  7. If you opened the door, E on the return field says Return and close. You go back, and both ends disappear. Send visitors through first. The door does not wait for them.
  8. If nobody closes it, the door, the field, and the Nowhere Like Home buff all go away when the timer ends.

Opening a door also starts The Tome Rests for 5 minutes. When that ends you can open again. A new door replaces your previous one, including a return field that is far away or in an unloaded area.

If a test world gets stuck, or old town portal markers are still on the map, turn on devcommands and run townportal_clear. It destroys every town portal door and return gate, including unloaded ones, erases their map markers, and clears The Tome Rests and Nowhere Like Home. Save the world once after that. The markers are gone from the save, so they do not come back when you exit.

Other players do not need a tome to use your door. They go to your bed, not theirs. Each person is checked for portal-blocked cargo on the way through.

Recipe

Craft Tome of Town Portal at a level 1 workbench:

Ingredient Amount
Mysterious Tome 1 (consumed)
Surtling core 10
Greydwarf eye 25
Leather scraps 15
Deer hide 5

There are no upgrade levels.

Mysterious Tome: "A ruined book. The way home is still written in it, for someone willing to make it whole."

Tome of Town Portal: "Restored to its former glory. While it is in your inventory, Alt+H or L2+right stick opens a door back to the bed you have claimed."

Finding a Mysterious Tome

  • Extra roll on loot chests in the Meadows and the Black Forest. About 1 in 4 also contain one tome.
  • The roll is separate. Axe heads and every other drop stay on their own tables.
  • Barrels are skipped. Chests a player placed are skipped.
  • Chests that already exist roll once, the first time they load with this mod, including chests you have opened before.
  • Haldor sells one for 250 coins after the Elder is dead. Finding one in a chest before that still lets you craft.

The finished tome is bound in warm reddish-brown leather. Cyan runes glow on the cover. The mysterious tome is the same book, dusty and grey-brown. The item names stay TownPortal_MysteriousTome and TownPortal_Tome.

Rules

These match a normal wood portal. This mod does not call portal code to do it.

  • NoPortals seals the tome. The deny sound plays and the door does not open.
  • NoBossPortals seals it while a boss is loaded.
  • TeleportAll lets every item through.
  • Otherwise each item's own teleport flag is checked. Ore, bars, and anything else a wood portal refuses are refused here too, for the caster and for anyone following.
  • Open water is refused. Grass, the starting stones, and other no-build camps do not stop the door. If every spot is underwater, the deny sound plays. "The door has nowhere to open."
  • The frame itself keeps the wood portal's collision. Only the return field is non-solid. Its use collider sits on the piece_nonsolid layer so E can find it.

The timer is real time, not world time. Sleeping does not burn it down, and logging out does not remove the door or the return gate. Nowhere Like Home and the return gate's hover text share that end time. The buff has no stat effect. It ends early if the caster takes the return gate. The Tome Rests still runs out its 5 minutes, so closing the door does not let you open another one immediately.

Config

BepInEx/config/com.townportal.mod.cfg

The server's copy wins for cooldown, duration, drop chance, price, Elder requirement, search radius, and yaw. The open key is per player. A saved Alt+T or Shift+T binding is switched to H + LeftAlt the next time the game starts. A controller also opens the door with L2 + right stick click (LT + R3), and that chord is not a config key. Restart after changing cooldown or duration so the buffs pick up the new length.

Section Key Default
Client Open Left Alt + H
Server CooldownSeconds 300
Server DurationSeconds 900
Server MysteriousTomeDropChance 0.25
Server HaldorPrice 250
Server HaldorRequiresElder true
Server SearchRadius 6
Server PortalYawOffset 0
Debug LogChestPrefabs false

If the wood frame faces the wrong way, set PortalYawOffset to 180.

LogChestPrefabs writes one line per container prefab the first time it is seen. Use it if a chest you expected is not rolling a tome. Prefab names that do not contain "chest" are ignored on purpose.

Install

Dependencies, both from Thunderstore:

  • denikson-BepInExPack_Valheim 5.4.2333
  • ValheimModding-Jotunn 2.30.2

Built package layout:

manifest.json
README.md
CHANGELOG.md
icon.png
plugins/TownPortal.dll

r2modman installs this under the Bat Boys team as BepInEx/plugins/BatBoys-TownPortal/TownPortal.dll. Put that same folder on a dedicated server. Everyone connected needs the mod.

This zip is the Thunderstore package. Upload it to the Bat Boys team as-is. It already contains TownPortal.dll. There is no project to compile.

Dedicated server

The server decides whether a door may open, spawns both objects, and checks cargo. Clients send the key press and play the teleport. A listen server does both.

Doors and return fields are saved with the world and remove themselves once expireTicks has passed, including after a restart. They are not damaged by players or creatures.

Not in this version

  • No PVP lock. Anyone who can reach the field door can walk into the caster's bedroom until the timer ends. A later caster-only switch should live in PortalService.Traverse and PortalService.Return.
  • Custom lines are English. The cargo refusal uses the game's own $msg_noteleport text.

Spawn

With devcommands on, the console drops either book at your feet:

spawn TownPortal_MysteriousTome 1
spawn TownPortal_Tome 1

The first is the ruined Mysterious Tome. The second is the finished Tome of Town Portal. Neither needs the Elder, a chest, or the workbench.

Test pass

In a test world with devcommands:

  1. spawn TownPortal_Tome 1. Put it in inventory. Alt+H. A blue wood portal appears beside you, not in the portal list, and it has no tag. spawn TownPortal_MysteriousTome 1 drops the ruined book used in the recipe.
  2. Walk through. You arrive at your bed, the return field is there, and its hover countdown matches Nowhere Like Home.
  3. Have a second character press E on the field. They return, and the door stays. You press E. The hover says "Return and close", you return, and both ends are gone. Nowhere Like Home drops off. The tome is still resting.
  4. Open a second door after 5 minutes. The first door and its field are gone.
  5. Pick up ore. The door refuses you with the same message a wood portal would. Drop it and the door works.
  6. On a world with portals disabled, Alt+H plays the deny sound and places nothing.
  7. Kill the Elder, or setkey defeated_gdking, and buy a Mysterious Tome from Haldor for 250.
  8. Load a Meadows ruin and a Black Forest chest. About one in four has a tome, and the axe heads that were there are still there.
  9. Join with a second character and walk through the first character's door. You arrive at their bed, not yours.

CHANGELOG

Changelog

1.0.40

  • The Tome of Town Portal now works on dedicated servers. Opening a door, stepping through it, using the return gate and the map markers all work the same on a dedicated server, a hosted game and single player.
  • The door's spot is now picked on your own PC, using the server's search radius and portal turn. The server makes the door, keeps one door per player, finds your Runic Spawn Point and handles the trip.
  • The tome no longer fails silently. If it can't open, you see why. With the build tool out it says "Put away your build tool first." If the server doesn't answer, it tells you.
  • Each open, trip and refusal writes one line to the log on your PC and one on the server, which makes problems easier to track down.
  • Return gates on a boat's Runic Spawn Point still follow the stone. Gate names, map markers and the way back are unchanged.
  • townportal_clear from a client now needs admin rights on the server. It also clears the tome cooldown for everyone online.
  • Every player and the server need 1.0.40.

1.0.39

  • Server settings now sync. When you join a server, its gameplay settings (cooldown, duration, drop chance, Haldor's price and Elder rule, search radius, portal turn, and the new base options) replace yours while you're connected, and changes reach everyone without a restart. Your key, gate names, map pin and log settings stay your own. Every player and the server need 1.0.39.
  • The tome's tooltip shows the key you actually set, plus the controller combo, and updates when you change it.
  • Your claimed Runic Spawn Point shows on your map as "Your spawn point", even on a moving boat. Only you see it. Turn it off with ShowSpawnPointPin.
  • New server option RunicSpawnPointIsBase (off by default) makes each stone count as a player base, so monsters don't spawn next to it. RunicSpawnPointBaseRadius sets how far that reaches.
  • New console command townportal_spawnpoint shows where your stone is, whether it's loaded and whether it's on a boat. townportal_spawnpoint clear drops your claim. Admins can add a player name to check or clear someone else's.
  • New devcommands command townportal_spawnstone places a Runic Spawn Point in front of you.
  • Text says "return gate" everywhere. Setting descriptions are rewritten, and the settings table in the README lists every setting.
  • The mod no longer uses reflection to save chests or check chat focus.
  • The website link is removed.

1.0.38

  • Runic Spawn Point is now built into Town Portal. You learn it the first time the finished tome is in your inventory. Remove the old Runic Spawn Point mod; your stones and claims keep working.

1.0.37

  • BoatSpawn is now called Runic Spawn Point. Town Portal's messages use the new name.
  • Return gates show whose they are. Hovering one reads "[name]'s return gate", and a small name floats above it when you are close. The floating name can be turned off with the ShowGateNames setting.

1.0.36

  • With BoatSpawn (now Runic Spawn Point) 1.0.2 or newer, the portal opens at your claimed spawn point, on deck wherever the boat is, and falls back to your bed if it's gone.

1.0.35

  • Book textures load through Unity's own image loader. The plugin no longer loads a DLL by name at runtime.

1.0.34

  • Republish for Thunderstore. The field manual link is on the package page.

1.0.33

  • Same package layout as the earlier releases.

1.0.32

  • Both tomes use a Valheim-style pixel look. The eight material textures are 128×128, and the cover runes are drawn as pixel art. Book textures use point filtering. Inventory icons are unchanged.

1.0.31

  • The book is no longer mirrored. The runes read the right way and the spine is on the correct side. X is negated on positions and normals when the mesh is built. The triangle flip from 1.0.30 is not used.

1.0.30

  • The book renders lit and brown. The mesh had every triangle wound inside-out, so the cover was lit from behind. This winding change was replaced by the un-mirror in 1.0.31.

1.0.29

  • The artist's brighter leather is in. The cover is no longer boosted in code. Metal stays off the leather, and only the iron caps use the metal map.

1.0.28

  • The inventory icons use a softer edge. The hard black outline is gone.

1.0.27

  • The leather was rendering as metal, so the cover stayed black in daylight while the runes glowed. Metal is off, the shine is low, and the cover color is lifted a little.

1.0.26

  • Removed the color processing on both books. They use the artist's textures as painted. Nothing in the plugin shifts them toward blue. The finished tome's runes still glow the color in the emission map.

1.0.25

  • The mysterious tome was still a dark block in daylight. Its leather is brighter, and it is no longer rendered as metal.

1.0.24

  • Both books were too dark on an item stand. The leather is brighter. The rune glow is unchanged.

1.0.23

  • The finished tome and the mysterious tome use the artist's own textures. The finished cover is blue leather with glowing runes. The mysterious tome is the grey book. Nothing is recolored in the plugin.

1.0.22

  • The finished book keeps its leather grain. The blue shift was turning the dark cover into a near-black slab. Stitches were the only part still bright enough to see.

1.0.21

  • The finished book was a flat blue with no leather. The color sliders were pinned to the end of their range, which wiped the texture. They sit at neutral now.

1.0.20

  • The controller chord is L2 + right stick click. L1 was opening the radial menu. That click does not crouch.

1.0.19

  • The leather texture shows on the dropped book. It was rendering as a black shell.
  • A book on an item stand uses the same model. The stand was still showing the empty amber attach.
  • The controller chord is L1 + D-pad down (LB + D-pad down). L2 + X was too close to Use.

1.0.18

  • The book on the ground keeps its leather, pages included. The cover was rendering black because the normal map was read in the wrong channels.

1.0.17

  • A controller opens the door with L2 + Square. That is LT + X on an Xbox pad or Steam Deck. Left Alt + H still works.

1.0.16

  • The finished tome is the strapped book with a blue hue, in the inventory and on the ground.
  • The mysterious tome is that same book, grey and faded. It no longer uses the old icon.

1.0.15

  • The finished tome uses the strapped leather book, in the inventory and on the ground. That art is inside the plugin now. The mysterious tome keeps the plain brown icon.

1.0.14

  • The return gate stays until the timer ends, including after you log out and come back. It was removed on load.
  • Using the return gate after a relog still closes the door.

1.0.13

  • Old town portal markers are deleted with the portal record, not just hidden. That includes duplicates and portals that already expired. A player who is offline does not get a marker unless their door is still open and they are back in the world.
  • townportal_clear removes those records from the world save and the markers from the map. Run it once, then save. They do not come back after you exit.

1.0.12

  • townportal_clear removes the portal mist with the door. It was left behind in the world.
  • A portal opened inside a crypt, cave, or other dungeon goes to your bed. It no longer drops you on the dungeon roof outside the map.

1.0.11

  • The tome on the ground is the strapped leather book. The finished tome uses that icon. The mysterious tome keeps the plain brown icon.

1.0.10

  • A tome another player picked up now opens a door. The bag on their screen had the book, but the server's copy of that inventory did not, so the shortcut was refused.

1.0.9

  • Another player can open a door with a Tome of Town Portal they picked up. The hotkey was only looking at the prefab pointer, which a traded or spawned tome often does not have, and it failed without a message.

1.0.8

  • An active town portal places a blue circle on the map, labeled with the caster's name. The pin goes away when the door closes, expires, or is cleared.

1.0.7

  • Added the devcommands console command townportal_clear. It destroys every town portal door and return gate, including unloaded ones, and clears The Tome Rests and Nowhere Like Home.

1.0.6

  • The return gate is blue instead of magenta, and a bit shorter. The pale block at the bottom was the leftover cube from the prefab.

1.0.5

  • The return gate is a pale gray field with a blue base, and more transparent. The magenta was a missing shader.
  • Arrival is a short step above the floor by the bed. It no longer puts you on the roof, and it does not drop you through the floor.

1.0.4

  • Fixed the world load hanging on ZDO not used when creating object TownPortal_Door. The door prefab stays active so a saved portal claims its ZDO.

1.0.3

  • The wood door shows the connected-portal swirl and a blue glow. It still does not join the portal tag network.
  • Arrival stands a meter above the floor you land on, including wooden floors, instead of the terrain underneath. You no longer drop through the floor.
  • The return gate hover shows your mapped Use key instead of $KEY_Use.

1.0.2

  • Fixed the door failing to open on every spot. The wood frame is switched on when it is created, so it gets a network id.
  • Removed the lookup of Player.m_placeDenied. That field is gone from Valheim and was logging a Harmony warning whenever the tome was refused.

1.0.1

  • Tome of Town Portal, crafted at a workbench. Left Alt + H opens a blue wood portal beside you. A saved Alt+T or Shift+T binding is switched to that chord on launch.
  • Console spawn names are TownPortal_MysteriousTome and TownPortal_Tome.
  • The portal uses the wood portal model only. It is not on the stone-portal network and does not pair with tagged portals.
  • Walking through sends you to the caster's claimed bed, or the starting stones if they never claimed one. Other players can follow.
  • A return field, about one Viking tall, appears at that spawn the first time someone goes through. It does not push players or furniture. Press E. The hover text shows the time left.
  • Both ends last 15 minutes, then disappear together. The Nowhere Like Home buff tracks that same timer. If the caster uses the return gate, both ends close immediately and the buff ends. Everyone else can pass until then.
  • The tome rests for 5 minutes after a successful open. Opening again replaces your previous door.
  • The door opens on the nearest ground beside you, including at the starting stones and in grass. It refuses only open water.
  • Ore and other cargo follow the same rule as a wood portal, including the world's portal setting.
  • Mysterious Tome is an extra 1-in-4 roll on Meadows and Black Forest loot chests. It does not take a slot from anything already in the chest, including axe heads. Barrels and chests you placed are left alone. It does not stack.
  • Haldor sells a Mysterious Tome for 250 coins after the Elder is dead.