Stardew Valley engine reference notes
Engine mechanics that the server/mod relies on. Prescriptive contributor rules live at .claude/rules/cabin-system.md and .claude/rules/host-automation.md (the festival rule lives under host-automation, item 3).
For full source-of-truth, the decompiled game lives at decompiled/sdv-1.6.15-24356/.
Sleep / wakeup / day-end
GameLocation.startSleep()does NOT setplayer.isInBed.isInBedis set dynamically byFarmer.Update()from tile properties — sosetTileLocation()to a bed tile MUST run BEFOREstartSleep().- On clients (
!IsMasterGame),doSleep()does NOT callGame1.NewDay(). It uses message type 14 (newDaySync).
Ready-check messages and game availability
- Ready-check messages use message type 31. They are blocked by
PasswordProtectionServicefor unauthenticated players. isGameAvailable()returns false duringnewDaySync. It stays false untilnewDaySync.destroy()(which runs AFTER all barriers + save +PollForEndOfNewDaySync).- When
isGameAvailable() == false, the server sends message type 11 (Client_WaitForHostAvailability); the client shows "Waiting for host event" inFarmhandMenuand times out after 45s. checkFarmhandRequestwithisGameAvailable() == falsesends type 11 and registers awhenGameAvailablecallback that callssendAvailableFarmhands(NOTCheck()); the client bounces back toFarmhandMenu.
newDaySync barrier behavior
- When a client disconnects during the barrier:
playerDisconnected()enqueues intodisconnectingFarmers,removeDisconnectedFarmers()removes the entry fromotherFarmers, and with emptyotherFarmersthebarrierReady()check returns true immediately. - Every instance runs the same
barrierReady()against its ownotherFarmers, farmhands included, and a farmhand is unmodded. A connected farmer that never checks in (an unauthenticated lobby player never receivesnewDaySync) therefore stalls every farmhand at the first barrier, and the host at the next one, however the host filters its own check. The server closes this by sending the barrier check-in on the excluded farmer's behalf (LobbyService.BarrierReady_Postfix).
Cabin system — reference
Prescriptive cabin invariants are in .claude/rules/cabin-system.md. Reference-only:
BuildStartingCabinsuses map-designated positions (tile 29/30 in the Paths layer), capped byGame1.startingCabins.
Server invite code
- LAN-only servers (
AllowIpConnections=true, no Steam account configured) never write an invite code.InviteCodeFile.Read()returns null in that configuration.