Vintage Story Mod DB · Vintage Story mod
Spawn In Bed
Sleeping in a bed sets your spawn point to it. Just that. Works with modded beds! Made because the usual mods for this aren't working on the latest version, so I took it upon myself to make my own implementation. Source Code (Sorry, too lazy to put this on gi
Quick answer
Which Spawn In Bed release should I use?
Spawn In Bed 1.0.0 targets 1.22.0, 1.22.1, 1.22.2. It must be installed on the client. Installation on the dedicated server is optional. No extra mods listed for this file.
Where it goes
Is Spawn In Bed required on the client, server, or both?
It must be installed on the client. Installation on the dedicated server is optional.
This release supports both sides, but the source does not require it on the server.
What else does Spawn In Bed 1.0.0 need?
1.0.0. Change the file and its required mods may change too.
This file does not list any required mods. Do not add a library just because a different file uses it.
This file does not list any required or optional mods.
Before you install it
Add Spawn In Bed without breaking your instance.
Built for Spawn In Bed 1.0.0. Pick another file and the loader, install side or required mods may change.
- 01
Stick to this file
Use 1.0.0. It targets 1.22.0, 1.22.1, 1.22.2; another release may have different loader, side or dependency requirements.
- 02
Bring the mods it needs
This file does not list any required mods. Do not add a library just because a different file uses it.
- 03
Put it on the correct side
It must be installed on the client. Installation on the dedicated server is optional.
- 04
Pick the file you checked
Use the “Get this file” button beside 1.0.0. It opens that exact file at the source.
About this project
What does Spawn In Bed add?
Sleeping in a bed sets your spawn point to it. Just that. Works with modded beds!
Made because the usual mods for this aren't working on the latest version, so I took it upon myself to make my own implementation.
using System;
using System.Collections.Generic;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.Datastructures;
using Vintagestory.API.Server;
namespace YangBed
{
public sealed class YangBedModSystem : ModSystem
{
private ICoreServerAPI sapi;
private readonly Dictionary<string, Action> mountListenersByPlayerUid = new Dictionary<string, Action>();
public override bool ShouldLoad(EnumAppSide forSide) { return forSide == EnumAppSide.Server; }
public override void StartServerSide(ICoreServerAPI api)
{
sapi = api;
sapi.Event.PlayerNowPlaying += OnPlayerNowPlaying;
sapi.Event.PlayerDisconnect += OnPlayerDisconnect;
}
private void OnPlayerNowPlaying(IServerPlayer player)
{
if (player == null || player.Entity == null) return;
UnregisterPlayer(player);
string playerUid = player.PlayerUID;
// Beds set tiredness.isSleeping via an enqueued task during mount, one-shot callback. No need to check anything each tick or something stupid like that.
Action listener = () => { sapi.Event.RegisterCallback(_ => TrySetSpawnFromSleep(playerUid), 50); };
mountListenersByPlayerUid[playerUid] = listener;
player.Entity.WatchedAttributes.RegisterModifiedListener("mountedOn", listener);
}
private void OnPlayerDisconnect(IServerPlayer player) { if (player == null) return; UnregisterPlayer(player); }
private void UnregisterPlayer(IServerPlayer player)
{
if (!mountListenersByPlayerUid.TryGetValue(player.PlayerUID, out Action listener)) return;
player.Entity?.WatchedAttributes.UnregisterListener(listener);
mountListenersByPlayerUid.Remove(player.PlayerUID);
}
private void TrySetSpawnFromSleep(string playerUid)
{
IServerPlayer player = sapi.World.PlayerByUid(playerUid) as IServerPlayer;
if (player == null || player.Entity == null) return;
EntityPlayer entity = player.Entity;
if (entity.MountedOn == null || !IsSleeping(entity)) return;
EntityPos seatPos = entity.MountedOn.SeatPosition ?? entity.Pos;
player.SetSpawnPosition(new PlayerSpawnPos
{
x = (int)Math.Floor(seatPos.X),
y = (int)Math.Ceiling(seatPos.InternalY),
z = (int)Math.Floor(seatPos.Z),
yaw = seatPos.Yaw,
pitch = 0f,
roll = 0f,
RemainingUses = -1
});
player.SendIngameError("yangbed-confirm", "Re-spawn Point Set...");
}
private static bool IsSleeping(EntityPlayer entity)
{
ITreeAttribute tiredness = entity.WatchedAttributes.GetTreeAttribute("tiredness");
return tiredness != null && tiredness.GetInt("isSleeping") > 0;
}
public override void Dispose()
{
if (sapi != null)
{
sapi.Event.PlayerNowPlaying -= OnPlayerNowPlaying;
sapi.Event.PlayerDisconnect -= OnPlayerDisconnect;
foreach (IPlayer player in sapi.World.AllOnlinePlayers) { if (player is IServerPlayer serverPlayer) { UnregisterPlayer(serverPlayer); } }
}
mountListenersByPlayerUid.Clear();
base.Dispose();
}
}
}
Project description from Vintage Story Mod DB.
Pick your setup
Spawn In Bed releases for each Vintage Story version.
Choose the version and loader you play, then open the matching release.
1.22.1
1 loader build1.22.0
1 loader buildCheck the dependencies, then try the file in a copied instance before changing a world you care about.
Recent files
Spawn In Bed versions and loaders
1.0.0
yangbed.zip
6 May 2026
Looking for an older file? The official Vintage Story Mod DB project page is in Resources.